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

OA系统

开发平台:

C#

  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Web;
  7. using System.Web.SessionState;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.HtmlControls;
  11. namespace OThinker.H3.Portal
  12. {
  13.     /// <summary>
  14.     /// 取消流程
  15.     /// </summary>
  16.     public partial class CancelInstance : PortalPage
  17.     {
  18.         public string InstanceId
  19.         {
  20.             get
  21.             {
  22.                 return this.Request.QueryString[Param_InstanceId];
  23.             }
  24.         }
  25.         public string ReturnUrl
  26.         {
  27.             get
  28.             {
  29.                 string url = this.Request.QueryString[Param_Q];
  30.                 return HttpUtility.UrlDecode(url);
  31.             }
  32.         }
  33.         protected void Page_Load(object sender, System.EventArgs e)
  34.         {
  35.             if (!this.IsPostBack)
  36.             {
  37.                 if (!this.UserValidator.ValidateAdministrator())
  38.                 {
  39.                     this.NotifyMessage(LackOfAuth);
  40.                 }
  41.                 if (this.ReturnUrl == null || this.ReturnUrl == "")
  42.                 {
  43.                     this.lnkReturn.Visible = false;
  44.                 }
  45.                 this.lnkReturn.NavigateUrl = this.ReturnUrl;
  46.                 // 流程标题
  47.                 this.lblInstanceName.Text = OThinker.H3.Server.Engine.InstanceManager.GetInstanceName(this.InstanceId);
  48.                 string package = OThinker.H3.Server.Engine.InstanceManager.GetInstanceWorkflowPackage(this.InstanceId);
  49.                 string name = OThinker.H3.Server.Engine.InstanceManager.GetInstanceWorkflowName(this.InstanceId);
  50.                 int version = OThinker.H3.Server.Engine.InstanceManager.GetInstanceWorkflowVersion(this.InstanceId);
  51.                 string workflowName = OThinker.H3.WorkflowTemplate.WorkflowTemplate.GetWorkflowFullName(package, name, version);
  52.                 this.lblWorkflowName.Text = workflowName;
  53.                 string originator = OThinker.H3.Server.Engine.InstanceManager.GetInstanceOriginator(this.InstanceId);
  54.                 this.lblOriginator.Text = OThinker.H3.Server.Engine.Organization.GetFullName(originator);
  55.                 // 邮件通知
  56.                 string[] participants = OThinker.H3.Server.Engine.WorkItemManager.QueryParticipant(this.InstanceId, null, OThinker.H3.Instance.Token.UnspecifiedID, OThinker.H3.WorkItem.WorkItemType.Unspecified, OThinker.H3.WorkItem.WorkItemState.Unspecified);
  57.                 if (participants != null)
  58.                 {
  59.                     foreach (string participant in participants)
  60.                     {
  61.                         string participantName = OThinker.H3.Server.Engine.Organization.GetFullName(participant);
  62.                         this.lblReceiver.Text += (participantName + "; ");
  63.                     }
  64.                 }
  65.                 // 邮件标题
  66.                 this.txtEmailTitle.Text = "流程" + this.InstanceId + "已经被取消";
  67.                 this.txtEmailContext.Text = "流程" + this.InstanceId + "已经被用户" + this.UserValidator.UserFullName + "取消。";
  68.             }
  69.         }
  70.         #region Web Form Designer generated code
  71.         override protected void OnInit(EventArgs e)
  72.         {
  73.             //
  74.             // CODEGEN: This call is required by the ASP.NET Web Form Designer.
  75.             //
  76.             InitializeComponent();
  77.             base.OnInit(e);
  78.         }
  79.         /// <summary>
  80.         /// Required method for Designer support - do not modify
  81.         /// the contents of this method with the code editor.
  82.         /// </summary>
  83.         private void InitializeComponent()
  84.         {
  85.         }
  86.         #endregion
  87.         protected void lnkOk_Click(object sender, EventArgs e)
  88.         {
  89.             // 发送邮件通知
  90.             string title = this.txtEmailTitle.Text;
  91.             string context = this.txtEmailContext.Text;
  92.             string[] participants = OThinker.H3.Server.Engine.WorkItemManager.QueryParticipant(this.InstanceId, null, OThinker.H3.Instance.Token.UnspecifiedID, OThinker.H3.WorkItem.WorkItemType.Unspecified, OThinker.H3.WorkItem.WorkItemState.Unspecified);
  93.             if (participants != null)
  94.             {
  95.                 foreach (string participant in participants)
  96.                 {
  97.                     OThinker.H3.Notification.Notification email = new OThinker.H3.Notification.Notification(
  98.                         OThinker.H3.Notification.NotifyType.Email,
  99.                         null,
  100.                         participant,
  101.                         null,
  102.                         OThinker.H3.Server.Engine.InstanceManager.GetInstanceWorkflowPackage(this.InstanceId),
  103.                         OThinker.H3.Server.Engine.InstanceManager.GetInstanceWorkflowName(this.InstanceId),
  104.                         OThinker.H3.Server.Engine.InstanceManager.GetInstanceWorkflowVersion(this.InstanceId),
  105.                         this.InstanceId,
  106.                         title,
  107.                         context,
  108.                         null);
  109.                     OThinker.H3.Server.Engine.Notifier.Notify(email);
  110.                 }
  111.             }
  112.             // 终止该流程
  113.             OThinker.H3.Server.Engine.InstanceManager.RemoveInstance(this.InstanceId);
  114.             // 设置session为空
  115.             string sessionName = OThinker.H3.WorkSheet.Sessions.GetInstanceContext(this.InstanceId);
  116.             this.Session[sessionName] = null;
  117.             // 显示已经终止
  118.             this.NotifyMessage("流程已经终止");
  119.         }
  120.     }
  121. }