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

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 MyInstance2 : PortalPage
  14.     {
  15.         protected DataTable InstanceTable
  16.         {
  17.             get
  18.             {
  19.                 return (DataTable)Session[OThinker.H3.WorkSheet.Sessions.GetMyWorkItemTable()];
  20.             }
  21.             set
  22.             {
  23.                 Session[OThinker.H3.WorkSheet.Sessions.GetMyWorkItemTable()] = value;
  24.             }
  25.         }
  26.         private OThinker.H3.Instance.InstanceState State
  27.         {
  28.             get
  29.             {
  30.                 string state = System.Web.HttpUtility.UrlDecode(this.Request.QueryString[Param_State]);
  31.                 if (state == null || state == "")
  32.                 {
  33.                     return OThinker.H3.Instance.InstanceState.Unfinished;
  34.                 }
  35.                 else
  36.                 {
  37.                     return OThinker.H3.Instance.InstanceStateConvertor.ToState(state);
  38.                 }
  39.             }
  40.         }
  41.         protected void Page_Load(object sender, EventArgs e)
  42.         {
  43.             if (!this.IsPostBack)
  44.             {
  45.                 // 工作流模板的包
  46.                 string[] packages = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowPackages();
  47.                 this.lstWorkflowPackage.Items.Add(new ListItem("所有", "All"));
  48.                 if (packages != null)
  49.                 {
  50.                     foreach (string package in packages)
  51.                     {
  52.                         this.lstWorkflowPackage.Items.Add(package);
  53.                     }
  54.                 }
  55.                 this.lstWorkflowPackage_SelectedIndexChanged(this, new EventArgs());
  56.                 // 设置搜索日期
  57.                 this.StartTime.TimeValue = System.DateTime.Now.Subtract(new TimeSpan(7, 0, 0, 0));
  58.                 this.EndTime.TimeValue = System.DateTime.Now.Add(new TimeSpan(1, 0, 0, 0));
  59.                 // 状态
  60.                 if (this.State == OThinker.H3.Instance.InstanceState.Unfinished)
  61.                 {
  62.                     this.lstState.SelectedIndex = 1;
  63.                 }
  64.                 else
  65.                 {
  66.                     this.lstState.SelectedIndex = 2;
  67.                 }
  68.                 // 搜索默认的工作项表
  69.                 // 查找我发起且未完成的流程表
  70.                 this.InstanceTable = Query.QueryInstance(
  71.                     null,
  72.                     new string[] { this.UserValidator.UserID },
  73.                     null,
  74.                     Instance.InstanceContext.UnspecifiedID,
  75.                     this.State,
  76.                     null,
  77.                     null,
  78.                     WorkflowTemplate.WorkflowTemplate.NullWorkflowVersion,
  79.                     System.DateTime.MinValue,
  80.                     System.DateTime.MaxValue, 
  81.                     null,
  82.                     OThinker.H3.Instance.PriorityType.Unspecified,
  83.                     OThinker.Data.BoolMatchValue.Unspecified,
  84.                     OThinker.Data.BoolMatchValue.Unspecified);
  85.             }
  86.             this.InstanceGridView.BindDataGrid(this.InstanceTable);
  87.         }
  88.         protected void lstWorkflowPackage_SelectedIndexChanged(object sender, EventArgs e)
  89.         {
  90.             this.lstWorkflowName.Items.Clear();
  91.             this.lstWorkflowName.Items.Add(new ListItem("所有", "All"));
  92.             if (this.lstWorkflowPackage.SelectedItem != null)
  93.             {
  94.                 string selectedPackage = this.lstWorkflowPackage.SelectedItem.Value;
  95.                 if (selectedPackage != null && selectedPackage != "" && selectedPackage != "All")
  96.                 {
  97.                     string[] names = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowNames(selectedPackage, OThinker.H3.WorkflowTemplate.WorkflowState.Active);
  98.                     if (names != null)
  99.                     {
  100.                         foreach (string name in names)
  101.                         {
  102.                             this.lstWorkflowName.Items.Add(name);
  103.                         }
  104.                     }
  105.                 }
  106.             }
  107.         }
  108.         protected void btnSearch_Click(object sender, EventArgs e)
  109.         {
  110.             // 工作流模板参数
  111.             string workflowPackage = null;
  112.             string workflowName = null;
  113.             if (this.lstWorkflowPackage.SelectedItem.Value == "All")
  114.             {
  115.             }
  116.             else
  117.             {
  118.                 workflowPackage = this.lstWorkflowPackage.SelectedItem.Value;
  119.                 if (this.lstWorkflowName.SelectedItem.Value == "All")
  120.                 {
  121.                 }
  122.                 else
  123.                 {
  124.                     workflowName = this.lstWorkflowName.SelectedItem.Value;
  125.                 }
  126.             }
  127.             // 时间
  128.             System.DateTime startTime = System.DateTime.MinValue;
  129.             System.DateTime endTime = System.DateTime.MaxValue;
  130.             try
  131.             {
  132.                 startTime = this.StartTime.TimeValue;
  133.             }
  134.             catch
  135.             {
  136.             }
  137.             try
  138.             {
  139.                 endTime = System.DateTime.Parse(this.EndTime.Text);
  140.             }
  141.             catch
  142.             {
  143.             }
  144.             // 状态
  145.             Instance.InstanceState state = OThinker.H3.Instance.InstanceState.Unspecified;
  146.             if (this.lstState.SelectedValue == "All")
  147.             {
  148.             }
  149.             else if (this.lstState.SelectedValue == "Unfinished")
  150.             {
  151.                 state = OThinker.H3.Instance.InstanceState.Unfinished;
  152.             }
  153.             else
  154.             {
  155.                 state = OThinker.H3.Instance.InstanceState.Complete;
  156.             }
  157.             // 关键字
  158.             string keyword = this.txtKeyword.Text == null ? null : this.txtKeyword.Text.Trim();
  159.             if(keyword == null || keyword == "")
  160.             {
  161.                 keyword = null;
  162.             }
  163.             if(this.lstScope.SelectedValue == "Originate" && keyword == null)
  164.             {
  165.             // 查找
  166.             this.InstanceTable = Query.QueryInstance(
  167.                 null, 
  168.                 new string[]{this.UserValidator.UserID}, 
  169.                 null, 
  170.                 Instance.InstanceContext.UnspecifiedID, 
  171.                 state, 
  172.                 workflowPackage, 
  173.                 workflowName,
  174.                 WorkflowTemplate.WorkflowTemplate.NullWorkflowVersion, 
  175.                 startTime, 
  176.                 endTime, 
  177.                 null,
  178.                 OThinker.H3.Instance.PriorityType.Unspecified,
  179.                     OThinker.Data.BoolMatchValue.Unspecified,
  180.                     OThinker.Data.BoolMatchValue.Unspecified);
  181.             }
  182.             else if(this.lstScope.SelectedValue == "Handle" && keyword == null)
  183.             {
  184.                 this.InstanceTable = Query.QueryHandledInstance(
  185.                     workflowPackage,
  186.                     workflowName, 
  187.                     WorkflowTemplate.WorkflowTemplate.NullWorkflowVersion,
  188.                     state,
  189.                     startTime,
  190.                     endTime, 
  191.                     this.UserValidator.UserID);
  192.             }
  193.             else if(this.lstScope.SelectedValue == "Originate" && keyword != null)
  194.             {
  195.                 this.InstanceTable = Query.QueryInstance(
  196.                     null, 
  197.                     new string[]{this.UserValidator.UserID}, 
  198.                     null, 
  199.                     Instance.InstanceContext.UnspecifiedID, 
  200.                     state, 
  201.                     workflowPackage, 
  202.                     workflowName,
  203.                     WorkflowTemplate.WorkflowTemplate.NullWorkflowVersion, 
  204.                     startTime, 
  205.                     endTime, 
  206.                     keyword,
  207.                     OThinker.H3.Instance.PriorityType.Unspecified,
  208.                     OThinker.Data.BoolMatchValue.Unspecified,
  209.                     OThinker.Data.BoolMatchValue.Unspecified);
  210.             }
  211.             else if(this.lstScope.SelectedValue == "Handle" && keyword != null)
  212.             {
  213.                 // 查找满足经办条件的
  214.                 string[] instances = OThinker.H3.Server.Engine.WorkItemManager.QueryHandledInstances(
  215.                     null,
  216.                     this.UserValidator.UserID,
  217.                     OThinker.H3.WorkItem.WorkItemState.Unspecified);
  218.                 // 查找表
  219.                 this.InstanceTable = Query.QueryInstance(
  220.                     instances,
  221.                     null,
  222.                     null, 
  223.                     Instance.InstanceContext.UnspecifiedID,
  224.                     state,
  225.                     workflowPackage,
  226.                     workflowName,
  227.                     WorkflowTemplate.WorkflowTemplate.NullWorkflowVersion,
  228.                     startTime,
  229.                     endTime, 
  230.                     keyword,
  231.                     OThinker.H3.Instance.PriorityType.Unspecified,
  232.                     OThinker.Data.BoolMatchValue.Unspecified,
  233.                     OThinker.Data.BoolMatchValue.Unspecified);
  234.             }
  235.             else{
  236.                 throw new NotImplementedException();
  237.             }
  238.             this.InstanceGridView.BindDataGrid(this.InstanceTable);
  239.         }
  240.     }
  241. }