Esempio n. 1
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);
        }
        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));
        }
Esempio n. 3
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();
 }
Esempio n. 4
0
 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();
 }
Esempio n. 5
0
        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
        }
Esempio n. 6
0
        public void Signature(S_WF_InsTaskExec taskExec, string execComment)
        {
            if (string.IsNullOrEmpty(this.SignatureField))
            {
                return;
            }

            foreach (string field in this.SignatureField.Split(','))
            {
                if (string.IsNullOrEmpty(field))
                {
                    continue;
                }
                SignatureExec(field, taskExec, execComment);
            }
        }
        /// <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);
                }
            }
        }
 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();
 }
Esempio n. 9
0
 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();
 }
Esempio n. 10
0
        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
        }
Esempio n. 11
0
        public ICollection <S_WF_InsTaskExec> CreateTaskExec()
        {
            try
            {
                var    entities  = FormulaHelper.GetEntities <WorkflowEntities>();
                string defFlowID = this.S_WF_InsDefStep.S_WF_InsDefFlow.DefFlowID;

                if (string.IsNullOrEmpty(defFlowID))
                {
                    throw new FlowException("流程不存在!");
                }

                var strTaskUserIDs   = this.TaskUserIDs.Split(',');
                var strTaskUserNames = this.TaskUserNames.Split(',');
                for (int i = 0; i < strTaskUserIDs.Length; i++)
                {
                    if (string.IsNullOrEmpty(strTaskUserIDs[i]))
                    {
                        continue;
                    }

                    if (this.S_WF_InsTaskExec.Where(c => c.TaskUserID == strTaskUserIDs[i] && c.ExecTime == null).Count() > 0)
                    {
                        continue;
                    }

                    //创建TaskExec
                    S_WF_InsTaskExec taskExec = new S_WF_InsTaskExec();
                    taskExec.ID           = FormulaHelper.CreateGuid();
                    taskExec.InsTaskID    = this.ID;
                    taskExec.CreateTime   = DateTime.Now;
                    taskExec.TaskUserID   = strTaskUserIDs[i];
                    taskExec.TaskUserName = strTaskUserNames[i];
                    //执行人
                    taskExec.ExecUserID   = taskExec.TaskUserID;
                    taskExec.ExecUserName = taskExec.TaskUserName;
                    taskExec.Type         = TaskExecType.Normal.ToString();

                    //处理事前委托
                    var flowDelegates = entities.S_WF_DefDelegate.Where(c => c.DefFlowID == defFlowID && c.DelegateUserID == taskExec.TaskUserID && DateTime.Now > c.BeginTime && DateTime.Now < c.EndTime);
                    foreach (var item in flowDelegates)
                    {
                        bool flag = false;
                        if (string.IsNullOrEmpty(item.DelegateRoleID) && string.IsNullOrEmpty(item.DelegateOrgID))
                        {
                            flag = true;
                        }
                        else if (string.IsNullOrEmpty(item.DelegateRoleID))
                        {
                            //if (FormulaHelper.InOrg(taskExec.TaskUserID, item.DelegateOrgID))
                            //    flag = true;
                            if (FormulaHelper.GetService <IUserService>().InOrg(taskExec.TaskUserID, item.DelegateOrgID))
                            {
                                flag = true;
                            }
                        }
                        else
                        {
                            //if (FormulaHelper.InRole(taskExec.TaskUserID, item.DelegateRoleID, item.DelegateOrgID))
                            //    flag = true;
                            if (FormulaHelper.GetService <IUserService>().InRole(taskExec.TaskUserID, item.DelegateRoleID, item.DelegateOrgID))
                            {
                                flag = true;
                            }
                        }
                        if (flag)
                        {
                            taskExec.ExecUserID   = item.BeDelegateUserID;
                            taskExec.ExecUserName = item.BeDelegateUserName;
                            taskExec.Type         = TaskExecType.Delegate.ToString();
                            break;
                        }
                    }

                    taskExec.InsTaskID    = this.ID;
                    taskExec.S_WF_InsFlow = this.S_WF_InsFlow;
                    taskExec.InsFlowID    = this.S_WF_InsFlow.ID;
                    this.S_WF_InsTaskExec.Add(taskExec);
                    taskExec.Create(this, this.S_WF_InsFlow, this.S_WF_InsDefStep.DefStepID, this.S_WF_InsFlow.S_WF_InsDefFlow.Code);//当作新任务,同步接口
                }

                return(this.S_WF_InsTaskExec);
            }
            catch (Exception ex)
            {
                throw new FlowException(ex.Message);
            }
        }
Esempio n. 12
0
        //签字(单个签字字段)
        private void SignatureExec(string signField, S_WF_InsTaskExec taskExec, string execComment)
        {
            if (string.IsNullOrEmpty(signField))
            {
                return;
            }

            SignatureObj signatureObj = new SignatureObj();
            UserInfo     user         = FormulaHelper.GetUserInfoByID(taskExec.ExecUserID);

            string formData       = HttpContext.Current.Request["FormData"];
            string connName       = GetFormConnName();
            string tableName      = GetFormTableName();
            string formInstanceID = taskExec.S_WF_InsTask.S_WF_InsFlow.FormInstanceID;

            //表单字典
            var formDic = S_WF_InsFlow.GetFormDic(formData, connName, tableName, formInstanceID);

            if (!formDic.ContainsKey(signField))
            {
                throw new FlowException(string.Format("签字字段不存在:{0}", signField));
            }

            if (!string.IsNullOrEmpty(this.SignatureProtectFields))
            {
                foreach (string protectField in this.SignatureProtectFields.Split(','))
                {
                    if (!formDic.ContainsKey(protectField))
                    {
                        throw new FlowException(string.Format("被保护的字段不存在:{0}", protectField));
                    }
                    signatureObj.SignatureProtectField.Add(protectField, formDic[protectField]);
                }
            }

            List <SignatureObj> list = null;
            string alreadySign       = formDic[signField].ToString();

            if (alreadySign != "" && alreadySign.StartsWith("[") == false)
            {
                throw new FlowException(string.Format("{0}字段的内容不能解析为签字格式!", signField));
            }
            if (!string.IsNullOrEmpty(alreadySign))
            {
                list = JsonHelper.ToObject <List <SignatureObj> >(alreadySign);
                //容错错误数据
                if (list == null)
                {
                    list = new List <SignatureObj>();
                }

                if (System.Configuration.ConfigurationManager.AppSettings["Flow_SignDistinct"] != "False")
                {
                    //消除重复签字
                    list = list.Where(c => c.ExecUserID != user.UserID).ToList();
                }
            }
            else
            {
                list = new List <SignatureObj>();
            }

            #region 处理用户分组

            List <Dictionary <string, string> > userList = null;
            if (!string.IsNullOrEmpty(taskExec.S_WF_InsTask.TaskUserIDsGroup))
            {
                userList = JsonHelper.ToObject <List <Dictionary <string, string> > >(taskExec.S_WF_InsTask.TaskUserIDsGroup);
                userList = userList.Where(c => c["UserID"] == taskExec.TaskUserID).ToList();
            }
            else
            {
                userList = new List <Dictionary <string, string> >();
                Dictionary <string, string> dic = new Dictionary <string, string>();
                dic.Add("UserID", taskExec.TaskUserID);
                dic.Add("UserName", taskExec.TaskUserName);
                dic.Add("GroupName", "");
                userList.Add(dic);
            }

            #endregion

            foreach (var dic in userList)
            {
                SignatureObj obj = new SignatureObj();
                obj.TaskUserGroupName     = dic["GroupName"];
                obj.TaskUserID            = dic["UserID"];
                obj.TaskUserName          = dic["UserName"];
                obj.ExecUserID            = user.UserID;
                obj.ExecUserName          = user.UserName;
                obj.RoutingCode           = this.Code;
                obj.RoutingName           = this.Name;
                obj.RoutingValue          = this.Value;
                obj.SignTime              = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                obj.SignComment           = execComment;
                obj.SignatureProtectValue = JsonHelper.ToJson(obj.SignatureProtectField).GetHashCode().ToString();
                obj.StepCode              = this.S_WF_InsDefStep.Code;
                obj.StepName              = this.S_WF_InsDefStep.Name;

                //电子签章显示位置DivID
                obj.SignatureDivID = this.SignatureDivID == null ? "" : this.SignatureDivID;
                if (obj.SignatureDivID.EndsWith("@UserID"))
                {
                    obj.SignatureDivID = obj.SignatureDivID.Replace("@UserID", user.UserID);
                }

                list.Add(obj);
            }

            string strSign = JsonHelper.ToJson <List <SignatureObj> >(list);

            SQLHelper sqlHelper = SQLHelper.CreateSqlHelper(connName);
            try
            {
                string strSql = string.Format("SELECT count(COLUMN_NAME) FROM USER_TAB_COLUMNS WHERE TABLE_NAME = upper('{0}') and COLUMN_NAME='MODIFYDATE'", tableName);
                if (Config.Constant.IsOracleDb == false)
                {
                    strSql = string.Format("select count(1) from syscolumns where id=object_id('{0}') and name='ModifyDate'", tableName);
                }

                if (sqlHelper.ExecuteScalar(strSql).ToString() != "0")
                {
                    string sql = string.Format("update {0} set {1}='{2}',ModifyDate='{4}' where ID='{3}'", tableName, signField, strSign, formInstanceID, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    sqlHelper.ExecuteNonQuery(sql);
                }
                else
                {
                    string sql = string.Format("update {0} set {1}='{2}' where ID='{3}'", tableName, signField, strSign, formInstanceID);
                    sqlHelper.ExecuteNonQuery(sql);
                }

                //金格签字保存到签字表
                if (!string.IsNullOrEmpty(HttpContext.Current.Request["signatureid"]) && !string.IsNullOrEmpty(HttpContext.Current.Request["signatureData"]))
                {
                    SQLHelper baseSqlHelper = SQLHelper.CreateSqlHelper(ConnEnum.Base);
                    strSql = "insert into S_UI_JinGeSign (ID,FormID,signatureid,signatureData,signUserId) values('{0}','{1}','{2}','{3}','{4}')";
                    strSql = string.Format(strSql, FormulaHelper.CreateGuid(), formInstanceID, HttpContext.Current.Request["signatureid"], HttpContext.Current.Request["signatureData"], taskExec.ExecUserID);
                    baseSqlHelper.ExecuteNonQuery(strSql);
                }
            }
            catch (Exception ex)
            {
                throw new FlowException("sql执行出错!", ex);
            }
        }
Esempio n. 13
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 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));
        }
Esempio n. 14
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);
        }
Esempio n. 15
0
        public void SendMsg(S_WF_InsTaskExec taskExec, string execComment, string nextUserIDs, string nextUserNames)
        {
            try
            {
                string msg = "";

                #region 生成消息
                string tmpl = this.MsgTmpl;
                Regex  reg  = new Regex("\\{[0-9a-zA-Z_\u4e00-\u9faf]*\\}");
                msg = reg.Replace(tmpl, (Match m) =>
                {
                    string value = m.Value.Trim('{', '}');

                    //先替换表单字段
                    if (taskExec.S_WF_InsFlow.FormDic.ContainsKey(value))
                    {
                        return(taskExec.S_WF_InsFlow.FormDic[value]);
                    }

                    switch (value)
                    {
                    case "TaskName":
                        return(taskExec.S_WF_InsTask.TaskName);

                    case "FlowName":
                        return(taskExec.S_WF_InsFlow.FlowName);

                    case "RoutingName":
                        return(this.Name);

                    case "TaskUserID":
                        return(taskExec.TaskUserID);

                    case "TaskUserName":
                        return(taskExec.TaskUserName);

                    case "ExecUserID":
                        return(taskExec.ExecUserID);

                    case "ExecUserName":
                        return(taskExec.ExecUserName);

                    case "ExecTime":
                        return(DateTime.Now.ToString());

                    case "ExecComment":
                        return(execComment);

                    case "NextUserIDs":
                        return(nextUserIDs);

                    case "NextUserNames":
                        return(nextUserNames);

                    case "NextStepCode":
                        return(this.S_WF_InsDefFlow.S_WF_InsDefStep.SingleOrDefault(c => c.ID == this.EndID).Code);

                    case "NextStepName":
                        return(this.S_WF_InsDefFlow.S_WF_InsDefStep.SingleOrDefault(c => c.ID == this.EndID).Name);

                    case "StepCode":
                        return(this.S_WF_InsDefStep.Code);

                    case "StepName":
                        return(this.S_WF_InsDefStep.Name);

                    default:
                        return(m.Value);
                    }
                });

                #endregion

                if (msg == "")
                {
                    return;
                }

                List <string> userIdList = new List <string>();

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

                //给指定人发消息
                if (!string.IsNullOrEmpty(this.MsgUserIDs))
                {
                    userIdList.AddRange(this.MsgUserIDs.Split(','));
                }


                //环节任务执行人
                if (!string.IsNullOrEmpty(this.MsgUserIDsFromStepExec))
                {
                    foreach (string stepId in this.MsgUserIDsFromStepExec.Split(','))
                    {
                        var task = flow.S_WF_InsTask.LastOrDefault(c => c.InsDefStepID == stepId);
                        if (task == null)
                        {
                            throw new Exception("发送消息配置错误");
                        }
                        foreach (var item in task.S_WF_InsTaskExec)
                        {
                            userIdList.Add(item.ExecUserID);
                        }
                    }
                }
                //环节任务接收人
                if (!string.IsNullOrEmpty(this.MsgUserIDsFromStep))
                {
                    foreach (string stepId in this.MsgUserIDsFromStep.Split(','))
                    {
                        var task = flow.S_WF_InsTask.LastOrDefault(c => c.InsDefStepID == this.MsgUserIDsFromStep);
                        if (task == null)
                        {
                            throw new Exception("发送消息配置错误");
                        }
                        userIdList.AddRange(task.TaskUserIDs.Split(','));
                    }
                }
                //环节任务发送人
                if (!string.IsNullOrEmpty(this.MsgUserIDsFromStepSender))
                {
                    foreach (string stepId in this.MsgUserIDsFromStepSender.Split(','))
                    {
                        var task = flow.S_WF_InsTask.LastOrDefault(c => c.InsDefStepID == this.MsgUserIDsFromStepSender);
                        if (task == null)
                        {
                            throw new Exception("发送消息配置错误");
                        }
                        userIdList.AddRange(task.SendTaskUserIDs.Split(','));
                    }
                }
                //取自字段
                if (!string.IsNullOrEmpty(this.MsgUserIDsFromField))
                {
                    userIdList.AddRange(flow.FormDic[this.MsgUserIDsFromField].Split(','));
                }

                #region 指定组织、角色

                string orgIDs  = this.MsgOrgIDs;
                string roleIDs = this.MsgRoleIDs;

                if (string.IsNullOrEmpty(orgIDs) && !string.IsNullOrEmpty(this.MsgOrgIDsFromField))
                {
                    orgIDs = flow.FormDic[this.MsgOrgIDsFromField];
                }
                if (string.IsNullOrEmpty(roleIDs) && !string.IsNullOrEmpty(this.MsgRoleIDsFromField))
                {
                    roleIDs = flow.FormDic[this.MsgRoleIDsFromField];
                }

                if (!string.IsNullOrEmpty(this.MsgOrgIDFromUser) && string.IsNullOrEmpty(orgIDs))
                {
                    var user = FormulaHelper.GetUserInfo();
                    orgIDs = user.UserOrgID;
                }


                if (!string.IsNullOrEmpty(roleIDs))
                {
                    IRoleService roleService = FormulaHelper.GetService <IRoleService>();
                    string       userIDs     = roleService.GetUserIDsInRoles(roleIDs, orgIDs);

                    //2018-1-30 剥离项目角色选人功能
                    var prjRoleUser = PrjRoleExt.GetRoleUserIDs(roleIDs, orgIDs);
                    if (!string.IsNullOrEmpty(prjRoleUser))
                    {
                        userIDs = (prjRoleUser + "," + userIDs).Trim(',');
                    }

                    userIdList.AddRange(userIDs.Split(','));
                }
                else if (!string.IsNullOrEmpty(orgIDs))
                {
                    IOrgService orgService = FormulaHelper.GetService <IOrgService>();
                    string      userIDs    = orgService.GetUserIDsInOrgs(orgIDs);
                    userIdList.AddRange(userIDs.Split(','));
                }

                #endregion

                if (this.MsgSendToTaskUser == "1")
                {
                    userIdList.AddRange(nextUserIDs.Split(','));
                }


                IUserService    userService  = FormulaHelper.GetService <IUserService>();
                IMessageService msgService   = FormulaHelper.GetService <IMessageService>();
                string          resutUserIDs = string.Join(",", userIdList.Distinct());
                resutUserIDs = resutUserIDs.Trim(' ', ',');
                string resultUserNames = userService.GetUserNames(resutUserIDs);

                var msgType = Config.MsgType.Normal;
                if (!string.IsNullOrEmpty(this.MsgType))
                {
                    msgType = (MsgType)Enum.Parse(typeof(Config.MsgType), this.MsgType);
                }

                string url = this.S_WF_InsDefFlow.FormUrl;
                if (url.Contains("?"))
                {
                    url += "&";
                }
                else
                {
                    url += "?";
                }
                url += "FuncType=View&ID=" + taskExec.S_WF_InsFlow.FormInstanceID;

                msgService.SendMsg(msg, msg, url, "", resutUserIDs, resultUserNames, null, MsgReceiverType.UserType, msgType);
            }
            catch (Exception ex)
            {
                throw new FlowException(ex.Message);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// 设置表单数据
        /// </summary>
        /// <param name="op"></param>
        /// <param name="execComment"></param>
        /// <param name="reverse"></param>
        public void SetFormData(string formInstanceID, S_WF_InsTaskExec taskExec, string execComment, string nextUserIDs, string nextUserNames)
        {
            if (string.IsNullOrEmpty(this.FormDataSet))
            {
                return;
            }

            string formDataSet = this.FormDataSet;

            //意见为空则不设置意见
            if (this.FormDataSet.Contains("{ExecComment}") && string.IsNullOrEmpty(execComment))
            {
                return;
            }

            if (Config.Constant.IsOracleDb)
            {
                string oracleDate = string.Format("to_date('{0}','yyyy-MM-dd HH24:mi:ss')", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                formDataSet = formDataSet.Replace("'{ExecTime}'", oracleDate);
            }


            Regex  reg            = new Regex("\\{[0-9a-zA-Z_\u4e00-\u9faf]*\\}");
            string strFormDataSet = reg.Replace(formDataSet, (Match m) =>
            {
                string value = m.Value.Trim('{', '}');

                switch (value)
                {
                case "TaskUserID":
                    return(taskExec.TaskUserID);

                case "TaskUserName":
                    return(taskExec.TaskUserName);

                case "ExecUserID":
                    return(taskExec.ExecUserID);

                case "ExecUserName":
                    return(taskExec.ExecUserName);

                case "ExecTime":
                    return(DateTime.Now.ToString());

                case "ExecComment":
                    return(execComment);

                case "NextUserIDs":
                    return(nextUserIDs);

                case "NextUserNames":
                    return(nextUserNames);

                case "NextStepCode":
                    return(this.S_WF_InsDefFlow.S_WF_InsDefStep.SingleOrDefault(c => c.ID == this.EndID).Code);

                case "NextStepName":
                    return(this.S_WF_InsDefFlow.S_WF_InsDefStep.SingleOrDefault(c => c.ID == this.EndID).Name);

                case "StepCode":
                    return(this.S_WF_InsDefStep.Code);

                case "StepName":
                    return(this.S_WF_InsDefStep.Name);

                default:
                    return(m.Value);
                }
            });

            string connName  = GetFormConnName();
            string tableName = GetFormTableName();

            try
            {
                if (Config.Constant.IsOracleDb)
                {
                    //SELECT COUNT(1) into flagExist FROM USER_TAB_COLUMNS WHERE TABLE_NAME = upper('{0}') and column_name = upper('{1}')
                    SQLHelper sqlHelper = SQLHelper.CreateSqlHelper(connName);
                    if (sqlHelper.ExecuteScalar(string.Format("SELECT COUNT(1) FROM USER_TAB_COLUMNS WHERE TABLE_NAME = upper('{0}') and column_name = upper('ModifyDate')", tableName)).ToString() != "0")
                    {
                        string sql = string.Format("update {0} set {1},ModifyDate=to_date('{3}','yyyy-MM-dd HH24:mi:ss') where ID='{2}'", tableName, strFormDataSet, formInstanceID, DateTime.Now);
                        sqlHelper.ExecuteNonQuery(sql);
                    }
                    else
                    {
                        string sql = string.Format("update {0} set {1} where ID='{2}'", tableName, strFormDataSet, formInstanceID);
                        sqlHelper.ExecuteNonQuery(sql);
                    }
                }
                else
                {
                    SQLHelper sqlHelper = SQLHelper.CreateSqlHelper(connName);
                    if (sqlHelper.ExecuteScalar(string.Format("select count(1) from syscolumns where id=object_id('{0}') and name='ModifyDate'", tableName)).ToString() != "0")
                    {
                        string sql = string.Format("update {0} set {1},ModifyDate='{3}' where ID='{2}'", tableName, strFormDataSet, formInstanceID, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        sqlHelper.ExecuteNonQuery(sql);
                    }
                    else
                    {
                        string sql = string.Format("update {0} set {1} where ID='{2}'", tableName, strFormDataSet, formInstanceID);
                        sqlHelper.ExecuteNonQuery(sql);
                    }
                }
            }
            catch
            {
                string msg = string.Format("流程路由配置错误,FormDataSet:{0}", this.FormDataSet);
                throw new FlowException(msg);
            }
        }
Esempio n. 17
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);
            }
        }