Exemple #1
0
        /// <summary>
        /// 创建任务
        /// </summary>
        /// <param name="flow"></param>
        /// <param name="fromTask"></param>
        /// <param name="routing"></param>
        /// <param name="taskUserIDs"></param>
        /// <param name="taskUserNames"></param>
        /// <param name="taskUserIDsGroup"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public S_WF_InsTask CreateTask(S_WF_InsFlow flow, S_WF_InsTask fromTask, S_WF_InsDefRouting routing, string taskUserIDs, string taskUserNames, string taskUserIDsGroup, string taskRoleIDs, string taskOrgIDs, UserInfo user)
        {
            try
            {
                var    task = new S_WF_InsTask();
                string senderTaskUserIDs   = user.UserID;
                string senderTaskUserNames = user.UserName;
                if (fromTask != null && fromTask.S_WF_InsDefStep.CooperationMode == TaskCooperationMode.All.ToString() && routing != null && routing.Type != RoutingType.Distribute.ToString())
                {
                    senderTaskUserIDs   = string.Join(",", fromTask.S_WF_InsTaskExec.Select(c => c.ExecUserID).ToArray());
                    senderTaskUserNames = string.Join(",", fromTask.S_WF_InsTaskExec.Select(c => c.ExecUserName).ToArray());
                }

                string complete = FlowTaskStatus.Complete.ToString();

                //所有分支路由使用同一个任务
                if (routing != null && routing.Type == RoutingType.Branch.ToString())
                {
                    var preTask = flow.S_WF_InsTask.Where(c => c.InsDefStepID == this.ID && c.Status != complete).LastOrDefault();
                    if (preTask != null && preTask.TaskUserIDs == taskUserIDs)
                    {
                        if (preTask.WaitingRoutings.Contains(routing.ID))//等待汇聚的任务
                        {
                            preTask.WaitingRoutings   = StringHelper.Exclude(preTask.WaitingRoutings, routing.ID);
                            preTask.SendTaskIDs       = StringHelper.Include(preTask.SendTaskIDs, fromTask.ID);
                            preTask.SendTaskUserIDs   = StringHelper.Include(preTask.SendTaskUserIDs, senderTaskUserIDs);
                            preTask.SendTaskUserNames = StringHelper.Include(preTask.SendTaskUserNames, senderTaskUserNames);
                        }
                        else //非等待汇聚任务(一般由分支分出的任务)
                        {
                            preTask.SendTaskIDs       = StringHelper.Include(preTask.SendTaskIDs, fromTask.ID);
                            preTask.SendTaskUserIDs   = StringHelper.Include(preTask.SendTaskUserIDs, senderTaskUserIDs);
                            preTask.SendTaskUserNames = StringHelper.Include(preTask.SendTaskUserNames, senderTaskUserNames);
                            preTask.CreateTime        = DateTime.Now; //重现修改创建时间
                        }
                        //设置任务的紧急度
                        if (FormulaHelper.ContextGetValueString("Urgency") == "true")
                        {
                            preTask.Urgency = "1";
                        }
                        else
                        {
                            preTask.Urgency = "0";
                        }
                        return(preTask);
                    }
                    else
                    {
                        string branch = RoutingType.Branch.ToString();
                        //增加汇聚路由的过滤
                        var routings = this.S_WF_InsDefFlow.S_WF_InsDefRouting.Where(c => c.Type == branch && c.EndID == this.ID && c.Name == routing.Name && c.ID != routing.ID).ToList();
                        routings             = FilterRouting(routings, flow);
                        task.WaitingRoutings = string.Join(",", routings.Select(c => c.ID).ToArray());
                    }
                }
                else if (routing != null && routing.Type != RoutingType.Distribute.ToString()) //非分支路由,任务执行人不变,不创建新任务
                {
                    var preTask = flow.S_WF_InsTask.Where(c => c.InsDefStepID == this.ID && c.Status != complete).LastOrDefault();
                    if (preTask != null && preTask.TaskUserIDs == taskUserIDs)
                    {
                        preTask.SendTaskIDs       = StringHelper.Include(preTask.SendTaskIDs, fromTask.ID);
                        preTask.SendTaskUserIDs   = StringHelper.Include(preTask.SendTaskUserIDs, senderTaskUserIDs);
                        preTask.SendTaskUserNames = StringHelper.Include(preTask.SendTaskUserNames, senderTaskUserNames);
                        //设置任务的紧急度
                        if (FormulaHelper.ContextGetValueString("Urgency") == "true")
                        {
                            preTask.Urgency = "1";
                        }
                        else
                        {
                            preTask.Urgency = "0";
                        }

                        //重新打开弱控按钮(弱控路由)
                        string strWeakType = RoutingType.Weak.ToString();
                        var    weakRouting = this.S_WF_InsDefRouting.Where(c => c.EndID == routing.InsDefStepID && c.Type == strWeakType).SingleOrDefault();
                        if (weakRouting != null)
                        {
                            foreach (var item in preTask.S_WF_InsTaskExec)
                            {
                                item.WeakedRoutingIDs = StringHelper.Exclude(item.WeakedRoutingIDs, weakRouting.ID);
                            }
                        }

                        return(preTask);
                    }
                }

                //设置任务的紧急度
                if (FormulaHelper.ContextGetValueString("Urgency") == "true")
                {
                    task.Urgency = "1";
                }
                else
                {
                    task.Urgency = "0";
                }

                if (this.Type == StepTaskType.Normal.ToString() && string.IsNullOrEmpty(taskUserIDs))
                {
                    throw new FlowException("路由的执行人配置不正确");
                }

                task.ID                = FormulaHelper.CreateGuid();
                task.CreateTime        = DateTime.Now;
                task.SendTaskIDs       = fromTask == null ? "" : fromTask.ID;
                task.SendTaskUserIDs   = senderTaskUserIDs;
                task.SendTaskUserNames = senderTaskUserNames;
                task.TaskUserIDs       = taskUserIDs;
                task.TaskUserNames     = taskUserNames;
                task.TaskUserIDsGroup  = taskUserIDsGroup;
                task.TaskRoleIDs       = taskRoleIDs;
                task.TaskOrgIDs        = taskOrgIDs;
                task.Status            = FlowTaskStatus.Processing.ToString();

                task.InsDefStepID    = this.ID;
                task.InsFlowID       = flow.ID;
                task.Type            = this.Type;
                task.TaskName        = flow.GetInsName(this.S_WF_InsDefFlow.TaskNameTemplete).Replace("{StepName}", this.Name).Replace("{FlowName}", this.S_WF_InsDefFlow.Name);
                task.TaskCategory    = flow.GetInsName(this.S_WF_InsDefFlow.TaskCategoryTemplete).Replace("{StepName}", this.Name).Replace("{FlowName}", this.S_WF_InsDefFlow.Name);
                task.TaskSubCategory = flow.GetInsName(this.S_WF_InsDefFlow.TaskSubCategoryTemplete).Replace("{StepName}", this.Name).Replace("{FlowName}", this.S_WF_InsDefFlow.Name);

                flow.S_WF_InsTask.Add(task);
                task.S_WF_InsFlow    = flow;
                task.S_WF_InsDefStep = this;

                //结束环节不要任务执行人
                if (task.Type == StepTaskType.Completion.ToString())
                {
                    task.TaskUserIDs      = "";
                    task.TaskUserNames    = "";
                    task.TaskUserIDsGroup = "";
                    task.TaskRoleIDs      = "";
                    task.TaskOrgIDs       = "";
                }

                //子流程任务执行人分配给系统
                if (task.Type == StepTaskType.SubFlow.ToString())
                {
                    task.TaskUserIDs      = "system";
                    task.TaskUserNames    = "系统";
                    task.TaskUserIDsGroup = "";
                    task.TaskRoleIDs      = "";
                    task.TaskOrgIDs       = "";
                }

                //任务的等待环节
                foreach (var t in flow.S_WF_InsTask.Where(c => c.CompleteTime == null))
                {
                    if (this.WaitingStepIDs.Split(',').Contains(t.InsDefStepID))
                    {
                        task.WaitingSteps += "," + t.InsDefStepID;
                    }
                }
                task.WaitingSteps = task.WaitingSteps.Trim(',');
                //更新其它等待本环节的任务
                foreach (var item in flow.S_WF_InsTask.Where(c => c.CompleteTime == null && c.ID != task.ID && c.S_WF_InsDefStep.WaitingStepIDs.Contains(this.ID)))
                {
                    if (item.WaitingSteps.Contains(this.ID) == false)
                    {
                        item.WaitingSteps += "," + this.ID;
                        item.WaitingSteps.Trim(',');
                    }
                }

                //当环节为组协作完成且用户没有分组时,按组织角色分组 2013-8
                if (this.CooperationMode == TaskCooperationMode.GroupSingle.ToString() && string.IsNullOrEmpty(task.TaskUserIDsGroup))
                {
                    throw new FlowException("环节设置为组单人完成,但执行用户无法分组");

                    //if (string.IsNullOrEmpty(task.TaskRoleIDs) || string.IsNullOrEmpty(task.TaskOrgIDs))
                    //    throw new FlowException("环节设置为组单人完成,但执行用户无法分组");

                    //List<Object> list = new List<object>();

                    //IUserService userService = FormulaHelper.GetService<IUserService>();

                    //foreach (string userID in task.TaskUserIDs.Split(','))
                    //{
                    //    foreach (string roleID in task.TaskRoleIDs.Split(','))
                    //    {
                    //        foreach (string orgID in task.TaskOrgIDs.Split(','))
                    //        {
                    //            if (userService.InRole(userID, roleID, orgID))
                    //            {
                    //                string groupName = string.Format("{0}.{1}", roleID, orgID).GetHashCode().ToString();
                    //                list.Add(new { GroupName = groupName, UserID = userID });
                    //            }
                    //        }
                    //    }
                    //}
                    //task.TaskUserIDsGroup = JsonHelper.ToJson(list);
                }

                //记录打回直送
                if (routing != null) //首环节时,routing为null
                {
                    if (routing.AllowDoBack == "1" || routing.OnlyDoBack == "1")
                    {
                        task.DoBackRoutingID = routing.ID;
                    }
                    if (routing.OnlyDoBack == "1")
                    {
                        task.OnlyDoBack = "1";
                    }
                }
                return(task);
            }
            catch (Exception ex)
            {
                throw new FlowException(ex.Message);
            }
        }
 protected override void OnFlowEnd(T_EXE_Audit entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing)
 {
     if (entity != null)
     {
         var products = this.BusinessEntities.Set <S_E_Product>().Where(d => d.AuditID == entity.ID).ToList();
         foreach (var product in products)
         {
             //product.Collactor = entity.Collactor;
             //product.CollactorName = entity.CollactorName;
             //product.Auditor = entity.Auditor;
             //product.AuditorName = entity.AuditorName;
             //product.Approver = entity.Approver;
             //product.ApproverName = entity.ApproverName;
             //更新成果的SignState
             product.SignState = product.AuditState;
             product.Save();
         }
         entity.Publish();
     }
     this.BusinessEntities.SaveChanges();
 }
Exemple #3
0
        public S_WF_InsTask CreateTask(S_WF_InsFlow flow, S_WF_InsTask fromTask, S_WF_InsDefRouting routing, string taskUserIDs, string taskUserNames, string taskUserIDsGroup, string taskRoleIDs, string taskOrgIDs)
        {
            UserInfo user = FormulaHelper.GetUserInfo();

            return(this.CreateTask(flow, fromTask, routing, taskUserIDs, taskUserNames, taskUserIDsGroup, taskRoleIDs, taskOrgIDs, user));
        }
 protected override void OnFlowEnd(T_EXE_MettingSign entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing)
 {
     if (entity != null)
     {
         entity.Push();
     }
     this.BusinessEntities.SaveChanges();
 }
        protected override void AfterExeTaskExec(Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing,
                                                 string nextExecUserIDs, string nextExecUserNames, string nextExecUserIDsGroup, string nextExecRoleIDs, string nextExecOrgIDs, string execComment)
        {
            var workFlowEntities = FormulaHelper.GetEntities <WorkflowEntities>();

            #region  步Activity

            var currentTask = taskExec.S_WF_InsTask;
            var flow        = taskExec.S_WF_InsFlow;
            if (flow == null)
            {
                throw new Formula.Exceptions.BusinessException("");
            }
            var currentStep = currentTask.S_WF_InsDefStep;
            var nextStep    = workFlowEntities.Set <S_WF_InsDefStep>().SingleOrDefault(c => c.ID == routing.EndID);
            var nextTask    = nextStep.S_WF_InsTask.OrderByDescending(c => c.CreateTime).FirstOrDefault(); //取最新的任务


            var entity = this.BusinessEntities.Set <T_EXE_Audit>().SingleOrDefault(c => c.ID == flow.FormInstanceID);
            if (entity != null)
            {
                var key         = currentStep.Code;
                var name        = "(" + entity.SerialNumber + ")" + currentStep.Name;
                var displayName = entity.PhaseCode + "-" + entity.MajorCode + "-" + currentStep.Name;
                var activity    = entity.CreateAcitivity(key, name, displayName);
                if (taskExec.CreateTime.HasValue)
                {
                    activity.CreateDate = taskExec.CreateTime.Value;
                }
                if (currentTask.Status == FlowTaskStatus.Complete.ToString())//解决协作完成时,只要有一个用户通过就更新成果状态的bug
                {
                    //校审环节编号为空时 默认给Flow
                    entity.SynchProductAuditState(string.IsNullOrEmpty(nextStep.Code) ? "Flow" : nextStep.Code);

                    //CAD消息随大事记发送 2019年4月4日
                    #region 发项目消息,用于发送cad通知

                    //var receiverIds = nextExecUserIDs;
                    //var receiverNames = nextExecUserNames;
                    //var title = /*currentStep.Name + routing.Name + */"校审通知";
                    //var content = "【" + entity.ProjectInfoName + "】";
                    //if (!string.IsNullOrEmpty(entity.SubProjectName))
                    //    content += "【" + entity.SubProjectName + "】";
                    //if (!string.IsNullOrEmpty(entity.PhaseCode))
                    //    content += "【" + FormulaHelper.GetService<IEnumService>().GetEnumText("Project.Phase", entity.PhaseCode) + "】";
                    //if (!string.IsNullOrEmpty(entity.MajorCode))
                    //    content += "【" + FormulaHelper.GetService<IEnumService>().GetEnumText("Project.Major", entity.MajorCode) + "】";
                    //if (routing.Code == "Pass")
                    //{
                    //    title = "校审流程通过通知";
                    //    content += "有成果通过校审流程";
                    //    receiverIds = entity.Designer;
                    //    receiverNames = entity.DesignerName;
                    //}
                    //else
                    //    content += "我的" + nextStep.Name + ":有成果需要" + nextStep.Name;
                    //FormulaHelper.CreateFO<ProjectInfoFO>().SendNotice(entity.ProjectInfoID, entity.WBSID, entity.MajorCode, "",
                    //    receiverIds, receiverNames, title, content, "", "", entity.ID, "T_EXE_Audit", ProjectNoticeType.Major.ToString(), "", "");
                    #endregion

                    #region 校审意见发消息
                    var sql = @"select * from T_EXE_Audit_AdviceDetail with(nolock) where T_EXE_AuditID='{0}' 
and ID not in (select RelateID from S_N_Notice where RelateType='T_EXE_Audit_AdviceDetail' and ProjectInfoID='{1}')";
                    sql = string.Format(sql, entity.ID, entity.ProjectInfoID);
                    var dt = this.ProjectSQLDB.ExecuteDataTable(sql);
                    foreach (DataRow row in dt.Rows)
                    {
                        var dic      = FormulaHelper.DataRowToDic(row);
                        var _title   = "批注通知";
                        var _content = "【" + entity.ProjectInfoName + "】";
                        if (!string.IsNullOrEmpty(entity.SubProjectName))
                        {
                            _content += "【" + entity.SubProjectName + "】";
                        }
                        if (!string.IsNullOrEmpty(entity.PhaseCode))
                        {
                            _content += "【" + FormulaHelper.GetService <IEnumService>().GetEnumText("Project.Phase", entity.PhaseCode) + "】";
                        }
                        if (!string.IsNullOrEmpty(entity.MajorCode))
                        {
                            _content += "【" + FormulaHelper.GetService <IEnumService>().GetEnumText("Project.Major", entity.MajorCode) + "】";
                        }
                        _content += "的成果【" + dic.GetValue("ProductCode") + "】由 " + dic.GetValue("CreateUserName") + " 增加了一条批注意见:" + dic.GetValue("MsitakeContent");
                        FormulaHelper.CreateFO <ProjectInfoFO>().SendNotice(entity.ProjectInfoID, entity.WBSID, entity.MajorCode, "",
                                                                            entity.Designer, entity.DesignerName, _title, _content, "", "", entity.ID, "T_EXE_Audit_AdviceDetail", ProjectNoticeType.User.ToString(),
                                                                            dic.GetValue("SubmitUser"), dic.GetValue("SubmitUserName"));
                    }
                    #endregion
                }
            }
            this.BusinessEntities.SaveChanges();
            #endregion
        }
Exemple #6
0
        public override bool ExecTaskExec(Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing, string nextExecUserIDs, string nextExecUserNames, string nextExecUserIDsGroup, string nextExecRoleIDs, string nextExecOrgIDs, string execComment)
        {
            WorkflowEntities entitiesFlow = FormulaHelper.GetEntities <WorkflowEntities>();
            bool             flowComplete = base.ExecTaskExec(taskExec, routing, nextExecUserIDs, nextExecUserNames, nextExecUserIDsGroup, nextExecRoleIDs, nextExecOrgIDs, execComment);
            S_D_Posting      model        = entities.Set <S_D_Posting>().Find(taskExec.S_WF_InsFlow.FormInstanceID);

            if (taskExec.S_WF_InsTask.Status == FlowTaskStatus.Complete.ToString())
            {
                if (model != null)
                {
                    if (string.IsNullOrEmpty(model.InsFlowID))
                    {
                        model.InsFlowID = taskExec.S_WF_InsTask.InsFlowID;
                    }

                    string[] arr = new string[2] {
                        routing.InsDefStepID, routing.EndID
                    };
                    List <S_WF_InsDefStep> steps = entitiesFlow.Set <S_WF_InsDefStep>().Where(c => arr.Contains(c.ID)).ToList();
                    string endID = routing.EndID;
                    if (steps.Find(c => c.ID == endID) != null)
                    {
                        model.Status = steps.Find(c => c.ID == endID).Code;
                    }
                    string exStatus = string.Empty;
                    string stepID   = routing.InsDefStepID;
                    if (steps.Find(c => c.ID == stepID) != null)
                    {
                        exStatus = steps.Find(c => c.ID == stepID).Code;
                    }
                    if (model.Status == PostingStatus.Draft.ToString())
                    {
                        string[] arrExecSteps = string.IsNullOrEmpty(model.ExecutedSteps) ? new string[1] {
                            exStatus
                        } : (model.ExecutedSteps + "," + exStatus).Split(',');
                        foreach (string str in arrExecSteps)
                        {
                            if (!string.IsNullOrEmpty(str))
                            {
                                string[] arrValTxt = new string[2] {
                                    str, str + "ID"
                                };
                                foreach (string s in arrValTxt)
                                {
                                    PropertyInfo pi = model.GetType().GetProperty(s, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
                                    if (pi != null && pi.CanWrite)
                                    {
                                        pi.SetValue(model, string.Empty, null);
                                    }
                                }
                            }
                        }
                        model.ExecutedSteps = string.Empty;
                    }
                    else
                    {
                        if (exStatus != string.Empty)
                        {
                            if (string.IsNullOrEmpty(model.ExecutedSteps))
                            {
                                model.ExecutedSteps = exStatus;
                            }
                            else
                            {
                                model.ExecutedSteps += "," + exStatus;
                            }
                        }
                    }
                    //转PDF
                    if (steps.Find(c => c.ID == stepID).Code == PostingStatus.TaoHong.ToString())
                    {
                        if (string.IsNullOrEmpty(model.MergeDocID))
                        {
                            model.MergeDocID = model.DocID;
                        }
                        PostingFO.AddPDFTask(model.MergeDocID);
                    }
                    entities.SaveChanges();
                }
            }

            return(flowComplete);
        }
        public override bool ExecTaskExec(Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing, string nextExecUserIDs, string nextExecUserNames, string nextExecUserIDsGroup, string nextExecRoleIDs, string nextExecOrgIDs, string execComment)
        {
            var user = FormulaHelper.GetUserInfo();
            Dictionary <string, object> formDic = Formula.Helper.JsonHelper.ToObject(Request["formData"]);
            string formID      = formDic.GetValue("ID");
            var    MettingSign = this.BusinessEntities.Set <T_EXE_MettingSign>().Find(formID);

            if (MettingSign == null)
            {
                throw new Formula.Exceptions.BusinessException("未找到会签流程表单信息");
            }

            #region 将流程意见写入详细列表的意见栏中
            var ProjectGroupMembersList = this.BusinessEntities.Set <T_EXE_MettingSign_ProjectGroupMembers>().Where(c => c.T_EXE_MettingSignID == formID).ToList();
            foreach (var item in ProjectGroupMembersList)
            {
                if (item.MettingUser.Contains(user.UserID))
                {
                    item.SignDate = DateTime.Now;
                    if (string.IsNullOrEmpty(item.SignComment))
                    {
                        item.SignComment = execComment;
                    }
                    else
                    {
                        item.SignComment += ";" + execComment;
                    }
                }
            }
            #endregion
            this.BusinessEntities.SaveChanges();

            if (MettingSign != null)
            {
                var workFlowEntities = FormulaHelper.GetEntities <WorkflowEntities>();
                var nextStep         = workFlowEntities.Set <S_WF_InsDefStep>().SingleOrDefault(c => c.ID == routing.EndID);
                var receiverIds      = nextExecUserIDs;
                var receiverNames    = nextExecUserNames;
                var title            = /* currentStep.Name + routing.Name +*/ "会签通知";
                var content          = "【" + MettingSign.ProjectInfoName + "】";
                if (!string.IsNullOrEmpty(MettingSign.SubProjectName))
                {
                    content += "【" + MettingSign.SubProjectName + "】";
                }
                if (!string.IsNullOrEmpty(MettingSign.Phase))
                {
                    content += "【" + FormulaHelper.GetService <IEnumService>().GetEnumText("Project.Phase", MettingSign.Phase) + "】";
                }
                if (routing.Code == "End")
                {
                    title         = "会签流程通过通知";
                    content      += "有成果通过会签流程";
                    receiverIds   = MettingSign.CreateUserID;
                    receiverNames = MettingSign.CreateUser;
                }
                else
                {
                    content += "需要" + nextStep.Name;
                }
                FormulaHelper.CreateFO <ProjectInfoFO>().SendNotice(MettingSign.ProjectInfoID, MettingSign.WBSID, MettingSign.Major, "",
                                                                    receiverIds, receiverNames, title, content, "", "", MettingSign.ID, "T_EXE_MettingSign", ProjectNoticeType.Major.ToString(), "", "");
            }

            return(base.ExecTaskExec(taskExec, routing, nextExecUserIDs, nextExecUserNames, nextExecUserIDsGroup, nextExecRoleIDs, nextExecOrgIDs, execComment));
        }
Exemple #8
0
 protected override void OnFlowEnd(S_E_AuditForm entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing)
 {
     if (entity != null)
     {
         entity.Push();
     }
     this.EPCEntites.SaveChanges();
 }
Exemple #9
0
        public override bool ExecTaskExec(Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing,
                                          string nextExecUserIDs, string nextExecUserNames, string nextExecUserIDsGroup, string nextExecRoleIDs, string nextExecOrgIDs, string execComment)
        {
            var workFlowEntities = FormulaHelper.GetEntities <WorkflowEntities>();

            #region  步工序步骤
            var currentTask = taskExec.S_WF_InsTask;
            var flow        = taskExec.S_WF_InsFlow;
            if (flow == null)
            {
                throw new Formula.Exceptions.BusinessValidationException("");
            }
            var currentStep = currentTask.S_WF_InsDefStep;
            var nextStep    = workFlowEntities.Set <S_WF_InsDefStep>().SingleOrDefault(c => c.ID == routing.EndID);
            var nextTask    = nextStep.S_WF_InsTask.OrderByDescending(c => c.CreateTime).FirstOrDefault(); //取最新的任务

            var entity = this.EPCEntites.Set <S_E_AuditForm>().SingleOrDefault(c => c.ID == flow.FormInstanceID);
            if (entity != null)
            {
                var key         = currentStep.Code;
                var name        = "(" + entity.SerialNumber + ")" + currentStep.Name;
                var displayName = entity.PhaseCode + "-" + entity.MajorCode + "-" + currentStep.Name;

                var taskProc = entity.CreateTaskProc(key, name, displayName);
                if (taskProc != null && taskExec.CreateTime.HasValue)
                {
                    taskProc.FactEndDate = taskExec.CreateTime.Value;
                }
                entity.SynchProductAuditState(nextStep.Code);
            }
            this.EPCEntites.SaveChanges();
            bool isFlowComplete = base.ExecTaskExec(taskExec, routing, nextExecUserIDs, nextExecUserNames, nextExecUserIDsGroup, nextExecRoleIDs, nextExecOrgIDs, execComment);
            #endregion
            return(isFlowComplete);
        }
        /// <summary>
        /// 流程结束反写的业务逻辑
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="taskExec"></param>
        /// <param name="routing"></param>
        protected override void OnFlowEnd(T_EXE_MajorPutInfo entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing)
        {
            if (entity != null)
            {
                entity.Publish();
            }
            this.BusinessEntities.SaveChanges();

            if (!string.IsNullOrEmpty(entity.CoopPlanID))
            {
                var coopPlan = this.BusinessEntities.Set <S_P_CooperationPlan>().FirstOrDefault(c => c.ID == entity.CoopPlanID);
                if (coopPlan != null && !string.IsNullOrEmpty(coopPlan.MileStoneID))
                {
                    var mileStone = this.BusinessEntities.Set <S_P_MileStone>().FirstOrDefault(c => c.ID == coopPlan.MileStoneID);
                    //同步关联的收款项的里程碑信息:时间、状态
                    //var fo = new Basic.Controllers.MileStoneExecuteController();
                    //fo.SyncReceiptObj(mileStone);
                }
            }
        }
Exemple #11
0
        public S_WF_InsDefFlow GetInsDefFlow()
        {
            try
            {
                if (this.AlreadyReleased != "1" || !this.ModifyTime.HasValue)
                {
                    throw new FlowException("流程定义尚未发布!");
                }

                var entities   = FormulaHelper.GetEntities <WorkflowEntities>();
                var insDefFlow = entities.S_WF_InsDefFlow.Where(c => c.DefFlowID == this.ID && c.ModifyTime.HasValue && c.ModifyTime.Value == this.ModifyTime.Value).SingleOrDefault();

                if (insDefFlow == null)
                {
                    lock (padlock)
                    {
                        insDefFlow = entities.S_WF_InsDefFlow.Where(c => c.DefFlowID == this.ID && c.ModifyTime.HasValue && c.ModifyTime.Value == this.ModifyTime.Value).SingleOrDefault();
                        if (insDefFlow == null)
                        {
                            insDefFlow = new S_WF_InsDefFlow();
                            FormulaHelper.UpdateModel(insDefFlow, this);
                            insDefFlow.ID        = GetInsIDs(this.ID);
                            insDefFlow.DefFlowID = this.ID;

                            foreach (var step in this.S_WF_DefStep)
                            {
                                S_WF_InsDefStep insStep = new S_WF_InsDefStep();
                                FormulaHelper.UpdateModel(insStep, step);
                                insStep.ID             = GetInsIDs(step.ID);
                                insStep.DefStepID      = step.ID;
                                insStep.InsDefFlowID   = GetInsIDs(step.DefFlowID);
                                insStep.WaitingStepIDs = GetInsIDs(step.WaitingStepIDs);
                                insStep.EmptyToStep    = GetInsIDs(step.EmptyToStep);

                                insDefFlow.S_WF_InsDefStep.Add(insStep);
                            }

                            foreach (var routing in this.S_WF_DefRouting)
                            {
                                S_WF_InsDefRouting insRouting = new S_WF_InsDefRouting();
                                FormulaHelper.UpdateModel(insRouting, routing);
                                insRouting.EndID                    = GetInsIDs(routing.EndID);
                                insRouting.ID                       = GetInsIDs(routing.ID);
                                insRouting.DefRoutingID             = routing.ID;
                                insRouting.InsDefFlowID             = GetInsIDs(routing.DefFlowID);
                                insRouting.InsDefStepID             = GetInsIDs(routing.DefStepID);
                                insRouting.UserIDsFromStep          = GetInsIDs(routing.UserIDsFromStep);
                                insRouting.UserIDsFromStepSender    = GetInsIDs(routing.UserIDsFromStepSender);
                                insRouting.UserIDsFromStepExec      = GetInsIDs(routing.UserIDsFromStepExec);
                                insRouting.MsgUserIDsFromStep       = GetInsIDs(routing.MsgUserIDsFromStep);
                                insRouting.MsgUserIDsFromStepSender = GetInsIDs(routing.MsgUserIDsFromStepSender);
                                insRouting.MsgUserIDsFromStepExec   = GetInsIDs(routing.MsgUserIDsFromStepExec);

                                var insStep = insDefFlow.S_WF_InsDefStep.Where(c => c.ID == insRouting.InsDefStepID).SingleOrDefault();
                                insStep.S_WF_InsDefRouting.Add(insRouting);
                            }

                            //更新流程图
                            string flowView = insDefFlow.ViewConfig;
                            foreach (string id in idDic.Keys)
                            {
                                flowView = flowView.Replace(id, idDic[id]);
                            }
                            insDefFlow.ViewConfig = flowView;

                            entities.S_WF_InsDefFlow.Add(insDefFlow);
                            entities.SaveChanges();
                        }
                    }
                }
                return(insDefFlow);
            }
            catch (Exception ex)
            {
                throw new FlowException(ex.Message);
            }
        }
        public override bool ExecTaskExec(Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing, string nextExecUserIDs, string nextExecUserNames, string nextExecUserIDsGroup, string nextExecRoleIDs, string nextExecOrgIDs, string execComment)
        {
            var entity = this.BusinessEntities.Set <T_EXE_MajorPutInfo>().SingleOrDefault(c => c.ID == taskExec.S_WF_InsFlow.FormInstanceID);

            if (entity != null)
            {
                //CAD消息随大事记发送 2019年4月4日

                //var workFlowEntities = FormulaHelper.GetEntities<WorkflowEntities>();
                //var nextStep = workFlowEntities.Set<S_WF_InsDefStep>().SingleOrDefault(c => c.ID == routing.EndID);
                //var receiverIds = nextExecUserIDs;
                //var receiverNames = nextExecUserNames;
                //var title =/* currentStep.Name + routing.Name +*/ "互提通知";
                //var content = "【" + entity.ProjectName + "】";
                //if (!string.IsNullOrEmpty(entity.SubProjectName))
                //    content += "【" + entity.SubProjectName + "】";
                //if (!string.IsNullOrEmpty(entity.Phase))
                //    content += "【" + FormulaHelper.GetService<IEnumService>().GetEnumText("Project.Phase", entity.Phase) + "】";
                //if (!string.IsNullOrEmpty(entity.OutMajorValue))
                //    content += "【" + FormulaHelper.GetService<IEnumService>().GetEnumText("Project.Major", entity.OutMajorValue) + "】";
                //if (routing.Code == "Receive")
                //{
                //    title = "互提流程通过通知";
                //    content += "有成果通过提资流程";
                //    receiverIds = entity.CreateUserID;
                //    receiverNames = entity.CreateUser;
                //}
                //else
                //    content += "提出资料需要" + nextStep.Name;
                //FormulaHelper.CreateFO<ProjectInfoFO>().SendNotice(entity.ProjectInfoID, entity.WBSID, entity.OutMajorValue, "",
                //    receiverIds, receiverNames, title, content, "", "", entity.ID, "T_EXE_MajorPutInfo", ProjectNoticeType.Major.ToString(), "", "");
            }
            return(base.ExecTaskExec(taskExec, routing, nextExecUserIDs, nextExecUserNames, nextExecUserIDsGroup, nextExecRoleIDs, nextExecOrgIDs, execComment));
        }
Exemple #13
0
        public void Execute(S_WF_InsDefRouting routing, string execComment, string allBranchRoutings, UserInfo user)
        {
            try
            {
                //弱控路由处理方式
                if (routing.Type == RoutingType.Weak.ToString())
                {
                    //弱控任务留痕 2014-11-20
                    this.WeakedRoutingIDs = StringHelper.Include(this.WeakedRoutingIDs, routing.ID);

                    var newTaskExec = new S_WF_InsTaskExec();
                    FormulaHelper.UpdateModel(newTaskExec, this);
                    this.S_WF_InsTask.S_WF_InsTaskExec.Add(newTaskExec);
                    newTaskExec.ID             = FormulaHelper.CreateGuid();
                    newTaskExec.ExecTime       = DateTime.Now;
                    newTaskExec.ExecComment    = execComment;
                    newTaskExec.TimeConsuming  = 0;
                    newTaskExec.ExecRoutingIDs = routing.ID;

                    return;//停止处理
                }
                this.ExecComment = execComment;

                if (string.IsNullOrEmpty(this.ExecRoutingIDs))
                {
                    this.ExecRoutingIDs = routing.ID;
                }
                else
                {
                    this.ExecRoutingIDs  = string.Join(",", (this.ExecRoutingIDs + "," + routing.ID).Split(',').Distinct());
                    this.ExecRoutingName = routing.Name;
                }

                RoutingType routingType = (RoutingType)Enum.Parse(typeof(RoutingType), routing.Type);


                switch (routingType)
                {
                case RoutingType.Normal:
                    this.ExecTime = DateTime.Now;
                    break;

                case RoutingType.Branch:
                    if (routing.ID == allBranchRoutings)
                    {
                        this.ExecTime = DateTime.Now;
                    }
                    else
                    {
                        if (StringHelper.HasAll(this.ExecRoutingIDs.Split(','), allBranchRoutings.Split(',')))
                        {
                            this.ExecTime = DateTime.Now;
                        }
                    }
                    break;

                case RoutingType.SingleBranch:
                    this.ExecTime = DateTime.Now;
                    break;

                case RoutingType.Weak:
                    break;

                case RoutingType.AntiWeak:
                    this.ExecTime = DateTime.Now;
                    break;

                case RoutingType.Distribute:
                    this.ExecTime = DateTime.Now;
                    break;

                case RoutingType.Back:
                    this.ExecTime = DateTime.Now;
                    break;

                case RoutingType.WithdrawOther:
                    this.ExecTime = DateTime.Now;
                    break;
                }

                if (this.ExecTime != null)
                {
                    this.Complete(this.S_WF_InsTask, this.S_WF_InsFlow, this.S_WF_InsTask.S_WF_InsDefStep.DefStepID, this.S_WF_InsFlow.S_WF_InsDefFlow.Code);

                    this.ExecUserID   = user.UserID;
                    this.ExecUserName = user.UserName;

                    var task = this.S_WF_InsTask;
                    if (task == null)
                    {
                        throw new FlowException("当前任务不存在或已执行!");
                    }
                    if (!string.IsNullOrEmpty(task.TaskUserIDsGroup)) //如果是组单人通过,则
                    {
                        List <Dictionary <string, string> > listDic = JsonHelper.ToObject <List <Dictionary <string, string> > >(this.S_WF_InsTask.TaskUserIDsGroup);
                        var arr = listDic.Where(c => c["UserID"] == this.TaskUserID).Select(c => c["GroupName"]).ToArray();

                        var entities = FormulaHelper.GetEntities <WorkflowEntities>();

                        foreach (string userid in listDic.Where(c => arr.Contains(c["GroupName"])).Select(c => c["UserID"]))
                        {
                            if (listDic.Count(c => c["UserID"] == userid && arr.Contains(c["GroupName"]) == false) == 0)//不在其它组中
                            {
                                var exec = task.S_WF_InsTaskExec.Where(c => c.TaskUserID == userid && c.TaskUserID != this.TaskUserID).SingleOrDefault();
                                if (exec != null)
                                {
                                    entities.S_WF_InsTaskExec.Remove(exec);
                                }
                            }
                        }
                    }

                    //计算耗时
                    var canlendarService = FormulaHelper.GetService <ICalendarService>();
                    this.TimeConsuming = canlendarService.GetWorkHourCount((DateTime)this.CreateTime, (DateTime)this.ExecTime);
                }
            }
            catch (Exception ex)
            {
                throw new FlowException(ex.Message);
            }
        }
Exemple #14
0
        public void Execute(S_WF_InsDefRouting routing, string execComment, string allBranchRoutings)
        {
            var user = FormulaHelper.GetUserInfo();

            this.Execute(routing, execComment, allBranchRoutings, user);
        }
 protected override void OnFlowEnd(T_EXE_ChangeAudit entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing)
 {
     if (entity != null)
     {
         var products = this.BusinessEntities.Set <S_E_Product>().Where(d => d.ChangeAuditID == entity.ID).ToList();
         foreach (var product in products)
         {
             //product.Collactor = entity.Collactor;
             //product.CollactorName = entity.CollactorName;
             //product.Auditor = entity.Auditor;
             //product.AuditorName = entity.AuditorName;
             //product.Approver = entity.Approver;
             //product.ApproverName = entity.ApproverName;
             //变更完更新状态
             if (product.State == ProductState.Change.ToString())
             {
                 product.State = ProductState.Create.ToString();
             }
             product.Save();
             if (product.State == ProductState.InInvalid.ToString())
             {
                 product.State = ProductState.Invalid.ToString();
                 //删除Document
                 var document = BusinessEntities.Set <S_D_Document>().FirstOrDefault(a => a.RelateID == product.ID && a.RelateTable == "S_E_Product");
                 if (document != null && document.State != "Archive")
                 {
                     //BusinessEntities.Set<S_D_Document>().Remove(document);
                     document.State = ProductState.Invalid.ToString();
                 }
                 //BusinessEntities.Set<S_E_Product>().Remove(product);
             }
         }
         entity.Publish();
     }
     this.BusinessEntities.SaveChanges();
 }
        protected override void AfterExeTaskExec(Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing,
                                                 string nextExecUserIDs, string nextExecUserNames, string nextExecUserIDsGroup, string nextExecRoleIDs, string nextExecOrgIDs, string execComment)
        {
            var workFlowEntities = FormulaHelper.GetEntities <WorkflowEntities>();

            #region  步Activity

            var currentTask = taskExec.S_WF_InsTask;
            var flow        = taskExec.S_WF_InsFlow;
            if (flow == null)
            {
                throw new Formula.Exceptions.BusinessException("");
            }
            var currentStep = currentTask.S_WF_InsDefStep;
            var nextStep    = workFlowEntities.Set <S_WF_InsDefStep>().SingleOrDefault(c => c.ID == routing.EndID);
            var nextTask    = nextStep.S_WF_InsTask.OrderByDescending(c => c.CreateTime).FirstOrDefault(); //取最新的任务

            var entity = this.BusinessEntities.Set <T_EXE_ChangeAudit>().SingleOrDefault(c => c.ID == flow.FormInstanceID);
            if (entity != null)
            {
                var key         = currentStep.Code;
                var name        = "(" + entity.SerialNumber + ")" + currentStep.Name;
                var displayName = entity.PhaseCode + "-" + entity.MajorCode + "-" + currentStep.Name;
                var activity    = entity.CreateAcitivity(key, name, displayName);
                if (taskExec.CreateTime.HasValue)
                {
                    activity.CreateDate = taskExec.CreateTime.Value;
                }
                if (currentTask.Status == FlowTaskStatus.Complete.ToString())//解决协作完成时,只要有一个用户通过就更新成果状态的bug
                {
                    //校审环节编号为空时 默认给Flow
                    entity.SynchProductChangeAuditState(string.IsNullOrEmpty(nextStep.Code) ? "Flow" : nextStep.Code);
                    if (!string.IsNullOrEmpty(entity.WBSID))
                    {
                        var task = this.BusinessEntities.Set <S_W_TaskWork>().FirstOrDefault(a => a.WBSID == entity.WBSID);
                        if (task != null)
                        {
                            if (nextStep.Code == AuditState.Design.ToString() ||
                                nextStep.Code == AuditState.Designer.ToString())
                            {
                                task.ChangeState = TaskWorkChangeState.AuditStart.ToString();
                            }
                            else
                            {
                                task.ChangeState = TaskWorkChangeState.AuditApprove.ToString();
                            }
                        }
                    }
                }
            }
            this.BusinessEntities.SaveChanges();
            #endregion
        }