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

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. /// 查询满足条件的流程实例
  15. /// </summary>
  16.     public partial class QueryInstanceByProperty : PortalPage
  17. {
  18. protected System.Web.UI.WebControls.Panel QueryPanel;
  19. protected void Page_Load(object sender, System.EventArgs e)
  20. {
  21.             this.OriginatorSelector.SelectUserUrl = PageName_SelectUser;
  22.             this.OriginatorSelector.SelectUserImageUrl = PageName_SelectUserImage;
  23. // 获得所有流程
  24. if(!IsPostBack)
  25. {
  26.                 // 验证是否具有管理员权限
  27.                 if (!this.UserValidator.ValidateViewReport())
  28.                 {
  29.                     this.NotifyMessage(LackOfAuth);
  30.                 }
  31. // 设置默认的搜索时间
  32. System.DateTime today = System.DateTime.Now;
  33. System.DateTime tomorrow = today.Add(new System.TimeSpan(1, 0, 0, 0, 0));
  34. this.txtFromTime.Text = today.ToShortDateString();
  35. this.txtToTime.Text = tomorrow.ToShortDateString();
  36. foreach(string instanceState in OThinker.H3.Instance.InstanceStateConvertor.GetAllState())
  37. {
  38.                     this.lstState.Items.Add(instanceState);
  39. }
  40. // 当前引擎内的所有流程类型
  41. string[] catalogs = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowPackages();
  42. // 添加一个空项
  43. this.lstWorkflowPackage.Items.Add("");
  44. if(catalogs != null)
  45. {
  46. foreach(string processCatalog in catalogs)
  47. {
  48. this.lstWorkflowPackage.Items.Add(processCatalog);
  49. }
  50. }
  51. this.lstWorkflowPackage_SelectedIndexChanged(this, null);
  52. }
  53. }
  54. #region Web Form Designer generated code
  55. override protected void OnInit(EventArgs e)
  56. {
  57. //
  58. // CODEGEN: This call is required by the ASP.NET Web Form Designer.
  59. //
  60. InitializeComponent();
  61. base.OnInit(e);
  62. }
  63. /// <summary>
  64. /// Required method for Designer support - do not modify
  65. /// the contents of this method with the code editor.
  66. /// </summary>
  67. private void InitializeComponent()
  68. {    
  69. this.btnQuery.Click += new System.Web.UI.ImageClickEventHandler(this.btnQuery_Click);
  70. }
  71. #endregion
  72. protected void lstWorkflowPackage_SelectedIndexChanged(object sender, System.EventArgs e)
  73. {
  74. this.lstWorkflowName.Items.Clear();
  75. string catalog = this.lstWorkflowPackage.SelectedValue;
  76. this.lstWorkflowName.Items.Add("");
  77.             string[] names = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowNames(catalog, OThinker.H3.WorkflowTemplate.WorkflowState.Unspecified);
  78. if(names != null)
  79. {
  80. foreach(string name in names)
  81. {
  82. this.lstWorkflowName.Items.Add(name);
  83. }
  84. }
  85. }
  86. private void btnQuery_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  87. {
  88. this.Query();
  89. }
  90. private void Query()
  91. {
  92. string[] originators = null;
  93.             string selectedUser = this.OriginatorSelector.SelectedUser;
  94.             if (selectedUser == null || selectedUser == "")
  95. {
  96. originators = null;
  97. }
  98. else
  99. {
  100.                 originators = OThinker.H3.Server.Engine.Organization.GetMembers(new string[] { selectedUser });
  101. }
  102. OThinker.H3.Instance.InstanceState state = OThinker.H3.Instance.InstanceStateConvertor.ToState(this.lstState.SelectedValue);
  103. string catalog;
  104. if(this.lstWorkflowPackage.SelectedValue == null || this.lstWorkflowPackage.SelectedValue == "")
  105. {
  106. catalog = null;
  107. }
  108. else
  109. {
  110. catalog = this.lstWorkflowPackage.SelectedValue.Trim();
  111. }
  112. string name;
  113. if(this.lstWorkflowName.SelectedValue == null || this.lstWorkflowName.SelectedValue == "")
  114. {
  115. name = null;
  116. }
  117. else
  118. {
  119. name = this.lstWorkflowName.SelectedValue.Trim();
  120. }
  121. System.DateTime from;
  122. try
  123. {
  124. from = System.DateTime.Parse(this.txtFromTime.Text);
  125. }
  126. catch
  127. {
  128. from = System.DateTime.MinValue;
  129. }
  130. System.DateTime to;
  131. try
  132. {
  133. to = System.DateTime.Parse(this.txtToTime.Text);
  134. }
  135. catch
  136. {
  137. to = System.DateTime.MaxValue;
  138. }
  139. if(
  140. originators == null && 
  141. state == OThinker.H3.Instance.InstanceState.Unspecified &&
  142. catalog == null && 
  143. name == null &&
  144. from == System.DateTime.MinValue && 
  145. to == System.DateTime.MaxValue)
  146. {
  147. // 所有的查询条件都没有赋值,不进行查询
  148. }
  149. else
  150. {
  151. // 查找满足条件的实例
  152. System.Data.DataTable table = Portal.Query.QueryInstance(
  153. null, 
  154. originators, 
  155. null, 
  156. OThinker.H3.Instance.InstanceContext.UnspecifiedID, 
  157. state, 
  158. catalog, 
  159. name,
  160.                     OThinker.H3.WorkflowTemplate.WorkflowTemplate.NullWorkflowVersion, 
  161. from, 
  162. to,
  163.                     null,
  164.                     OThinker.H3.Instance.PriorityType.Unspecified, 
  165.                     OThinker.Data.BoolMatchValue.Unspecified,
  166.                     OThinker.Data.BoolMatchValue.Unspecified);
  167. this.InstanceGridView.BindDataGrid(table);
  168. }
  169. }
  170. protected void lnkQuery_Click(object sender, System.EventArgs e)
  171. {
  172. this.Query();
  173. }
  174. }
  175. }