Beispiel #1
0
 /// <summary>
 /// 新增流程
 /// </summary>
 /// <param name="flow"></param>
 /// <returns></returns>
 public bool AddFlowDefine(V_FLOWDEFINITION flow)
 {
     try
     {
         return dal.AddFlowDefine(flow);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message, ex);
     }
 }
Beispiel #2
0
 /// <summary>
 /// 新增流程
 /// </summary>
 /// <param name="flow"></param>
 /// <returns></returns>
 public string AddFlowDefine(V_FLOWDEFINITION flow)
 {
     try
     {
         if(flowBLL.AddFlowDefine(flow))
         {
             return "1";
         }
         return "新建流程失败!";
     }
     catch (Exception ex)
     {
         Tracer.Debug("新建流程出错:" + ex.Message + "   公司ID:" + flow.ModelRelation.COMPANYID);
         return ex.Message;
     }
 }
Beispiel #3
0
        /// <summary>
        /// 新增流程
        /// </summary>
        /// <param name="flow">视图</param>    
        /// <returns>bool</returns>
        public bool AddFlowDefine(V_FLOWDEFINITION flow)
        {
            //OracleConnection conn = MicrosoftOracle.CreateOracleConnection(ConnectionString);
            //OracleCommand command = conn.CreateCommand();
            //OracleTransaction transaction;
            //transaction = conn.BeginTransaction(System.Data.IsolationLevel.ReadCommitted);
            dao.BeginTransaction();
            try
            {
                AdddFlowDefine(flow);
                dao.Commit();

                return true;
            }
            catch (Exception ex)
            {
               dao.Rollback();

                throw new Exception(ex.Message, ex);
            }
        }
Beispiel #4
0
 /// <summary>
 /// 插入历史数据,然后删除
 /// </summary>
 /// <param name="conn">数据库链接</param>
 /// <param name="command">数据库命令</param>
 /// <param name="companyID">公司ID</param>
 /// <param name="modelCode">模块</param>
 /// <param name="departmentID">部门</param>
 /// <param name="flow">视图</param>
 /// <returns>string</returns>
 private string InsertHistory(string companyID, string modelCode, string departmentID, V_FLOWDEFINITION flow)
 {
     try
     {
         StringBuilder sb = new StringBuilder();
         string flowCode = string.Empty;
         sb.AppendLine("select  flowcode from FLOW_MODELFLOWRELATION_T t");
         sb.AppendLine(" where t.COMPANYID='" + companyID + "'  and t.MODELCODE='" + modelCode + "'");
         if (!string.IsNullOrWhiteSpace(departmentID))
         {
             sb.AppendLine(" AND DEPARTMENTID ='" + departmentID + "'");
         }
         else
         {
             sb.AppendLine(" AND t.departmentid is null");
         }
         DataTable dt = dao.GetDataTable(sb.ToString());
         if (dt.Rows.Count > 0)
         {
             sb.Clear();
             flowCode = dt.Rows[0]["FLOWCODE"].ToString();
             sb.AppendLine("insert into flow_flowdefine_t_history ");
             sb.AppendLine("SELECT sys_guid(),FLOWCODE,DESCRIPTION,XOML,RULES,LAYOUT,FLOWTYPE,CREATEUSERID,CREATEUSERNAME,CREATECOMPANYID,CREATEDEPARTMENTID,");
             sb.AppendLine("CREATEPOSTID,CREATEDATE,'" + flow.FlowDefinition.EDITUSERID + "' as EDITUSERID,'" + flow.FlowDefinition.EDITUSERNAME + "' as EDITUSERNAME,EDITDATE,");
             sb.AppendLine("SYSTEMCODE,BUSINESSOBJECT,WFLAYOUT,FLOWCODE1 FROM FLOW_FLOWDEFINE_T  t");
             sb.AppendLine("where t.FLOWCODE='" + flowCode + "'");
             int n = dao.ExecuteNonQuery(sb.ToString());
             if (n > 0)
             {
                 sb.Clear();
                 sb.AppendLine("delete FLOW_MODELFLOWRELATION_T t where FLOWCODE='" + flowCode + "'");
                 dao.ExecuteNonQuery(sb.ToString());
                 sb.Clear();
                 sb.AppendLine("delete FLOW_FLOWDEFINE_T t where FLOWCODE='" + flowCode + "'");
                 dao.ExecuteNonQuery(sb.ToString());
             }
         }
         return flowCode;
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message, ex);
     }
 }
Beispiel #5
0
 /// <summary>
 /// 新增流程
 /// </summary>
 /// <param name="conn"></param>
 /// <param name="command"></param>
 /// <param name="flow"></param>
 private void AdddFlowDefine(V_FLOWDEFINITION flow)
 {
     try
     {
         FLOW_MODELFLOWRELATION_T relation = flow.ModelRelation;
         FLOW_FLOWDEFINE_T define = flow.FlowDefinition;
         string[] companyids = relation.COMPANYID.TrimEnd('|').Split('|');//所有关联公司的ID
         string[] companynames = relation.COMPANYNAME.TrimEnd('|').Split('|');//所有关联公司的名称
         for (int i = 0; i < companyids.Length; i++)//循环公司新增
         {
             if (!string.IsNullOrEmpty(relation.DEPARTMENTID))//如果存在部门
             {
                 string[] departmentids = relation.DEPARTMENTID.TrimEnd('|').Split('|');//所有关联部门的ID
                 string[] departmentnames = relation.DEPARTMENTNAME.TrimEnd('|').Split('|');//所有关联部门名称
                 for (int j = 0; j < departmentids.Length; j++)//循环部门新增
                 {
                     string flowCode = InsertHistory(companyids[i], relation.MODELCODE, departmentids[j], flow);
                     if (string.IsNullOrWhiteSpace(flowCode))
                     {
                         flowCode = Guid.NewGuid().ToString().Replace("-", string.Empty);
                     }
                     relation.COMPANYID = companyids[i];
                     relation.COMPANYNAME = companynames[i];
                     relation.DEPARTMENTID = departmentids[j];
                     relation.DEPARTMENTNAME = departmentnames[j];
                     relation.FLOWCODE = flowCode;
                     define.FLOWCODE = flowCode;
                     AddFlow(define);
                     AddRelation(relation);
                 }
             }
             else
             {
                 string flowCode = InsertHistory(companyids[i], relation.MODELCODE, string.Empty, flow);
                 if (string.IsNullOrWhiteSpace(flowCode))
                 {
                     flowCode = Guid.NewGuid().ToString().Replace("-", string.Empty);
                 }
                 relation.COMPANYID = companyids[i];
                 relation.COMPANYNAME = companynames[i];
                 relation.FLOWCODE = flowCode;
                 define.FLOWCODE = flowCode;
                 AddFlow(define);
                 AddRelation(relation);
             }
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message, ex);
     }
 }
Beispiel #6
0
        /// <summary>
        /// 根据FlowCode取流程
        /// </summary>
        /// <param name="flowCode">FlowCode</param>
        /// <returns>V_FLOWDEFINITION</returns>
        public V_FLOWDEFINITION GetFlowEntity(string flowCode)
        {
            string sql = "SELECT  a.FlowDefineID, a.FlowCode, a.Description, a.XOML, a.Rules, a.WFLayout, a.Layout, a.FlowType, a.CreateUserId, " +
                         "        a.CreateUserName, a.CreateCompanyId, a.CreateDepartmentID, a.CreatePostId, " +
                         "        a.CreateDate, a.EditUserId, a.EditUserName, a.EditDate,a.SYSTEMCODE,a.BUSINESSOBJECT, " +
                         "        b.MODELFLOWRELATIONID, b.COMPANYID, b.DEPARTMENTID, b.MODELCODE, " +
                          "        b.COMPANYNAME, b.DEPARTMENTNAME, b.SYSTEMCODE as SYSTEMCODE2, " +
                         "        b.FLAG, b.CREATEUSERID M_CreateUserId, b.CREATEUSERNAME M_CreateuserName, b.CREATECOMPANYID M_CreateCompanyId, " +
                         "        b.CREATEDEPARTMENTID M_CreateDepartmentId, b.CREATEPOSTID M_CreatePostId, b.CREATEDATE M_CreateDate, " +
                         "        b.EDITUSERID M_EditUserId, b.EDITUSERNAME M_EditUserName, b.EDITDATE M_EditDate " +
                         " FROM    Flow_FlowDefine_t a left join Flow_Modelflowrelation_t b on a.Flowcode = b.FlowCode " +
                         "WHERE   a.FlowCode = '" + flowCode + "' ";
            V_FLOWDEFINITION flowDefinition = new V_FLOWDEFINITION();
            try
            {

                DataTable dtFlow = dao.GetDataTable(sql);

                if (dtFlow.Rows.Count > 0)
                {
                    DataRow drFlow = dtFlow.Rows[0];
                    #region 流程定义表
                    flowDefinition.FlowDefinition = new FLOW_FLOWDEFINE_T()
                    {
                        FLOWDEFINEID = drFlow["FlowDefineID"].ToString(),
                        FLOWCODE = drFlow["FlowCode"].ToString(),
                        DESCRIPTION = drFlow["Description"].ToString(),
                        XOML = drFlow["XOML"].ToString(),
                        RULES = drFlow["Rules"].ToString(),
                        LAYOUT = drFlow["Layout"].ToString(),
                        WFLAYOUT = drFlow["WFLayout"].ToString(),
                        FLOWTYPE = drFlow["FlowType"].ToString(),
                        CREATEUSERID = drFlow["CreateUserId"].ToString(),
                        CREATEUSERNAME = drFlow["CreateUserName"].ToString(),
                        CREATECOMPANYID = drFlow["CreateCompanyId"].ToString(),
                        CREATEDEPARTMENTID = drFlow["CreateDepartmentID"].ToString(),
                        CREATEPOSTID = drFlow["CreatePostId"].ToString(),
                        CREATEDATE = DateTime.Parse(drFlow["CreateDate"].ToString()),
                        EDITUSERID = DBNull.Value.Equals(drFlow["EditUserId"]) ? string.Empty : drFlow["EditUserId"].ToString(),
                        EDITUSERNAME = DBNull.Value.Equals(drFlow["EditUserName"]) ? string.Empty : drFlow["EditUserName"].ToString(),
                        EDITDATE = DBNull.Value.Equals(drFlow["EditDate"]) ? DateTime.Now : DateTime.Parse(drFlow["EditDate"].ToString()),
                        SYSTEMCODE = drFlow["SYSTEMCODE"].ToString(),
                        BUSINESSOBJECT = drFlow["BUSINESSOBJECT"].ToString()
                    };
                    #endregion
                    #region 模块与流程定义关联表
                    if (!DBNull.Value.Equals(drFlow["MODELCODE"]))
                    {
                        flowDefinition.ModelRelation = new FLOW_MODELFLOWRELATION_T()
                        {
                            MODELFLOWRELATIONID = drFlow["MODELFLOWRELATIONID"].ToString(),
                            COMPANYID = drFlow["COMPANYID"].ToString(),
                            DEPARTMENTID = drFlow["DEPARTMENTID"].ToString(),

                            COMPANYNAME = drFlow["COMPANYNAME"].ToString(),//公司名称
                            DEPARTMENTNAME = drFlow["DEPARTMENTNAME"].ToString(),//部门名称
                            SYSTEMCODE = drFlow["SYSTEMCODE2"].ToString(),//系统代码

                            MODELCODE = drFlow["MODELCODE"].ToString(),
                            FLOWCODE = drFlow["FLOWCODE"].ToString(),
                            FLAG = drFlow["FLAG"].ToString(),
                            FLOWTYPE = drFlow["FLOWTYPE"].ToString(),
                            CREATEUSERID = drFlow["M_CREATEUSERID"].ToString(),
                            CREATEUSERNAME = drFlow["M_CREATEUSERNAME"].ToString(),
                            CREATECOMPANYID = drFlow["M_CREATECOMPANYID"].ToString(),
                            CREATEDEPARTMENTID = drFlow["M_CREATEDEPARTMENTID"].ToString(),
                            CREATEPOSTID = drFlow["M_CREATEPOSTID"].ToString(),
                            CREATEDATE = DateTime.Parse(drFlow["M_CREATEDATE"].ToString()),
                            EDITUSERID = DBNull.Value.Equals(drFlow["M_EDITUSERID"]) ? string.Empty : drFlow["M_EDITUSERID"].ToString(),
                            EDITUSERNAME = DBNull.Value.Equals(drFlow["M_EDITUSERNAME"]) ? string.Empty : drFlow["M_EDITUSERNAME"].ToString(),
                            EDITDATE = DBNull.Value.Equals(drFlow["M_EditDate"]) ? DateTime.Now : DateTime.Parse(drFlow["M_EDITDATE"].ToString()),
                        };
                    }
                    #endregion
                    return flowDefinition;//返回
                }
                else
                {
                    return null;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }