示例#1
0
 protected BaseFlowStatusActor(ActorService actorService, ActorId actorId,
                               Integration.Common.Interface.IBinaryMessageSerializer binaryMessageSerializer,
                               Integration.Common.Actor.Interface.IActorClient actorClient,
                               Integration.Common.Interface.IKeyValueStorage <string> storage, ILogger logger) : base(actorService, actorId, binaryMessageSerializer, actorClient, storage, logger)
 {
     FlowStatus = FlowStatus.Started;
 }
示例#2
0
 protected FlowStatusVM ConvertToViewModel(FlowStatus entity) => new FlowStatusVM
 {
     Id     = entity.Id,
     SeqNo  = entity.SeqNo,
     Name   = entity.Name,
     Enable = entity.Enable
 };
示例#3
0
        public static FlowInfo CreateChildFlow(FlowInfo parent, FlowStatus status)
        {
            FlowInfo childflow = new FlowInfo();

            childflow.ReqId    = parent.ReqId;
            childflow.ParentId = parent.FlowId;
            childflow.Status   = status;
            childflow.FlowId   = CreateFlow(childflow);
            return(childflow);
        }
示例#4
0
        private static void SF_MoveAfterTaskDone(UserInfo currentUser, FlowInfo flow, RequestInfo request, ActionType action, string comments)
        {
            FlowStatus nextStatus = flow.Status;

            switch (flow.Status)
            {
                #region case RequestStatus.Created
            case FlowStatus.Created:
                switch (action)
                {
                case ActionType.Submit:
                    nextStatus = FlowStatus.Submitted;
                    break;

                default:
                    throw new Exception("Wrong Action");
                }
                break;
                #endregion

                #region case RequestStatus.Submitted
            case FlowStatus.Submitted:
                switch (action)
                {
                case ActionType.Approve:
                    if (WorkflowMgr.IsLastApprover(currentUser.UID, flow))
                    {
                        nextStatus = FlowStatus.Approved;
                    }
                    break;

                case ActionType.Reject:
                    nextStatus = FlowStatus.Rejected;
                    WorkflowMgr.CancelAllOtherTasks(currentUser, flow, action);
                    break;

                case ActionType.Cancel:
                    nextStatus = FlowStatus.Canceled;
                    WorkflowMgr.CancelAllOtherTasks(currentUser, flow, action);             // if cancel, then not need manager approval any more.
                    break;

                default:
                    throw new Exception("Wrong Action");
                }
                break;

                #endregion
            }

            if (nextStatus != flow.Status)
            {
                SF_MoveTo(currentUser, flow, nextStatus, request, comments);
            }
        }
示例#5
0
        //刷新流程进度
        public void RefreshFlow(FlowStatus flowName)
        {
            if (flowName == FlowStatus.Start)
            {
                foreach (Button btn in flowList)
                {
                    btn.ImageKey = btn.Name + "Default";
                }
            }
            else if (flowName == FlowStatus.End)
            {
                foreach (Button btn in flowList)
                {
                    btn.ImageKey = btn.Name + "Done";
                }
            }
            else
            {
                int flowIndex = -1;
                foreach (Control ctrl in this.panel1.Controls)
                {
                    if (ctrl.Name == flowName.ToString())
                    {
                        flowIndex = flowList.IndexOf(ctrl as Button);
                    }
                }

                if (flowIndex < 0)
                {
                    return;
                }

                for (int i = 0; i < flowList.Count; i++)
                {
                    Button btn = flowList[i];
                    if (i < flowIndex)
                    {
                        btn.ImageKey = btn.Name + "Done";
                    }
                    else if (i == flowIndex)
                    {
                        btn.ImageKey = btn.Name + "Running";
                        this.panel1.ScrollControlIntoView(btn);
                    }
                    else
                    {
                        btn.ImageKey = btn.Name + "Default";
                    }
                }
            }

            this.panel1.Refresh();
        }
示例#6
0
        private void InvokeControl()
        {
            FlowStatus   fs   = FlowStatus.Continue;
            IFlowControl ctrl = (obj as IFlowControl);

            while (ctrl.CheckDo() == FlowStatus.Continue)
            {
                InvokeSubActions();
                if (!ctrl.IsIterate)
                {
                    break;
                }
            }
        }
示例#7
0
        private void ExecuteProcess()
        {
            var retriedTimes = 0;

            _currentStatus = FlowStatus.Running;
            Log.Info(string.Format("{0}: Started.", GetType().Name));

            while (true)
            {
                try
                {
                    _tokenSource.Token.ThrowIfCancellationRequested();
                    ExecutePeriod();
                }
                catch (OperationCanceledException)
                {
                    _currentStatus = FlowStatus.Stopped;
                    Log.Info(string.Format("{0}: Stopped.", GetType().Name));
                    break;
                }
                catch (Exception ex)
                {
                    if (retriedTimes < TimesToRetry)
                    {
                        retriedTimes++;
                        _currentStatus = FlowStatus.Retrying;

                        Log.Warn(string.Format("{0}: {1}", GetType().Name, ex));
                        Log.Warn(string.Format("{0}: Retrying {1} times.", GetType().Name, retriedTimes));
                        Thread.Sleep(TimeSpan.FromSeconds(10));
                        _tokenSource.Token.ThrowIfCancellationRequested();
                        continue;
                    }

                    _currentStatus = FlowStatus.Broken;

                    Log.Error(ex);
                    Log.Error(string.Format("{0}: Shut down because broken!", GetType().Name));
                    break;
                }

                if (_currentStatus == FlowStatus.Retrying)
                {
                    _currentStatus = FlowStatus.Running;

                    Log.Info(string.Format("{0}: Resuming after {1} times.", GetType().Name, retriedTimes));
                    retriedTimes = 0;
                }
            }
        }
示例#8
0
        private static void SF_MoveTo(UserInfo currentUser, FlowInfo flow, FlowStatus nextStatus, RequestInfo request, string comments)
        {
            Dictionary <ApproverInfo, RoleType> nextUser = new Dictionary <ApproverInfo, RoleType>();

            switch (nextStatus)
            {
                #region case RequestStatus.Submitted
            case FlowStatus.Submitted:
                //List<UserInfo> users = OrgMgr.GetApprovers(flow.FlowId, "approver");
                List <ApproverInfo> approvers = OrgMgr.GetApprovers(flow.FlowId).FindAll(obj => { return(obj.ApproveType == "approver"); });
                foreach (var item in approvers)
                {
                    nextUser.Add(item, RoleType.Approver);
                }
                break;
                #endregion

                #region case RequestStatus.Approved
            case FlowStatus.Approved:
                List <ApproverInfo> engs = OrgMgr.GetApprovers(flow.FlowId).FindAll(obj => { return(obj.ApproveType == "eng"); });
                if (request.FlowType == 1)      //并行
                {
                    foreach (var item in engs)
                    {
                        nextUser.Add(item, RoleType.Eng);
                    }
                }
                else      //串行
                {
                    nextUser.Add(engs[0], RoleType.Eng);
                }
                break;
                #endregion
            }

            WorkflowMgr.UpdateStatus(flow.FlowId, nextStatus);
            flow.Status = nextStatus;
            AddTasks(nextUser, flow);

            SendMail(currentUser, request, flow, nextUser, comments);
        }
示例#9
0
        public object MyList(int formId, FlowStatus status = FlowStatus.Doing, int page = 1, int rows = 5)
        {
            var list = Core.UserFormInfoManager.GetUserInfoList(new FormInfoParameter
            {
                FormId     = formId,
                UserId     = Identity.ID,
                FlowStatus = new[] { status },
                Read       = false,
                Page       = new Loowoo.Common.PageParameter(page, rows),
            });

            return(list.Select(e => new
            {
                e.ID,
                e.FormId,
                e.InfoId,
                e.Title,
                e.CreateTime,
                e.UpdateTime,
                e.Reminded,
                e.CC,
                Poster = e.Poster == null ? null : e.Poster.RealName,
            }));
        }
示例#10
0
 public static void UpdateStatus(int flowId, FlowStatus status)
 {
     _flow.UpdateStatus(flowId, status);
 }
 public static void SetStatusValue(this FlowProcess flow, FlowStatus value)
 {
     flow.Status = (int)value;
 }
示例#12
0
        public static void HandleTask(UserInfo currentUser, int taskId, FlowInfo flow,
                                      RequestInfo request, ActionType action, string comments)
        {
            IList <ActionType> accessList = GetRequestPermission(taskId, flow, request, currentUser.UID);

            //judge current user whether have permission to do the action
            if (accessList.IndexOf(action) < 0)
            {
                throw new Exception("You don't have permission to do this action.");
            }

            WorkflowMgr.UpdateTask(taskId, action, comments);
            //FlowStatus oldStatus = flow.Status;
            FlowStatus nextStatus = flow.Status;
            Dictionary <ApproverInfo, RoleType> nextUser = new Dictionary <ApproverInfo, RoleType>();

            if (flow.Status == FlowStatus.Approved)
            {
                if (action == ActionType.Commit)
                {
                    if (request.FlowType == 1)   // 并行
                    {
                        if (WorkflowMgr.IsParallelLastApprover(currentUser.UID, flow))
                        {
                            nextStatus = FlowStatus.Closed;
                            WorkflowMgr.UpdateStatus(flow.FlowId, nextStatus);

                            SendMail(currentUser, request, flow, nextUser, comments);
                        }
                    }
                    else  //串行
                    {
                        List <ApproverInfo> approvers = OrgMgr.GetApprovers(flow.FlowId).FindAll(obj => { return(obj.ApproveType == "eng"); });

                        TaskInfo ts = WorkflowMgr.GetTask(taskId);
                        if (ts.UID.ToLower() == approvers[approvers.Count - 1].UID.ToLower())
                        {
                            nextStatus = FlowStatus.Closed;
                            WorkflowMgr.UpdateStatus(flow.FlowId, nextStatus);

                            SendMail(currentUser, request, flow, nextUser, comments);
                        }
                        else
                        {
                            int idx = approvers.FindIndex(obj => { return(obj.UID.ToLower() == ts.UID.ToLower()); });
                            nextUser.Add(approvers[idx + 1], RoleType.Eng);

                            AddTasks(nextUser, flow);
                            //send mail to next eng
                            SendMail(currentUser, request, flow, nextUser, comments);
                        }
                    }
                }
                else if (action == ActionType.Cancel)
                {
                    nextStatus = FlowStatus.Canceled;
                    WorkflowMgr.CancelAllOtherTasks(currentUser, flow, action);

                    WorkflowMgr.UpdateStatus(flow.FlowId, nextStatus);

                    SendMail(currentUser, request, flow, nextUser, comments);
                }
                else
                {
                    throw new Exception("Wrong Action");
                }
            }
            else
            {
                SF_MoveAfterTaskDone(currentUser, flow, request, action, comments);
            }
        }