/// <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);
        }
        /// <summary>
        /// 获得流程变量列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="workflowId">流程模版Id</param>
        /// <returns>流程变量列表</returns>
        public DataTable GetWorkFlowVar(UserInfo userInfo, string workflowId)
        {
            var parameter = ParameterUtil.CreateWithOutMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName);
            var dataTable = new DataTable(TaskVarTable.TableName);

            ServiceUtil.ProcessWorkFlowDb(userInfo, parameter, dbProvider =>
            {
                var manager = new TaskVarManager(dbProvider, userInfo);
                dataTable   = manager.GetWorkflowVar(workflowId);
            });
            return(dataTable);
        }
        /// <summary>
        /// 删除任务变量
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="taskVarId">任务变量主键</param>
        /// <returns>大于0成功</returns>
        public int DeleteTaskVar(UserInfo userInfo, string taskVarId)
        {
            var returnValue = -1;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.WorkFlowUserControlService_DeleteTaskVar);

            ServiceUtil.ProcessWorkFlowDbWithTransaction(userInfo, parameter, dbProvider =>
            {
                var manager = new TaskVarManager(dbProvider, userInfo);
                returnValue = manager.DeleteTaskVar(taskVarId);
            });
            return(returnValue);
        }
        /// <summary>
        /// 判断任务变量是否存在
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="taskVarId">任务变量Id</param>
        /// <returns>true存在</returns>
        public bool ExistsTaskVar(UserInfo userInfo, string taskVarId)
        {
            var returnValue = false;
            var parameter   = ParameterUtil.CreateWithOutMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName);

            ServiceUtil.ProcessWorkFlowDbWithTransaction(userInfo, parameter, dbProvider =>
            {
                var manager = new TaskVarManager(dbProvider, userInfo);
                returnValue = manager.Exists(taskVarId);
            });
            return(returnValue);
        }
        /// <summary>
        /// 增加任务变量
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="entity">任务变量实体</param>
        /// <returns>增加成功返回实体主键</returns>
        public string InsertTaskVar(UserInfo userInfo, TaskVarEntity entity)
        {
            var returnValue = string.Empty;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.WorkFlowUserControlService_InsertTaskVar);

            ServiceUtil.ProcessWorkFlowDbWithTransaction(userInfo, parameter, dbProvider =>
            {
                var manager = new TaskVarManager(dbProvider, userInfo);
                returnValue = manager.InsertTaskVar(entity);
            });
            return(returnValue);
        }
        /// <summary>
        /// 取流程变量或者任务变量值,两者的变量名不能重复
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <param name="workFlowId">流程模版Id</param>
        /// <param name="workTaskId">任务模版Id</param>
        /// <param name="workFlowInstanceId">流程实例Id</param>
        /// <param name="WorkTaskInstanceId">任务实例Id</param>
        /// <param name="varName">变量名称</param>
        /// <returns></returns>
        private string GetWorkTaskVarValue(string userId, string workFlowId, string workTaskId, string workFlowInstanceId, string WorkTaskInstanceId, string varName)
        {
            var varDataBase   = "";
            var varTableName  = "";
            var varFieldName  = "";
            var varInitValue  = "";
            var varAccessType = "";//变量类型
            var varType       = "";
            var varSql        = "";
            var resultValue   = "";
            var tmpVarName    = "";
            var paixu         = "";                                //排序

            tmpVarName = varName.Substring(2, varName.Length - 4); //去掉两头的<%%>
            var dt = new TaskVarManager(this.DBProvider, this.UserInfo).GetTaskVarByName(workFlowId, tmpVarName);

            if (dt != null && dt.Rows.Count > 0)
            {
                varDataBase   = dt.Rows[0][TaskVarTable.FieldDataBaseName].ToString();
                varTableName  = dt.Rows[0][TaskVarTable.FieldTableName].ToString();
                varFieldName  = dt.Rows[0][TaskVarTable.FieldTableField].ToString();
                varInitValue  = dt.Rows[0][TaskVarTable.FieldInitValue].ToString();
                varAccessType = dt.Rows[0][TaskVarTable.FieldAccessType].ToString();
                varType       = dt.Rows[0][TaskVarTable.FieldVarType].ToString();
                paixu         = dt.Rows[0][TaskVarTable.FieldSortField].ToString();
            }
            switch (varAccessType)
            {
            case WorkFlowConst.Access_WorkFlow:
                varSql = string.Format("SELECT " + varFieldName + " FROM " + varTableName + " WHERE WORKFLOWID={0} AND WORKFLOWINSID={1}",
                                       DBProvider.GetParameter("workflowId"),
                                       DBProvider.GetParameter("workFlowInstanceId"));
                if (paixu != "" && paixu != "请选择...")
                {
                    varSql = varSql + " ORDER BY " + paixu + " DESC";
                }

                resultValue = BusinessLogic.ConvertToString(
                    this.DBProvider.ExecuteScalar(varSql, new IDbDataParameter[] {
                    DBProvider.MakeParameter("workflowId", workFlowId),
                    DBProvider.MakeParameter("workFlowInstanceId", workFlowInstanceId)
                }));

                if (varType == "string")
                {
                    resultValue = "'" + resultValue + "'";
                }
                break;

            case WorkFlowConst.Access_WorkTask:
                varSql = string.Format("SELECT " + varFieldName + " FROM " + varTableName + " WHERE WORKFLOWID={0} AND WORKFLOWINSID={1} " +
                                       " AND WORKTASKINSID={2} ",
                                       DBProvider.GetParameter("workflowId"),
                                       DBProvider.GetParameter("workFlowInstanceId"),
                                       DBProvider.GetParameter("WorkTaskInsId"));
                if (paixu != "" && paixu != "请选择...")
                {
                    varSql = varSql + " ORDER BY " + paixu + " DESC";
                }
                resultValue = BusinessLogic.ConvertToString(
                    this.DBProvider.ExecuteScalar(varSql, new IDbDataParameter[] {
                    DBProvider.MakeParameter("workflowId", workFlowId),
                    DBProvider.MakeParameter("workFlowInstanceId", workFlowInstanceId),
                    DBProvider.MakeParameter("WorkTaskInsId", WorkTaskInstanceId)
                }));
                if (varType == "string")
                {
                    resultValue = "'" + resultValue + "'";
                }
                break;
            }

            if (string.IsNullOrEmpty(resultValue))
            {
                resultValue = varInitValue;
            }
            //if (varType == WorkFlowConst.SYSVarType_string) resultValue = "'" + resultValue + "'";//字符型要加单引号
            //if (string.IsNullOrEmpty(resultValue)) resultValue = "'" + resultValue + "'";//默认返回带引号的空字符串
            return(resultValue);
        }