WorkflowAcl.aspx.cs
资源名称:H3_OA.rar [点击查看]
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:11k
源码类别:
OA系统
开发平台:
C#
- using System;
- using System.Collections;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Web;
- using System.Web.SessionState;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.HtmlControls;
- namespace OThinker.H3.Portal
- {
- /// <summary>
- /// Summary description for WorkflowACL.
- /// </summary>
- public partial class WorkflowAcl : PortalPage
- {
- #region 参数
- private string UserID
- {
- get
- {
- if(this.Request.QueryString[Param_UserID] == null || this.Request.QueryString[Param_UserID] == "")
- {
- return null;
- }
- else
- {
- return System.Web.HttpUtility.UrlDecode(this.Request.QueryString[Param_UserID]);
- }
- }
- }
- private string WorkflowPackage
- {
- get
- {
- if(this.Request.QueryString[Param_WorkflowPackage] == null || this.Request.QueryString[Param_WorkflowPackage] == "")
- {
- return null;
- }
- else
- {
- return System.Web.HttpUtility.UrlDecode(this.Request.QueryString[Param_WorkflowPackage]);
- }
- }
- }
- private string WorkflowName
- {
- get
- {
- if(this.Request.QueryString[Param_WorkflowName] == null || this.Request.QueryString[Param_WorkflowName] == "")
- {
- return null;
- }
- else
- {
- return System.Web.HttpUtility.UrlDecode(this.Request.QueryString[Param_WorkflowName]);
- }
- }
- }
- #endregion
- protected void Page_Load(object sender, System.EventArgs e)
- {
- if(!this.IsPostBack)
- {
- // 验证是否具有管理员权限
- if (!this.UserValidator.ValidateAdministrator())
- {
- this.NotifyMessage(LackOfAuth);
- }
- string[] catalogs = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowPackages();
- this.lstWorkflowPackage.Items.Add("");
- if(catalogs != null)
- {
- foreach(string catalog in catalogs)
- {
- this.lstWorkflowPackage.Items.Add(catalog);
- }
- if(this.lstWorkflowPackage.Items.FindByText(this.WorkflowPackage) != null)
- {
- this.lstWorkflowPackage.SelectedValue = this.WorkflowPackage;
- this.lstWorkflowPackage_SelectedIndexChanged(this, null);
- if(this.lstWorkflowName.Items.FindByText(this.WorkflowName) != null)
- {
- this.lstWorkflowName.SelectedValue = this.WorkflowName;
- this.lstWorkflowName_SelectedIndexChanged(this, null);
- }
- }
- }
- this.lstWorkflowName_SelectedIndexChanged(this, new System.EventArgs());
- }
- this.SelectionCheckBoxes.Clear();
- this.WorkflowACLGrid.DataSource = this.WorkflowACLTable;
- this.WorkflowACLGrid.DataBind();
- }
- // CaseGrid对应的表
- private System.Data.DataTable WorkflowACLTable
- {
- get
- {
- return (System.Data.DataTable)this.Session[OThinker.H3.WorkSheet.Sessions.GetWorkflowACLTable(this.UserID, this.WorkflowPackage, this.WorkflowName)];
- }
- set
- {
- this.Session[OThinker.H3.WorkSheet.Sessions.GetWorkflowACLTable(this.UserID, this.WorkflowPackage, this.WorkflowName)] = value;
- }
- }
- #region Web Form Designer generated code
- override protected void OnInit(EventArgs e)
- {
- //
- // CODEGEN: This call is required by the ASP.NET Web Form Designer.
- //
- InitializeComponent();
- base.OnInit(e);
- }
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- this.WorkflowACLGrid.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.InstanceGrid_ItemDataBound);
- }
- #endregion
- #region 获得选中的ID
- private System.Collections.ArrayList SelectionCheckBoxes
- {
- get
- {
- if(this.Session[OThinker.H3.WorkSheet.Sessions.GetWorkflowACLCheckBoxes(this.UserID, this.WorkflowPackage, this.WorkflowName)] == null)
- {
- this.Session[OThinker.H3.WorkSheet.Sessions.GetWorkflowACLCheckBoxes(this.UserID, this.WorkflowPackage, this.WorkflowName)] = new System.Collections.ArrayList();
- }
- return (System.Collections.ArrayList)this.Session[OThinker.H3.WorkSheet.Sessions.GetWorkflowACLCheckBoxes(this.UserID, this.WorkflowPackage, this.WorkflowName)];
- }
- }
- // 获得选中的Case ID
- private string[] GetSelectedACLs()
- {
- // 获得选中的
- System.Collections.ArrayList selections = new ArrayList();
- for(int count=0; count<this.SelectionCheckBoxes.Count; count++)
- {
- if(((System.Web.UI.WebControls.CheckBox)this.SelectionCheckBoxes[count]).Checked)
- {
- System.Data.DataRow row = this.WorkflowACLTable.Rows[count];
- selections.Add(row["ObjectID"]);
- }
- }
- string[] selectedCases = new string[selections.Count];
- for(int count=0; count<selectedCases.Length; count++)
- {
- selectedCases[count] = selections[count].ToString();
- }
- return selectedCases;
- }
- private void InstanceGrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
- {
- if(
- e.Item.ItemType != System.Web.UI.WebControls.ListItemType.Header &&
- e.Item.ItemType != System.Web.UI.WebControls.ListItemType.Footer)
- {
- CheckBox box = new System.Web.UI.WebControls.CheckBox();
- this.SelectionCheckBoxes.Add(box);
- e.Item.Cells[0].Controls.Add(box);
- e.Item.Cells[2].Text = OThinker.H3.Server.Engine.Organization.GetFullName(e.Item.Cells[2].Text);
- Label processFullName = new Label();
- processFullName.Text = e.Item.Cells[3].Text + "\" + e.Item.Cells[4].Text;
- e.Item.Cells[5].Controls.Add(processFullName);
- // 授予权限
- CheckBox administrator = new CheckBox();
- administrator.Enabled = false;
- if(e.Item.Cells[6].Text == "1")
- {
- administrator.Checked = true;
- }
- else
- {
- administrator.Checked = false;
- }
- e.Item.Cells[6].Controls.Add(administrator);
- // 发起流程
- CheckBox createInstance = new CheckBox();
- createInstance.Enabled = false;
- if(e.Item.Cells[7].Text == "1")
- {
- createInstance.Checked = true;
- }
- else
- {
- createInstance.Checked = false;
- }
- e.Item.Cells[7].Controls.Add(createInstance);
- // // 发布新版本
- // CheckBox publishNewVersion = new CheckBox();
- // publishNewVersion.Enabled = false;
- // if(e.Item.Cells[6].Text == "1")
- // {
- // publishNewVersion.Checked = true;
- // }
- // else
- // {
- // publishNewVersion.Checked = false;
- // }
- // e.Item.Cells[6].Controls.Add(publishNewVersion);
- //
- // // 查看性能报表
- // CheckBox viewReport = new CheckBox();
- // viewReport.Enabled = false;
- // if(e.Item.Cells[7].Text == "1")
- // {
- // viewReport.Checked = true;
- // }
- // else
- // {
- // viewReport.Checked = false;
- // }
- // e.Item.Cells[7].Controls.Add(viewReport);
- //
- // // 查看该模板下的所有流程
- // CheckBox viewCases = new CheckBox();
- // viewCases.Enabled = false;
- // if(e.Item.Cells[8].Text == "1")
- // {
- // viewCases.Checked = true;
- // }
- // else
- // {
- // viewCases.Checked = false;
- // }
- // e.Item.Cells[8].Controls.Add(viewCases);
- //
- // // 管理该模板下的所有流程
- // CheckBox adminCases = new CheckBox();
- // adminCases.Enabled = false;
- // if(e.Item.Cells[9].Text == "1")
- // {
- // adminCases.Checked = true;
- // }
- // else
- // {
- // adminCases.Checked = false;
- // }
- // e.Item.Cells[9].Controls.Add(adminCases);
- }
- }
- #endregion
- protected void btnAdd_Click(object sender, System.EventArgs e)
- {
- string catalog = this.lstWorkflowPackage.SelectedValue;
- string name = this.lstWorkflowName.SelectedValue;
- if(
- catalog != null && catalog != "" &&
- name != null && name != "")
- {
- this.Response.Redirect(
- PageName_AddWorkflowAcl + "?" +
- Param_WorkflowPackage + "=" + System.Web.HttpUtility.UrlEncode(catalog) + "&" +
- Param_WorkflowName + "=" + System.Web.HttpUtility.UrlEncode(name));
- }
- }
- protected void btnUpdate_Click(object sender, System.EventArgs e)
- {
- string[] acls = this.GetSelectedACLs();
- if(acls.Length == 0)
- {
- // ERROR,导到错误页面上
- }
- else
- {
- this.Response.Redirect(PageName_UpdateWorkflowAcl + "?" + Param_AclID + "=" + acls[0]);
- }
- }
- protected void lstWorkflowPackage_SelectedIndexChanged(object sender, System.EventArgs e)
- {
- string catalog = this.lstWorkflowPackage.SelectedValue;
- if (catalog == null || catalog == "")
- {
- this.lstWorkflowName.Items.Clear();
- }
- else
- {
- string[] names = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowNames(catalog, OThinker.H3.WorkflowTemplate.WorkflowState.Unspecified);
- this.lstWorkflowName.Items.Clear();
- this.lstWorkflowName.Items.Add("");
- foreach(string name in names)
- {
- this.lstWorkflowName.Items.Add(name);
- }
- }
- this.WorkflowACLTable = null;
- }
- protected void lstWorkflowName_SelectedIndexChanged(object sender, System.EventArgs e)
- {
- string catalog = this.lstWorkflowPackage.SelectedValue;
- string name = this.lstWorkflowName.SelectedValue;
- if(
- catalog != null && catalog != "" &&
- name != null && name != "" &&
- this.UserValidator.ValidateWorkflowAdministrator(catalog, name))
- {
- // 拥有设置的权限
- this.btnAdd.Enabled = true;
- this.btnDel.Enabled = true;
- this.btnUpdate.Enabled = true;
- this.WorkflowACLTable
- = OThinker.H3.Server.Engine.WorkflowAclManager.QueryDataTable(
- null,
- catalog,
- name,
- OThinker.Data.BoolMatchValue.Unspecified,
- OThinker.Data.BoolMatchValue.Unspecified);
- }
- else
- {
- this.btnAdd.Enabled = false;
- this.btnDel.Enabled = false;
- this.btnUpdate.Enabled = false;
- this.WorkflowACLTable = null;
- }
- this.SelectionCheckBoxes.Clear();
- this.WorkflowACLGrid.DataSource = this.WorkflowACLTable;
- this.WorkflowACLGrid.DataBind();
- }
- protected void btnDel_Click(object sender, System.EventArgs e)
- {
- string[] ids = this.GetSelectedACLs();
- foreach (string id in ids)
- {
- OThinker.H3.Server.Engine.WorkflowAclManager.Delete(id);
- }
- // 刷新这个页面
- string catalog = this.lstWorkflowPackage.SelectedValue;
- string name = this.lstWorkflowName.SelectedValue;
- this.Response.Redirect(
- PageName_WorkflowAcl + "?" +
- Param_WorkflowPackage + "=" + System.Web.HttpUtility.UrlEncode(catalog) + "&" +
- Param_WorkflowName + "=" + System.Web.HttpUtility.UrlEncode(name));
- }
- }
- }