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

OA系统

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. namespace OThinker.H3.Portal
  12. {
  13.     public partial class ActivateWorkflow : PortalPage
  14.     {
  15.         protected void Page_Load(object sender, EventArgs e)
  16.         {
  17.             if (!this.IsPostBack)
  18.             {
  19.                 // 验证是否具有管理员权限
  20.                 if (!this.UserValidator.ValidateAdministrator())
  21.                 {
  22.                     this.NotifyMessage(LackOfAuth);
  23.                 }
  24.                 // 加载模板类型
  25.                 this.lstWorkflowPackage.Items.Clear();
  26.                 string[] packages = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowPackages();
  27.                 if (packages != null && packages.Length != 0)
  28.                 {
  29.                     foreach (string package in packages)
  30.                     {
  31.                         this.lstWorkflowPackage.Items.Add(package);
  32.                     }
  33.                     this.lstWorkflowPackage.SelectedIndex = 0;
  34.                     this.lstWorkflowPackage_SelectedIndexChanged(this, new EventArgs());
  35.                 }
  36.             }
  37.         }
  38.         protected void lstWorkflowPackage_SelectedIndexChanged(object sender, EventArgs e)
  39.         {
  40.             if (this.lstWorkflowPackage.SelectedItem == null)
  41.             {
  42.                 return;
  43.             }
  44.             string package = this.lstWorkflowPackage.SelectedItem.Text;
  45.             OThinker.H3.WorkflowTemplate.WorkflowState filterState = new OThinker.H3.WorkflowTemplate.WorkflowState();
  46.             filterState.OriginatorVisible = false;
  47.             string[] names = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowNames(package, filterState);
  48.             this.lstWorkflowName.Items.Clear();
  49.             if (names != null && names.Length != 0)
  50.             {
  51.                 foreach (string name in names)
  52.                 {
  53.                     this.lstWorkflowName.Items.Add(name);
  54.                 }
  55.                 this.lstWorkflowName.SelectedIndex = 0;
  56.             }
  57.             this.lstWorkflowName_SelectedIndexChanged(this, new EventArgs());
  58.         }
  59.         protected void lstWorkflowName_SelectedIndexChanged(object sender, EventArgs e)
  60.         {
  61.             string package = this.lstWorkflowPackage.SelectedItem.Text;
  62.             if (this.lstWorkflowName.SelectedItem == null)
  63.             {
  64.                 return;
  65.             }
  66.             string name = this.lstWorkflowName.SelectedItem.Text;
  67.             // 获得选中的工作流模板的状态
  68.             WorkflowTemplate.WorkflowState state = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowState(package, name);
  69.             this.chkOriginatorVisible.Checked = state.OriginatorVisible;
  70.             this.chkPerformanceReportVisible.Checked = state.PerformanceReportVisible;
  71.             this.chkSearchWorkItemVisible.Checked = state.SearchWorkItemVisible;
  72.             this.chkSearchInstanceVisible.Checked = state.SearchInstanceVisible;
  73.         }
  74.         protected void btnSubmit_Click(object sender, EventArgs e)
  75.         {
  76.             // 检查是否有被选中的
  77.             if (this.lstWorkflowPackage.SelectedItem == null || this.lstWorkflowName.SelectedItem == null)
  78.             {
  79.                 this.NotifyMessage("没有选中的工作流模板");
  80.             }
  81.             string package = this.lstWorkflowPackage.SelectedItem.Text;
  82.             string name = this.lstWorkflowName.SelectedItem.Text;
  83.             // 获得选中的工作流模板的状态
  84.             WorkflowTemplate.WorkflowState state = new OThinker.H3.WorkflowTemplate.WorkflowState();
  85.             state.OriginatorVisible = this.chkOriginatorVisible.Checked;
  86.             state.PerformanceReportVisible = this.chkPerformanceReportVisible.Checked;
  87.             state.SearchInstanceVisible = this.chkSearchInstanceVisible.Checked;
  88.             state.SearchWorkItemVisible = this.chkSearchWorkItemVisible.Checked;
  89.             // 设置状态
  90.             OThinker.H3.Server.Engine.WorkflowManager.SetWorkflowState(package, name, state);
  91.             // 通知结果
  92.             this.NotifyMessage("设置流程模板状态成功");
  93.         }
  94.     }
  95. }