WorkflowReportBase.cs
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:3k
源码类别:

OA系统

开发平台:

C#

  1. using System;
  2. namespace OThinker.H3.Portal
  3. {
  4. /// <summary>
  5. /// Summary description for WorkflowReportBase.
  6. /// </summary>
  7. public class WorkflowReportBase : ReportPage
  8. {
  9. public WorkflowReportBase()
  10. {
  11. }
  12. protected System.DateTime ParseFromTime(string FromTime)
  13. {
  14. if(this.IsSelectedNull(FromTime))
  15. {
  16. return System.DateTime.MinValue;
  17. }
  18. else
  19. {
  20. try
  21. {
  22. return System.DateTime.Parse(FromTime);
  23. }
  24. catch
  25. {
  26. return System.DateTime.MinValue;
  27. }
  28. }
  29. }
  30. protected System.DateTime ParseToTime(string ToTime)
  31. {
  32. if(this.IsSelectedNull(ToTime))
  33. {
  34. return System.DateTime.MaxValue;
  35. }
  36. else
  37. {
  38. try
  39. {
  40. return System.DateTime.Parse(ToTime);
  41. }
  42. catch
  43. {
  44. return System.DateTime.MaxValue;
  45. }
  46. }
  47. }
  48. // 获得发起人
  49. protected string[] ParseOriginators(string InputOriginator)
  50. {
  51. if(this.IsSelectedNull(InputOriginator))
  52. {
  53. return null;
  54. }
  55. else
  56. {
  57. return OThinker.H3.Server.Engine.Organization.GetChildren(InputOriginator, OThinker.Organization.UnitType.User, true);
  58. }
  59. }
  60. protected System.Data.DataTable CreatePerformanceTable()
  61. {
  62. System.Data.DataTable table = new System.Data.DataTable();
  63. table.Columns.Add("流程模板全名");
  64. table.Columns.Add("执行次数");
  65. table.Columns.Add("最短完成时间");
  66. table.Columns.Add("平均完成时间");
  67. table.Columns.Add("最长完成时间");
  68. return table;
  69. }
  70. // 获得性能,并将结果添加到性能统计表中
  71. protected void GetPerformance(
  72. System.Data.DataTable Performances, 
  73. string WorkflowPackage, 
  74. string WorkflowName, 
  75. int WorkflowVersion, 
  76. string[] Originators, 
  77. System.DateTime From, 
  78. System.DateTime To)
  79. {
  80. // 获得性能统计值
  81.             OThinker.H3.WorkflowTemplate.WorkflowPerformance performance
  82.                 = OThinker.H3.Server.Engine.InstanceManager.GetWorkflowPerformance(
  83. Originators, 
  84. null, 
  85. WorkflowPackage, 
  86. WorkflowName, 
  87. WorkflowVersion, 
  88. From, 
  89. To);
  90. // 获得流程模板全名
  91. string fullName;
  92. if(WorkflowName == null)
  93. {
  94.                 fullName = H3.WorkflowTemplate.WorkflowTemplate.GetWorkflowFullName(WorkflowPackage);
  95. }
  96. else if(
  97.                 WorkflowVersion == OThinker.H3.WorkflowTemplate.WorkflowTemplate.AllWorkflowVersion ||
  98.                 WorkflowVersion == OThinker.H3.WorkflowTemplate.WorkflowTemplate.NullWorkflowVersion)
  99. {
  100.                 fullName = H3.WorkflowTemplate.WorkflowTemplate.GetWorkflowFullName(WorkflowPackage, WorkflowName);
  101. }
  102. else
  103. {
  104.                 fullName = H3.WorkflowTemplate.WorkflowTemplate.GetWorkflowFullName(WorkflowPackage, WorkflowName, WorkflowVersion);
  105. }
  106. if(performance == null)
  107. {
  108. Performances.Rows.Add(
  109. new object[]{
  110. fullName, 
  111. 0, 
  112. null, 
  113. null, 
  114. null});
  115. }
  116. else
  117. {
  118. Performances.Rows.Add(
  119. new object[]{
  120. fullName, 
  121. performance.ExecutedTimes, 
  122. OThinker.Data.Convertor.Format(new System.TimeSpan(performance.ShortestUsedTime)), 
  123. OThinker.Data.Convertor.Format(new System.TimeSpan(performance.AverageUsedTime)), 
  124. OThinker.Data.Convertor.Format(new System.TimeSpan(performance.LongestUsedTime))});
  125. }
  126. }
  127. }
  128. }