/// <summary>
        /// 结束工作任务
        /// </summary>
        /// <param name="MvcPost">MVC表单传递过来的值</param>
        /// <param name="Approval">审核结果</param>
        /// <param name="ActionEventType">事件类型</param>
        /// <param name="ActionButtonType">按钮类型</param>
        public void ForwardWorkItem(
            List <DataItemParam> paramList, string code, string schemaCode, string instanceId, string workItemCode)
        {
            OThinker.H3.Instance.InstanceContext  ic     = this.Engine.InstanceManager.GetInstanceContext(instanceId);
            OThinker.H3.DataModel.BizObjectSchema schema = this.Engine.BizObjectManager.GetPublishedSchema(schemaCode);
            OThinker.H3.DataModel.BizObject       bo     = new OThinker.H3.DataModel.BizObject(Engine, schema, code);
            OThinker.H3.WorkItem.WorkItem         item   = this.Engine.WorkItemManager.GetWorkItem(workItemCode);


            bo.ObjectID = ic.BizObjectId;
            bo.Load();//装载流程数据;

            if (paramList != null)
            {
                // 这里可以在创建流程的时候赋值
                foreach (DataItemParam param in paramList)
                {
                    if (bo.Schema.ContainsField(param.ItemName))
                    {
                        bo[param.ItemName] = param.ItemValue;
                    }
                }
            }

            bo.Update();

            if (!string.IsNullOrEmpty(workItemCode))
            {
                // 结束工作项
                this.Engine.WorkItemManager.FinishWorkItem(
                    workItemCode,
                    code,
                    OThinker.H3.WorkItem.AccessPoint.ExternalSystem,
                    null,
                    OThinker.Data.BoolMatchValue.True,
                    string.Empty,
                    null,
                    OThinker.H3.WorkItem.ActionEventType.Forward,
                    (int)OThinker.H3.Controllers.SheetButtonType.Submit);

                // 需要通知实例事件管理器结束事件
                Messages.AsyncEndMessage endMessage = new OThinker.H3.Messages.AsyncEndMessage(
                    Messages.MessageEmergencyType.Normal,
                    instanceId,
                    item.ActivityCode,
                    item.TokenId,
                    OThinker.Data.BoolMatchValue.True,
                    false,
                    OThinker.Data.BoolMatchValue.True,
                    true,
                    null);
                this.Engine.InstanceManager.SendMessage(endMessage);
            }
        }
Esempio n. 2
0
        public JsonResult SubmitWorkItem(string userCode, string workItemId, string paramValues)
        {
            // 获取工作项
            OThinker.H3.WorkItem.WorkItem item = this.Engine.WorkItemManager.GetWorkItem(workItemId);
            if (item == null)
            {
                throw new Exception("工作任务不存在");
            }
            OThinker.Organization.User user = this.Engine.Organization.GetUserByCode(userCode) as OThinker.Organization.User;
            if (user == null)
            {
                throw new Exception("用户不存在");
            }
            List <DataItemParam> listParamValues = JSSerializer.Deserialize <List <DataItemParam> >(paramValues);

            // 保存数据项
            SaveBizObject(item, user, OThinker.Data.BoolMatchValue.True, listParamValues);

            // 结束工作项
            this.Engine.WorkItemManager.FinishWorkItem(
                item.ObjectID,
                user.UnitID,
                OThinker.H3.WorkItem.AccessPoint.ExternalSystem,
                null,
                OThinker.Data.BoolMatchValue.True,
                string.Empty,
                null,
                OThinker.H3.WorkItem.ActionEventType.Forward,
                11);

            // 需要通知实例事件管理器结束事件
            AsyncEndMessage endMessage = new OThinker.H3.Messages.AsyncEndMessage(
                MessageEmergencyType.Normal,
                item.InstanceId,
                item.ActivityCode,
                item.TokenId,
                OThinker.Data.BoolMatchValue.True,
                false,
                OThinker.Data.BoolMatchValue.True,
                true,
                null);

            this.Engine.InstanceManager.SendMessage(endMessage);
            return(Json(new
            {
                Result = true,
                Message = string.Empty
            }));
        }
        /// <summary>
        /// 给工作项添加审批意见
        /// </summary>
        /// <param name="item">工作项</param>
        /// <param name="approval">审批结果</param>
        /// <param name="commentText">审批意见</param>
        private void AppendComment(OThinker.H3.Instance.InstanceContext Instance, OThinker.H3.WorkItem.WorkItem item, OThinker.Data.BoolMatchValue approval, string commentText)
        {
            // 添加一个审批意见
            WorkflowTemplate.PublishedWorkflowTemplate workflow = this.Engine.WorkflowManager.GetPublishedTemplate(
                item.WorkflowCode,
                item.WorkflowVersion);
            // 审批字段
            string approvalDataItem = null;

            if (workflow != null)
            {
                OThinker.H3.DataModel.BizObjectSchema schema = this.Engine.BizObjectManager.GetPublishedSchema(item.WorkflowCode);
                approvalDataItem = workflow.GetDefaultCommentDataItem(schema, item.ActivityCode);
            }
            if (approvalDataItem != null)
            {
                // 创建审批
                OThinker.H3.Data.Comment comment = new Data.Comment();
                comment.Activity            = item.ActivityCode;
                comment.Approval            = approval;
                comment.CreatedTime         = System.DateTime.Now;
                comment.DataField           = approvalDataItem;
                comment.InstanceId          = item.InstanceId;
                comment.BizObjectId         = Instance.BizObjectId;
                comment.BizObjectSchemaCode = Instance.BizObjectSchemaCode;
                comment.OUName   = this.Engine.Organization.GetName(this.Engine.Organization.GetParent(item.Participant));
                comment.Text     = commentText;
                comment.TokenId  = item.TokenId;
                comment.UserID   = item.Participant;
                comment.UserName = item.ParticipantName;

                // 设置用户的默认签章
                Organization.Signature[] signs = this.Engine.Organization.GetSignaturesByUnit(item.Participant);
                if (signs != null && signs.Length > 0)
                {
                    foreach (Organization.Signature sign in signs)
                    {
                        if (sign.IsDefault)
                        {
                            comment.SignatureId = sign.ObjectID;
                            break;
                        }
                    }
                }
                this.Engine.BizObjectManager.AddComment(comment);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 保存表单数据
        /// </summary>
        /// <param name="workItem"></param>
        /// <param name="user"></param>
        /// <param name="boolMatchValue"></param>
        /// <param name="paramValues"></param>
        private void SaveBizObject(OThinker.H3.WorkItem.WorkItem workItem, OThinker.Organization.User user, OThinker.Data.BoolMatchValue boolMatchValue, List <DataItemParam> paramValues)
        {
            InstanceContext InstanceContext = this.Engine.InstanceManager.GetInstanceContext(workItem.InstanceId);
            string          bizObjectId     = InstanceContext == null ? string.Empty : InstanceContext.BizObjectId;

            OThinker.H3.DataModel.BizObjectSchema schema = this.Engine.BizObjectManager.GetPublishedSchema(InstanceContext.BizObjectSchemaCode);
            OThinker.H3.DataModel.BizObject       bo     = new OThinker.H3.DataModel.BizObject(this.Engine, schema, workItem.Participant);
            bo.ObjectID = bizObjectId;
            bo.Load();

            // 设置数据项的值
            foreach (DataItemParam param in paramValues)
            {
                OThinker.H3.DataModel.PropertySchema property = schema.GetProperty(param.ItemName);
                if (property.LogicType == DataLogicType.Comment)
                {// 审核意见
                    CommentParam comment = JSSerializer.Deserialize <CommentParam>(param.ItemValue + string.Empty);
                    this.Engine.BizObjectManager.AddComment(new Comment()
                    {
                        BizObjectId         = bo.ObjectID,
                        BizObjectSchemaCode = schema.SchemaCode,
                        InstanceId          = workItem.InstanceId,
                        TokenId             = workItem.TokenId,
                        Approval            = boolMatchValue,
                        Activity            = workItem.ActivityCode,
                        DataField           = property.Name,
                        UserID      = user.ObjectID,
                        SignatureId = comment.SignatureId,
                        Text        = comment.Text
                    });
                }
                else
                {
                    new BPM().SetItemValue(bo, property, param.ItemValue);
                }
            }

            bo.Update();
        }
Esempio n. 5
0
        public System.Web.Mvc.ActionResult RejectWorkItem(string appId, string pwd, string userCode, string workItemId, string rejectToActivity, string paramValues)
        {
            // 获取工作项
            OThinker.H3.WorkItem.WorkItem item = this.Engine.WorkItemManager.GetWorkItem(workItemId);
            if (item == null)
            {
                throw new Exception("工作任务不存在");
            }
            OThinker.Organization.User user = this.Engine.Organization.GetUserByCode(userCode) as OThinker.Organization.User;
            if (user == null)
            {
                throw new Exception("用户不存在");
            }
            List <DataItemParam> listParamValues = JSSerializer.Deserialize <List <DataItemParam> >(paramValues);

            // 保存数据项
            SaveBizObject(item, user, OThinker.Data.BoolMatchValue.True, listParamValues);

            // 获取驳回节点
            if (string.IsNullOrEmpty(rejectToActivity))
            {// 目标节点为空,则判断当前节点允许驳回的环节
                PublishedWorkflowTemplate template = this.Engine.WorkflowManager.GetPublishedTemplate(item.WorkflowCode, item.WorkflowVersion);
                ParticipativeActivity     activity = template.GetActivityByCode(item.ActivityCode) as ParticipativeActivity;
                if (activity == null)
                {
                    throw new Exception("当前环节不允许驳回");
                }
                if (activity.PermittedActions.RejectToStart)
                {
                    rejectToActivity = template.StartActivityCode;                                          // 驳回到开始
                }
                else if (activity.PermittedActions.RejectToFixed || activity.PermittedActions.RejectToAny)
                {
                    if (activity.PermittedActions.RejectToActivityCodes != null && activity.PermittedActions.RejectToActivityCodes.Length > 0)
                    {
                        rejectToActivity = activity.PermittedActions.RejectToActivityCodes[0];
                    }
                }
                else if (activity.PermittedActions.Reject)
                {// 驳回上一步
                    InstanceContext context = this.Engine.InstanceManager.GetInstanceContext(item.InstanceId);
                    int[]           tokens  = context.GetToken(item.TokenId).PreTokens;
                    if (tokens != null && tokens.Length > 0)
                    {
                        rejectToActivity = context.GetToken(tokens[0]).Activity;
                    }
                }

                if (string.IsNullOrEmpty(rejectToActivity))
                {
                    rejectToActivity = template.StartActivityCode;
                }
            }

            // 结束工作项
            this.Engine.WorkItemManager.FinishWorkItem(
                item.ObjectID,
                user.ObjectID,
                AccessPoint.ExternalSystem,
                null,
                OThinker.Data.BoolMatchValue.False,
                string.Empty,
                null,
                ActionEventType.Backward,
                10);
            // 准备触发后面Activity的消息
            OThinker.H3.Messages.ActivateActivityMessage activateMessage
                = new OThinker.H3.Messages.ActivateActivityMessage(
                      OThinker.H3.Messages.MessageEmergencyType.Normal,
                      item.InstanceId,
                      rejectToActivity,
                      OThinker.H3.Instance.Token.UnspecifiedID,
                      null,
                      new int[] { item.TokenId },
                      false,
                      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(Json(new
            {
                Result = true,
                Message = string.Empty
            }));
        }
Esempio n. 6
0
        public System.Web.Mvc.ActionResult GetInstanceInfo(string appId, string pwd, string userCode, string workItemId)
        {
            OThinker.H3.WorkItem.WorkItem workItem = this.Engine.WorkItemManager.GetWorkItem(workItemId);
            if (workItem == null)
            {
                throw new Exception("工作任务不存在");
            }
            OThinker.H3.Instance.InstanceContext instance = this.Engine.InstanceManager.GetInstanceContext(workItem.InstanceId);

            OThinker.H3.WorkflowTemplate.PublishedWorkflowTemplate template = this.Engine.WorkflowManager.GetPublishedTemplate(instance.WorkflowCode, instance.WorkflowVersion);
            OThinker.H3.WorkflowTemplate.Activity activity = template.GetActivityByCode(workItem.ActivityCode);

            InstanceInfo result = new InstanceInfo()
            {
                ActivityCode    = activity.ActivityCode,
                ActivityName    = activity.DisplayName,
                DataPermissions = (activity is OThinker.H3.WorkflowTemplate.ParticipativeActivity) ? ((OThinker.H3.WorkflowTemplate.ParticipativeActivity)activity).DataPermissions : null,
                InstanceId      = instance.InstanceId,
                InstanceState   = instance.State,
                Originator      = instance.Originator,
                TokenId         = workItem.TokenId,
                WorkflowCode    = template.WorkflowCode,
                WorkflowName    = template.WorkflowFullName,
                SequenceNo      = instance.SequenceNo,
                WorkItemState   = workItem.State
            };

            OThinker.Organization.User user = this.Engine.Organization.GetUserByCode(userCode) as OThinker.Organization.User;
            if (user != null)
            {
                OThinker.Organization.Signature[] signatures = this.Engine.Organization.GetSignaturesByUnit(user.ObjectID);
                result.MySignatures = new List <SignatureParam>();
                if (signatures != null)
                {
                    foreach (OThinker.Organization.Signature signature in signatures)
                    {
                        result.MySignatures.Add(new SignatureParam()
                        {
                            IsDefault     = signature.IsDefault,
                            SignatureName = signature.Name,
                            SignautreId   = signature.ObjectID,
                            SortKey       = signature.SortKey
                        });
                    }
                }

                result.FrequentlyComment = this.Engine.Organization.GetFrequentlyUsedCommentTextsByUser(user.ObjectID);

                if (activity is OThinker.H3.WorkflowTemplate.ParticipativeActivity)
                {
                    // PermittedActions actions = new PermittedActions();
                    OThinker.H3.WorkflowTemplate.ParticipativeActivity participative = activity as OThinker.H3.WorkflowTemplate.ParticipativeActivity;
                    //actions.AdjustParticipant = participative.PermittedActions.AdjustParticipant;
                    //actions.Assist = participative.PermittedActions.Assist;
                    //actions.CancelIfUnfinished = participative.PermittedActions.CancelIfUnfinished;
                    //actions.Choose = participative.PermittedActions.Choose;
                    //actions.Circulate = participative.PermittedActions.Circulate;
                    //actions.Consult = participative.PermittedActions.Consult;
                    //actions.Forward = participative.PermittedActions.Forward;
                    //actions.Reject = participative.PermittedActions.Reject || participative.PermittedActions.RejectToAny || participative.PermittedActions.RejectToFixed;

                    if (participative.PermittedActions.RejectToAny)
                    {// 获取允许驳回的节点
                        List <ActivityParam> rejectActivies = new List <ActivityParam>();
                        foreach (OThinker.H3.Instance.Token token in instance.Tokens)
                        {
                            if (token.Activity == activity.ActivityCode)
                            {
                                continue;
                            }
                            ParticipativeActivity act = template.GetActivityByCode(token.Activity) as ParticipativeActivity;
                            if (act == null)
                            {
                                continue;
                            }
                            rejectActivies.Add(new ActivityParam()
                            {
                                ActivityCode = act.ActivityCode,
                                DisplayName  = act.DisplayName
                            });
                        }
                        result.RejectActivies = rejectActivies;
                    }

                    result.PermittedActions = participative.PermittedActions;
                }
            }

            return(Json(result));
        }
        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);
        }
        /// <summary>
        /// 结束工作任务
        /// </summary>
        public void ENDWorkItem(string UpdateUserId, string schemaCode, string workItemID, string STATE)
        {
            OThinker.H3.WorkItem.WorkItem item = this.Engine.WorkItemManager.GetWorkItem(workItemID);

            if (!string.IsNullOrEmpty(schemaCode))
            {
                OThinker.H3.DataModel.BizObjectSchema schema = this.Engine.BizObjectManager.GetPublishedSchema(schemaCode);
                OThinker.H3.DataModel.BizObject       bo     = new OThinker.H3.DataModel.BizObject(Engine, schema, UpdateUserId);

                OThinker.H3.Instance.InstanceContext ic = this.Engine.InstanceManager.GetInstanceContext(item.InstanceId);

                if (!string.IsNullOrEmpty(workItemID))
                {
                    bo.ObjectID = ic.BizObjectId;
                    bo.Load();//装载流程数据;

                    if (!string.IsNullOrEmpty(STATE))
                    {
                        if (bo.Schema.ContainsField("LCZT"))
                        {
                            bo["LCZT"] = STATE;
                        }
                        if (bo.Schema.ContainsField("OperationStates"))
                        {
                            bo["OperationStates"] = STATE;
                        }
                        if (bo.Schema.ContainsField("states"))
                        {
                            bo["states"] = STATE;
                        }
                    }

                    bo.Update();
                }
            }

            // 结束工作项
            this.Engine.WorkItemManager.FinishWorkItem(
                workItemID,
                UpdateUserId,
                OThinker.H3.WorkItem.AccessPoint.ExternalSystem,
                null,
                OThinker.Data.BoolMatchValue.True,
                string.Empty,
                null,
                OThinker.H3.WorkItem.ActionEventType.Forward,
                (int)OThinker.H3.Controllers.SheetButtonType.Submit);

            // 需要通知实例事件管理器结束事件
            Messages.AsyncEndMessage endMessage = new OThinker.H3.Messages.AsyncEndMessage(
                Messages.MessageEmergencyType.Normal,
                item.InstanceId,
                item.ActivityCode,
                item.TokenId,
                OThinker.Data.BoolMatchValue.True,
                false,
                OThinker.Data.BoolMatchValue.True,
                true,
                null);
            this.Engine.InstanceManager.SendMessage(endMessage);
        }