Example #1
0
        public Response Start(StartFlowInstanceReq obj)
        {
            var result = new Response();

            try
            {
                _app.Start(obj);
            }
            catch (Exception ex)
            {
                result.Code    = 500;
                result.Message = ex.InnerException?.Message ?? ex.Message;
            }

            return(result);
        }
Example #2
0
        /// <summary>启动流程</summary>
        /// <remarks> 通常是对状态为【草稿】的流程进行操作,进入运行状态 </remarks>
        public void Start(StartFlowInstanceReq request)
        {
            FlowInstance flowInstance = Get(request.FlowInstanceId);

            if (flowInstance.IsFinish != FlowInstanceStatus.Draft)
            {
                throw new Exception("当前流程不是草稿状态,不能启动");
            }
            var wfruntime = new FlowRuntime(flowInstance);
            var user      = _auth.GetCurrentUser();

            #region 根据运行实例改变当前节点状态
            flowInstance.ActivityId     = wfruntime.nextNodeId;
            flowInstance.ActivityType   = wfruntime.GetNextNodeType();
            flowInstance.ActivityName   = wfruntime.nextNode.name;
            flowInstance.PreviousId     = wfruntime.currentNodeId;
            flowInstance.CreateUserId   = user.User.Id;
            flowInstance.CreateUserName = user.User.Account;
            flowInstance.MakerList      = (wfruntime.GetNextNodeType() != 4 ? GetNextMakers(wfruntime) : "");
            flowInstance.IsFinish       = (wfruntime.GetNextNodeType() == 4
                ? FlowInstanceStatus.Finished
                : FlowInstanceStatus.Running);

            UnitWork.Update(flowInstance);
            #endregion 根据运行实例改变当前节点状态

            #region 流程操作记录

            FlowInstanceOperationHistory processOperationHistoryEntity = new FlowInstanceOperationHistory
            {
                InstanceId     = flowInstance.Id,
                CreateUserId   = user.User.Id,
                CreateUserName = user.User.Name,
                CreateDate     = DateTime.Now,
                Content        = $"【启动】由用户{user.User.Name}启动"
            };
            UnitWork.Add(processOperationHistoryEntity);

            #endregion 流程操作记录

            AddTransHistory(wfruntime);
            UnitWork.Save();
        }