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

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 StartInstance : 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 void Page_Load(object sender, EventArgs e)
  72.         {
  73.             // 获得工作流模板
  74.             OThinker.H3.WorkflowTemplate.WorkflowTemplate workflow = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflow(this.WorkflowPackage, this.WorkflowName, this.WorkflowVersion);
  75.             // 开始节点
  76.             OThinker.H3.WorkflowTemplate.ActivityTemplate startActivity = null;
  77.             // 开始的表单
  78.             OThinker.H3.WorkflowTemplate.Sheet startSheet = null;
  79.             if (workflow.StartWithSheet &&
  80.                 (startActivity = workflow.GetActivity(workflow.StartActivity))!= null &&
  81.                 (startActivity.SheetName != null && startActivity.SheetName != "") &&
  82.                 (startSheet = workflow.GetSheet(startActivity.SheetName)) != null)
  83.             {
  84.                 string url = PortalPage.GetSheetBaseUrl(startSheet.SheetType, startSheet.SheetAddress);
  85.                 if (url.LastIndexOf("?") == -1)
  86.                 {
  87.                     // url的形式应该是http://.../page1.aspx
  88.                     url += "?";
  89.                 }
  90.                 else if (url.LastIndexOf("&") == -1)
  91.                 {
  92.                     // url的形式应该是http://.../page1.aspx?
  93.                 }
  94.                 else
  95.                 {
  96.                     // url的形式应该是http://.../page1.aspx?param1=value1
  97.                     url += "&";
  98.                 }
  99.                 this.Response.Redirect(
  100.                     url + 
  101.                     OThinker.H3.WorkSheet.SheetEnviroment.Param_Mode + "=" + OThinker.H3.WorkSheet.SheetMode.Originate + "&" +
  102.                     PortalPage.Param_WorkflowPackage + "=" + System.Web.HttpUtility.UrlEncode(workflow.WorkflowPackageName) + "&" +
  103.                     PortalPage.Param_WorkflowName + "=" + System.Web.HttpUtility.UrlEncode(workflow.WorkflowName) + "&" +
  104.                     PortalPage.Param_WorkflowVersion + "=" + workflow.WorkflowVersion);
  105.             }
  106.             else
  107.             {
  108.                 string itemId = base.OriginateInstance(this.WorkflowPackage, this.WorkflowName, this.WorkflowVersion, this.Priority, null, null, null);
  109.                 OThinker.H3.WorkItem.WorkItem item = OThinker.H3.Server.Engine.WorkItemManager.GetWorkItem(itemId);
  110.                 this.Response.Redirect(PortalPage.GetWorkSheetUrl(item));
  111.             }
  112.         }
  113.     }
  114. }