RetrieveWorkItem.aspx.cs
资源名称:H3_OA.rar [点击查看]
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:5k
源码类别:
OA系统
开发平台:
C#
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- namespace OThinker.H3.Portal
- {
- public partial class RetrieveWorkItem : PortalPage
- {
- public string _WorkItemID = OThinker.H3.WorkItem.WorkItem.NullWorkItemID;
- public string WorkItemID
- {
- get
- {
- if (this._WorkItemID == OThinker.H3.WorkItem.WorkItem.NullWorkItemID)
- {
- string itemId = Request.QueryString[Param_WorkItemID];
- if (itemId != null && itemId != "")
- {
- this._WorkItemID = itemId;
- }
- }
- return this._WorkItemID;
- }
- }
- private OThinker.H3.WorkItem.WorkItem _WorkItem = null;
- public OThinker.H3.WorkItem.WorkItem WorkItem
- {
- get
- {
- if(this._WorkItem == null)
- {
- this._WorkItem = OThinker.H3.Server.Engine.WorkItemManager.GetWorkItem(this.WorkItemID);
- }
- return this._WorkItem;
- }
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- // 检查是否能够取回
- if (this.WorkItem == null)
- {
- this.NotifyMessage("该工作项不存在");
- }
- // 获得当前的Token是否存在多个分支
- OThinker.H3.Instance.IToken currentToken = OThinker.H3.Server.Engine.TokenPool.GetToken(this.WorkItem.InstanceId, this.WorkItem.TokenId);
- if (currentToken == null)
- {
- this.NotifyMessage("不具有取回的条件");
- }
- // 获得后继的Token
- long[] postTokenIds = OThinker.H3.Server.Engine.TokenPool.QueryPostToken(this.WorkItem.InstanceId, this.WorkItem.TokenId);
- // 发送回退消息
- if (postTokenIds == null || postTokenIds.Length == 0)
- {
- // 已经取回过了
- this.NotifyMessage("不存在后继活动,或者已经取回过了");
- }
- else if (postTokenIds.Length > 1)
- {
- this.NotifyMessage("不具有取回的条件,后继存在多个活动");
- }
- long postTokenId = postTokenIds[0];
- OThinker.H3.Instance.IToken postToken = OThinker.H3.Server.Engine.TokenPool.GetToken(this.WorkItem.InstanceId, postTokenId);
- if (!postToken.Retrievable)
- {
- // 无法取回
- this.NotifyMessage("不具有取回的条件,后继活动已经不允许取回,或者后继已经做了不可取回的操作了");
- }
- // 具备取回的条件
- // 记录流程ID,TokenID和参与者信息
- string instanceId = this.WorkItem.InstanceId;
- long tokenId = this.WorkItem.TokenId;
- string participant = this.WorkItem.Participant;
- OThinker.H3.Messages.CancelActivityMessage rollback
- = new OThinker.H3.Messages.CancelActivityMessage(
- OThinker.H3.Messages.MessageEmergencyType.Normal,
- this.WorkItem.InstanceId,
- postToken.Activity,
- true,
- null);
- OThinker.H3.Server.Engine.InstanceManager.SendMessage(rollback);
- // 读取新的工作项
- // 获得该实例的任务
- string[] items = null;
- for (int triedTimes = 0; triedTimes < 10; triedTimes++)
- {
- System.Threading.Thread.Sleep(1500);
- items = OThinker.H3.Server.Engine.WorkItemManager.Query(
- null,
- new string[] { instanceId },
- new string[] { participant },
- System.DateTime.MinValue,
- System.DateTime.MaxValue,
- OThinker.H3.WorkItem.WorkItemState.Unfinished);
- if (items != null && items.Length != 0)
- {
- break;
- }
- }
- if (items == null || items.Length == 0)
- {
- this.NotifyMessage(
- "超时,可能是如下原因造成的:<BR>" +
- "1、创建或启动流程的时候出现了异常,请点击Web控制台上的管理->异常,查看是否出现了异常<BR>" +
- "2、系统正忙,请稍后在待办任务中查看是否存在该工作项");
- }
- else
- {
- // 获得该任务
- OThinker.H3.WorkItem.WorkItem item = OThinker.H3.Server.Engine.WorkItemManager.GetWorkItem(items[0]);
- // 任务已经收到
- this.Response.Redirect(PortalPage.GetWorkSheetUrl(item));
- }
- }
- }
- }