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

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 StartInstanceSps : PortalPage
  14.     {
  15.         protected string WorkflowPackage
  16.         {
  17.             get
  18.             {
  19.                 return HttpUtility.UrlDecode(this.Request.QueryString[Param_WorkflowPackage]);
  20.             }
  21.         }
  22.         protected string WorkflowName
  23.         {
  24.             get
  25.             {
  26.                 return HttpUtility.UrlDecode(this.Request.QueryString[Param_WorkflowName]);
  27.             }
  28.         }
  29.         private int _WorkflowVersion = WorkflowTemplate.WorkflowTemplate.NullWorkflowVersion;
  30.         protected int WorkflowVersion
  31.         {
  32.             get
  33.             {
  34.                 if (this._WorkflowVersion == WorkflowTemplate.WorkflowTemplate.NullWorkflowVersion)
  35.                 {
  36.                     string strVersion = this.Request.QueryString[Param_WorkflowVersion];
  37.                     if (strVersion == null || strVersion == "")
  38.                     {
  39.                         this._WorkflowVersion = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowDefaultVersion(this.WorkflowPackage, this.WorkflowName);
  40.                     }
  41.                     else
  42.                     {
  43.                         this._WorkflowVersion = int.Parse(strVersion);
  44.                     }
  45.                 }
  46.                 return this._WorkflowVersion;
  47.             }
  48.         }
  49.         protected string InstanceName
  50.         {
  51.             get
  52.             {
  53.                 return this.Request.QueryString[Param_InstanceName];
  54.             }
  55.         }
  56.         protected OThinker.H3.Instance.PriorityType Priority
  57.         {
  58.             get
  59.             {
  60.                 string strPriority = this.Request.QueryString[Param_Priority];
  61.                 if (strPriority == null || strPriority == "")
  62.                 {
  63.                     return OThinker.H3.Instance.PriorityType.Normal;
  64.                 }
  65.                 else
  66.                 {
  67.                     return OThinker.H3.Instance.PriorityTypeConvertor.ToPriorityType(strPriority);
  68.                 }
  69.             }
  70.         }
  71.         protected string SpsSite
  72.         {
  73.             get
  74.             {
  75.                 return HttpUtility.UrlDecode(this.Request.QueryString[Instance.InstanceContext.PropertyName_SpsSite]);
  76.             }
  77.         }
  78.         protected string SpsWebName
  79.         {
  80.             get
  81.             {
  82.                 return HttpUtility.UrlDecode(this.Request.QueryString[Instance.InstanceContext.PropertyName_SpsWebName]);
  83.             }
  84.         }
  85.         protected string SpsList
  86.         {
  87.             get
  88.             {
  89.                 return HttpUtility.UrlDecode(this.Request.QueryString[Instance.InstanceContext.PropertyName_SpsList]);
  90.             }
  91.         }
  92.         protected int SpsListItemId
  93.         {
  94.             get
  95.             {
  96.                 return int.Parse(HttpUtility.UrlDecode(this.Request.QueryString[Instance.InstanceContext.PropertyName_SpsListItemId]));
  97.             }
  98.         }
  99.         protected string OriginateRole
  100.         {
  101.             get
  102.             {
  103.                 return this.Request.QueryString[Param_OriginateRole];
  104.             }
  105.         }
  106.         protected void Page_Load(object sender, EventArgs e)
  107.         {
  108.             string[] groups = null;
  109.             if (this.OriginateRole != null && this.OriginateRole != "")
  110.             {
  111.                 this.Originate(this.OriginateRole);
  112.             }
  113.             else if ((groups = OThinker.H3.Server.Engine.Organization.GetParentGroups(this.UserValidator.UserID)) == null || groups.Length == 0)
  114.             {
  115.                 this.Originate(null);
  116.             }
  117.             else if(groups.Length == 0)
  118.             {
  119.                 this.Originate(groups[0]);
  120.             }
  121.             else
  122.             {
  123.                 foreach (string group in groups)
  124.                 {
  125.                     string groupPath = OThinker.H3.Server.Engine.Organization.GetFullName(group);
  126.                     this.lstOriginateRole.Items.Add(new ListItem(groupPath, group));
  127.                 }
  128.             }
  129.         }
  130.         private void Originate(string OriginateRole)
  131.         {
  132.             // Parameters
  133.             System.Collections.Generic.Dictionary<string, object> instanceParamter = new System.Collections.Generic.Dictionary<string, object>();
  134.             instanceParamter.Add(Instance.InstanceContext.PropertyName_SpsSite, this.SpsSite);
  135.             instanceParamter.Add(Instance.InstanceContext.PropertyName_SpsWebName, this.SpsWebName);
  136.             instanceParamter.Add(Instance.InstanceContext.PropertyName_SpsList, this.SpsList);
  137.             instanceParamter.Add(Instance.InstanceContext.PropertyName_SpsListItemId, this.SpsListItemId);
  138.             // 发起流程
  139.             string itemId = base.OriginateInstance(this.WorkflowPackage, this.WorkflowName, this.WorkflowVersion, this.Priority, null, null, instanceParamter);
  140.             OThinker.H3.WorkItem.WorkItem item = OThinker.H3.Server.Engine.WorkItemManager.GetWorkItem(itemId);
  141.             this.Response.Redirect(PortalPage.GetWorkSheetUrl(item));
  142.         }
  143.         protected void lnkSubmit_Click(object sender, EventArgs e)
  144.         {
  145.             string group = this.lstOriginateRole.SelectedValue;
  146.             this.Originate(group);
  147.         }
  148. }
  149. }