Exemplo n.º 1
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);
        }
Exemplo n.º 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);
            }));
        }
Exemplo n.º 3
0
 public JsonResult GetExceptionLogDetail(string id)
 {
     return(ExecuteFunctionRun(() =>
     {
         ActionResult result = new ActionResult();
         ExceptionDetailViewModel model = new ExceptionDetailViewModel();
         bool isFixed = false;//是否已修复
         OThinker.H3.Exceptions.ExceptionLog log = this.Engine.ExceptionManager.GetException(id);
         if (log != null)
         {
             model.Action = log.Action.ToString();
             model.Block = log.Block.ToString();
             OThinker.H3.Instance.InstanceContext context = this.Engine.InstanceManager.GetInstanceContext(log.InstanceId);
             if (context == null)
             {
                 result.Message = "ExceptionLog.WorkflowNotExist";
                 result.Success = false;
                 return Json(result, JsonRequestBehavior.AllowGet);
             }
             model.InstanceName = string.IsNullOrWhiteSpace(context.InstanceName) ? context.InstanceId : context.InstanceName;
             model.InstanceUrl = this.GetInstanceUrl(log.InstanceId, DateTime.Now.ToString("yyyyMMddHHmmss"));
             model.Message = log.Message.Replace("\r\n", "<BR>");
             if (log.State == OThinker.H3.Exceptions.ExceptionState.Fixed)
             {
                 model.Fix = "ExceptionLog.Fixed";
                 model.FixTime = log.FixedTime.ToString();
                 isFixed = true;
             }
             else
             {
                 model.Fix = "ExceptionLog.UnFixed";
                 model.FixTime = null;
                 isFixed = false;
             }
             model.ObjectID = log.ObjectID;
             model.WorkflowPackage = log.WorkflowCode;
             model.WorkflowVersion = log.WorkflowVersion.ToString();
             model.SourceName = log.SourceName;
             model.ExceptionSource = log.SourceType.ToString();
             model.OccurrenceTime = log.ThrownTime.ToString();
         }
         result.Success = true;
         result.Extend = new
         {
             IsFixed = isFixed,
             ExceptionDetail = model
         };
         return Json(result, JsonRequestBehavior.AllowGet);
     }));
 }
Exemplo n.º 4
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);
        }
        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);
        }