Esempio n. 1
0
        /// <summary>
        /// 继续执行工作流
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="user"></param>
        /// <param name="ExecuteResult"></param>
        /// <param name="ExecuteComment"></param>
        /// <param name="Memo"></param>
        public void LabData_ContinueDBWF(string InstanceStepExecutorId, string ToStepId, string ExecuteResult, string ExecuteComment, string Memo,
                                         string currentUserId, string currentUserName, bool continueWF)
        {
            var InstanceStepExecutor = InstanceStepExecutorDAO.Get(InstanceStepExecutorId);
            var InstanceStep         = WFDA.Instance.GetInstanceStep(InstanceStepExecutor.InstanceStepId);
            var Instance             = WFDA.Instance.GetInstance(InstanceStepExecutor.InstanceId);

            // 更新 InstanceStepExecutor 的 Extend01 字段,让工作流进行流转
            var toStep = WFDA.Instance.GetStep(ToStepId);

            SetFinished(InstanceStepExecutorId, ExecuteResult, ExecuteComment, Memo, currentUserName);
            WFDA.Instance.UpdateInstanceStepExt(InstanceStep.InstanceStepId, "Extend01", toStep.StepId, currentUserName);
            WFDA.Instance.UpdateInstanceStepExt(InstanceStep.InstanceStepId, "Extend02", toStep.StepName, currentUserName);

            if (continueWF)
            {
                var engine = NinjectHelper.Get <IEngine>();
                if (engine == null)
                {
                    throw new Exception("找不到 IEngine".GetRes());
                }
                // 继续工作流
                engine.ContinueDBWF(Instance.ModelId, Instance.InstanceId, InstanceStep.InstanceStepId, true, currentUserId, currentUserName);
            }
        }
Esempio n. 2
0
        public void Goto(string InstanceStepExecutorId, string ExecuteComment, string ExecuteResult, string ToStepId, string CurrentUserId, string CurrentUserName)
        {
            var InstanceStepExecutor = InstanceStepExecutorDAO.Get(InstanceStepExecutorId);

            if (InstanceStepExecutor.ExecuteStatus == Pub.Finished)
            {
                throw new WFException("该签核任务已经完成");
            }
            // 更新当前任务已经完成
            SetFinished(InstanceStepExecutorId, ExecuteResult, ExecuteComment, CurrentUserName);

            BackToAdditionalSource(InstanceStepExecutor.InstanceStepId, CurrentUserName);
            if (!string.IsNullOrWhiteSpace(ToStepId))
            {
                GotoStep(InstanceStepExecutorId, ToStepId, CurrentUserId, CurrentUserName);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 尝试某个运行时节点的下面的步骤
        /// </summary>
        /// <param name="InstanceStepId"></param>
        /// <returns></returns>
        private List <WFItem> TryGetNextSteps(string InstanceStepExecutorId)
        {
            var InstanceStepExecutor = InstanceStepExecutorDAO.Get(InstanceStepExecutorId);
            var InstanceStep         = WFDA.Instance.GetInstanceStep(InstanceStepExecutor.InstanceStepId);
            var instance             = WFDA.Instance.GetInstance(InstanceStep.InstanceId);

            var data1 = WFBusinessData.AddPrefix("WF_T_INSTANCE_", WFBusinessData.CreateInstance <WF_T_INSTANCE>(instance));
            var data2 = WFBusinessData.AddPrefix("WF_T_INSTANCESTEP_", WFBusinessData.CreateInstance <WF_T_INSTANCESTEP>(InstanceStep));
            var data3 = WFBusinessData.AddPrefix("WF_T_INSTANCESTEPEXECUTOR_", WFBusinessData.CreateInstance <WF_T_INSTANCESTEPEXECUTOR>(InstanceStepExecutor));

            WFBusinessData.Merge(data2, data1);
            WFBusinessData.Merge(data3, data1);
            var businessData = data1;

            var Step = WFDA.Instance.GetStep(InstanceStep.StepId);
            var sql  = Pub.GetOriginalSql(Step.Script);

            return(GetWFItems(instance, businessData, ref sql));
        }
Esempio n. 4
0
        /// <summary>
        /// 如果有加签人,就返回到加签人,如果没有加签人,直接忽略
        /// </summary>
        /// <param name="InstanceStepId"></param>
        /// <param name="currentUser"></param>
        private void BackToAdditionalSource(string InstanceStepId, string currentUser)
        {
            var instanceStep = WFDA.Instance.GetInstanceStep(InstanceStepId);

            if (!string.IsNullOrWhiteSpace(instanceStep.Extend04))
            {
                var item = InstanceStepExecutorDAO.Get(instanceStep.Extend04);
                if (item != null)
                {
                    var list = InstanceStepExecutorDAO.QueryByExecuteStatus(InstanceStepId, Pub.Unfinished);
                    list.ForEach(a => a.Extend01 = string.Format("{0}", a.Extend01));
                    if (!list.Any(a => a.Extend01.Contains("签")))
                    {
                        // 转签加签都完成了
                        ExecutorImp.InsertOneAndProxy(InstanceStepId, item.ExecutorId, item.ExecutorName, string.Empty, currentUser, true);
                        // 需要返回到加签的来源人
                        WFDA.Instance.UpdateInstanceStepExt(InstanceStepId, "Extend04", null, currentUser);
                    }
                }
            }
        }
Esempio n. 5
0
        public override void SetAccess(FormM form, DFDictionary entity)
        {
            var InstanceStepExecutorId = entity["InstanceStepExecutorId"];
            var actionName             = DFPub.UrlDecode(entity["actionName"]);
            var action = entity["action"];

            if (string.IsNullOrWhiteSpace(InstanceStepExecutorId))
            {
                throw new WFException("缺少参数 InstanceStepExecutorId");
            }

            //form.GetControlM("NextStep").Text = actionName;
            var InstanceStepExecutor = InstanceStepExecutorDAO.Get(InstanceStepExecutorId);

            if (new StateEngineHelper().IsHideNextStep(InstanceStepExecutor.InstanceStepId))
            {
                // 加签不影响流程走向,所以要隐藏下一步
                form.GetControlM("NextStep").Visible = false;
            }
            else
            {
                if (action == "btnSubmit" || action == "btnApprove")
                {
                    var list = new StateEngineHelper().GetSubmitOrApproveSteps(InstanceStepExecutorId);
                    base.SetSelectDataSource(form, "NextStep", list.Select(a => new DFSelectItem()
                    {
                        Text = a.text, Value = a.value
                    }).ToList());
                }
                else if (action == "btnRollback" || action == "btnReject")
                {
                    var list = new StateEngineHelper().GetRejectOrRollbackSteps(InstanceStepExecutorId);
                    base.SetSelectDataSource(form, "NextStep", list.Select(a => new DFSelectItem()
                    {
                        Text = a.text, Value = a.value
                    }).ToList());
                }
            }
            base.SetAccess(form, entity);
        }
Esempio n. 6
0
        /// <summary>
        /// 从某个运行时步骤到另外一个步骤
        /// </summary>
        /// <param name="InstanceStepExecutorId"></param>
        /// <param name="ToStepId"></param>
        /// <param name="CurrentUserId"></param>
        /// <param name="CurrentUserName"></param>
        private void GotoStep(string InstanceStepExecutorId, string ToStepId, string CurrentUserId, string CurrentUserName)
        {
            var InstanceStepExecutor = InstanceStepExecutorDAO.Get(InstanceStepExecutorId);
            var ToStep = WFDA.Instance.GetStep(ToStepId);

            if (ToStep.StepId == InstanceStepExecutor.StepId)
            {
                throw new WFException("当前步骤和下一步骤不能相同".GetRes());
            }

            var engine = NinjectHelper.Get <IEngine>();

            if (engine == null)
            {
                throw new WFException("找不到 IEngine".GetRes());
            }

            // 更新步骤签核信息
            InstanceStepExecutorDAO.UpdateUnfinishedByInstanceStepId(InstanceStepExecutor.InstanceStepId, "自动完成", Pub.Finished, CurrentUserName);

            var rollback = new List <string>()
            {
                "回退", "不同意", "拒绝"
            };

            if (rollback.Contains(InstanceStepExecutor.ExecuteResult))
            {
                engine.RollbackDBWF(ToStep.ModelId, InstanceStepExecutor.InstanceId, InstanceStepExecutor.InstanceStepId, ToStep.StepId, true, CurrentUserId, CurrentUserName);
            }
            else
            {
                Extend02(CurrentUserId, CurrentUserName, InstanceStepExecutor, engine);
                // 继续工作流
                engine.GotoDBWF(ToStep.ModelId, InstanceStepExecutor.InstanceId, InstanceStepExecutor.InstanceStepId, ToStep.StepId, true, CurrentUserId, CurrentUserName);
            }
        }
        private static int GetAccess(FormM form, DFDictionary entity)
        {
            var InstanceStepExecutorId = entity["InstanceStepExecutorId"];

            if (string.IsNullOrWhiteSpace(InstanceStepExecutorId))
            {
                return(0);
            }
            var result = 0;
            var InstanceStepExecutor = InstanceStepExecutorDAO.Get(InstanceStepExecutorId);

            if (null != InstanceStepExecutor)
            {
                if (InstanceStepExecutor.ExecuteStatus == Pub.Finished)
                {
                    var user = Util.GetCurrentUser();
                    // 判断是否是流程管理员
                    if (WFDA.Instance.IsInstanceStepRunning(InstanceStepExecutorId) && WFDA.Instance.IsWorkflowAdmin(user.UserName, InstanceStepExecutor.ModelName))
                    {
                        // 允许加签转签功能
                        result = result | 32;
                        result = result | 64;
                    }
                    return(result);
                }
                var Step = WFDA.Instance.GetStep(InstanceStepExecutor.StepId);
                if (null != Step && !string.IsNullOrWhiteSpace(Step.AllowActions))
                {
                    // 1 保存 2 提交 3 同意 4 不同意 5 回退 6 转签 7 加签
                    var list = Step.AllowActions.Split(',');
                    if (list.Contains("1"))
                    {
                        result = result | 1;
                    }
                    if (list.Contains("2"))
                    {
                        result = result | 2;
                    }
                    if (list.Contains("3"))
                    {
                        result = result | 4;
                    }
                    if (list.Contains("4"))
                    {
                        result = result | 8;
                    }
                    if (list.Contains("5"))
                    {
                        result = result | 16;
                    }
                    if (list.Contains("6"))
                    {
                        result = result | 32;
                    }
                    if (list.Contains("7"))
                    {
                        result = result | 64;
                    }
                }
            }
            return(result);
        }