예제 #1
0
        /// <summary>
        /// 提交工作项
        /// </summary>
        /// <param name="workItemId">工作项ID</param>
        /// <param name="approval">审批结果</param>
        /// <param name="commentText">审批意见</param>
        /// <param name="userId">处理人</param>
        public void SubmitItem(string workItemId, OThinker.Data.BoolMatchValue approval, string commentText, string userId)
        {
            //Console.Write("开始提交工作项");
            // 获取工作项
            OThinker.H3.WorkItem.WorkItem        item     = this.Engine.WorkItemManager.GetWorkItem(workItemId);
            OThinker.H3.Instance.InstanceContext instance = this.Engine.InstanceManager.GetInstanceContext(item.InstanceId);
            // 添加意见
            this.AppendComment(instance, item, OThinker.Data.BoolMatchValue.Unspecified, commentText);

            // 结束工作项
            this.Engine.WorkItemManager.FinishWorkItem(
                item.ObjectID,
                userId,
                OThinker.H3.WorkItem.AccessPoint.ExternalSystem,

                null,
                approval,
                commentText,
                null,
                OThinker.H3.WorkItem.ActionEventType.Forward,
                (int)OThinker.H3.Controllers.SheetButtonType.Submit);
            // 需要通知实例事件管理器结束事件
            OThinker.H3.Messages.AsyncEndMessage endMessage = new OThinker.H3.Messages.AsyncEndMessage(
                OThinker.H3.Messages.MessageEmergencyType.Normal,
                item.InstanceId,
                item.ActivityCode,
                item.TokenId,
                approval,
                false,
                approval,
                true,
                null);
            this.Engine.InstanceManager.SendMessage(endMessage);
        }
예제 #2
0
        public static void SubmitItem(string WorkitemId, OThinker.Data.BoolMatchValue approval, string commentText, string userId)
        {
            // 获取工作项
            OThinker.H3.WorkItem.WorkItem        item     = AppUtility.Engine.WorkItemManager.GetWorkItem(WorkitemId);
            OThinker.H3.Instance.InstanceContext instance = AppUtility.Engine.InstanceManager.GetInstanceContext(item.InstanceId);

            // 结束工作项
            AppUtility.Engine.WorkItemManager.FinishWorkItem(
                item.ObjectID,
                userId,
                OThinker.H3.WorkItem.AccessPoint.ExternalSystem,

                null,
                approval,
                commentText,
                null,
                OThinker.H3.WorkItem.ActionEventType.Forward,
                (int)OThinker.H3.Controllers.SheetButtonType.Submit);
            // 需要通知实例事件管理器结束事件
            AsyncEndMessage endMessage = new OThinker.H3.Messages.AsyncEndMessage(
                MessageEmergencyType.Normal,
                item.InstanceId,
                item.ActivityCode,
                item.TokenId,
                approval,
                false,
                approval,
                true,
                null);

            AppUtility.Engine.InstanceManager.SendMessage(endMessage);
        }
예제 #3
0
        /// <summary>
        /// 移动办公任务驳回
        /// </summary>
        /// <param name="WorkItemID"></param>
        /// <param name="Approval"></param>
        /// <param name="Comment"></param>
        /// <param name="RejectTo"></param>
        public static string GetReturnMobileWorkItemUrl(
            string WorkItemID,
            OThinker.Data.BoolMatchValue Approval,
            string Comment,
            string RejectTo)
        {
            string formattedComment = null;

            if (Comment == null)
            {
                formattedComment = null;
            }
            else if (Comment.Length <= 150)
            {
                formattedComment = Comment;
            }
            else
            {
                formattedComment = Comment.Substring(0, 150);
            }
            return(PortalRoot + "/Mobile/ReturnMobileWorkItem.aspx?" +
                   "WorkItemID=" + WorkItemID + "&" +
                   "Approval=" + Approval.ToString() + "&" +
                   "Comment=" + System.Web.HttpUtility.UrlEncode(formattedComment) + "&" +
                   "RejectTo=" + System.Web.HttpUtility.UrlEncode(RejectTo));
        }
예제 #4
0
        /// <summary>
        /// 移动办公提交任务
        /// </summary>
        /// <param name="WorkItemID"></param>
        /// <param name="Approval"></param>
        /// <param name="Comment"></param>
        /// <param name="ActionName"></param>
        /// <param name="ActionEventType"></param>
        /// <param name="ActionButtonType"></param>
        /// <param name="Originate"></param>
        /// <param name="DestActivityCode"></param>
        /// <returns></returns>
        public static string GetFinishMobileWorkItemUrl(
            string WorkItemID,
            OThinker.Data.BoolMatchValue Approval,
            string Comment,
            string ActionName,
            int ActionEventType,
            int ActionButtonType,
            OThinker.Data.BoolMatchValue Originate,
            string DestActivityCode)
        {
            string formattedComment = null;

            if (Comment == null)
            {
                formattedComment = null;
            }
            else if (Comment.Length <= 150)
            {
                formattedComment = Comment;
            }
            else
            {
                formattedComment = Comment.Substring(0, 150);
            }
            return(PortalRoot + "/Mobile/FinishMobileWorkItem.aspx?" +
                   "WorkItemID=" + WorkItemID + "&" +
                   "Approval=" + Approval.ToString() + "&" +
                   "Comment=" + System.Web.HttpUtility.UrlEncode(formattedComment) + "&" +
                   "ActionName=" + System.Web.HttpUtility.UrlEncode(ActionName) + "&" +
                   "ActionEventType=" + ActionEventType + "&" +
                   "ActionButtonType=" + ActionButtonType + "&" +
                   "Originate=" + Originate.ToString() + "&" +
                   "DestActivityCode=" + DestActivityCode);
            // REVIEW, 本来要返回的URL中,需要包含FromDest的,但是,我把下面的代码注释掉了,需要确认是否需要这个FromDesk参数
            //if (HttpContext.Current.Request["FromDesk"] != null)
            //    url += "&FromDesk=true";
        }
        private void AppendComment(WorkItem.WorkItem Item, OThinker.Data.BoolMatchValue Approval, string Comment)
        {
            WorkflowTemplate.PublishedWorkflowTemplate workflow = GetWorkflowTemplate(Item.WorkflowCode, Item.WorkflowVersion);
            // 审批字段
            string approvalDataItem = null;

            if (workflow != null)
            {
                PublishedWorkflowTemplate             workflowTemplate = this.Engine.WorkflowManager.GetPublishedTemplate(Item.WorkflowCode, Item.WorkflowVersion);
                OThinker.H3.DataModel.BizObjectSchema schema           = GetSchema(workflowTemplate.BizObjectSchemaCode);
                approvalDataItem = workflow.GetDefaultCommentDataItem(schema, Item.ActivityCode);
            }
            if (approvalDataItem != null)
            {
                // 创建审批
                //TODO:此处待修改,Item.BizObjectId不存在,通过 OT_InstanceContext获取
                Instance.InstanceContext InstanceContext = this.Engine.InstanceManager.GetInstanceContext(Item.InstanceId);
                string BizObjectId = InstanceContext == null ? string.Empty : InstanceContext.BizObjectId;

                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.OUName      = this.Engine.Organization.GetName(this.Engine.Organization.GetParent(Item.Participant));
                comment.Text        = Comment;
                comment.TokenId     = Item.TokenId;
                comment.UserID      = Item.Participant;
                comment.UserName    = Item.ParticipantName;
                //comment.BizObjectId = Item.BizObjectId;
                comment.BizObjectId         = BizObjectId;
                comment.BizObjectSchemaCode = Item.WorkflowCode;
                this.Engine.BizObjectManager.AddComment(comment);
            }
        }
예제 #6
0
        /// <summary>
        /// 提交工作项
        /// </summary>
        /// <param name="workflowCode"></param>
        /// <param name="instanceId"></param>
        /// <param name="workItemId"></param>
        /// <param name="approval"></param>
        /// <param name="commentText"></param>
        /// <param name="userId"></param>
        /// <param name="values"></param>
        /// <returns></returns>
        private BPMServiceResult SubmitItem(string workflowCode, string instanceId, string workItemId, OThinker.Data.BoolMatchValue approval, string commentText, string userId, List <DataItemParam> values)
        {
            BPMServiceResult result = new BPMServiceResult();

            try
            {
                string user = GetUserIDByCode(userId);
                if (user == null)
                {
                    return(new BPMServiceResult(false, "流程启动失败,用户{" + userId + "}不存在。"));
                }
                OThinker.H3.WorkflowTemplate.PublishedWorkflowTemplate workflowTemplate = Engine.WorkflowManager.GetDefaultWorkflow(workflowCode);
                InstanceContext ic = Engine.InstanceManager.GetInstanceContext(instanceId);
                if (ic == null)
                {
                    return(new BPMServiceResult(false, "InstanceID错误,此ID在H3系统中不存在,请检查"));
                }
                OThinker.H3.DataModel.BizObjectSchema schema = Engine.BizObjectManager.GetPublishedSchema(workflowTemplate.BizObjectSchemaCode);
                OThinker.H3.DataModel.BizObject       bo     = new OThinker.H3.DataModel.BizObject(Engine.Organization, Engine.MetadataRepository, Engine.BizObjectManager, null, schema, user);
                bo.ObjectID = ic.BizObjectId;
                bo.Load();
                foreach (DataItemParam value in values)
                {
                    OThinker.H3.DataModel.PropertySchema property = schema.GetProperty(value.ItemName);
                    if (property.LogicType == OThinker.H3.Data.DataLogicType.BizObjectArray)
                    {
                        var t = new List <OThinker.H3.DataModel.BizObject>();
                        foreach (List <DataItemParam> list in (IEnumerable)value.ItemValue)
                        {
                            var m = new OThinker.H3.DataModel.BizObject(Engine.Organization, Engine.MetadataRepository, Engine.BizObjectManager, null, property.ChildSchema, bo.OwnerId);
                            foreach (DataItemParam dataItem in list)
                            {
                                if (m.Schema.ContainsField(dataItem.ItemName))
                                {
                                    m.SetValue(dataItem.ItemName, dataItem.ItemValue);
                                }
                            }
                            t.Add(m);
                        }
                        bo[value.ItemName] = t.ToArray();
                    }
                    else if (bo.Schema.ContainsField(value.ItemName))
                    {
                        bo[value.ItemName] = value.ItemValue;
                    }
                }
                bo.Update();
                // 获取工作项
                OThinker.H3.WorkItem.WorkItem        item     = Engine.WorkItemManager.GetWorkItem(workItemId);
                OThinker.H3.Instance.InstanceContext instance = Engine.InstanceManager.GetInstanceContext(item.InstanceId);
                // 结束工作项
                Engine.WorkItemManager.FinishWorkItem(item.ObjectID, userId, OThinker.H3.WorkItem.AccessPoint.ExternalSystem, null, approval,
                                                      commentText, null, OThinker.H3.WorkItem.ActionEventType.Forward, (int)OThinker.H3.Controllers.SheetButtonType.Submit);
                // 需要通知实例事件管理器结束事件
                OThinker.H3.Messages.AsyncEndMessage endMessage = new OThinker.H3.Messages.AsyncEndMessage(OThinker.H3.Messages.MessageEmergencyType.Normal,
                                                                                                           item.InstanceId, item.ActivityCode, item.TokenId, approval, false, approval, true, null);
                Engine.InstanceManager.SendMessage(endMessage);
                result = new BPMServiceResult(true, "", null, "流程实例启动成功!", "");
            }
            catch (Exception ex)
            {
                result = new BPMServiceResult(false, "流程实例启动失败!错误:" + ex.Message);
            }
            return(result);
        }
        /// <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)
        {
            Instance.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
                {
                    this.SetItemValue(bo, property, param.ItemValue);
                }
            }

            bo.Update();
        }
예제 #8
0
        /// <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)
        {
            // 添加一个审批意见
            OThinker.H3.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 OThinker.H3.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;

                // 设置用户的默认签章
                OThinker.Organization.Signature[] signs = this.Engine.Organization.GetSignaturesByUnit(item.Participant);
                if (signs != null && signs.Length > 0)
                {
                    foreach (OThinker.Organization.Signature sign in signs)
                    {
                        if (sign.IsDefault)
                        {
                            comment.SignatureId = sign.ObjectID;
                            break;
                        }
                    }
                }
                this.Engine.BizObjectManager.AddComment(comment);
            }
        }