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

OA系统

开发平台:

C#

  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Web;
  7. using System.Web.SessionState;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.HtmlControls;
  11. namespace OThinker.H3.Portal
  12. {
  13. /// <summary>
  14. /// Summary description for UserReport.
  15. /// </summary>
  16.     public partial class UserReport : ReportPage
  17. {
  18. protected System.Web.UI.WebControls.DropDownList lstTaskName;
  19. protected void Page_Load(object sender, System.EventArgs e)
  20. {
  21. if(!this.IsPostBack)
  22. {
  23.                 // 验证是否具有管理员权限
  24.                 if (!this.UserValidator.ValidateViewReport())
  25.                 {
  26.                     this.NotifyMessage(LackOfAuth);
  27.                 }
  28. // 设置默认的搜索时间
  29. System.DateTime today = System.DateTime.Now;
  30. System.DateTime tomorrow = today.Add(new System.TimeSpan(1, 0, 0, 0, 0));
  31. this.txtFromTime.Text = today.ToShortDateString();
  32. this.txtToTime.Text = tomorrow.ToShortDateString();
  33.                 string[] catalogs = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowPackages();
  34. // 添加一空元素表示全部
  35. this.lstWorkflowPackage.Items.Add(NullItemValue);
  36. foreach(string catalog in catalogs)
  37. {
  38. this.lstWorkflowPackage.Items.Add(catalog);
  39. }
  40. }
  41. }
  42. #region Web Form Designer generated code
  43. override protected void OnInit(EventArgs e)
  44. {
  45. //
  46. // CODEGEN: This call is required by the ASP.NET Web Form Designer.
  47. //
  48. InitializeComponent();
  49. base.OnInit(e);
  50. }
  51. /// <summary>
  52. /// Required method for Designer support - do not modify
  53. /// the contents of this method with the code editor.
  54. /// </summary>
  55. private void InitializeComponent()
  56. {    
  57. this.btnQuery.Click += new System.Web.UI.ImageClickEventHandler(this.btnQuery_Click);
  58. }
  59. #endregion
  60. protected void lstWorkflowPackage_SelectedIndexChanged(object sender, System.EventArgs e)
  61. {
  62. string catalog = this.lstWorkflowPackage.SelectedValue;
  63. this.lstWorkflowName.Items.Clear();
  64. this.lstWorkflowVersion.Items.Clear();
  65. this.lstActivityName.Items.Clear();
  66. if(this.IsSelectedNull(catalog))
  67. {
  68. this.lstWorkflowName.Items.Add(NullItemValue);
  69. this.lstWorkflowVersion.Items.Add(NullItemValue);
  70. this.lstActivityName.Items.Add(NullItemValue);
  71. }
  72. else
  73. {
  74.                 string[] names = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowNames(catalog, OThinker.H3.WorkflowTemplate.WorkflowState.Unspecified);
  75. this.lstWorkflowName.Items.Add(NullItemValue);
  76. foreach(string name in names)
  77. {
  78. this.lstWorkflowName.Items.Add(name);
  79. }
  80. }
  81. }
  82. protected void lstWorkflowName_SelectedIndexChanged(object sender, System.EventArgs e)
  83. {
  84. string catalog = this.lstWorkflowPackage.SelectedValue;
  85. string name = this.lstWorkflowName.SelectedValue;
  86. this.lstWorkflowVersion.Items.Clear();
  87. this.lstActivityName.Items.Clear();
  88. if(this.IsSelectedNull(name))
  89. {
  90. this.lstWorkflowVersion.Items.Add(NullItemValue);
  91. this.lstActivityName.Items.Add(NullItemValue);
  92. }
  93. else
  94. {
  95. int[] versions = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowVersions(
  96. catalog, 
  97. name);
  98. this.lstWorkflowVersion.Items.Add(NullItemValue);
  99. if(versions != null)
  100. {
  101. foreach(int version in versions)
  102. {
  103. this.lstWorkflowVersion.Items.Add(version.ToString());
  104. }
  105. }
  106. }
  107. }
  108. protected void lstWorkflowVersion_SelectedIndexChanged(object sender, System.EventArgs e)
  109. {
  110. string catalog = this.lstWorkflowPackage.SelectedValue;
  111. string name = this.lstWorkflowName.SelectedValue;
  112.             int version = OThinker.H3.WorkflowTemplate.WorkflowTemplate.NullWorkflowVersion;
  113. this.lstActivityName.Items.Clear();
  114. if(this.IsSelectedNull(this.lstWorkflowVersion.SelectedValue))
  115. {
  116. this.lstActivityName.Items.Add(NullItemValue);
  117. }
  118. else
  119. {
  120. version = int.Parse(this.lstWorkflowVersion.SelectedValue);
  121. // 获得该流程
  122.                 OThinker.H3.WorkflowTemplate.WorkflowTemplate process = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflow(
  123. catalog, 
  124. name, 
  125. version);
  126.                 foreach (OThinker.H3.WorkflowTemplate.ActivityTemplate task in process.Activities)
  127. {
  128. this.lstActivityName.Items.Add(task.Name);
  129. }
  130. }
  131. }
  132. #region 查询
  133.         protected override string ReportTableSessionName
  134.         {
  135.             get
  136.             {
  137.                 return OThinker.H3.WorkSheet.Sessions.GetUserReportTable();
  138.             }
  139.         }
  140. private void btnQuery_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  141. {
  142. this.Query();
  143. }
  144. protected void lnkQuery_Click(object sender, System.EventArgs e)
  145. {
  146. this.Query();
  147. }
  148. private void Query()
  149. {
  150. #region 查找相关人员
  151. // 类型
  152. string catalog = null;
  153. if(!this.IsSelectedNull(this.lstWorkflowPackage.SelectedValue))
  154. {
  155. catalog = this.lstWorkflowPackage.SelectedValue;
  156. }
  157. // 名称
  158. string name = null;
  159. if(!this.IsSelectedNull(this.lstWorkflowName.SelectedValue))
  160. {
  161. name = this.lstWorkflowName.SelectedValue;
  162. }
  163. // 版本号
  164. int version = OThinker.H3.WorkflowTemplate.WorkflowTemplate.NullWorkflowVersion;
  165. if(!this.IsSelectedNull(this.lstWorkflowVersion.SelectedValue))
  166. {
  167. version = int.Parse(this.lstWorkflowVersion.SelectedValue);
  168. }
  169. string taskName = null;
  170. if(!this.IsSelectedNull(this.lstActivityName.SelectedValue))
  171. {
  172. taskName = this.lstActivityName.SelectedValue;
  173. }
  174. System.DateTime from;
  175. try
  176. {
  177. from = System.DateTime.Parse(this.txtFromTime.Text);
  178. }
  179. catch
  180. {
  181. from = System.DateTime.MinValue;
  182. }
  183. System.DateTime to;
  184. try
  185. {
  186. to = System.DateTime.Parse(this.txtToTime.Text);
  187. }
  188. catch
  189. {
  190. to = System.DateTime.MaxValue;
  191. }
  192. // 查询操作人员
  193. string[] actors = OThinker.H3.Server.Engine.WorkItemManager.GetWorkflowParticipants(
  194. catalog, 
  195. name, 
  196. version, 
  197. taskName, 
  198. from, 
  199. to);
  200. #endregion
  201. System.Data.DataTable performanceTable = new DataTable();
  202. performanceTable.Columns.Add("User Name");
  203. performanceTable.Columns.Add("Times");
  204. performanceTable.Columns.Add("Shortest Wait Time");
  205. performanceTable.Columns.Add("Average Wait Time");
  206. performanceTable.Columns.Add("Longest Wait Time");
  207. performanceTable.Columns.Add("Shortest Used Time");
  208. performanceTable.Columns.Add("Average Used Time");
  209. performanceTable.Columns.Add("Longest Used Time");
  210. if(actors != null)
  211. {
  212. foreach(string actor in actors)
  213. {
  214. OThinker.H3.WorkItem.UserPerformance performance = OThinker.H3.Server.Engine.WorkItemManager.GetUserPerformance(
  215. catalog, 
  216. name, 
  217. version, 
  218. taskName, 
  219. actor, 
  220. from, 
  221. to);
  222. string userName = OThinker.H3.Server.Engine.Organization.GetFullName(actor);
  223. if(performance == null)
  224. {
  225. performanceTable.Rows.Add(
  226. new object[]{
  227. userName, 
  228. 0, 
  229. null,
  230. null,
  231. null, 
  232. null, 
  233. null, 
  234. null});
  235. }
  236. else
  237. {
  238. performanceTable.Rows.Add(
  239. new object[]{
  240. userName, 
  241. performance.ExecutedTimes, 
  242. OThinker.Data.Convertor.Format(new System.TimeSpan(performance.ShortestWaitTime)),
  243. OThinker.Data.Convertor.Format(new System.TimeSpan(performance.AverageWaitTime)),
  244. OThinker.Data.Convertor.Format(new System.TimeSpan(performance.LongestWaitTime)), 
  245. OThinker.Data.Convertor.Format(new System.TimeSpan(performance.ShortestUsedTime)), 
  246. OThinker.Data.Convertor.Format(new System.TimeSpan(performance.AverageUsedTime)), 
  247. OThinker.Data.Convertor.Format(new System.TimeSpan(performance.LongestUsedTime))});
  248. }
  249. }
  250. this.ReportTable = performanceTable;
  251. // 保存结果
  252. this.UserPerformanceGrid.DataSource = this.ReportTable;
  253. this.UserPerformanceGrid.DataBind();
  254. }
  255. }
  256. #endregion
  257. #region 导出报表
  258. private void btnExport_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  259. {
  260. this.Export();
  261. }
  262. protected void lnkExport_Click(object sender, System.EventArgs e)
  263. {
  264. this.Export();
  265. }
  266. #endregion
  267. }
  268. }