/// <summary>
        /// 结束流程
        /// </summary>
        /// <param name="instanceId"></param>
        /// <returns></returns>
        public static bool FinishedInstance(string instanceId)
        {
            try
            {
                AppUtility.Engine.LogWriter.Write(DateTime.Now.ToString() + " 根据instanceid强制结束流程开始,流程实例ID:" + instanceId);
                OThinker.H3.Instance.InstanceContext context = AppUtility.Engine.InstanceManager.GetInstanceContext(instanceId);
                if (context == null)
                {
                    return(false);
                }

                OThinker.H3.WorkflowTemplate.PublishedWorkflowTemplate workflow = AppUtility.Engine.WorkflowManager.GetDefaultWorkflow(context.WorkflowCode);

                OThinker.H3.Messages.ActivateActivityMessage activateMessage = new OThinker.H3.Messages.ActivateActivityMessage(
                    OThinker.H3.Messages.MessageEmergencyType.High,
                    instanceId,
                    workflow.EndActivityCode,
                    OThinker.H3.Instance.Token.UnspecifiedID,
                    null,
                    null,
                    false,
                    OThinker.H3.WorkItem.ActionEventType.Adjust
                    );
                AppUtility.Engine.InstanceManager.SendMessage(activateMessage);
                AppUtility.Engine.LogWriter.Write(DateTime.Now.ToString() + " 根据instanceid强制结束流程成功,流程实例ID:" + instanceId);
                return(true);
            }
            catch
            {
                AppUtility.Engine.LogWriter.Write(DateTime.Now.ToString() + " 根据instanceid强制结束流程失败,流程实例ID:" + instanceId);
                return(false);
            }
        }
示例#2
0
        public JsonResult FixException(string id)
        {
            return(ExecuteFunctionRun(() =>
            {
                ActionResult result = new ActionResult();

                OThinker.H3.Exceptions.ExceptionLog log = this.Engine.ExceptionManager.GetException(id);

                //查找到异常环节
                OThinker.H3.Instance.InstanceContext context = this.Engine.InstanceManager.GetInstanceContext(log.InstanceId);
                Token ExceptionToken = null;
                foreach (Token t in context.Tokens)
                {
                    if (t.Exceptional)
                    {
                        ExceptionToken = t;
                        break;
                    }
                }

                //修复
                if (log.State != OThinker.H3.Exceptions.ExceptionState.Fixed)
                {
                    this.Engine.ExceptionManager.FixException(id);
                }

                System.Threading.Thread.Sleep(5000);

                //重新激活
                if (ExceptionToken != null)
                {
                    OThinker.H3.Messages.ActivateActivityMessage activateMessage
                        = new OThinker.H3.Messages.ActivateActivityMessage(
                              OThinker.H3.Messages.MessageEmergencyType.Normal,
                              context.InstanceId, ExceptionToken.Activity,
                              ExceptionToken.TokenId,
                              ExceptionToken.Participants,
                              null,
                              false,
                              H3.WorkItem.ActionEventType.Adjust);

                    this.Engine.InstanceManager.SendMessage(activateMessage);
                }
                result.Success = true;
                log = this.Engine.ExceptionManager.GetException(id);
                result.Extend = new
                {
                    IsFixed = true,
                    ExceptionDetail = new ExceptionDetailViewModel()
                    {
                        Fix = "ExceptionLog.Fixed",
                        FixTime = log.FixedTime.ToShortDateString(),
                    }
                };

                return Json(result, JsonRequestBehavior.AllowGet);
            }));
        }
 public bool ActiveToken(string instanceId, string activityCode, string[] participants)
 {
     try
     {
         // 准备触发后面Activity的消息
         OThinker.H3.Messages.ActivateActivityMessage activateMessage
             = new OThinker.H3.Messages.ActivateActivityMessage(
                   OThinker.H3.Messages.MessageEmergencyType.Normal,
                   instanceId,
                   activityCode,
                   OThinker.H3.Instance.Token.UnspecifiedID,
                   participants,
                   null,
                   false,
                   H3.WorkItem.ActionEventType.Adjust);
         this.Engine.InstanceManager.SendMessage(activateMessage);
         return(true);
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#4
0
        /// <summary>
        /// 驳回工作任务
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="workItemId"></param>
        /// <param name="commentText"></param>
        /// <returns></returns>
        public bool ReturnItem(string userId, string workItemId, string commentText)
        {
            //Console.Write("不回");
            OThinker.Organization.User user = this.Engine.Organization.GetUnit(userId) as OThinker.Organization.User;
            if (user == null)
            {
                return(false);
            }
            // 获取工作项
            OThinker.H3.WorkItem.WorkItem        item    = this.Engine.WorkItemManager.GetWorkItem(workItemId);
            OThinker.H3.Instance.InstanceContext context = this.Engine.InstanceManager.GetInstanceContext(item.InstanceId);
            // ToKen
            OThinker.H3.Instance.IToken Token = context.GetToken(item.TokenId);
            if (Token.PreTokens == null)
            {
                return(false);
            }
            int PreToken = int.Parse(Token.PreTokens[0].ToString());

            OThinker.H3.Instance.IToken PreToken1 = context.GetToken(PreToken);
            string activityName = PreToken1.Activity;

            // 添加意见
            this.AppendComment(context, item, OThinker.Data.BoolMatchValue.False, commentText);
            // 结束工作项
            this.Engine.WorkItemManager.FinishWorkItem(
                item.ObjectID,
                user.ObjectID,
                OThinker.H3.WorkItem.AccessPoint.ExternalSystem,

                null,
                OThinker.Data.BoolMatchValue.False,
                commentText,
                null,
                OThinker.H3.WorkItem.ActionEventType.Backward,
                (int)OThinker.H3.Controllers.SheetButtonType.Return);
            // 准备触发后面Activity的消息
            OThinker.H3.Messages.ActivateActivityMessage activateMessage
                = new OThinker.H3.Messages.ActivateActivityMessage(
                      OThinker.H3.Messages.MessageEmergencyType.Normal,
                      item.InstanceId,
                      activityName,
                      OThinker.H3.Instance.Token.UnspecifiedID,
                      null,
                      new int[] { item.TokenId },
                      false,
                      OThinker.H3.WorkItem.ActionEventType.Backward);

            // 通知该Activity已经完成
            OThinker.H3.Messages.AsyncEndMessage endMessage =
                new OThinker.H3.Messages.AsyncEndMessage(
                    OThinker.H3.Messages.MessageEmergencyType.Normal,
                    item.InstanceId,
                    item.ActivityCode,
                    item.TokenId,
                    OThinker.Data.BoolMatchValue.False,
                    true,
                    OThinker.Data.BoolMatchValue.False,
                    false,
                    activateMessage);
            this.Engine.InstanceManager.SendMessage(endMessage);
            return(true);
        }
        /// <summary>
        /// 批量拒绝
        /// </summary>
        /// <param name="WorkItemIDs"></param>
        /// <param name="CommentText"></param>
        /// <returns></returns>
        private string ReturnWorkItems(string[] WorkItemIDs, string CommentText)
        {
            string errors = null;

            foreach (string itemId in WorkItemIDs)
            {
                WorkItem.WorkItem item = this.Engine.WorkItemManager.GetWorkItem(itemId);

                if (item == null || !item.IsUnfinished)
                {
                    continue;
                }
                if (item.BatchProcessing == false)
                {
                    errors += item.DisplayName + ";";
                    continue;
                }
                WorkflowTemplate.PublishedWorkflowTemplate workflow = GetWorkflowTemplate(item.WorkflowCode, item.WorkflowVersion);
                // 添加意见
                this.AppendComment(item, OThinker.Data.BoolMatchValue.True, CommentText);

                // 结束工作项
                this.Engine.WorkItemManager.FinishWorkItem(
                    item.ObjectID,
                    this.UserValidator.UserID,
                    H3.WorkItem.AccessPoint.ExternalSystem,
                    //null,
                    null,
                    OThinker.Data.BoolMatchValue.False,
                    CommentText,
                    null,
                    H3.WorkItem.ActionEventType.Backward,
                    (int)SheetButtonType.Return);
                // 准备触发后面Activity的消息
                OThinker.H3.Messages.ActivateActivityMessage activateMessage
                    = new OThinker.H3.Messages.ActivateActivityMessage(
                          OThinker.H3.Messages.MessageEmergencyType.Normal,
                          item.InstanceId,
                          workflow.StartActivityCode,
                          OThinker.H3.Instance.Token.UnspecifiedID,
                          null,
                          new int[] { item.TokenId },
                          false,
                          H3.WorkItem.ActionEventType.Backward);

                // 通知该Activity已经完成
                OThinker.H3.Messages.AsyncEndMessage endMessage =
                    new OThinker.H3.Messages.AsyncEndMessage(
                        OThinker.H3.Messages.MessageEmergencyType.Normal,
                        item.InstanceId,
                        item.ActivityCode,
                        item.TokenId,
                        OThinker.Data.BoolMatchValue.False,
                        true,
                        OThinker.Data.BoolMatchValue.False,
                        false,
                        activateMessage);
                this.Engine.InstanceManager.SendMessage(endMessage);
            }
            return(errors);
        }
        public bool ReturnItem(string userId, string workItemId, string activityCode, string SchemaCode, double xbzjye, string state, DateTime bzjyedysj, string userName, string PassState, double yzzfbzj)
        {
            Organization.User user = this.Engine.Organization.GetUnit(userId) as Organization.User;
            if (user == null)
            {
                return(false);
            }
            // 获取工作项

            OThinker.H3.DataModel.BizObjectSchema schema  = this.Engine.BizObjectManager.GetPublishedSchema(SchemaCode);
            OThinker.H3.WorkItem.WorkItem         item    = this.Engine.WorkItemManager.GetWorkItem(workItemId);
            OThinker.H3.Instance.InstanceContext  context = this.Engine.InstanceManager.GetInstanceContext(item.InstanceId);
            OThinker.H3.DataModel.BizObject       bo      = new OThinker.H3.DataModel.BizObject(Engine, schema, userId);
            bo.ObjectID = context.BizObjectId;
            bo.Load();                            //装载流程数据;

            if (bo.Schema.ContainsField("BZJYE")) //保证金余额
            {
                bo["BZJYE"] = xbzjye;
            }
            if (bo.Schema.ContainsField("LCZT"))
            {
                bo["LCZT"] = state;
            }
            if (bo.Schema.ContainsField("BZJYEDYSJ"))
            {
                bo["BZJYEDYSJ"] = bzjyedysj;
            }
            if (bo.Schema.ContainsField("CWCLR"))
            {
                bo["CWCLR"] = userName;
            }
            if (bo.Schema.ContainsField("CWSPRID"))
            {
                bo["CWSPRID"] = userId;
            }
            //this.AppendComment(item.InstanceId, item, OThinker.Data.BoolMatchValue.Unspecified, "现保证金余额x钱,应再支付X保证金");



            // 结束工作项
            if (PassState == "TG")
            {//财务通过
                this.Engine.WorkItemManager.FinishWorkItem(
                    item.ObjectID,
                    user.ObjectID,
                    H3.WorkItem.AccessPoint.ExternalSystem,
                    null,
                    OThinker.Data.BoolMatchValue.True,
                    string.Empty,
                    null,
                    H3.WorkItem.ActionEventType.Backward,
                    (int)OThinker.H3.Controllers.SheetButtonType.Return);

                if (bo.Schema.ContainsField("CWSPYJDX"))
                {
                    bo["CWSPYJDX"] = "通过";
                }

                this.AppendComment(context, item, OThinker.Data.BoolMatchValue.True, "通过");//财务部通过后,显示通过
            }
            else
            {//财务驳回
                this.Engine.WorkItemManager.FinishWorkItem(
                    item.ObjectID,
                    user.ObjectID,
                    H3.WorkItem.AccessPoint.ExternalSystem,
                    null,
                    OThinker.Data.BoolMatchValue.False,
                    string.Empty,
                    null,
                    H3.WorkItem.ActionEventType.Backward,
                    (int)OThinker.H3.Controllers.SheetButtonType.Return);
                var info = "现保证金余额" + string.Format("{0:N2}", xbzjye) + "元,应再支付" + string.Format("{0:N2}", yzzfbzj) + "保证金";
                this.AppendComment(context, item, OThinker.Data.BoolMatchValue.False, info);

                if (bo.Schema.ContainsField("CWSPYJDX"))
                {
                    bo["CWSPYJDX"] = "驳回";
                }

                try
                {
                    MessageClass ms = new MessageClass();

                    string    sql = @"select distinct a.PARTICIPANT,b.code, d.objectid  , d.code jxsuserCode, e.JXS,e.JXSCODE from Ot_Workitemfinished  a
join Ot_User b on a.PARTICIPANT = b.objectid 
join Ot_Instancecontext c on c.objectid = a.instanceid 
join OT_User d on d.objectid = c.ORIGINATOR 
join I_DealerLoan e on e.objectid = c.bizobjectid
where   ACTIVITYCODE='Activity3' and c.workFlowCode = 'DealerLoan' and instanceid='" + item.InstanceId + "'";
                    DataTable dt  = OThinker.H3.Controllers.AppUtility.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteDataTable(sql);

                    string msstr1 = dt.Rows[0]["JXS"].ToString() + "(" + dt.Rows[0]["JXSCODE"].ToString() + ") 还需要支付<font color=\"red\">" + string.Format("{0:N2}", yzzfbzj) + "</font> 元 保证金金额才可以进行本次贷款申请,现保证金账户余额 " + string.Format("{0:N2}", xbzjye) + " 元";

                    string msstr2 = "您的账户还需要支付<font color=\"red\">" + string.Format("{0:N2}", yzzfbzj) + "</font> 元 保证金金额才可以进行本次贷款申请,现保证金账户余额 " + string.Format("{0:N2}", xbzjye) + "元";

                    if (dt != null && dt.Rows != null && dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            ms.InsertMSG(dt.Rows[i]["PARTICIPANT"].ToString(), dt.Rows[i]["code"].ToString(), msstr1, true, 0, "");
                        }
                    }

                    ms.InsertMSG(dt.Rows[0]["objectid"].ToString(), dt.Rows[0]["jxsCode"].ToString(), msstr2, false, 0, "");
                }
                catch (Exception e)
                {
                }
            }

            bo.Update();
            // 准备触发后面Activity的消息
            OThinker.H3.Messages.ActivateActivityMessage activateMessage
                = new OThinker.H3.Messages.ActivateActivityMessage(
                      OThinker.H3.Messages.MessageEmergencyType.Normal,
                      item.InstanceId,
                      activityCode,
                      OThinker.H3.Instance.Token.UnspecifiedID,
                      null,
                      new int[] { item.TokenId },
                      false,
                      H3.WorkItem.ActionEventType.Backward);

            // 通知该Activity已经完成
            OThinker.H3.Messages.AsyncEndMessage endMessage =
                new OThinker.H3.Messages.AsyncEndMessage(
                    OThinker.H3.Messages.MessageEmergencyType.Normal,
                    item.InstanceId,
                    item.ActivityCode,
                    item.TokenId,
                    OThinker.Data.BoolMatchValue.False,
                    true,
                    OThinker.Data.BoolMatchValue.False,
                    false,
                    activateMessage);
            this.Engine.InstanceManager.SendMessage(endMessage);



            return(true);
        }