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

OA系统

开发平台:

C#

  1. //===========================================================================
  2. // This file was modified as part of an ASP.NET 2.0 Web project conversion.
  3. // The class name was changed and the class modified to inherit from the abstract base class 
  4. // in file 'App_CodeMigratedconsoleStub_casedetail_aspx_cs.cs'.
  5. // During runtime, this allows other classes in your web application to bind and access 
  6. // the code-behind page using the abstract base class.
  7. // The associated content page 'consolecasedetail.aspx' was also modified to refer to the new class name.
  8. // For more information on this code pattern, please refer to http://go.microsoft.com/fwlink/?LinkId=46995 
  9. //===========================================================================
  10. using System;
  11. using System.Collections;
  12. using System.ComponentModel;
  13. using System.Data;
  14. using System.Drawing;
  15. using System.Web;
  16. using System.Web.SessionState;
  17. using System.Web.UI;
  18. using System.Web.UI.WebControls;
  19. using System.Web.UI.HtmlControls;
  20. namespace OThinker.H3.Portal
  21. {
  22.     /// <summary>
  23.     /// Summary description for CaseDetail.
  24.     /// </summary>
  25.     public partial class InstanceDetail : PortalPage
  26.     {
  27.         #region 参数
  28.         public string InstanceId
  29.         {
  30.             get
  31.             {
  32.                 return this.Request.QueryString[Param_InstanceId];
  33.             }
  34.         }
  35.         public OThinker.H3.Instance.InstanceContext InstanceContext
  36.         {
  37.             get
  38.             {
  39.                 string sessionName = OThinker.H3.WorkSheet.Sessions.GetInstanceContext(this.InstanceId);
  40.                 if (this.Session[sessionName] == null)
  41.                 {
  42.                     this.Session[sessionName] = OThinker.H3.Server.Engine.InstanceManager.GetInstanceContext(this.InstanceId);
  43.                 }
  44.                 return (OThinker.H3.Instance.InstanceContext)this.Session[sessionName];
  45.             }
  46.             set
  47.             {
  48.                 string sessionName = OThinker.H3.WorkSheet.Sessions.GetInstanceContext(this.InstanceId);
  49.                 this.Session[sessionName] = value;
  50.             }
  51.         }
  52.         #endregion
  53.         protected void Page_Load(object sender, System.EventArgs e)
  54.         {
  55.             if (!this.IsPostBack)
  56.             {
  57.                 // 如果该流程不存在则显示不存在
  58.                 if (this.InstanceContext == null)
  59.                 {
  60.                     this.NotifyMessage("该流程不存在");
  61.                 }
  62.                 this.ViewInstanceSheets();
  63.                 // 如果是管理员,那么显示某些按钮
  64.                 if (this.UserValidator.ValidateAdministrator())
  65.                 {
  66.                     foreach (OThinker.H3.Instance.ActivityContext activity in this.InstanceContext.ActivityArray)
  67.                     {
  68.                         if (activity.State == OThinker.H3.Instance.ActivityState.Running)
  69.                         {
  70.                             // 处于活动状态中的活动
  71.                             this.lstActivateActivity.Items.Add(activity.Name);
  72.                         }
  73.                         else
  74.                         {
  75.                             // 显示要激活的活动列表
  76.                             this.lstActivity.Items.Add(activity.Name);
  77.                         }
  78.                     }
  79.                     if (this.lstActivateActivity.Items.Count > 0)
  80.                     {
  81.                         this.lstActivateActivity.SelectedIndex = 0;
  82.                     }
  83.                     else
  84.                     {
  85.                         this.lnkCancelActivity.Enabled = false;
  86.                     }
  87.                 }
  88.                 else
  89.                 {
  90.                     this.AdminPanel.Visible = false;
  91.                 }
  92.                 // 如果该流程已经完成则隐藏某些按钮
  93.                 if (this.InstanceContext.State == OThinker.H3.Instance.InstanceState.Complete)
  94.                 {
  95.                     this.lstActivity.Enabled = false;
  96.                     this.lnkActivate.Enabled = false;
  97.                     this.lstActivateActivity.Enabled = false;
  98.                     this.lnkCancelActivity.Enabled = false;
  99.                 }
  100.                 string cancelUrl = PageName_CancelInstance + "?" + Param_InstanceId + "=" + this.InstanceId;
  101.                 string cancelJs = "if(confirm('确定要删除?'))location='" + cancelUrl + "'";
  102.                 this.lnkTerminate.Attributes.Add("onClick",cancelJs);
  103.                 this.btnTerminate.Attributes.Add("onClick",cancelJs);
  104.             }
  105.         }
  106.         #region Web Form Designer generated code
  107.         override protected void OnInit(EventArgs e)
  108.         {
  109.             //
  110.             // CODEGEN: This call is required by the ASP.NET Web Form Designer.
  111.             //
  112.             InitializeComponent();
  113.             base.OnInit(e);
  114.         }
  115.         /// <summary>
  116.         /// Required method for Designer support - do not modify
  117.         /// the contents of this method with the code editor.
  118.         /// </summary>
  119.         private void InitializeComponent()
  120.         {
  121.             this.btnViewSheet.Click += new System.Web.UI.ImageClickEventHandler(this.btnViewSheet_Click);
  122.             this.btnChartInstanceState.Click += new System.Web.UI.ImageClickEventHandler(this.btnChartInstanceState_Click);
  123.             this.btnUrge.Click += new System.Web.UI.ImageClickEventHandler(this.btnUrge_Click);
  124.             this.btnViewCurrentActivity.Click += new System.Web.UI.ImageClickEventHandler(this.btnViewCurrentActivity_Click);
  125.             this.btnViewCaseData.Click += new System.Web.UI.ImageClickEventHandler(this.btnViewCaseData_Click);
  126.             this.btnViewHeapData.Click += new System.Web.UI.ImageClickEventHandler(this.btnViewHeapData_Click);
  127.             this.btnQueryToken.Click += new System.Web.UI.ImageClickEventHandler(this.btnQueryToken_Click);
  128.         }
  129.         #endregion
  130.         private void btnViewCaseData_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  131.         {
  132.             this.ViewInstanceData();
  133.         }
  134.         protected void lnkViewCaseData_Click(object sender, System.EventArgs e)
  135.         {
  136.             this.ViewInstanceData();
  137.         }
  138.         private void ViewInstanceData()
  139.         {
  140.             this.DetailFrame.Attributes.Add(
  141.                 "src",
  142.                 PageName_InstanceData + "?" + Param_InstanceId + "=" + this.InstanceId);
  143.         }
  144.         private void btnViewHeapData_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  145.         {
  146.             this.ViewHeapData();
  147.         }
  148.         protected void lnkViewHeapData_Click(object sender, System.EventArgs e)
  149.         {
  150.             this.ViewHeapData();
  151.         }
  152.         private void ViewHeapData()
  153.         {
  154.             this.DetailFrame.Attributes.Add(
  155.                 "src",
  156.                 PageName_HeapData + "?" + Param_InstanceId + "=" + this.InstanceId);
  157.         }
  158.         private void btnChartInstanceState_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  159.         {
  160.             this.ChartInstanceState();
  161.         }
  162.         protected void lnkChartInstanceState_Click(object sender, System.EventArgs e)
  163.         {
  164.             this.ChartInstanceState();
  165.         }
  166.         private void ChartInstanceState()
  167.         {
  168.             this.DetailFrame.Attributes.Add(
  169.                 "src",
  170.                 PageName_InstanceStateChart + "?" + Param_InstanceId + "=" + this.InstanceId);
  171.         }
  172.         private void btnUrge_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  173.         {
  174.             this.Urge();
  175.         }
  176.         protected void lnkUrge_Click(object sender, System.EventArgs e)
  177.         {
  178.             this.Urge();
  179.         }
  180.         private void Urge()
  181.         {
  182.             this.DetailFrame.Attributes.Add(
  183.                 "src",
  184.                 PageName_UrgeInstance + "?" + Param_InstanceId + "=" + this.InstanceId);
  185.         }
  186.         private void btnViewCurrentActivity_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  187.         {
  188.             this.ViewActivity();
  189.         }
  190.         protected void lnkViewCurrentActivity_Click(object sender, System.EventArgs e)
  191.         {
  192.             this.ViewActivity();
  193.         }
  194.         private void ViewActivity()
  195.         {
  196.             this.DetailFrame.Attributes.Add(
  197.                 "src",
  198.                 PageName_EnabledActivity + "?" + Param_InstanceId + "=" + this.InstanceId);
  199.         }
  200.         private void btnViewSheet_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  201.         {
  202.             this.ViewInstanceSheets();
  203.         }
  204.         protected void lnkViewSheet_Click(object sender, System.EventArgs e)
  205.         {
  206.             this.ViewInstanceSheets();
  207.         }
  208.         private void ViewInstanceSheets()
  209.         {
  210.             this.DetailFrame.Attributes.Add(
  211.                 "src",
  212.                 PageName_InstanceSheets + "?" +
  213.                 Param_InstanceId + "=" + this.InstanceId + "&" +
  214.                 Param_WorkflowPackage + "=" + System.Web.HttpUtility.UrlEncode(this.InstanceContext.WorkflowPackage) + "&" +
  215.                 Param_WorkflowName + "=" + System.Web.HttpUtility.UrlEncode(this.InstanceContext.WorkflowName) + "&" +
  216.                 Param_WorkflowVersion + "=" + System.Web.HttpUtility.UrlEncode(this.InstanceContext.WorkflowVersion.ToString()));
  217.         }
  218.         private void btnQueryToken_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  219.         {
  220.             this.QueryToken();
  221.         }
  222.         protected void lnkQueryToken_Click(object sender, System.EventArgs e)
  223.         {
  224.             this.QueryToken();
  225.         }
  226.         private void QueryToken()
  227.         {
  228.             this.DetailFrame.Attributes.Add(
  229.                 "src",
  230.                 PageName_InstanceToken + "?" +
  231.                 Param_InstanceId + "=" + this.InstanceContext.InstanceId);
  232.         }
  233.         protected void lnkActivate_Click(object sender, EventArgs e)
  234.         {
  235.             string activity = this.lstActivity.SelectedValue;
  236.             this.Response.Redirect(
  237.                 PageName_ActivateActivity + "?" + 
  238.                 Param_InstanceId + "=" + this.InstanceId + "&" + 
  239.                 Param_DestActivityName + "=" + HttpUtility.UrlEncode(activity));
  240.         }
  241.         protected void lnkCancelActivity_Click(object sender, EventArgs e)
  242.         {
  243.             string activity = this.lstActivateActivity.SelectedValue;
  244.             if (this.InstanceContext.State == OThinker.H3.Instance.InstanceState.Running &&
  245.                 this.InstanceContext.Suspended == false &&
  246.                 this.InstanceContext.Exceptional == false)
  247.             {
  248.                 // 准备触发后面Activity的消息
  249.                 OThinker.H3.Messages.CancelActivityMessage cancelMessage
  250.                     = new OThinker.H3.Messages.CancelActivityMessage(
  251.                     OThinker.H3.Messages.MessageEmergencyType.Normal,
  252.                     this.InstanceId,
  253.                     activity,
  254.                     false,
  255.                     null);
  256.                 OThinker.H3.Server.Engine.InstanceManager.SendMessage(cancelMessage);
  257.                 // 重写缓存
  258.                 this.InstanceContext = null;
  259.                 this.NotifyMessage(System.String.Format("取消活动{0}已成功", activity));
  260.             }
  261.             else
  262.             {
  263.                 this.NotifyMessage(System.String.Format("取消活动{0}失败", activity));
  264.             }
  265.         }
  266. }
  267. }