Beispiel #1
0
 public void Delete(S_WF_InsTask ss = null, S_WF_InsFlow sf = null, string defStepID = "", string s_WF_InsDefFlowCode = "")
 {
     //判断是否需要推送到钉钉待办
     if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["OutTxtTaskApi"]))
     {
         Thread thread = new Thread(new ParameterizedThreadStart(delegate { ToDD("Cannel", ss, sf, defStepID, s_WF_InsDefFlowCode); }));
         thread.Start();
     }
 }
Beispiel #2
0
        /// <summary>
        /// 创建流程
        /// </summary>
        /// <param name="formInstanceID"></param>
        /// <param name="userID"></param>
        /// <param name="userName"></param>
        /// <returns></returns>
        public S_WF_InsFlow CreateFlow(string formInstanceID, string userID, string userName)
        {
            try
            {
                S_WF_InsFlow insFlow = new S_WF_InsFlow();
                insFlow.S_WF_InsDefFlow = this;
                insFlow.ID             = FormulaHelper.CreateGuid();
                insFlow.CreateTime     = DateTime.Now;
                insFlow.CreateUserID   = userID;
                insFlow.CreateUserName = userName;
                insFlow.FormInstanceID = formInstanceID;
                insFlow.Status         = FlowTaskStatus.Processing.ToString();


                insFlow.FlowName        = insFlow.GetInsName(this.FlowNameTemplete);
                insFlow.FlowCategory    = insFlow.GetInsName(this.FlowCategorytemplete);
                insFlow.FlowSubCategory = insFlow.GetInsName(this.FlowSubCategoryTemplete);

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

                //初始化流程变量
                if (!string.IsNullOrEmpty(this.InitVariable))
                {
                    foreach (string str in this.InitVariable.Split(','))
                    {
                        if (string.IsNullOrWhiteSpace(str))
                        {
                            continue;
                        }

                        string strKey   = str.Split('=')[0];
                        string strValue = str.Contains('=') ? str.Split('=')[1] : "";

                        strValue = strValue.Trim('\'');

                        var variable = new S_WF_InsVariable();
                        variable.ID            = FormulaHelper.CreateGuid();
                        variable.VariableName  = strKey;
                        variable.VariableValue = strValue;
                        insFlow.S_WF_InsVariable.Add(variable);
                    }
                }
                return(insFlow);
            }
            catch (Exception ex)
            {
                throw new FlowException(ex.Message);
            }
        }
Beispiel #3
0
 public void Create(S_WF_InsTask ss, S_WF_InsFlow sf = null, string defStepID = "", string s_WF_InsDefFlowCode = "")
 {
     //TODO:先判断
     if (_created || !string.IsNullOrEmpty(ss.WaitingRoutings) || !string.IsNullOrEmpty(ss.WaitingSteps))
     {
         return;
     }
     _created = true;
     //判断是否需要推送到钉钉待办
     if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["OutTxtTaskApi"]))
     {
         Thread thread = new Thread(new ParameterizedThreadStart(delegate { ToDD("Create", ss, sf, defStepID, s_WF_InsDefFlowCode); }));
         thread.Start();
     }
 }
Beispiel #4
0
        private bool HasFormDataAuth(S_WF_InsFlow flow, string authFormData)
        {
            if (string.IsNullOrEmpty(authFormData))
            {
                return(true);
            }
            var formDic = flow.FormDic;

            var user = FormulaHelper.GetUserInfo();

            Regex reg = new Regex(@"\{[0-9a-zA-Z_\u4e00-\u9faf]*\}", RegexOptions.IgnoreCase);

            authFormData = reg.Replace(authFormData, (Match m) =>
            {
                string value = m.Value.Trim('{', '}');

                switch (value)
                {
                case "CurrentUserID":
                    return(user.UserID);

                case "CurrentUserOrgID":
                    return(user.UserOrgID);

                default:
                    if (!formDic.ContainsKey(value))
                    {
                        throw new Exception(string.Format("权限过滤出错,字段:“{0}”不存在", value));
                    }
                    return(formDic[value] == null ? "" : formDic[value].ToString());
                }
            });

            //string sql = string.Format("select count(1) where {0}", authFormData);
            //为了兼容Oracle修改
            string    sql       = string.Format("select count(1) from S_WF_DefFlow where {0}", authFormData);
            SQLHelper sqlHelper = SQLHelper.CreateSqlHelper("Workflow");
            object    obj       = sqlHelper.ExecuteScalar(sql);

            return(Convert.ToInt32(obj) > 0);
        }
Beispiel #5
0
        void ToDD(string Action, S_WF_InsTask ss = null, S_WF_InsFlow sf = null, string defStepID = "", string s_WF_InsDefFlowCode = "")
        {
            ITaskOutCenterService iotte = FormulaHelper.GetService <ITaskOutCenterService>();

            if (ss == null)
            {
                ss = this.S_WF_InsTask;
            }
            if (sf == null)
            {
                sf = this.S_WF_InsFlow;
            }
            if (string.IsNullOrEmpty(defStepID))
            {
                defStepID = ss.S_WF_InsDefStep.DefStepID;
            }
            if (string.IsNullOrEmpty(s_WF_InsDefFlowCode))
            {
                s_WF_InsDefFlowCode = this.S_WF_InsFlow.S_WF_InsDefFlow.Code;
            }
            iotte.TxtTask(this.ID, s_WF_InsDefFlowCode, sf.FlowName, ss.InsFlowID, sf.CreateTime.GetValueOrDefault(), sf.FormInstanceID, sf.Status, ss.Type, Action, defStepID, sf.CreateUserName, sf.CreateUserID, this.ExecUserID, this.ExecUserName);
            //iotte.TxtTask(this, Action, ss);
        }
Beispiel #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="variableSet"></param>
        /// <param name="nextExecUserIDs"></param>
        /// <param name="execComment"></param>
        /// <param name="proxyRoles">当前用户所代理的角色</param>
        /// <param name="reverse">是否反向操作(撤回需要反向操作</param>
        public void SetFlowVariable(S_WF_InsFlow flow)
        {
            if (string.IsNullOrEmpty(this.VariableSet))
            {
                return;
            }

            foreach (string str in this.VariableSet.Split(','))
            {
                if (string.IsNullOrWhiteSpace(str))
                {
                    continue;
                }

                string strKey   = str.Split('=')[0];
                string strValue = str.Contains('=') ? str.Split('=')[1] : "";


                strValue = strValue.Trim('\'', ' ');


                S_WF_InsVariable variable = flow.S_WF_InsVariable.Where(c => c.VariableName == strKey).SingleOrDefault();
                if (variable == null)
                {
                    variable               = new S_WF_InsVariable();
                    variable.ID            = FormulaHelper.CreateGuid();
                    variable.VariableName  = strKey;
                    variable.VariableValue = strValue;
                    flow.S_WF_InsVariable.Add(variable);
                }
                else
                {
                    variable.VariableValue = strValue;
                }
            }
        }
Beispiel #7
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);
            }
        }
Beispiel #8
0
        private List <S_WF_InsDefRouting> FilterRouting(List <S_WF_InsDefRouting> routings, S_WF_InsFlow flow)
        {
            for (int i = routings.Count - 1; i >= 0; i--)
            {
                var routing = routings[i];
                if (!string.IsNullOrEmpty(routing.AuthFormData))
                {
                    if (HasFormDataAuth(flow, routing.AuthFormData) == false)
                    {
                        routings.Remove(routing);
                        continue;
                    }
                }
                if (!string.IsNullOrEmpty(routing.AuthVariable))
                {
                    if (HasVariableAuth(flow.ID, routing.AuthVariable) == false)
                    {
                        routings.Remove(routing);
                        continue;
                    }
                }
            }

            return(routings);
        }
Beispiel #9
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));
        }
Beispiel #10
0
        /// <summary>
        /// 设置表单数据
        /// </summary>
        /// <param name="op"></param>
        /// <param name="execComment"></param>
        /// <param name="reverse"></param>
        public void SetFormPhase(S_WF_InsFlow flow, S_WF_InsDefStep nextStep, string completeStepName)
        {
            try
            {
                if (string.IsNullOrEmpty(flow.FormInstanceID))
                {
                    throw new FlowException("表单未找到。");
                }

                //string connName = GetFormConnName();
                //string tableName = GetFormTableName();
                string connName  = this.S_WF_InsDefFlow.ConnName;
                string tableName = this.S_WF_InsDefFlow.TableName;

                SQLHelper sqlHelper = SQLHelper.CreateSqlHelper(connName);

                string    sql = string.Format("select * from {0} where ID='{1}'", tableName, flow.FormInstanceID);
                DataTable dt  = sqlHelper.ExecuteDataTable(sql);

                string flowPhase = "";
                if (nextStep != null)
                {
                    flowPhase = nextStep.Phase;
                }
                else if (flow.CompleteTime != null)
                {
                    flowPhase = FlowTaskStatus.Complete.ToString();
                }

                sql = "";
                if (flowPhase != "")
                {
                    if (dt.Columns.Contains("FlowPhase") || dt.Columns.Contains("FLOWPHASE")) //FLOWPHASE为了兼容Oracle
                    {
                        var sqlUpdate = string.Format(" update {0} set FlowPhase='{1}' where ID='{2}'", tableName, flowPhase, flow.FormInstanceID);
                        sql += sqlUpdate;
                        if (Config.Constant.IsOracleDb)
                        {
                            sqlHelper.ExecuteNonQuery(sqlUpdate);
                        }
                    }
                }
                if (dt.Columns.Contains("StepName") || dt.Columns.Contains("STEPNAME"))   //STEPNAME为了兼容Oracle
                {
                    string stepName = "";
                    if (nextStep != null)
                    {
                        stepName = nextStep.Name;
                    }
                    if (dt.Rows.Count > 0)
                    {
                        stepName += "," + dt.Rows[0]["StepName"].ToString();
                    }
                    stepName = string.Join(",", stepName.Split(',').Distinct().Where(c => c != completeStepName && c != "").ToArray()).Trim(',');

                    //流程完成后环节清空
                    if (flow.CompleteTime != null)
                    {
                        stepName = "结束";
                    }
                    flow.CurrentStep = stepName;

                    var sqlUpdate = string.Format(" update {0} set StepName='{1}' where ID='{2}'", tableName, stepName, flow.FormInstanceID);
                    sql += sqlUpdate;
                    if (Config.Constant.IsOracleDb)
                    {
                        sqlHelper.ExecuteNonQuery(sqlUpdate);
                    }
                }

                if (sql != "" && !Config.Constant.IsOracleDb)
                {
                    sqlHelper.ExecuteNonQuery(sql);
                }
            }
            catch (Exception ex)
            {
                string msg = "表单表必须有字段FlowPhase!";
                throw new FlowException(msg, ex);
            }
        }
Beispiel #11
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);
            }
        }