コード例 #1
0
        /// <summary>
        /// 删除一个流程模板
        /// </summary>
        /// <param name="workflowId">流程模板Id</param>
        /// <returns></returns>
        public int DeleteWorkFlow(string workflowId)
        {
            int returnInt = -1;

            if (workflowId.Trim().Length == 0 || workflowId == null)
            {
                throw new Exception("DeleteWorkFlow方法错误,workflowId 不能为空!");
            }

            try
            {
                //1、存储过程方式删除流程模板
                //returnInt = this.DBProvider.ExecuteProcedure("DeleteWorkFlow", new IDbDataParameter[] { DBProvider.MakeParameter(WorkFlowTemplateTable.FieldWorkFlowId, workflowId) });

                /*
                 *  删除的各语句
                 *  DELETE  WORKFLOW  WHERE   WORKFLOWID = @WORKFLOWID
                 *  DELETE  WORKTASK  WHERE   WORKFLOWID = @WORKFLOWID
                 *  DELETE  WORKLINK  WHERE   WORKFLOWID = @WORKFLOWID
                 *  DELETE  TASKVAR   WHERE   WORKFLOWID = @WORKFLOWID
                 *  DELETE  OPERATOR  WHERE   WORKFLOWID = @WORKFLOWID
                 *  DELETE  WORKTASKCOMMANDS  WHERE   WORKFLOWID = @WORKFLOWID
                 *  DELETE  SUBWORKFLOW  WHERE   WORKFLOWID = @WORKFLOWID
                 *  DELETE  WORKTASKCONTROLS WHERE   WORKFLOWID = @WORKFLOWID
                 *  DELETE  WORKFLOWEVENT  WHERE   WORKFLOWID = @WORKFLOWID
                 *  DELETE  WORKOUTTIME  WHERE   WORKFLOWID = @WORKFLOWID
                 */
                //2、直接语句方式删除流程模板
                //2.1、删除流程模板
                returnInt += new WorkFlowTemplateManager(DBProvider, this.UserInfo, WorkFlowTemplateTable.TableName).Delete(WorkFlowTemplateTable.FieldWorkFlowId, workflowId);
                //2.2、删除任务节点
                returnInt += new WorkTaskManager(DBProvider, this.UserInfo, WorkFlowTemplateTable.TableName).Delete(WorkTaskTable.FieldWorkFlowId, workflowId);
                //2.3、删除连线
                returnInt += new WorkLinkManager(DBProvider, this.UserInfo, WorkLinkTable.TableName).Delete(WorkLinkTable.FieldWorkFlowId, workflowId);
                //2.4、删除任务节点变量
                returnInt += new TaskVarManager(DBProvider, this.UserInfo, TaskVarTable.TableName).Delete(TaskVarTable.FieldWorkFlowId, workflowId);
                //2.5、删除操作者
                returnInt += new OperatorManager(DBProvider, this.UserInfo, OperatorTable.TableName).Delete(OperatorTable.FieldWorkFlowId, workflowId);
                //2.5、删除任务节点命令
                returnInt += new WorkTaskCommandsManager(DBProvider, this.UserInfo, WorkTaskCommandsTable.TableName).Delete(WorkTaskCommandsTable.FieldWorkFlowId, workflowId);
                //2.6、删除子流程
                returnInt += new SubWorkFlowManager(DBProvider, this.UserInfo, SubWorkFlowTable.TableName).Delete(SubWorkFlowTable.FieldWorkFlowId, workflowId);
                //2.7、删除任务节点表单
                returnInt += new WorkTaskControlsManager(DBProvider, this.UserInfo, WorkTaskControlsTable.TableName).Delete(WorkTaskControlsTable.FieldWorkflowId, workflowId);
                //2.8、删除任务节点事件通知
                returnInt += new WorkFlowEventManager(DBProvider, this.UserInfo, WorkFlowEventTable.TableName).Delete(WorkFlowEventTable.FieldWorkFlowId, workflowId);
                //2.9、删除任务节点工作任务超时设置
                returnInt += new WorkOutTimeManager(DBProvider, this.UserInfo, WorkOutTimeTable.TableName).Delete(WorkOutTimeTable.FieldWorkFlowId, workflowId);
            }
            catch (Exception ex)
            {
                throw new Exception("BizLogicError:删除流程失败,请与管理员联系!Error:" + ex.Message);
            }
            return(returnInt);
        }
コード例 #2
0
        /// <summary>
        /// 设置任务节点的控制权限
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="powerName">权限名</param>
        /// <param name="workflowid">workflowid</param>
        /// <param name="worktaskId">worktaskId</param>
        /// <returns></returns>
        public string SetWorkTaskPower(UserInfo userInfo, string powerName, string workflowid, string worktaskId)
        {
            var returnValue = string.Empty;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.WorkFlowTemplateService_SetWorkTaskPower);

            ServiceUtil.ProcessWorkFlowDbWithTransaction(userInfo, parameter, dbProvider =>
            {
                var manager = new WorkTaskManager(dbProvider, userInfo);
                returnValue = manager.SetTaskPower(powerName, workflowid, worktaskId);
            });
            return(returnValue);
        }
コード例 #3
0
        /// <summary>
        /// 删除指定任务的所有任务变量
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="worktaskId">任务模板id</param>
        /// <returns>大于0操作成功</returns>
        public int DeleteWorkTaskAllTaskVar(UserInfo userInfo, string worktaskId)
        {
            var returnValue = -1;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.WorkFlowTemplateService_DeleteWorkTaskAllTaskVar);

            ServiceUtil.ProcessWorkFlowDbWithTransaction(userInfo, parameter, dbProvider =>
            {
                var manager = new WorkTaskManager(dbProvider, userInfo);
                returnValue = manager.DeleteAllTaskVar(worktaskId);
            });
            return(returnValue);
        }
コード例 #4
0
        /// <summary>
        /// 获得任务节点绑定的表单列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="workTaskId">任务模板Id</param>
        /// <returns>表单列表</returns>
        public DataTable GetWorkTaskControls(UserInfo userInfo, string workTaskId)
        {
            var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.WorkFlowTemplateService_GetWorkTaskControls);
            var dataTable = new DataTable(WorkTaskTable.TableName);

            ServiceUtil.ProcessWorkFlowDb(userInfo, parameter, dbProvider =>
            {
                var manager = new WorkTaskManager(dbProvider, userInfo);
                dataTable   = manager.GetTaskControls(workTaskId);
            });
            return(dataTable);
        }
コード例 #5
0
        /// <summary>
        /// 修改任务节点
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="entity">任务节点实体</param>
        /// <returns>大于0修改成功</returns>
        public int UpdateWorkTask(UserInfo userInfo, WorkTaskEntity entity)
        {
            var returnValue = -1;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.WorkFlowTemplateService_UpdateWorkTask);

            ServiceUtil.ProcessWorkFlowDbWithTransaction(userInfo, parameter, dbProvider =>
            {
                var manager = new WorkTaskManager(dbProvider, userInfo);
                returnValue = manager.UpdateTask(entity);
            });
            return(returnValue);
        }
コード例 #6
0
        /// <summary>
        /// 获得任务名称
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="workTaskId">任务模板Id</param>
        /// <returns></returns>
        public string GetWorkTaskCaption(UserInfo userInfo, string workTaskId)
        {
            var returnValue = string.Empty;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.WorkFlowTemplateService_GetWorkTaskCaption);

            ServiceUtil.ProcessWorkFlowDb(userInfo, parameter, dbProvider =>
            {
                var manager = new WorkTaskManager(dbProvider, userInfo);
                returnValue = manager.GetTaskCaption(workTaskId);
            });
            return(returnValue);
        }
コード例 #7
0
        /// <summary>
        /// 判断节点是否存在
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="workTaskId">任务模板Id</param>
        /// <returns>true:存在</returns>
        public bool ExistWorkTask(UserInfo userInfo, string workTaskId)
        {
            var returnValue = false;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.WorkFlowTemplateService_ExistWorkTask);

            ServiceUtil.ProcessWorkFlowDb(userInfo, parameter, dbProvider =>
            {
                var manager = new WorkTaskManager(dbProvider, userInfo);
                returnValue = manager.ExistTask(workTaskId);
            });
            return(returnValue);
        }
コード例 #8
0
        /// <summary>
        /// 创建处理者实例
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <param name="oldWorktaskInsId"></param>
        /// <param name="oldworktaskId"></param>
        /// <param name="workFlowId"></param>
        /// <param name="workTaskId"></param>
        /// <param name="workFlowInstanceId"></param>
        /// <param name="WorkTaskInstanceId"></param>
        /// <param name="operParam"></param>
        /// <returns></returns>
        private string CreateOperInstance(string userId, string oldWorktaskInsId, string oldworktaskId, string workFlowId, string workTaskId, string workFlowInstanceId, string WorkTaskInstanceId, OperParameter operParam)
        {
            int    operType;             //处理类型
            string operContent;          //处理者id
            int    OperRelation;         //处理者关系
            var    OperContentText = ""; //处理者的名称

            //动态指定下一任务处理人
            DataTable tmpDyDt = new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).GetTaskInsNextOperTable(workFlowId, oldworktaskId, workFlowInstanceId, oldWorktaskInsId);

            foreach (DataRow dr in tmpDyDt.Rows)
            {
                operContent = dr[WorkTaskInsNextOperTable.FieldUserId].ToString();
                if (string.IsNullOrEmpty(operContent))
                {
                    continue;
                }
                var userName = new PiUserManager(DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType, SystemInfo.RDIFrameworkDbConectionString), this.UserInfo).GetEntity(operContent).RealName;
                operParam.OperContent    = operContent;
                operParam.OperContenText = userName;
                operParam.OperRelation   = 0;
                operParam.OperType       = 3;
                new InstanceTypeManager(this.DBProvider, this.UserInfo).AssignUser(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
            }

            DataTable tmpTeDt = new WorkTaskManager(this.DBProvider, this.UserInfo).GetTaskOperator(workFlowId, workTaskId);

            //如果没有处理者
            if ((tmpTeDt == null || tmpTeDt.Rows.Count <= 0) && (tmpDyDt.Rows.Count <= 0))
            {
                return(WorkFlowConst.NoFoundOperatorCode);
            }

            foreach (DataRow dr in tmpTeDt.Rows)
            {
                operType                 = System.Convert.ToInt16(dr[OperatorTable.FieldOperType].ToString());
                operContent              = dr[OperatorTable.FieldOperContent].ToString();
                OperRelation             = Convert.ToInt16(dr[OperatorTable.FieldRelation]);
                OperContentText          = dr[OperatorTable.FieldOperDisplay].ToString();
                operParam.OperType       = operType;
                operParam.OperContent    = operContent;
                operParam.OperRelation   = OperRelation;
                operParam.OperContenText = OperContentText;
                switch (operType)
                {       //在此函数中加入处理者策略
                case 1: //流程启动者
                    var startflowUser     = new InstanceTypeManager(this.DBProvider, this.UserInfo).GetStartWorkflowUser(workFlowInstanceId);
                    var startflowUserName = new PiUserManager(DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType, SystemInfo.RDIFrameworkDbConectionString), this.UserInfo).GetEntity(startflowUser).UserName;
                    operParam.OperContent    = startflowUser;
                    operParam.OperContenText = startflowUserName;
                    if (OperRelation == 0)    //无处理这关系
                    {
                        new InstanceTypeManager(this.DBProvider, this.UserInfo).AssignUser(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                    }
                    else
                    {
                        new InstanceTypeManager(this.DBProvider, this.UserInfo).UserRelation(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                    }
                    break;

                case 2:    //某一任务实际处理者
                    var dtTaskUser = new InstanceTypeManager(this.DBProvider, this.UserInfo).GetTaskInstanceUser(workFlowInstanceId, operContent);
                    foreach (DataRow drUser in dtTaskUser.Rows)
                    {
                        var rlUserId   = drUser["USERID"].ToString();
                        var rlUserName = new PiUserManager(DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType, SystemInfo.RDIFrameworkDbConectionString), this.UserInfo).GetEntity(rlUserId).RealName;
                        operParam.OperContent    = rlUserId;
                        operParam.OperContenText = rlUserName;
                        if (OperRelation == 0)    //无处理这关系
                        {
                            new InstanceTypeManager(this.DBProvider, this.UserInfo).AssignUser(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                        }
                        else
                        {
                            new InstanceTypeManager(this.DBProvider, this.UserInfo).UserRelation(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                        }
                    }
                    break;

                case 3:    //指定人员
                    if (OperRelation == 0)
                    {
                        new InstanceTypeManager(this.DBProvider, this.UserInfo).AssignUser(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                    }
                    else
                    {
                        new InstanceTypeManager(this.DBProvider, this.UserInfo).UserRelation(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                    }
                    break;

                case 4:    //部门
                    if (OperRelation == 0)
                    {
                        new InstanceTypeManager(this.DBProvider, this.UserInfo).AssignArchitecture(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                    }
                    else
                    {
                        new InstanceTypeManager(this.DBProvider, this.UserInfo).ArchRelation(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                    }
                    break;

                case 5:    //角色
                    new InstanceTypeManager(this.DBProvider, this.UserInfo).AssignGroup(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                    break;

                case 6:    //岗位
                    new InstanceTypeManager(this.DBProvider, this.UserInfo).AssignArchitecture(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                    break;

                case 7:    //从变量中获取
                    var varUser = GetWorkTaskVarValue(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, OperContentText);
                    if (varUser.Length > 2)
                    {
                        varUser = varUser.Substring(1, varUser.Length - 2);

                        var varUserName = new PiUserManager(DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType, SystemInfo.RDIFrameworkDbConectionString), this.UserInfo).GetEntity(varUser).UserName;
                        if (string.IsNullOrEmpty(varUserName) || varUserName == "'")
                        {
                            return(WorkFlowConst.IsNullUserIdCode);   //如果用户取不到就报错
                        }
                        operParam.OperContent    = varUser;
                        operParam.OperContenText = varUserName;
                    }
                    else
                    {
                        return(WorkFlowConst.IsNullUserIdCode); //如果用户取不到就报错
                    }
                    if (OperRelation == 0)                      //无处理者关系
                    {
                        new InstanceTypeManager(this.DBProvider, this.UserInfo).AssignUser(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                    }
                    else
                    {
                        new InstanceTypeManager(this.DBProvider, this.UserInfo).UserRelation(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                    }

                    break;

                case 8:    //某一任务选择的处理者
                    throw new Exception("无此类型");
                    break;

                case 9:    //所有人
                    new InstanceTypeManager(this.DBProvider, this.UserInfo).AssignAll(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                    break;

                case 10:    //指派
                    throw new Exception("无此类型");
                    break;

                case 11:    //授权
                    throw new Exception("无此类型");
                    break;

                default:
                    Console.WriteLine("Default case");
                    break;
                }
            }
            return(WorkFlowConst.SuccessCode);
        }