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

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 WorkflowACL.
  15. /// </summary>
  16.     public partial class WorkflowAcl : PortalPage
  17. {
  18. #region 参数
  19. private string UserID
  20. {
  21. get
  22. {
  23. if(this.Request.QueryString[Param_UserID] == null || this.Request.QueryString[Param_UserID] == "")
  24. {
  25. return null;
  26. }
  27. else
  28. {
  29. return System.Web.HttpUtility.UrlDecode(this.Request.QueryString[Param_UserID]);
  30. }
  31. }
  32. }
  33. private string WorkflowPackage
  34. {
  35. get
  36. {
  37. if(this.Request.QueryString[Param_WorkflowPackage] == null || this.Request.QueryString[Param_WorkflowPackage] == "")
  38. {
  39. return null;
  40. }
  41. else
  42. {
  43. return System.Web.HttpUtility.UrlDecode(this.Request.QueryString[Param_WorkflowPackage]);
  44. }
  45. }
  46. }
  47. private string WorkflowName
  48. {
  49. get
  50. {
  51. if(this.Request.QueryString[Param_WorkflowName] == null || this.Request.QueryString[Param_WorkflowName] == "")
  52. {
  53. return null;
  54. }
  55. else
  56. {
  57. return System.Web.HttpUtility.UrlDecode(this.Request.QueryString[Param_WorkflowName]);
  58. }
  59. }
  60. }
  61. #endregion
  62. protected void Page_Load(object sender, System.EventArgs e)
  63. {
  64. if(!this.IsPostBack)
  65. {
  66.                 // 验证是否具有管理员权限
  67.                 if (!this.UserValidator.ValidateAdministrator())
  68.                 {
  69.                     this.NotifyMessage(LackOfAuth);
  70.                 }
  71.                 string[] catalogs = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowPackages();
  72. this.lstWorkflowPackage.Items.Add("");
  73. if(catalogs != null)
  74. {
  75. foreach(string catalog in catalogs)
  76. {
  77. this.lstWorkflowPackage.Items.Add(catalog);
  78. }
  79. if(this.lstWorkflowPackage.Items.FindByText(this.WorkflowPackage) != null)
  80. {
  81. this.lstWorkflowPackage.SelectedValue = this.WorkflowPackage;
  82. this.lstWorkflowPackage_SelectedIndexChanged(this, null);
  83. if(this.lstWorkflowName.Items.FindByText(this.WorkflowName) != null)
  84. {
  85. this.lstWorkflowName.SelectedValue = this.WorkflowName;
  86. this.lstWorkflowName_SelectedIndexChanged(this, null);
  87. }
  88. }
  89. }
  90.                 this.lstWorkflowName_SelectedIndexChanged(this, new System.EventArgs());
  91. }
  92. this.SelectionCheckBoxes.Clear();
  93. this.WorkflowACLGrid.DataSource = this.WorkflowACLTable;
  94. this.WorkflowACLGrid.DataBind();
  95. }
  96. // CaseGrid对应的表
  97. private System.Data.DataTable WorkflowACLTable
  98. {
  99. get
  100. {
  101. return (System.Data.DataTable)this.Session[OThinker.H3.WorkSheet.Sessions.GetWorkflowACLTable(this.UserID, this.WorkflowPackage, this.WorkflowName)];
  102. }
  103. set
  104. {
  105. this.Session[OThinker.H3.WorkSheet.Sessions.GetWorkflowACLTable(this.UserID, this.WorkflowPackage, this.WorkflowName)] = value;
  106. }
  107. }
  108. #region Web Form Designer generated code
  109. override protected void OnInit(EventArgs e)
  110. {
  111. //
  112. // CODEGEN: This call is required by the ASP.NET Web Form Designer.
  113. //
  114. InitializeComponent();
  115. base.OnInit(e);
  116. }
  117. /// <summary>
  118. /// Required method for Designer support - do not modify
  119. /// the contents of this method with the code editor.
  120. /// </summary>
  121. private void InitializeComponent()
  122. {    
  123. this.WorkflowACLGrid.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.InstanceGrid_ItemDataBound);
  124. }
  125. #endregion
  126. #region 获得选中的ID
  127. private System.Collections.ArrayList SelectionCheckBoxes
  128. {
  129. get
  130. {
  131. if(this.Session[OThinker.H3.WorkSheet.Sessions.GetWorkflowACLCheckBoxes(this.UserID, this.WorkflowPackage, this.WorkflowName)] == null)
  132. {
  133. this.Session[OThinker.H3.WorkSheet.Sessions.GetWorkflowACLCheckBoxes(this.UserID, this.WorkflowPackage, this.WorkflowName)] = new System.Collections.ArrayList();
  134. }
  135. return (System.Collections.ArrayList)this.Session[OThinker.H3.WorkSheet.Sessions.GetWorkflowACLCheckBoxes(this.UserID, this.WorkflowPackage, this.WorkflowName)];
  136. }
  137. }
  138. // 获得选中的Case ID
  139.         private string[] GetSelectedACLs()
  140. {
  141. // 获得选中的
  142. System.Collections.ArrayList selections = new ArrayList();
  143. for(int count=0; count<this.SelectionCheckBoxes.Count; count++)
  144. {
  145. if(((System.Web.UI.WebControls.CheckBox)this.SelectionCheckBoxes[count]).Checked)
  146. {
  147. System.Data.DataRow row = this.WorkflowACLTable.Rows[count];
  148. selections.Add(row["ObjectID"]);
  149. }
  150. }
  151.             string[] selectedCases = new string[selections.Count];
  152. for(int count=0; count<selectedCases.Length; count++)
  153. {
  154. selectedCases[count] = selections[count].ToString();
  155. }
  156. return selectedCases;
  157. }
  158. private void InstanceGrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
  159. {
  160. if(
  161. e.Item.ItemType != System.Web.UI.WebControls.ListItemType.Header && 
  162. e.Item.ItemType != System.Web.UI.WebControls.ListItemType.Footer)
  163. {
  164. CheckBox box = new System.Web.UI.WebControls.CheckBox();
  165. this.SelectionCheckBoxes.Add(box);
  166. e.Item.Cells[0].Controls.Add(box);
  167. e.Item.Cells[2].Text = OThinker.H3.Server.Engine.Organization.GetFullName(e.Item.Cells[2].Text);
  168. Label processFullName = new Label();
  169. processFullName.Text = e.Item.Cells[3].Text + "\" + e.Item.Cells[4].Text;
  170. e.Item.Cells[5].Controls.Add(processFullName);
  171. // 授予权限 
  172. CheckBox administrator = new CheckBox();
  173. administrator.Enabled = false;
  174. if(e.Item.Cells[6].Text == "1")
  175. {
  176. administrator.Checked = true;
  177. }
  178. else
  179. {
  180. administrator.Checked = false;
  181. }
  182. e.Item.Cells[6].Controls.Add(administrator);
  183. // 发起流程
  184.                 CheckBox createInstance = new CheckBox();
  185. createInstance.Enabled = false;
  186. if(e.Item.Cells[7].Text == "1")
  187. {
  188. createInstance.Checked = true;
  189. }
  190. else
  191. {
  192. createInstance.Checked = false;
  193. }
  194. e.Item.Cells[7].Controls.Add(createInstance);
  195. // // 发布新版本 
  196. // CheckBox publishNewVersion = new CheckBox();
  197. // publishNewVersion.Enabled = false;
  198. // if(e.Item.Cells[6].Text == "1")
  199. // {
  200. // publishNewVersion.Checked = true;
  201. // }
  202. // else
  203. // {
  204. // publishNewVersion.Checked = false;
  205. // }
  206. // e.Item.Cells[6].Controls.Add(publishNewVersion);
  207. //
  208. // // 查看性能报表 
  209. // CheckBox viewReport = new CheckBox();
  210. // viewReport.Enabled = false;
  211. // if(e.Item.Cells[7].Text == "1")
  212. // {
  213. // viewReport.Checked = true;
  214. // }
  215. // else
  216. // {
  217. // viewReport.Checked = false;
  218. // }
  219. // e.Item.Cells[7].Controls.Add(viewReport);
  220. //
  221. // // 查看该模板下的所有流程 
  222. // CheckBox viewCases = new CheckBox();
  223. // viewCases.Enabled = false;
  224. // if(e.Item.Cells[8].Text == "1")
  225. // {
  226. // viewCases.Checked = true;
  227. // }
  228. // else
  229. // {
  230. // viewCases.Checked = false;
  231. // }
  232. // e.Item.Cells[8].Controls.Add(viewCases);
  233. //
  234. // // 管理该模板下的所有流程 
  235. // CheckBox adminCases = new CheckBox();
  236. // adminCases.Enabled = false;
  237. // if(e.Item.Cells[9].Text == "1")
  238. // {
  239. // adminCases.Checked = true;
  240. // }
  241. // else
  242. // {
  243. // adminCases.Checked = false;
  244. // }
  245. // e.Item.Cells[9].Controls.Add(adminCases);
  246. }
  247. }
  248. #endregion
  249. protected void btnAdd_Click(object sender, System.EventArgs e)
  250. {
  251. string catalog = this.lstWorkflowPackage.SelectedValue;
  252. string name = this.lstWorkflowName.SelectedValue;
  253. if(
  254. catalog != null && catalog != "" && 
  255. name != null && name != "")
  256. {
  257. this.Response.Redirect(
  258. PageName_AddWorkflowAcl + "?" + 
  259. Param_WorkflowPackage + "=" + System.Web.HttpUtility.UrlEncode(catalog) + "&" + 
  260. Param_WorkflowName + "=" + System.Web.HttpUtility.UrlEncode(name));
  261. }
  262. }
  263. protected void btnUpdate_Click(object sender, System.EventArgs e)
  264. {
  265.             string[] acls = this.GetSelectedACLs();
  266. if(acls.Length == 0)
  267. {
  268. // ERROR,导到错误页面上
  269. }
  270. else
  271. {
  272. this.Response.Redirect(PageName_UpdateWorkflowAcl + "?" + Param_AclID + "=" + acls[0]);
  273. }
  274. }
  275. protected void lstWorkflowPackage_SelectedIndexChanged(object sender, System.EventArgs e)
  276. {
  277. string catalog = this.lstWorkflowPackage.SelectedValue;
  278.             if (catalog == null || catalog == "")
  279.             {
  280.                 this.lstWorkflowName.Items.Clear();
  281.             }
  282.             else
  283. {
  284.                 string[] names = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowNames(catalog, OThinker.H3.WorkflowTemplate.WorkflowState.Unspecified);
  285. this.lstWorkflowName.Items.Clear();
  286. this.lstWorkflowName.Items.Add("");
  287. foreach(string name in names)
  288. {
  289. this.lstWorkflowName.Items.Add(name);
  290. }
  291.             }
  292.             this.WorkflowACLTable = null;
  293. }
  294. protected void lstWorkflowName_SelectedIndexChanged(object sender, System.EventArgs e)
  295. {
  296. string catalog = this.lstWorkflowPackage.SelectedValue;
  297. string name = this.lstWorkflowName.SelectedValue;
  298. if(
  299. catalog != null && catalog != "" && 
  300. name != null && name != "" &&
  301. this.UserValidator.ValidateWorkflowAdministrator(catalog, name))
  302. {
  303. // 拥有设置的权限
  304. this.btnAdd.Enabled = true;
  305. this.btnDel.Enabled = true;
  306. this.btnUpdate.Enabled = true;
  307. this.WorkflowACLTable 
  308. = OThinker.H3.Server.Engine.WorkflowAclManager.QueryDataTable(
  309. null, 
  310. catalog, 
  311. name, 
  312. OThinker.Data.BoolMatchValue.Unspecified, 
  313. OThinker.Data.BoolMatchValue.Unspecified);
  314. }
  315. else
  316. {
  317. this.btnAdd.Enabled = false;
  318. this.btnDel.Enabled = false;
  319. this.btnUpdate.Enabled = false;
  320. this.WorkflowACLTable = null;
  321. }
  322. this.SelectionCheckBoxes.Clear();
  323. this.WorkflowACLGrid.DataSource = this.WorkflowACLTable;
  324. this.WorkflowACLGrid.DataBind();
  325. }
  326. protected void btnDel_Click(object sender, System.EventArgs e)
  327. {
  328.             string[] ids = this.GetSelectedACLs();
  329.             foreach (string id in ids)
  330. {
  331. OThinker.H3.Server.Engine.WorkflowAclManager.Delete(id);
  332. }
  333. // 刷新这个页面
  334. string catalog = this.lstWorkflowPackage.SelectedValue;
  335. string name = this.lstWorkflowName.SelectedValue;
  336. this.Response.Redirect(
  337.                 PageName_WorkflowAcl + "?" + 
  338. Param_WorkflowPackage + "=" + System.Web.HttpUtility.UrlEncode(catalog) + "&" + 
  339. Param_WorkflowName + "=" + System.Web.HttpUtility.UrlEncode(name));
  340. }
  341. }
  342. }