LoopQueryStatement.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System.Data;
  2. using IwbZero.IocNamed;
  3. using IwbZero.IwbBase;
  4. using IwbZero.IwbDataQuery;
  5. using WeEngine.ComponentInfo;
  6. using WeEngine.Components.InterfaceFactory;
  7. namespace WeEngine.Components.Statements
  8. {
  9. /// <summary>
  10. /// 多条记录循环执行事务
  11. /// </summary>
  12. [IocNamed(CompStmtType.LoopQuery)]
  13. public class LoopQueryStatement : IStatementRunner
  14. {
  15. public bool Run(ComponentRunner runner, IwbXmlNode poStatement)
  16. {
  17. {
  18. bool flag = true;
  19. string childValue = poStatement.GetChildValue("Condition");
  20. string pcDataSourceId = poStatement.GetChildValue("DataSourceId");
  21. IwbXmlNode childNode = poStatement.GetChildNode("Content");
  22. IwbDataSource dataSource = runner.GetDataSource(pcDataSourceId);
  23. if ((childNode != null) && (childNode.Nodes.Count > 0))
  24. {
  25. if (((dataSource == null) || (dataSource.Data == null)) || !dataSource.Data.IsOpened)
  26. {
  27. return false;
  28. }
  29. var data = dataSource.Data;
  30. DataRow currentRow = data.CurrentRow;
  31. //data.IsToFireRecordMovedEvent = false;
  32. data.MoveFirst();
  33. childValue = Condition.ConditionMappingToConditionString(childValue);
  34. childValue= childValue.Replace("[", "").Replace("]", "");
  35. for (int i = 0; i < data.RecCount; i++)
  36. {
  37. data.Go(i);
  38. //runner.ShowRecordInfo(recCount, i + 1, "");
  39. if (runner.EvaluateBool(childValue))
  40. {
  41. runner.RunStatements(childNode.Nodes);
  42. }
  43. if (!runner.ProcessResult)
  44. {
  45. flag = false;
  46. break;
  47. }
  48. }
  49. data.GoTo(currentRow);
  50. //data.IsToFireRecordMovedEvent = true;
  51. }
  52. return flag;
  53. }
  54. }
  55. }
  56. }