/// <summary>
 /// 新增未提交的代办
 /// </summary>
 /// <param name="dask"></param>
 /// <returns></returns>
 public string AddTask(T_WF_DOTASK dask)
 {
     try
     {
         Tracer.Debug("AddTask()开始调用");
         EngineServicesBLL bll = new EngineServicesBLL();
         bll.AddTask(dask);
         return "1";
     }
     catch (Exception ex)
     {
         Tracer.Debug("AddTask()" + ex.Message);
         return ex.Message;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 新增待办
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="dr1"></param>
        /// <param name="SourceValueDT"></param>
        /// <param name="strAPPFIELDVALUE"></param>
        public void AddDoTask(T_WF_DOTASK entity, DataRow dr1, DataTable SourceValueDT, string strAPPFIELDVALUE)
        {
            ClosedDoTaskStatus(entity.SYSTEMCODE, entity.ORDERID, null);
            try
            {
                string[] strListUser;
                if (entity.RECEIVEUSERID.IndexOf('|') != -1)
                {
                    strListUser = entity.RECEIVEUSERID.ToString().Split('|');
                }
                else
                {
                    strListUser = new string[1];
                    strListUser[0] = entity.RECEIVEUSERID.ToString();
                }
                //dao.Open();
                foreach (string User in strListUser)
                {
                    string insSql = @"INSERT INTO T_WF_DOTASK (DOTASKID,COMPANYID,ORDERID,ORDERUSERID,ORDERUSERNAME,ORDERSTATUS,MESSAGEBODY,
                                     APPLICATIONURL,RECEIVEUSERID,BEFOREPROCESSDATE,DOTASKTYPE,DOTASKSTATUS,MAILSTATUS,
                                     RTXSTATUS,APPFIELDVALUE,FLOWXML,APPXML,SYSTEMCODE,MODELCODE,MODELNAME)
                                     VALUES (:DOTASKID,:COMPANYID,:ORDERID,:ORDERUSERID,:ORDERUSERNAME,:ORDERSTATUS,:MESSAGEBODY,:APPLICATIONURL,
                                    :RECEIVEUSERID,:BEFOREPROCESSDATE,:DOTASKTYPE,:DOTASKSTATUS,:MAILSTATUS,:RTXSTATUS,
                                    :APPFIELDVALUE,:FLOWXML,:APPXML,:SYSTEMCODE,:MODELCODE,:MODELNAME)";
                    OracleParameter[] pageparm =
                        {               
                            new OracleParameter(":DOTASKID",OracleType.NVarChar,100), 
                            new OracleParameter(":COMPANYID",OracleType.NVarChar,100), 
                            new OracleParameter(":ORDERID",OracleType.NVarChar,100), 
                            new OracleParameter(":ORDERUSERID",OracleType.NVarChar,100), 
                            new OracleParameter(":ORDERUSERNAME",OracleType.NVarChar,100), 
                            new OracleParameter(":ORDERSTATUS",OracleType.Number,22), 
                            new OracleParameter(":MESSAGEBODY",OracleType.NVarChar,4000), 
                            new OracleParameter(":APPLICATIONURL",OracleType.NVarChar,2000), 
                            new OracleParameter(":RECEIVEUSERID",OracleType.NVarChar,100), 
                            new OracleParameter(":BEFOREPROCESSDATE",OracleType.DateTime), 
                            new OracleParameter(":DOTASKTYPE",OracleType.Number,22),
                            new OracleParameter(":DOTASKSTATUS",OracleType.Number,22), 
                            new OracleParameter(":MAILSTATUS",OracleType.Number,22), 
                            new OracleParameter(":RTXSTATUS",OracleType.Number,22),                  
                            new OracleParameter(":APPFIELDVALUE",OracleType.Clob), 
                            new OracleParameter(":FLOWXML",OracleType.Clob), 
                            new OracleParameter(":APPXML",OracleType.Clob), 
                            new OracleParameter(":SYSTEMCODE",OracleType.NVarChar,100), 
                            new OracleParameter(":MODELCODE",OracleType.NVarChar,100), 
                            new OracleParameter(":MODELNAME",OracleType.NVarChar,200),                  

                        };
                    pageparm[0].Value = MsOracle.GetValue(Guid.NewGuid().ToString());//待办任务ID
                    pageparm[1].Value = MsOracle.GetValue(entity.COMPANYID);//公司ID
                    pageparm[2].Value = MsOracle.GetValue(entity.ORDERID);//单据ID
                    pageparm[3].Value = MsOracle.GetValue(entity.ORDERUSERID);//单据所属人ID
                    pageparm[4].Value = MsOracle.GetValue(entity.ORDERUSERNAME);//单据所属人名称
                    pageparm[5].Value = MsOracle.GetValue(entity.ORDERSTATUS);//单据状态
                    #region 消息体
                    string XmlTemplete = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "\r\n" +
                                  "<System>" + "\r\n" +
                                  "{0}" +
                                  "</System>";
                    if (dr1["MESSAGEBODY"].ToString() == "")//默认消息为空
                    {
                        string strMsgBody = string.Empty;
                        string strMsgUrl = string.Empty;
                        ModelMsgDefine(dr1["SYSTEMCODE"].ToString(), dr1["MODELCODE"].ToString(), entity.COMPANYID, ref strMsgBody, ref strMsgUrl);
                        if (string.IsNullOrEmpty(strMsgBody))
                        {
                            try
                            {
                                DataRow[] drvList = SourceValueDT.Select("ColumnName='ModelName'");
                                if (drvList.Count() == 1)
                                {
                                    pageparm[6].Value = MsOracle.GetValue(drvList[0]["ColumnText"].ToString() + "已审批通过");//消息体                                    
                                }
                                else
                                {
                                    pageparm[6].Value = MsOracle.GetValue(entity.ORDERID + "已审批通过");//消息体 

                                }
                            }
                            catch { }

                        }
                        else
                        {
                            pageparm[6].Value = MsOracle.GetValue(ReplaceMessageBody(strMsgBody, SourceValueDT));//消息体                             
                        }
                        string strUrl = string.Format(XmlTemplete, ReplaceValue(strMsgUrl, SourceValueDT));
                        pageparm[7].Value = MsOracle.GetValue(strUrl);//应用URL                         
                    }
                    else//在引擎配置界面定义了消息内容
                    {
                        pageparm[6].Value = MsOracle.GetValue(ReplaceMessageBody(dr1["MESSAGEBODY"].ToString(), SourceValueDT));//消息体
                        pageparm[7].Value = MsOracle.GetValue(string.Format(XmlTemplete, ReplaceValue(dr1["APPLICATIONURL"].ToString(), SourceValueDT)));//应用URL   

                    }
                    #endregion
                    pageparm[8].Value = MsOracle.GetValue(entity.RECEIVEUSERID);//接收用户ID
                    if (entity.BEFOREPROCESSDATE != null)//流程过期时间属性
                    {
                        //sql += "to_date('" + entity.BEFOREPROCESSDATE + "','YYYY-MM-DD hh24:mi:ss')";
                        pageparm[9].Value = MsOracle.GetValue(entity.BEFOREPROCESSDATE);//可处理时间(主要针对KPI考核)
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(dr1["LASTDAYS"].ToString()))
                        {
                            pageparm[9].Value = MsOracle.GetValue(DateTime.Now.AddDays(3));//可处理时间(主要针对KPI考核)
                        }
                        else
                        {
                            pageparm[9].Value = MsOracle.GetValue(DateTime.Now.AddDays(int.Parse(dr1["LASTDAYS"].ToString())));//可处理时间(主要针对KPI考核)                             
                        }
                    }
                    pageparm[10].Value = MsOracle.GetValue(0);//待办任务类型(0、待办任务、1、流程咨询、3 ) 
                    pageparm[11].Value = MsOracle.GetValue(0);//代办任务状态(0、未处理 1、已处理 、2、任务撤销 10、删除)
                    pageparm[12].Value = MsOracle.GetValue(0);//邮件状态(0、未发送 1、已发送、2、未知 )
                    pageparm[13].Value = MsOracle.GetValue(0);//RTX状态(0、未发送 1、已发送、2、未知 )
                    pageparm[14].Value = MsOracle.GetValue(strAPPFIELDVALUE);//应用字段值
                    pageparm[15].Value = MsOracle.GetValue(entity.FLOWXML);//流程XML
                    pageparm[16].Value = MsOracle.GetValue(entity.APPXML);//应用XML
                    pageparm[17].Value = MsOracle.GetValue(entity.SYSTEMCODE);//系统代码
                    pageparm[18].Value = MsOracle.GetValue(entity.MODELCODE);//模块代码
                    pageparm[19].Value = MsOracle.GetValue(entity.MODELNAME);//模块名称                
                    int result = MsOracle.ExecuteSQLByTransaction(insSql, pageparm);
                }


            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("命名空间:SMT.Workflow.Engine.Services.DAL类方法:AddDoTask()" + ex.Message);
            }

        }
Exemplo n.º 3
0
        /// <summary>
        /// 新增待办任务消息
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="drDefine"></param>
        /// <param name="SourceValueDT"></param>
        public void AddDoTaskMessage(T_WF_DOTASK entity, DataRow drDefine, DataTable SourceValueDT)
        {

            ClosedDoTaskStatus(entity.SYSTEMCODE, entity.ORDERID, null);
            try
            {
                string ReceiveUser = entity.RECEIVEUSERID;
                if ((string.IsNullOrEmpty(ReceiveUser) || ReceiveUser.ToUpper() == "END") && drDefine != null)
                {
                    entity.RECEIVEUSERID = drDefine["RECEIVEUSER"].ToString();
                }
                string sql = "INSERT INTO T_WF_DOTASKMESSAGE(DOTASKMESSAGEID,MESSAGEBODY,SYSTEMCODE,RECEIVEUSERID,ORDERID,COMPANYID,MESSAGESTATUS,MAILSTATUS,RTXSTATUS,REMARK) VALUES ('" + Guid.NewGuid().ToString() + "',";
                #region MESSAGEBODY
                if (drDefine != null)//在引擎定义了触发条件有消息定义
                {
                    string strMsgBody = drDefine["MESSAGEBODY"].ToString();
                    if (!string.IsNullOrEmpty(strMsgBody))
                    {
                        sql += "'" + ReplaceMessageBody(strMsgBody, SourceValueDT) + "'";
                    }
                    else
                    {
                        DataRow[] drvList = SourceValueDT.Select("ColumnName='ModelName'");
                        if (drvList.Count() == 1)
                        {
                            sql += "'" + drvList[0]["ColumnValue"].ToString() + "已审批通过'";
                        }
                        else
                        {
                            DataRow[] drvList2 = SourceValueDT.Select("ColumnName='ModelCode'");
                            if (drvList2.Count() == 1)
                            {
                                sql += "'" + drvList2[0]["ColumnValue"].ToString() + "已审批通过'";
                            }
                            else
                            {
                                sql += "'已审批通过'";
                            }

                        }
                    }
                }
                else//在引擎配置界面定义了消息内容
                {
                    DataRow[] drvList = SourceValueDT.Select("ColumnName='ModelName'");
                    if (drvList.Count() == 1)
                    {
                        sql += "'" + drvList[0]["ColumnValue"].ToString() + "已审批通过'";
                    }
                    else
                    {
                        DataRow[] drvList2 = SourceValueDT.Select("ColumnName='ModelCode'");
                        if (drvList2.Count() == 1)
                        {
                            sql += "'" + drvList2[0]["ColumnValue"].ToString() + "已审批通过'";
                        }
                        else
                        {
                            sql += "'已审批通过'";
                        }
                    }
                }
                #endregion
                sql += ",'" + entity.SYSTEMCODE + "','" + entity.RECEIVEUSERID + "','" + entity.ORDERID + "','" + entity.COMPANYID + "',0,0,0,'业务系统新增')";
                int result = dao.ExecuteNonQuery(sql);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("命名空间:SMT.Workflow.Engine.Services.DAL类方法:AddDoTaskMessage()" + ex.Message);
            }
        }
Exemplo n.º 4
0
        public bool AddTask(T_WF_DOTASK dask)
        {
            if (dask.ENGINECODE != "1")
            {
                ClosedDoTaskStatus(dask.SYSTEMCODE, dask.ORDERID, dask.RECEIVEUSERID);
            }
            try
            {
                using (OracleConnection con = new OracleConnection(dao.DatabaseString))
                {
                    string insSql = @"INSERT INTO T_WF_DOTASK (DOTASKID,COMPANYID,ORDERID,ORDERUSERID,ORDERUSERNAME,ORDERSTATUS,MESSAGEBODY,
                                     APPLICATIONURL,RECEIVEUSERID,BEFOREPROCESSDATE,ENGINECODE,DOTASKTYPE,DOTASKSTATUS,MAILSTATUS,
                                     RTXSTATUS,SYSTEMCODE,MODELCODE,REMARK)
                                     VALUES (:DOTASKID,:COMPANYID,:ORDERID,:ORDERUSERID,:ORDERUSERNAME,:ORDERSTATUS,:MESSAGEBODY,
                                    :APPLICATIONURL,:RECEIVEUSERID,:BEFOREPROCESSDATE,:ENGINECODE,:DOTASKTYPE,:DOTASKSTATUS,:MAILSTATUS,
                                    :RTXSTATUS,:SYSTEMCODE,:MODELCODE,:REMARK)";
                    #region
                    #region
                    OracleParameter[] pageparm =
                        {               
                            new OracleParameter(":DOTASKID",OracleType.NVarChar,100), 
                            new OracleParameter(":COMPANYID",OracleType.NVarChar,100), 
                            new OracleParameter(":ORDERID",OracleType.NVarChar,100), 
                            new OracleParameter(":ORDERUSERID",OracleType.NVarChar,100), 
                            new OracleParameter(":ORDERUSERNAME",OracleType.NVarChar,100), 
                            new OracleParameter(":ORDERSTATUS",OracleType.Number), 
                            new OracleParameter(":MESSAGEBODY",OracleType.NVarChar,4000), 
                            new OracleParameter(":APPLICATIONURL",OracleType.NVarChar,2000), 
                            new OracleParameter(":RECEIVEUSERID",OracleType.NVarChar,100), 
                            new OracleParameter(":BEFOREPROCESSDATE",OracleType.DateTime), 
                            new OracleParameter(":ENGINECODE",OracleType.NVarChar,100), 
                            new OracleParameter(":DOTASKTYPE",OracleType.Number),
                            new OracleParameter(":DOTASKSTATUS",OracleType.Number), 
                            new OracleParameter(":MAILSTATUS",OracleType.Number), 
                            new OracleParameter(":RTXSTATUS",OracleType.Number),
                            new OracleParameter(":SYSTEMCODE",OracleType.NVarChar,100), 
                            new OracleParameter(":MODELCODE",OracleType.NVarChar,100), 
                            new OracleParameter(":REMARK",OracleType.NVarChar,200),                  

                        };
                    #endregion
                    pageparm[0].Value = MsOracle.GetValue(Guid.NewGuid().ToString());//待办任务ID
                    pageparm[1].Value = MsOracle.GetValue(dask.COMPANYID);//公司ID
                    pageparm[2].Value = MsOracle.GetValue(dask.ORDERID);//单据ID
                    pageparm[3].Value = MsOracle.GetValue(dask.RECEIVEUSERID);//单据所属人ID
                    pageparm[4].Value = MsOracle.GetValue(dask.ORDERUSERNAME);//单据所属人名称
                    pageparm[5].Value = MsOracle.GetValue(0);//单据状态
                    pageparm[6].Value = MsOracle.GetValue(dask.MESSAGEBODY);
                    pageparm[7].Value = MsOracle.GetValue(dask.APPLICATIONURL);
                    pageparm[8].Value = MsOracle.GetValue(dask.RECEIVEUSERID);
                    pageparm[9].Value = MsOracle.GetValue(DateTime.Now.AddDays(3));
                    pageparm[10].Value = MsOracle.GetValue("");//
                    pageparm[11].Value = MsOracle.GetValue(4);//待办任务类型(0、待办任务、1、流程咨询、3 ) 
                    pageparm[12].Value = MsOracle.GetValue(0);//代办任务状态(0、未处理 1、已处理 、2、任务撤销 10、删除)
                    pageparm[13].Value = MsOracle.GetValue(0);//邮件状态(0、未发送 1、已发送、2、未知 )
                    pageparm[14].Value = MsOracle.GetValue(0);//RTX状态(0、未发送 1、已发送、2、未知 )
                    pageparm[15].Value = MsOracle.GetValue(dask.SYSTEMCODE);
                    pageparm[16].Value = MsOracle.GetValue(dask.MODELCODE);
                    pageparm[17].Value = MsOracle.GetValue("未提交单据");
                    #endregion
                    return MsOracle.ExecuteNonQuery(con, CommandType.Text, insSql, pageparm) > 0 ? true : false;
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("新增未提交单据待办消息出错:" + ex);
                throw new Exception(ex.Message, ex);
            }
        }
Exemplo n.º 5
0
        public T_WF_DOTASK GetDoTaskEntity(string orderID, string receiveUserID)
        {
            try
            {
                dao.Open();
                string strFields = " DOTASKID,ORDERID,MESSAGEBODY,APPLICATIONURL,RECEIVEUSERID,BEFOREPROCESSDATE,CLOSEDDATE,DOTASKSTATUS,SYSTEMCODE,MODELCODE,CREATEDATETIME ";
                string sql = "SELECT  " + strFields + "  FROM T_WF_DOTASK where ORDERID='" + orderID + "' and RECEIVEUSERID='" + receiveUserID + "' order by CREATEDATETIME desc ";
                DataTable dt = dao.GetDataTable(sql);
                if (dt != null && dt.Rows.Count > 0)
                {
                    T_WF_DOTASK task = new T_WF_DOTASK();
                    DateTime? now = null;
                    task.DOTASKID = string.Concat(dt.Rows[0]["DOTASKID"]);
                    task.ORDERID = string.Concat(dt.Rows[0]["ORDERID"]);
                    task.MESSAGEBODY = string.Concat(dt.Rows[0]["MESSAGEBODY"]);
                    task.APPLICATIONURL = string.Concat(dt.Rows[0]["APPLICATIONURL"]);
                    task.RECEIVEUSERID = string.Concat(dt.Rows[0]["RECEIVEUSERID"]);
                    task.BEFOREPROCESSDATE = dt.Rows[0]["BEFOREPROCESSDATE"] != DBNull.Value ? Convert.ToDateTime(dt.Rows[0]["BEFOREPROCESSDATE"].ToString()) : now;
                    task.CLOSEDDATE = dt.Rows[0]["CLOSEDDATE"] != DBNull.Value ? Convert.ToDateTime(dt.Rows[0]["CLOSEDDATE"].ToString()) : now;
                    task.DOTASKSTATUS = int.Parse(dt.Rows[0]["DOTASKSTATUS"].ToString());
                    task.SYSTEMCODE = string.Concat(dt.Rows[0]["SYSTEMCODE"]);
                    task.MODELCODE = string.Concat(dt.Rows[0]["MODELCODE"]);
                    task.CREATEDATETIME = Convert.ToDateTime(dt.Rows[0]["CREATEDATETIME"].ToString());
                    return task;
                }
                return null;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
            finally
            {
                dao.Close();
            }

        }
Exemplo n.º 6
0
        public void AddDoTask(OracleConnection con, T_WF_DOTASK entity, DataRow dr1, DataTable SourceValueDT, string strReceiveID, string ApplicationCode, string strAPPFIELDVALUE, string strMsg, string strFormTypes)
        {
            CloseDoTaskStatus(con, entity.SYSTEMCODE, entity.ORDERID, null);
            try
            {
                string insSql = @"INSERT INTO T_WF_DOTASK (DOTASKID,COMPANYID,ORDERID,ORDERUSERID,ORDERUSERNAME,ORDERSTATUS,MESSAGEBODY,
                                     APPLICATIONURL,RECEIVEUSERID,BEFOREPROCESSDATE,ENGINECODE,DOTASKTYPE,DOTASKSTATUS,MAILSTATUS,
                                     RTXSTATUS,APPFIELDVALUE,FLOWXML,APPXML,SYSTEMCODE,MODELCODE,MODELNAME)
                                     VALUES (:DOTASKID,:COMPANYID,:ORDERID,:ORDERUSERID,:ORDERUSERNAME,:ORDERSTATUS,:MESSAGEBODY,:APPLICATIONURL,
                                    :RECEIVEUSERID,:BEFOREPROCESSDATE,:ENGINECODE,:DOTASKTYPE,:DOTASKSTATUS,:MAILSTATUS,:RTXSTATUS,
                                    :APPFIELDVALUE,:FLOWXML,:APPXML,:SYSTEMCODE,:MODELCODE,:MODELNAME)";
                #region
                #region
                OracleParameter[] pageparm =
                        {               
                            new OracleParameter(":DOTASKID",OracleType.NVarChar,100), 
                            new OracleParameter(":COMPANYID",OracleType.NVarChar,100), 
                            new OracleParameter(":ORDERID",OracleType.NVarChar,100), 
                            new OracleParameter(":ORDERUSERID",OracleType.NVarChar,100), 
                            new OracleParameter(":ORDERUSERNAME",OracleType.NVarChar,100), 
                            new OracleParameter(":ORDERSTATUS",OracleType.Number,22), 
                            new OracleParameter(":MESSAGEBODY",OracleType.NVarChar,4000), 
                             new OracleParameter(":APPLICATIONURL",OracleType.NVarChar,2000), 
                            new OracleParameter(":RECEIVEUSERID",OracleType.NVarChar,100), 
                            new OracleParameter(":BEFOREPROCESSDATE",OracleType.DateTime), 
                             new OracleParameter(":ENGINECODE",OracleType.NVarChar,100), 
                            new OracleParameter(":DOTASKTYPE",OracleType.Number,22),
                            new OracleParameter(":DOTASKSTATUS",OracleType.Number,22), 
                            new OracleParameter(":MAILSTATUS",OracleType.Number,22), 
                            new OracleParameter(":RTXSTATUS",OracleType.Number,22),                  
                            new OracleParameter(":APPFIELDVALUE",OracleType.Clob), 
                            new OracleParameter(":FLOWXML",OracleType.Clob), 
                            new OracleParameter(":APPXML",OracleType.Clob), 
                            new OracleParameter(":SYSTEMCODE",OracleType.NVarChar,100), 
                            new OracleParameter(":MODELCODE",OracleType.NVarChar,100), 
                            new OracleParameter(":MODELNAME",OracleType.NVarChar,200),                  

                        };
                #endregion
                pageparm[0].Value = MsOracle.GetValue(Guid.NewGuid().ToString());//待办任务ID
                pageparm[1].Value = MsOracle.GetValue(entity.COMPANYID);//公司ID
                pageparm[2].Value = MsOracle.GetValue(ApplicationCode);//单据ID
                pageparm[3].Value = MsOracle.GetValue("");//单据所属人ID
                pageparm[4].Value = MsOracle.GetValue("");//单据所属人名称
                pageparm[5].Value = MsOracle.GetValue("");//单据状态
                #region 消息体
                string XmlTemplete = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "\r\n" +
                              "<System>" + "\r\n" +
                              "{0}" +
                              "</System>";
                if (dr1["MESSAGEBODY"].ToString() == "")//默认消息为空
                {
                    string strMsgBody = string.Empty;
                    string strMsgUrl = string.Empty;
                    ModelMsgDefine(con, dr1["SYSTEMCODE"].ToString(), dr1["MODELCODE"].ToString(), entity.COMPANYID, ref strMsgBody, ref strMsgUrl);
                    if (string.IsNullOrEmpty(strMsgBody))
                    {
                        try
                        {
                            DataRow[] drvList = SourceValueDT.Select("ColumnName='ModelName'");
                            if (drvList.Count() == 1)
                            {
                                string value = drvList[0]["ColumnValue"].ToString();
                                if (string.IsNullOrWhiteSpace(value))
                                {
                                    value = drvList[0]["ColumnText"].ToString();
                                }                             
                                pageparm[6].Value = MsOracle.GetValue(value + "已审批通过");//消息体                                    
                            }
                            else
                            {
                                pageparm[6].Value = MsOracle.GetValue(ApplicationCode + "已审批通过");//消息体 

                            }
                        }
                        catch { }

                    }
                    else
                    {
                        pageparm[6].Value = MsOracle.GetValue(ReplaceMessageBody(strMsgBody, SourceValueDT));//消息体                             
                    }
                    if (string.IsNullOrEmpty(strFormTypes))
                    {
                        pageparm[7].Value = MsOracle.GetValue(string.Format(XmlTemplete, ReplaceValue(strMsgUrl, SourceValueDT)));//应用URL 
                        LogHelper.WriteLog("查询到得消息链接:" + pageparm[7].Value + "单据ID:" + entity.ORDERID);
                    }
                    else
                    {
                        pageparm[7].Value = MsOracle.GetValue(EncyptFormType(ReplaceValue(strMsgUrl, SourceValueDT), strFormTypes));//应用URL
                        LogHelper.WriteLog("查询到得消息链接:" + pageparm[7].Value + "单据ID:" + entity.ORDERID);
                    }
                }
                else//在引擎配置界面定义了消息内容
                {
                    pageparm[6].Value = MsOracle.GetValue(ReplaceMessageBody(strMsg, SourceValueDT));//消息体
                    pageparm[7].Value = MsOracle.GetValue(string.Format(XmlTemplete, ReplaceValue(dr1["APPLICATIONURL"].ToString(), SourceValueDT)));//应用URL   

                }
                #endregion              
                pageparm[8].Value = MsOracle.GetValue(strReceiveID);//接收用户ID
                if (entity.BEFOREPROCESSDATE != null)//流程过期时间属性
                {
                    //sql += "to_date('" + entity.BEFOREPROCESSDATE + "','YYYY-MM-DD hh24:mi:ss')";
                    pageparm[9].Value = MsOracle.GetValue(entity.BEFOREPROCESSDATE);//可处理时间(主要针对KPI考核)
                }
                else
                {
                    if (string.IsNullOrEmpty(dr1["LASTDAYS"].ToString()))
                    {
                        pageparm[9].Value = MsOracle.GetValue(DateTime.Now.AddDays(3));//可处理时间(主要针对KPI考核)
                    }
                    else
                    {
                        pageparm[9].Value = MsOracle.GetValue(DateTime.Now.AddDays(int.Parse(dr1["LASTDAYS"].ToString())));//可处理时间(主要针对KPI考核)                             
                    }
                }
                pageparm[10].Value = MsOracle.GetValue(dr1["DOTASKRULEID"].ToString());               
                pageparm[11].Value = MsOracle.GetValue(0);//待办任务类型(0、待办任务、1、流程咨询、3 ) 
                pageparm[12].Value = MsOracle.GetValue(0);//代办任务状态(0、未处理 1、已处理 、2、任务撤销 10、删除)
                pageparm[13].Value = MsOracle.GetValue(0);//邮件状态(0、未发送 1、已发送、2、未知 )
                pageparm[14].Value = MsOracle.GetValue(0);//RTX状态(0、未发送 1、已发送、2、未知 )
                pageparm[15].Value = MsOracle.GetValue(strAPPFIELDVALUE);//应用字段值
                pageparm[16].Value = MsOracle.GetValue(entity.FLOWXML);//流程XML
                pageparm[17].Value = MsOracle.GetValue(entity.APPXML);//应用XML
                pageparm[18].Value = MsOracle.GetValue(entity.SYSTEMCODE);//系统代码
                DataRow[] ModelCodeList = SourceValueDT.Select("ColumnName='ModelCode'");
                if (ModelCodeList.Count() == 1)
                {
                    pageparm[19].Value = ModelCodeList[0]["ColumnValue"];//模块                    
                }
                else
                {
                    pageparm[19].Value = "";//模块               
                }
                DataRow[] ModelCodeList1 = SourceValueDT.Select("ColumnName='ModelName'");
                if (ModelCodeList1.Count() == 1)
                {
                    pageparm[20].Value = ModelCodeList1[0]["ColumnValue"];//模块                    
                }
                else
                {
                    pageparm[20].Value = "";//模块               
                }
                //pageparm[19].Value = MsOracle.GetValue(entity.MODELCODE);//模块代码
                //pageparm[20].Value = MsOracle.GetValue(entity.MODELNAME);//模块名称
                #endregion
                int result = MsOracle.ExecuteSQLByTransaction(con, insSql, pageparm);// dao.ExecuteNonQuery(sql);
                if (result > 0)
                {
                    LogHelper.WriteLog("B新增待办任务AddDoTask (成功)  FormID=" + entity.ORDERID + " 接收人ID=" + strReceiveID);
                }
                else
                {
                    LogHelper.WriteLog("B新增待办任务AddDoTask (失败)  FormID=" + entity.ORDERID + " 接收人ID=" + strReceiveID);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("B新增待办任务发生AddDoTask(失败)FormID=" + entity.ORDERID + " 命名空间: SMT.FlowDAL.EnginFlowDAL 类方法:AddDoTask()" + ex.Message);
              
                throw new Exception("新增待办任务发生异常 FormID=" + entity.ORDERID);

            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 业务系统直接新增消息
        /// </summary>
        /// <param name="strFlowMessage"></param>
        /// <param name="strBOObject"></param>
        /// <returns></returns>
        public bool SaveFlowTriggerData(string strFlow, string strBOObject)
        {
            T_WF_DOTASK entity = new T_WF_DOTASK();
            string strEntityType = string.Empty;//EntityType (表名)
            string strEntityKey = string.Empty;//EntityKey (主键)
            string IsTask = "1";//是否任务
            try
            {
                try
                {
                    #region 解析XML
                    StringReader strRdr = new StringReader(strFlow);
                    XmlReader xr = XmlReader.Create(strRdr);
                    StringBuilder _ConbinString = new StringBuilder();
                    while (xr.Read())
                    {
                        if (xr.NodeType == XmlNodeType.Element)
                        {
                            string elementName = xr.Name;
                            if (elementName == "Message")
                            {
                                while (xr.Read())
                                {
                                    string type = xr.NodeType.ToString();
                                    #region

                                    if (xr["Name"] != null)
                                    {
                                        _ConbinString.Append(xr["Name"] + "|" + xr["DataValue"] + "Ё");
                                        if (xr["Name"].ToUpper() == "COMPANYID")
                                        {
                                            entity.COMPANYID = xr["DataValue"];
                                        }
                                        if (xr["Name"].ToUpper() == "MODELCODE")
                                        {
                                            entity.MODELCODE = xr["DataValue"];
                                        }
                                        if (xr["Name"].ToUpper() == "MODELNAME")
                                        {
                                            entity.MODELNAME = xr["DataValue"];
                                        }
                                        if (xr["Name"].ToUpper() == "FORMID")
                                        {
                                            entity.ORDERID = xr["DataValue"];
                                        }
                                        if (xr["Name"].ToUpper() == "CHECKSTATE")
                                        {
                                            entity.ORDERSTATUS = int.Parse(xr["DataValue"]);
                                        }
                                        if (xr["Name"].ToUpper() == "APPUSERID")
                                        {
                                            entity.RECEIVEUSERID = xr["DataValue"];
                                        }
                                        if (xr["Name"].ToUpper() == "ISTASK")
                                        {
                                            IsTask = xr["DataValue"];
                                        }
                                        if (xr["Name"].ToUpper() == "OUTTIME")
                                        {

                                            if (!string.IsNullOrEmpty(xr["DataValue"]))
                                            {
                                                entity.BEFOREPROCESSDATE = DateTime.Now.AddMinutes(int.Parse(xr["DataValue"]));
                                            }
                                        }
                                    }
                                    #endregion
                                }
                            }
                        }
                        entity.FLOWXML = strFlow;
                        entity.APPXML = strBOObject;
                    }
                    #endregion
                    #region strBusiness
                    if (!string.IsNullOrEmpty(strBOObject))
                    {
                        StringReader rd = new StringReader(strBOObject);
                        XmlReader xdr = XmlReader.Create(rd);
                        StringBuilder BOObject = new StringBuilder();
                        while (xdr.Read())
                        {
                            if (xdr.NodeType == XmlNodeType.Element)
                            {
                                string elementName = xdr.Name;
                                if (elementName == "Name")
                                {
                                    while (xdr.Read())
                                    {
                                        entity.SYSTEMCODE = xdr.Value;
                                        break;
                                    }
                                }
                                if (elementName == "Object")
                                {
                                    try
                                    { //非手机的XML时没有表明和主键的
                                        strEntityType = xdr["Name"];
                                        strEntityKey = xdr["Key"];
                                    }
                                    catch
                                    {
                                        Tracer.Debug("异常无法取得业务数据表,单据:" + entity.ORDERID + ":表:" + strEntityType + ":主键:" + strEntityKey + "");
                                    }
                                    while (xdr.Read())
                                    {
                                        if (xdr.Name == "Attribute")
                                        {
                                            if (xdr["Name"] != null)
                                            {
                                                BOObject.Append(xdr["Name"] + "|" + xdr["DataValue"] + "Г" + (xdr["DataText"] != null ? xdr["DataText"] : xdr["DataValue"]) + "Ё");
                                                #region
                                                if (xdr["Name"].ToUpper() == "OWNERID")
                                                {
                                                    entity.ORDERUSERID = xdr["DataValue"];
                                                }
                                                if (xdr["Name"].ToUpper() == "OWNERNAME")
                                                {
                                                    entity.ORDERUSERNAME = xdr["DataValue"];
                                                }
                                                if (xdr["Name"].ToUpper() == "CREATEUSERID")
                                                {
                                                    //有些特殊的模块需要改变接收人
                                                    if (Common.CheckModelName(entity.MODELCODE) && entity.ORDERSTATUS == 2)
                                                    {
                                                        entity.RECEIVEUSERID = xdr["DataValue"];
                                                    }
                                                }

                                                #endregion
                                            }

                                        }
                                    }
                                }
                            }
                        }
                        entity.APPFIELDVALUE = _ConbinString.ToString() + BOObject.ToString().TrimEnd('Ё');

                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    return false;
                }
                bool IsExecute = EngineExecute(entity, IsTask);
                if (IsExecute)
                {
                    try
                    {
                        /****************更新业务系统单据审核状态***********************/
                        if (Config.IsNeedUpdateAudit)//是否执行更新审核状态
                        {
                            if (!string.IsNullOrEmpty(entity.SYSTEMCODE) && !string.IsNullOrEmpty(strEntityType) && !string.IsNullOrEmpty(strEntityKey))
                            {
                                UpdateAuditStatus(entity.SYSTEMCODE, strEntityType, strEntityKey, entity.ORDERID, entity.ORDERSTATUS.ToString());
                            }
                        }

                    }
                    catch (Exception ex)
                    {
                        return false;
                    }
                }
                return IsExecute;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// 新增未提交的代办
 /// </summary>
 /// <param name="dask"></param>
 /// <returns></returns>
 public string AddTask(T_WF_DOTASK dask)
 {
     try
     {
         Record.WriteLogFunction("AddTask()开始调用");
         EngineServicesBLL bll = new EngineServicesBLL();
         bll.AddTask(dask);
         return "1";
     }
     catch (Exception ex)
     {
         Record.WriteLogFunction("AddTask()" + ex.Message);
         return ex.Message;
     }
 }
Exemplo n.º 9
0
        /// <summary>
        ///调用业务系统
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="strEntityType"></param>
        /// <param name="strEntityKey"></param>
        /// <param name="ErroMessage"></param>
        private bool CallBusinessSystem(SubmitData submitData, T_WF_DOTASK entity, string strEntityKey, ref string ErroMessage)
        {
            bool isOK = true;
            Tracer.Debug("设置业务系统的审核状态是否需要审核 Config.IsNeedUpdateAudit=" + Config.IsNeedUpdateAudit.ToString());
            /****************更新业务系统单据审核状态***********************/
            if (Config.IsNeedUpdateAudit)//是否执行更新审核状态
            {
                if (!string.IsNullOrEmpty(entity.SYSTEMCODE) && !string.IsNullOrEmpty(strEntityKey))
                {
                    Tracer.Debug("UpdateAuditStatus 开始 更新业务系统单据审核状态 FormID=" + entity.ORDERID);
                    bool bol = UpdateAuditStatus(submitData, entity.SYSTEMCODE, entity.MODELCODE, strEntityKey, entity.ORDERID, entity.ORDERSTATUS.ToString(), ref ErroMessage);
                    Tracer.Debug("UpdateAuditStatus 结束 更新业务系统单据审核状态 FormID=" + entity.ORDERID);
                    if (!bol)
                    {
                        return bol;
                        //throw new Exception(ErroMessage);
                    }
                    ErroMessage = "";

                }
                else
                {
                    isOK = false;
                    Tracer.Debug("不能更新业务系统,因为entity.SYSTEMCODE=" + entity.SYSTEMCODE + " ;strEntityType=" + entity.MODELCODE + " ;strEntityKey=" + strEntityKey + " ;FormID=" + entity.ORDERID);
                }
            }

            return isOK;
        }
Exemplo n.º 10
0
        public bool AddTask(T_WF_DOTASK dask)
        {
            if (dask.ENGINECODE != "1")
            {
                ClosedDoTaskStatus(dask.SYSTEMCODE, dask.ORDERID, dask.RECEIVEUSERID);
            }
            try
            {
                    string insSql = @"INSERT INTO T_WF_DOTASK (DOTASKID,COMPANYID,ORDERID,ORDERUSERID,ORDERUSERNAME,ORDERSTATUS,MESSAGEBODY,
                                     APPLICATIONURL,RECEIVEUSERID,BEFOREPROCESSDATE,ENGINECODE,DOTASKTYPE,DOTASKSTATUS,MAILSTATUS,
                                     RTXSTATUS,SYSTEMCODE,MODELCODE,REMARK)
                                     VALUES (:DOTASKID,:COMPANYID,:ORDERID,:ORDERUSERID,:ORDERUSERNAME,:ORDERSTATUS,:MESSAGEBODY,
                                    :APPLICATIONURL,:RECEIVEUSERID,:BEFOREPROCESSDATE,:ENGINECODE,:DOTASKTYPE,:DOTASKSTATUS,:MAILSTATUS,
                                    :RTXSTATUS,:SYSTEMCODE,:MODELCODE,:REMARK)";
                    #region
                    #region
                    Parameter[] pageparm =
                        {
                            new Parameter(":DOTASKID",null),
                            new Parameter(":COMPANYID",null),
                            new Parameter(":ORDERID",null),
                            new Parameter(":ORDERUSERID",null),
                            new Parameter(":ORDERUSERNAME",null),
                            new Parameter(":ORDERSTATUS",null),
                            new Parameter(":MESSAGEBODY",null),
                            new Parameter(":APPLICATIONURL",null),
                            new Parameter(":RECEIVEUSERID",null),
                            new Parameter(":BEFOREPROCESSDATE",null),
                            new Parameter(":ENGINECODE",null),
                            new Parameter(":DOTASKTYPE",null),
                            new Parameter(":DOTASKSTATUS",null),
                            new Parameter(":MAILSTATUS",null),
                            new Parameter(":RTXSTATUS",null),
                            new Parameter(":SYSTEMCODE",null),
                            new Parameter(":MODELCODE",null),
                            new Parameter(":REMARK",null),

                        };
                    #endregion
                    pageparm[0].ParameterValue = GetValue(Guid.NewGuid().ToString());//待办任务ID
                    pageparm[1].ParameterValue = GetValue(dask.COMPANYID);//公司ID
                    pageparm[2].ParameterValue = GetValue(dask.ORDERID);//单据ID
                    pageparm[3].ParameterValue = GetValue(dask.RECEIVEUSERID);//单据所属人ID
                    pageparm[4].ParameterValue = GetValue(dask.ORDERUSERNAME);//单据所属人名称
                    pageparm[5].ParameterValue = GetValue(0);//单据状态
                    pageparm[6].ParameterValue = GetValue(dask.MESSAGEBODY);
                    pageparm[7].ParameterValue = GetValue(dask.APPLICATIONURL);
                    pageparm[8].ParameterValue = GetValue(dask.RECEIVEUSERID);
                    pageparm[9].ParameterValue = GetValue(DateTime.Now.AddDays(3));
                    pageparm[10].ParameterValue = GetValue("");//
                    pageparm[11].ParameterValue = GetValue(4);//待办任务类型(0、待办任务、1、流程咨询、3 )
                    pageparm[12].ParameterValue = GetValue(0);//代办任务状态(0、未处理 1、已处理 、2、任务撤销 10、删除)
                    pageparm[13].ParameterValue = GetValue(0);//邮件状态(0、未发送 1、已发送、2、未知 )
                    pageparm[14].ParameterValue = GetValue(0);//RTX状态(0、未发送 1、已发送、2、未知 )
                    pageparm[15].ParameterValue = GetValue(dask.SYSTEMCODE);
                    pageparm[16].ParameterValue = GetValue(dask.MODELCODE);
                    pageparm[17].ParameterValue = GetValue("未提交单据");
                    #endregion
                    ParameterCollection paras = new ParameterCollection();
                    foreach (var item in pageparm)
                    {
                        paras.Add(item);
                    }
                    return dao.ExecuteNonQuery(insSql, CommandType.Text, paras) > 0 ? true : false;

            }
            catch (Exception ex)
            {
                Tracer.Debug("新增未提交单据待办消息出错:" + ex);
                throw new Exception(ex.Message, ex);
            }
        }
Exemplo n.º 11
0
        public void AddDoTask(T_WF_DOTASK entity, DataRow dr1, DataTable SourceValueDT, string strReceiveID, string ApplicationCode, string strAPPFIELDVALUE, string strMsg, string strFormTypes)
        {
            ClosedDoTaskStatus(entity.SYSTEMCODE, entity.ORDERID, null);
            try
            {
                string insSql = @"INSERT INTO T_WF_DOTASK (DOTASKID,COMPANYID,ORDERID,ORDERUSERID,ORDERUSERNAME,ORDERSTATUS,MESSAGEBODY,
                                     APPLICATIONURL,RECEIVEUSERID,BEFOREPROCESSDATE,ENGINECODE,DOTASKTYPE,DOTASKSTATUS,MAILSTATUS,
                                     RTXSTATUS,APPFIELDVALUE,FLOWXML,APPXML,SYSTEMCODE,MODELCODE,MODELNAME)
                                     VALUES (:DOTASKID,:COMPANYID,:ORDERID,:ORDERUSERID,:ORDERUSERNAME,:ORDERSTATUS,:MESSAGEBODY,:APPLICATIONURL,
                                    :RECEIVEUSERID,:BEFOREPROCESSDATE,:ENGINECODE,:DOTASKTYPE,:DOTASKSTATUS,:MAILSTATUS,:RTXSTATUS,
                                    :APPFIELDVALUE,:FLOWXML,:APPXML,:SYSTEMCODE,:MODELCODE,:MODELNAME)";
                #region
                #region
                Parameter[] pageparm =
                        {
                            new Parameter(":DOTASKID",null),
                            new Parameter(":COMPANYID",null),
                            new Parameter(":ORDERID",null),
                            new Parameter(":ORDERUSERID",null),
                            new Parameter(":ORDERUSERNAME",null),
                            new Parameter(":ORDERSTATUS",null),
                            new Parameter(":MESSAGEBODY",null),
                             new Parameter(":APPLICATIONURL",null),
                            new Parameter(":RECEIVEUSERID",null),
                            new Parameter(":BEFOREPROCESSDATE",null),
                             new Parameter(":ENGINECODE",null),
                            new Parameter(":DOTASKTYPE",null),
                            new Parameter(":DOTASKSTATUS",null),
                            new Parameter(":MAILSTATUS",null),
                            new Parameter(":RTXSTATUS",null),
                            new Parameter(":APPFIELDVALUE",null),
                            new Parameter(":FLOWXML",null),
                            new Parameter(":APPXML",null),
                            new Parameter(":SYSTEMCODE",null),
                            new Parameter(":MODELCODE",null),
                            new Parameter(":MODELNAME",null),

                        };
                #endregion
                pageparm[0].ParameterValue = GetValue(Guid.NewGuid().ToString());//待办任务ID
                pageparm[1].ParameterValue = GetValue(entity.COMPANYID);//公司ID
                pageparm[2].ParameterValue = GetValue(ApplicationCode);//单据ID
                pageparm[3].ParameterValue = GetValue("");//单据所属人ID
                pageparm[4].ParameterValue = GetValue("");//单据所属人名称
                pageparm[5].ParameterValue = GetValue("");//单据状态
                #region 消息体
                string XmlTemplete = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "\r\n" +
                              "<System>" + "\r\n" +
                              "{0}" +
                              "</System>";
                if (dr1["MESSAGEBODY"].ToString() == "")//默认消息为空
                {
                    string strMsgBody = string.Empty;
                    string strMsgUrl = string.Empty;
                    ModelMsgDefine(dr1["SYSTEMCODE"].ToString(), dr1["MODELCODE"].ToString(), entity.COMPANYID, ref strMsgBody, ref strMsgUrl);
                    if (string.IsNullOrEmpty(strMsgBody))
                    {
                        try
                        {
                            DataRow[] drvList = SourceValueDT.Select("ColumnName='ModelName'");
                            if (drvList.Count() == 1)
                            {
                                pageparm[6].ParameterValue = GetValue(drvList[0]["ColumnValue"].ToString() + "已审批通过");//消息体
                            }
                            else
                            {
                                pageparm[6].ParameterValue = GetValue(ApplicationCode + "已审批通过");//消息体

                            }
                        }
                        catch { }

                    }
                    else
                    {
                        pageparm[6].ParameterValue = GetValue(ReplaceMessageBody(strMsgBody, SourceValueDT));//消息体
                    }
                    if (string.IsNullOrEmpty(strFormTypes))
                    {
                        pageparm[7].ParameterValue = GetValue(string.Format(XmlTemplete, ReplaceValue(strMsgUrl, SourceValueDT)));//应用URL
                    }
                    else
                    {
                        pageparm[7].ParameterValue = GetValue(EncyptFormType(ReplaceValue(strMsgUrl, SourceValueDT), strFormTypes));//应用URL
                    }
                }
                else//在引擎配置界面定义了消息内容
                {
                    pageparm[6].ParameterValue = GetValue(ReplaceMessageBody(strMsg, SourceValueDT));//消息体
                    pageparm[7].ParameterValue = GetValue(string.Format(XmlTemplete, ReplaceValue(dr1["APPLICATIONURL"].ToString(), SourceValueDT)));//应用URL

                }
                #endregion

                pageparm[8].ParameterValue = GetValue(strReceiveID);//接收用户ID
                if (entity.BEFOREPROCESSDATE != null)//流程过期时间属性
                {
                    //sql += "to_date('" + entity.BEFOREPROCESSDATE + "','YYYY-MM-DD hh24:mi:ss')";
                    pageparm[9].ParameterValue = GetValue(entity.BEFOREPROCESSDATE);//可处理时间(主要针对KPI考核)
                }
                else
                {
                    if (string.IsNullOrEmpty(dr1["LASTDAYS"].ToString()))
                    {
                        pageparm[9].ParameterValue = GetValue(DateTime.Now.AddDays(3));//可处理时间(主要针对KPI考核)
                    }
                    else
                    {
                        pageparm[9].ParameterValue = GetValue(DateTime.Now.AddDays(int.Parse(dr1["LASTDAYS"].ToString())));//可处理时间(主要针对KPI考核)
                    }
                }
                pageparm[10].ParameterValue = GetValue(dr1["DOTASKRULEID"].ToString());
                pageparm[11].ParameterValue = GetValue(0);//待办任务类型(0、待办任务、1、流程咨询、3 )
                pageparm[12].ParameterValue = GetValue(0);//代办任务状态(0、未处理 1、已处理 、2、任务撤销 10、删除)
                pageparm[13].ParameterValue = GetValue(0);//邮件状态(0、未发送 1、已发送、2、未知 )
                pageparm[14].ParameterValue = GetValue(0);//RTX状态(0、未发送 1、已发送、2、未知 )
                pageparm[15].ParameterValue = GetValue(strAPPFIELDVALUE);//应用字段值
                pageparm[16].ParameterValue = GetValue(entity.FLOWXML);//流程XML
                pageparm[17].ParameterValue = GetValue(entity.APPXML);//应用XML
                pageparm[18].ParameterValue = GetValue(entity.SYSTEMCODE);//系统代码
                DataRow[] ModelCodeList = SourceValueDT.Select("ColumnName='ModelCode'");
                if (ModelCodeList.Count() == 1)
                {
                    pageparm[19].ParameterValue = ModelCodeList[0]["ColumnValue"];//模块
                }
                else
                {
                    pageparm[19].ParameterValue = "";//模块
                }
                DataRow[] ModelCodeList1 = SourceValueDT.Select("ColumnName='ModelName'");
                if (ModelCodeList1.Count() == 1)
                {
                    pageparm[20].ParameterValue = ModelCodeList1[0]["ColumnValue"];//模块
                }
                else
                {
                    pageparm[20].ParameterValue = "";//模块
                }
                //pageparm[19].ParameterValue = GetValue(entity.MODELCODE);//模块代码
                //pageparm[20].ParameterValue = GetValue(entity.MODELNAME);//模块名称
                #endregion

                ParameterCollection paras = new ParameterCollection();
                foreach (var item in pageparm)
                {
                    paras.Add(item);
                }
                int result = dao.ExecuteNonQuery(insSql,CommandType.Text,paras);// dao.ExecuteNonQuery(sql);
            }
            catch (Exception ex)
            {
                Tracer.Debug("新增待办消息出错:命名空间:SMT.Workflow.Engine.Services.DAL类方法:AddDoTask()" + ex);
                throw new Exception(ex.Message, ex);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// 新增待办任务消息
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="drDefine"></param>
        /// <param name="SourceValueDT"></param>
        public void AddDoTaskMessage(T_WF_DOTASK entity, DataRow drDefine, DataTable SourceValueDT)
        {
            string sql = "";
            CloseDoTaskStatus(entity.SYSTEMCODE, entity.ORDERID, null);
            try
            {
                string ReceiveUser = entity.RECEIVEUSERID;
                if ((string.IsNullOrEmpty(ReceiveUser) || ReceiveUser.ToUpper() == "END") && drDefine != null)
                {
                    entity.RECEIVEUSERID = drDefine["RECEIVEUSER"].ToString();
                }
                 sql = "INSERT INTO T_WF_DOTASKMESSAGE(DOTASKMESSAGEID,MESSAGEBODY,SYSTEMCODE,RECEIVEUSERID,ORDERID,COMPANYID,MESSAGESTATUS,MAILSTATUS,RTXSTATUS,REMARK) VALUES ('" + Guid.NewGuid().ToString() + "',";
                #region MESSAGEBODY
                if (drDefine != null)//在引擎定义了触发条件有消息定义
                {
                    string strMsgBody = drDefine["MESSAGEBODY"].ToString();
                    if (!string.IsNullOrEmpty(strMsgBody))
                    {
                        sql += "'" + ReplaceMessageBody(strMsgBody, SourceValueDT).Replace("\'","\"") + "'";
                    }
                    else
                    {
                        DataRow[] drvList = SourceValueDT.Select("ColumnName='ModelName'");
                        if (drvList.Count() == 1)
                        {
                            sql += "'" + drvList[0]["ColumnValue"].ToString() + "已审批通过'";
                        }
                        else
                        {
                            DataRow[] drvList2 = SourceValueDT.Select("ColumnName='ModelCode'");
                            if (drvList2.Count() == 1)
                            {
                                sql += "'" + drvList2[0]["ColumnValue"].ToString() + "已审批通过'";
                            }
                            else
                            {
                                sql += "'已审批通过'";
                            }

                        }
                    }
                }
                else//在引擎配置界面定义了消息内容
                {
                    DataRow[] drvList = SourceValueDT.Select("ColumnName='ModelName'");
                    if (drvList.Count() == 1)
                    {
                        sql += "'" + drvList[0]["ColumnValue"].ToString() + "已审批通过'";
                    }
                    else
                    {
                        DataRow[] drvList2 = SourceValueDT.Select("ColumnName='ModelCode'");
                        if (drvList2.Count() == 1)
                        {
                            sql += "'" + drvList2[0]["ColumnValue"].ToString() + "已审批通过'";
                        }
                        else
                        {
                            sql += "'已审批通过'";
                        }
                    }
                }
                #endregion
                sql += ",'" + entity.SYSTEMCODE + "','" + entity.RECEIVEUSERID + "','" + entity.ORDERID + "','" + entity.COMPANYID + "',0,0,0,'系统新增')";

                int result = dao.ExecuteNonQuery(sql);// dao.ExecuteNonQuery(sql);
                Tracer.Debug("新增待办任务消息(成功) FormID=" + entity.ORDERID + " SQL语句=" + sql);
            }
            catch (Exception ex)
            {
                Tracer.Debug("AddDoTaskMessage()新增待办任务消息(失败):FormID=" + entity.ORDERID + "SQL语句=" +sql+" \r\n 异常信息:\r\n"+ ex.Message);
                throw new Exception("新增待办任务消息发生异常 FormID=" + entity.ORDERID);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// 新增待办
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="dr1"></param>
        /// <param name="SourceValueDT"></param>
        /// <param name="strAPPFIELDVALUE"></param>
        public void AddDoTask(T_WF_DOTASK entity, DataRow[] drs, DataTable SourceValueDT, string strAPPFIELDVALUE, string submitUserName, string ModeName, string applicationUrl)
        {
            CloseDoTaskStatus(entity.SYSTEMCODE, entity.ORDERID, null);
            try
            {
                string[] strListUser;
                if (entity.RECEIVEUSERID.IndexOf('|') != -1)
                {
                    strListUser = entity.RECEIVEUSERID.ToString().Split('|');
                }
                else
                {
                    strListUser = new string[1];
                    strListUser[0] = entity.RECEIVEUSERID.ToString();
                }
                //
                foreach (string User in strListUser)
                {
                    string insSql = @"INSERT INTO T_WF_DOTASK (DOTASKID,COMPANYID,ORDERID,ORDERUSERID,ORDERUSERNAME,ORDERSTATUS,MESSAGEBODY,
                                     APPLICATIONURL,RECEIVEUSERID,BEFOREPROCESSDATE,DOTASKTYPE,DOTASKSTATUS,MAILSTATUS,
                                     RTXSTATUS,APPFIELDVALUE,FLOWXML,APPXML,SYSTEMCODE,MODELCODE,MODELNAME,REMARK)
                                     VALUES (@DOTASKID,@COMPANYID,@ORDERID,@ORDERUSERID,@ORDERUSERNAME,@ORDERSTATUS,@MESSAGEBODY,@APPLICATIONURL,
                                    @RECEIVEUSERID,@BEFOREPROCESSDATE,@DOTASKTYPE,@DOTASKSTATUS,@MAILSTATUS,@RTXSTATUS,
                                    @APPFIELDVALUE,@FLOWXML,@APPXML,@SYSTEMCODE,@MODELCODE,@MODELNAME,@REMARK)";
                    Parameter[] pageparm =
                        {
                            new Parameter("@DOTASKID",null),
                            new Parameter("@COMPANYID",null),
                            new Parameter("@ORDERID",null),
                            new Parameter("@ORDERUSERID",null),
                            new Parameter("@ORDERUSERNAME",null),
                            new Parameter("@ORDERSTATUS",null),
                            new Parameter("@MESSAGEBODY",null),
                            new Parameter("@APPLICATIONURL",null),
                            new Parameter("@RECEIVEUSERID",null),
                            new Parameter("@BEFOREPROCESSDATE",null),
                            new Parameter("@DOTASKTYPE",null),
                            new Parameter("@DOTASKSTATUS",null),
                            new Parameter("@MAILSTATUS",null),
                            new Parameter("@RTXSTATUS",null),
                            new Parameter("@APPFIELDVALUE",null),
                            new Parameter("@FLOWXML",null),
                            new Parameter("@APPXML",null),
                            new Parameter("@SYSTEMCODE",null),
                            new Parameter("@MODELCODE",null),
                            new Parameter("@MODELNAME",null),
                            new Parameter("@REMARK",null)
                        };
                    pageparm[0].ParameterValue = GetValue(Guid.NewGuid().ToString());//待办任务ID
                    pageparm[1].ParameterValue = GetValue(entity.COMPANYID);//公司ID
                    pageparm[2].ParameterValue = GetValue(entity.ORDERID);//单据ID
                    pageparm[3].ParameterValue = GetValue(entity.ORDERUSERID);//单据所属人ID
                    pageparm[4].ParameterValue = GetValue(entity.ORDERUSERNAME);//单据所属人名称
                    pageparm[5].ParameterValue = GetValue(entity.ORDERSTATUS);//单据状态

                    if (SourceValueDT != null)
                    {
                        foreach (DataRow dr in SourceValueDT.Rows)
                        {
                            if (!string.IsNullOrEmpty(dr["ColumnValue"].ToString().Trim()))
                            {
                                if (dr["ColumnName"].ToString().ToLower() == "appusername")
                                {
                                    string AppUserName = dr["ColumnValue"].ToString();
                                    pageparm[20].ParameterValue = AppUserName;//接收员工名,使用remark字段
                                }
                            }
                        }
                    }
                    #region 消息体
                    string XmlTemplete = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "\r\n" +
                                  "<System>" + "\r\n" +
                                  "{0}" +
                                  "</System>";

                    string strMsgBody = string.Empty;
                    string strMsgUrl = applicationUrl;
                    if (drs.Count() == 0)//如果没有设置消息,则构造默认消息:请审核xxx提交的"xxxx",
                    {
                        strMsgBody = "请审核[" + submitUserName + @"]提交的[" + ModeName + "]";
                        pageparm[6].ParameterValue = strMsgBody;//消息体
                        pageparm[7].ParameterValue = ReplaceLowerValue(strMsgUrl, SourceValueDT);//应用URL
                    }
                    else
                    {
                        DataRow dr1 = drs[0];
                        if (dr1["MESSAGEBODY"].ToString() == "")//默认消息为空
                        {
                            if (dr1 != null)
                            {
                                ModelMsgDefine(dr1["SYSTEMCODE"].ToString(), dr1["MODELCODE"].ToString(), entity.COMPANYID, ref strMsgBody, ref strMsgUrl);
                            }
                            if (string.IsNullOrEmpty(strMsgBody))
                            {
                                try
                                {
                                    DataRow[] drvList = SourceValueDT.Select("ColumnName='ModelName'");
                                    if (drvList.Count() == 1)
                                    {
                                        string value = drvList[0]["ColumnValue"].ToString();
                                        if (string.IsNullOrWhiteSpace(value))
                                        {
                                            value = drvList[0]["ColumnText"].ToString();
                                        }
                                        pageparm[6].ParameterValue = GetValue(value + "已审批通过");//消息体
                                    }
                                    else
                                    {
                                        pageparm[6].ParameterValue = GetValue(entity.ORDERID + "已审批通过");//消息体

                                    }
                                }
                                catch { }

                            }
                            else
                            {
                                pageparm[6].ParameterValue = GetValue(ReplaceMessageBody(strMsgBody, SourceValueDT));//消息体
                            }
                            string strUrl = string.Format(XmlTemplete, ReplaceValue(strMsgUrl, SourceValueDT));
                            Tracer.Debug("查询到得消息链接:" + strUrl + "单据ID:" + entity.ORDERID);
                            pageparm[7].ParameterValue = GetValue(strUrl);//应用URL
                        }
                        else//在引擎配置界面定义了消息内容
                        {
                            Tracer.Debug("Formid=" + entity.ORDERID + "开始 待办消息体:" + dr1["MESSAGEBODY"].ToString() + "\n\r 开始 打开待办连接的参数:" + dr1["APPLICATIONURL"].ToString());
                            string rowsValues = "Formid=" + entity.ORDERID + "\r\n";//每一行的值
                            for (int j = 0; j < SourceValueDT.Rows.Count; j++)
                            {
                                for (int i = 0; i < SourceValueDT.Columns.Count; i++)
                                {
                                    string columnName = SourceValueDT.Columns[i].ColumnName;
                                    rowsValues += columnName + "=" + SourceValueDT.Rows[j][columnName].ToString() + ";";
                                }
                                rowsValues += "\r\n";
                            }
                            Tracer.Debug("SourceValueDT表数据:" + rowsValues);
                            pageparm[6].ParameterValue = GetValue(ReplaceMessageBody(dr1["MESSAGEBODY"].ToString(), SourceValueDT));//消息体
                            pageparm[7].ParameterValue = GetValue(string.Format(XmlTemplete, ReplaceValue(dr1["APPLICATIONURL"].ToString(), SourceValueDT)));//应用URL
                            Tracer.Debug("Formid=" + entity.ORDERID + "最后 待办消息体:" + pageparm[6].ParameterValue + "\n\r 最后 打开待办连接的参数:" + pageparm[7].ParameterValue);
                        }
                    }
                    #endregion
                    pageparm[8].ParameterValue = GetValue(User);// GetValue(entity.RECEIVEUSERID);//接收用户ID
                    if (entity.BEFOREPROCESSDATE != null)//流程过期时间属性
                    {
                        //sql += "to_date('" + entity.BEFOREPROCESSDATE + "','YYYY-MM-DD hh24:mi:ss')";
                        pageparm[9].ParameterValue = GetValue(entity.BEFOREPROCESSDATE);//可处理时间(主要针对KPI考核)
                    }
                    else
                    {
                        if (drs.Count() > 0)//如果没有设置消息,则构造默认消息:请审核xxx提交的"xxxx",
                        {
                            DataRow dr1 = drs[0];
                            if (dr1["LASTDAYS"] != null)
                            {
                                if (string.IsNullOrEmpty(dr1["LASTDAYS"].ToString()))
                                {
                                    pageparm[9].ParameterValue = GetValue(DateTime.Now.AddDays(3));//可处理时间(主要针对KPI考核)
                                }
                                else
                                {
                                    pageparm[9].ParameterValue = GetValue(DateTime.Now.AddDays(int.Parse(dr1["LASTDAYS"].ToString())));//可处理时间(主要针对KPI考核)
                                }
                            }
                            else
                            {
                                pageparm[9].ParameterValue = GetValue(DateTime.Now.AddDays(3));
                            }
                        }
                    }
                    pageparm[10].ParameterValue = GetValue(0);//待办任务类型(0、待办任务、1、流程咨询、3 )
                    pageparm[11].ParameterValue = GetValue(0);//代办任务状态(0、未处理 1、已处理 、2、任务撤销 10、删除)
                    pageparm[12].ParameterValue = GetValue(0);//邮件状态(0、未发送 1、已发送、2、未知 )
                    pageparm[13].ParameterValue = GetValue(0);//RTX状态(0、未发送 1、已发送、2、未知 )
                    pageparm[14].ParameterValue = GetValue(strAPPFIELDVALUE);//应用字段值
                    pageparm[15].ParameterValue = GetValue(entity.FLOWXML);//流程XML
                    pageparm[16].ParameterValue = GetValue(entity.APPXML);//应用XML
                    pageparm[17].ParameterValue = GetValue(entity.SYSTEMCODE);//系统代码
                    pageparm[18].ParameterValue = GetValue(entity.MODELCODE);//模块代码
                    pageparm[19].ParameterValue = GetValue(entity.MODELNAME);//模块名称
                    //DataRow[] ModelCodeList = SourceValueDT.Select("ColumnName='ModelCode'");
                    //if (ModelCodeList.Count() == 1)
                    //{
                    //    sql += "'" + ModelCodeList[0]["ColumnValue"].ToString() + "')";
                    //}
                    //else
                    //{
                    //    sql += "'')";
                    //}
                    int result = dao.ExecuteNonQuery(insSql, pageparm);
                    if (result > 0)
                    {
                        Tracer.Debug("A新增待办任务AddDoTask (成功)  FormID=" + entity.ORDERID + " 接收人ID=" + User);
                    }
                    else
                    {
                        Tracer.Debug("A新增待办任务AddDoTask (失败)  FormID=" + entity.ORDERID + " 接收人ID=" + User);
                    }
                }

            }
            catch (Exception ex)
            {
                Tracer.Debug("A新增待办任AddDoTask (失败) FormID=" + entity.ORDERID + " 命名空间: SMT.FlowDAL.EnginFlowDAL 类方法:AddDoTask()" + ex.Message);
                throw new Exception("新增待办任失败 FormID=" + entity.ORDERID);
            }
        }
Exemplo n.º 14
0
        private bool EngineExecute(OracleConnection con, T_WF_DOTASK Entity, string IsTask, ref string ErroMessage)
        {
            bool result = false;
            EnginFlowDAL dal = new EnginFlowDAL();
            string strAppFieldValue = string.Empty;
            LogHelper.WriteLog("开始将数据源字段转换成数据表....");
            DataTable sourceTable = FieldStringToDataTable(Entity.APPFIELDVALUE, ref strAppFieldValue);//将业务数据与流程数据转换成DataTable作为替换的源数据
            LogHelper.WriteLog("结束将数据源字段转换成数据表");
            //通过系统代号,模块代号,企业ID,流程状态查到引擎配置内容

            LogHelper.WriteLog("开始通过系统代号,模块代号,企业ID,流程状态查到引擎配置内容....");
            DataTable dtFlowTrigger = dal.FlowTriggerTable(con, Entity.SYSTEMCODE, Entity.MODELCODE, Entity.ORDERSTATUS.ToString(), Entity.COMPANYID);
            LogHelper.WriteLog("结束通过系统代号,模块代号,企业ID,流程状态查到引擎配置内容");
            if (dtFlowTrigger == null || dtFlowTrigger.Rows.Count == 0)
            {

                dtFlowTrigger = dal.FlowTriggerTable(con, Entity.SYSTEMCODE, Entity.MODELCODE, Entity.ORDERSTATUS.ToString());
            }          
            LogHelper.WriteLog("数量:" + dtFlowTrigger.Rows.Count.ToString());
           
            if (dtFlowTrigger != null && dtFlowTrigger.Rows.Count > 0)
            {
                #region
                
                DataRow[] drs = dtFlowTrigger.Select("ISDEFAULTMSG=1");//发的是默认流程触发条件
                if (drs.Count() > 0)
                {
                    ErroMessage+="开始-发的是默认流程触发条件\r\n";
                    if (IsTask == "1")//新增待办任务
                    {
                        ErroMessage += "开始-新增待办任务\r\n";
                        dal.AddDoTask(con, Entity, drs[0], sourceTable, strAppFieldValue);//新增待办任务
                        ErroMessage += "结束-新增待办任务\r\n";
                    }
                    else if (IsTask == "0")//消息
                    {
                        ErroMessage += "开始-新增消息\r\n";
                        dal.AddDoTaskMessage(con, Entity, drs[0], sourceTable);
                        ErroMessage += "结束-新增消息\r\n";
                    }
                    ErroMessage += "结束-发的是默认流程触发条件\r\n";
                }
                
                DataRow[] NotDefaultMsg = dtFlowTrigger.Select("ISDEFAULTMSG=0");//非默认消息,需要调用的WCF待办任务
                if (NotDefaultMsg != null && NotDefaultMsg.Count() > 0)
                {
                    foreach (DataRow dr1 in NotDefaultMsg)
                    {
                        string strAppMsg = string.Empty;
                        ErroMessage += "开始-调用WCF服务\r\n";
                        CallWCFService(con, dr1, sourceTable, ref strAppMsg, ref  ErroMessage);//调用WCF服务
                        ErroMessage += "结束-调用WCF服务\r\n";
                        if (!string.IsNullOrEmpty(strAppMsg))
                        {
                            try
                            {
                                string IsNewFlow = "1";
                                string NewFormID = string.Empty;
                                string strFormTypes = string.Empty;//表单状态
                                DataRow DRNewTrigger = null;
                                if (ApplicationValueToDataTable(con, strAppMsg, string.Concat(Entity.COMPANYID), ref sourceTable, ref IsNewFlow, ref NewFormID, ref strFormTypes, ref DRNewTrigger))
                                {
                                    //通过岗位查找用户,并且取第一个用户为发送消息的对像
                                    PersonnelServiceClient HRClient = new PersonnelServiceClient();
                                    if (!string.IsNullOrEmpty(dr1["OWNERPOSTID"].ToString()))
                                    {
                                        string[] Employees = HRClient.GetEmployeeIDsByPostID(dr1["OWNERPOSTID"].ToString());
                                        if (Employees != null && Employees.Count() > 0)
                                        {
                                            dal.AddDoTask(con, Entity, dr1, sourceTable, Employees[0], NewFormID, strAppFieldValue, string.Concat(dr1["MESSAGEBODY"]), strFormTypes);//发送消息
                                        }
                                    }
                                    else
                                    {
                                        string cMessage = "引擎调用新流程时没有选定岗位 SystemCode:" + string.Concat(DRNewTrigger["SYSTEMCODE"]) + " MODELCODE:" + string.Concat(DRNewTrigger["MODELCODE"]) + " NewFormID:" + NewFormID;
                                        ErroMessage += cMessage;
                                        throw new Exception("命名空间:SMT.FlowWFService.EnginFlowBLL类方法:EngineExecute()引擎调用新流程时没有选定岗位");
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                LogHelper.WriteLog(ErroMessage);
                                throw new Exception("命名空间:SMT.FlowWFService.EnginFlowBLL类方法:EngineExecute()" + ex.Message);
                            }
                        }
                    }
                }
                result = true;
                #endregion
            }
            else
            {

                string strMsg = "系统代号" + Entity.SYSTEMCODE + "\r\n" +
                                 "模块代号:" + Entity.MODELCODE + "\r\n" +
                                 "触发条件:" + Entity.ORDERSTATUS +
                                 "公司ID:" + Entity.COMPANYID + "\r\n" +
                                 "单据ID:" + Entity.ORDERID;
                ErroMessage += "该单据所对应的引擎系统设置未找到,请先配置该模块引擎消息(审核通过、审核不通过、审核中):\r\n" + strMsg;
                LogHelper.WriteLog(ErroMessage);
                throw new Exception("该单据所对应的引擎系统设置未找到,请先配置该模块引擎消息(审核通过、审核不通过、审核中)" + strMsg);
            }
            return result;
        }
Exemplo n.º 15
0
        private bool SendDotask(string submitUserName, string modeName, string msgOpen, T_WF_DOTASK Entity, string IsTask, ref FlowUser sUser, ref string ErroMessage)
        {
            bool result = false;
            dal = new EnginFlowDAL();
            strAppFieldValue = string.Empty;
            //sUser.TrackingMessage+="开始将数据源字段转换成数据表 FORMID="+sUser.FormID+"r\n";
            //将业务数据与流程数据转换成DataTable作为替换的源数据
            sourceTable = FieldStringToDataTable(Entity.APPFIELDVALUE, ref strAppFieldValue);
            //sUser.TrackingMessage += "结束将数据源字段转换成数据表 FORMID=" + sUser.FormID + "r\n";
            //通过系统代号,模块代号,企业ID,流程状态查到引擎配置内容
            //Tracer.Debug("开始通过系统代号,模块代号,企业ID,流程状态查[消息规则]内容 FORMID=" + sUser.FormID + "");
            dtFlowTrigger = dal.FlowTriggerTable(Entity.SYSTEMCODE, Entity.MODELCODE, Entity.ORDERSTATUS.ToString(), Entity.COMPANYID);
            //Tracer.Debug("结束通过系统代号,模块代号,企业ID,流程状态查[消息规则]内容 FORMID=" + sUser.FormID + "");
            if (dtFlowTrigger == null || dtFlowTrigger.Rows.Count == 0)
            {
                //sUser.ErrorMsg += "没有找到[消息规则]内容 再次通过全局默认消息继续查找 FORMID=" + sUser.FormID + " 异常信息:" + ErroMessage + "\r\n";
                //Tracer.Debug("dtFlowTrigger=null或者dtFlowTrigger.Rows.Count == 0  没有找到[消息规则]内容 再次通过全局默认消息继续查找  FORMID=" + sUser.FormID + "");
                dtFlowTrigger = dal.FlowTriggerTable(Entity.SYSTEMCODE, Entity.MODELCODE, Entity.ORDERSTATUS.ToString());
            }
            //if (dtFlowTrigger != null && dtFlowTrigger.Rows.Count > 0)
            //{
            //}
            //else
            //{
            //    //string strMsg =  "系统代号:" + Entity.SYSTEMCODE + "\r\n" +
            //    //                 "模块代号:" + Entity.MODELCODE + "\r\n" +
            //    //                 "触发条件:" + Entity.ORDERSTATUS + "\r\n" +
            //    //                 "公司 ID:" + Entity.COMPANYID + "\r\n" +
            //    //                 "单据 ID:" + Entity.ORDERID;
            //    //ErroMessage = "FORMID=" + sUser.FormID + " 发送待办任务失败, 该单据所对应的[消息规则]设置未找到,请先配置公司[" + sUser.CompayName+ "("+sUser.CompayID+")] 下的模块[ " + sUser.ModelName + " ]的 [消息规则](审核通过、审核不通过、审核中):\r\n" + strMsg;
            //    //sUser.ErrorMsg += "发送待办任务失败 FORMID=" + sUser.FormID + " 异常信息:" + ErroMessage + "\r\n";
            //    //Tracer.Debug(ErroMessage);
            //    //暂是没有默认消息也可以审核通过
            //   // throw new Exception("该单据所对应的引擎系统设置未找到,请先配置该模块 " + sUser.ModelName + " 引擎消息(审核通过、审核不通过、审核中)");
            //}

            #region 发送待办任务(不管有没有配置消息规则,都发送待办任务)
            DataRow[] drs = new DataRow[] { };
            if (dtFlowTrigger != null && dtFlowTrigger.Rows.Count > 0)
            {
                drs = dtFlowTrigger.Select("ISDEFAULTMSG=1");//不管有没有配置
            }
            //edit by ken 2015-7-17
            //if (drs.Count() > 0)
            //{
            //sUser.ErrorMsg += "发现默认流程触发[消息规则]内容 FORMID=" + sUser.FormID + " IsTask:" + IsTask.ToString() + "\r\n";
            //Tracer.Debug("FORMID=" + sUser.FormID + " 发现默认流程触发消息规则 IsTask=" + IsTask.ToString());
            //if (IsTask == "1")//新增待办任务
            //{
            dal.AddDoTask(Entity, drs, sourceTable, strAppFieldValue, submitUserName, modeName, msgOpen);//新增待办任务
            //FlowEngine.TaskCacheReflesh(Entity.RECEIVEUSERID);
            //}
            //else if (IsTask == "0")//消息
            //{
            //dal.AddDoTaskMessage(Entity, drs[0], sourceTable);
            //}
            //}
            //else
            //{
            //    sUser.ErrorMsg += "没有发现默认流程触发(审核通过、审核不通过、审核中)[消息规则]内容 FORMID=" + sUser.FormID + " IsTask:" + IsTask.ToString() + "\r\n";
            //    Tracer.Debug("FORMID=" + sUser.FormID + " 没有发现默认流程触发(审核通过、审核不通过、审核中)消息规则 ");
            //    //throw new Exception("该单据所对应的默认[消息规则]设置未找到,请先配置该模块 " + sUser.ModelName + " 默认消息规则(审核通过、审核不通过、审核中)");
            //}
            //end edit by ken 2015-7-17
            DataRow[] NotDefaultMsg = dtFlowTrigger.Select("ISDEFAULTMSG=0");//非默认消息,需要调用的WCF待办任务
            if (NotDefaultMsg != null && NotDefaultMsg.Count() > 0)
            {
                //AutoCallFlow(  dal,Entity,dtFlowTrigger,sourceTable, ref  sUser, strAppFieldValue, ref ErroMessage);
                #region 非默认消息时,自动发起流程
                //foreach (DataRow dr1 in NotDefaultMsg)
                //{
                //    string strAppMsg = string.Empty;
                //    CallWCFService( dr1, sourceTable, ref sUser, ref strAppMsg, ref  ErroMessage);//调用WCF服务
                //    if (!string.IsNullOrEmpty(strAppMsg))
                //    {
                //        try
                //        {
                //            string IsNewFlow = "1";
                //            string NewFormID = string.Empty;
                //            string strFormTypes = string.Empty;//表单状态
                //            DataRow DRNewTrigger = null;
                //            if (ApplicationValueToDataTable( strAppMsg, string.Concat(Entity.COMPANYID), ref sourceTable, ref IsNewFlow, ref NewFormID, ref strFormTypes, ref DRNewTrigger))
                //            {
                //                //通过岗位查找用户,并且取第一个用户为发送消息的对像

                //                PersonnelServiceClient HRClient = new PersonnelServiceClient();
                //                if (!string.IsNullOrEmpty(dr1["OWNERPOSTID"].ToString()))
                //                {
                //                    string[] Employees = HRClient.GetEmployeeIDsByPostID(dr1["OWNERPOSTID"].ToString());
                //                    if (Employees != null && Employees.Count() > 0)
                //                    {
                //                        dal.AddDoTask( Entity, dr1, sourceTable, Employees[0], NewFormID, strAppFieldValue, string.Concat(dr1["MESSAGEBODY"]), strFormTypes);//发送消息
                //                    }
                //                }
                //                else
                //                {
                //                    string cMessage = "引擎调用新流程时没有选定岗位 SystemCode:" + string.Concat(DRNewTrigger["SYSTEMCODE"]) + " MODELCODE:" + string.Concat(DRNewTrigger["MODELCODE"]) + " NewFormID:" + NewFormID;
                //                    ErroMessage = cMessage;

                //                    throw new Exception("命名空间:SMT.FlowWFService.EnginFlowBLL类方法:EngineExecute()引擎调用新流程时没有选定岗位");
                //                }
                //            }
                //        }
                //        catch (Exception ex)
                //        {
                //            throw new Exception("命名空间:SMT.FlowWFService.EnginFlowBLL类方法:EngineExecute() FORMID=" + sUser.FormID + "" + ex.Message);
                //        }
                //    }
                //}
                #endregion
            }
            result = true;
            #endregion

            return result;
        }
Exemplo n.º 16
0
        /// <summary>
        /// 流程触发
        /// </summary>
        /// <param name="strFlow">流程数据</param>
        /// <param name="strBusiness">业务数据</param>    
        /// <returns></returns>
        public bool SaveFlowTriggerData(OracleConnection con, string strFlow, string strBusiness, ref string ErroMessage)
        {
            
            T_WF_DOTASK entity = new T_WF_DOTASK();
            string strEntityType = string.Empty;//EntityType (表名)
            string strEntityKey = string.Empty;//EntityKey (主键)
            string IsTask = "1";//是否任务
            #region 获取 SystemCode
            string SystemCode = "";
            Byte[] bFlow = System.Text.UTF8Encoding.UTF8.GetBytes(strFlow);
            XElement xeFlow = XElement.Load(System.Xml.XmlReader.Create(new MemoryStream(bFlow)));
            var strReturn = from item in xeFlow.Descendants("SystemCode")
                               select item;
            if (strReturn.FirstOrDefault() != null)
            {
                SystemCode=strReturn.FirstOrDefault().Value.Replace("\"", "");
            }
            #endregion
            try
            {
                try
                {
                    //消息解析
                    //LogHelper.WriteLog("strFlow:\r\n" + strFlow);
                    //LogHelper.WriteLog("strBusiness:\r\n" + strBusiness);
                    LogHelper.WriteLog("开始消息解析");
                    #region 龙康才新增
                    #region XmlReader
                    #region strFlow
                    //Byte[] BytebFlow = System.Text.UTF8Encoding.UTF8.GetBytes(strFlow);

                    //XmlReader xr = XmlReader.Create(new MemoryStream(BytebFlow));
                    //StringBuilder _ConbinString = new StringBuilder();
                    StringReader strRdr = new StringReader(strFlow);
                    XmlReader xr = XmlReader.Create(strRdr);
                    StringBuilder _ConbinString = new StringBuilder();
                    while (xr.Read())
                    {
                        if (xr.NodeType == XmlNodeType.Element)
                        {
                            string elementName = xr.Name;
                            if (elementName == "Message")
                            {
                                while (xr.Read())
                                {
                                    string type = xr.NodeType.ToString();
                                    #region

                                    if (xr["Name"] != null)
                                    {
                                        _ConbinString.Append(xr["Name"] + "|" + xr["DataValue"] + "Ё");
                                        if (xr["Name"].ToUpper() == "COMPANYID")
                                        {
                                            entity.COMPANYID = xr["DataValue"];
                                        }
                                        if (xr["Name"].ToUpper() == "MODELCODE")
                                        {
                                            entity.MODELCODE = xr["DataValue"];
                                        }
                                        if (xr["Name"].ToUpper() == "MODELNAME")
                                        {
                                            entity.MODELNAME = xr["DataValue"];
                                        }
                                        if (xr["Name"].ToUpper() == "FORMID")
                                        {
                                            entity.ORDERID = xr["DataValue"];
                                        }
                                        if (xr["Name"].ToUpper() == "CHECKSTATE")
                                        {
                                            entity.ORDERSTATUS = int.Parse(xr["DataValue"]);
                                        }
                                        if (xr["Name"].ToUpper() == "APPUSERID")
                                        {
                                            entity.RECEIVEUSERID = xr["DataValue"];
                                        }
                                        if (xr["Name"].ToUpper() == "ISTASK")
                                        {
                                            IsTask = xr["DataValue"];
                                        }
                                        if (xr["Name"].ToUpper() == "OUTTIME")
                                        {

                                            if (!string.IsNullOrEmpty(xr["DataValue"]))
                                            {
                                                entity.BEFOREPROCESSDATE = DateTime.Now.AddMinutes(int.Parse(xr["DataValue"]));
                                            }
                                        }
                                    }
                                    #endregion
                                }
                            }
                        }
                        entity.FLOWXML = strFlow;
                        entity.APPXML = strBusiness;
                    }
                    #endregion
                    #region strBusiness
                    if (!string.IsNullOrEmpty(strBusiness))
                    {
                        StringReader rd = new StringReader(strBusiness);
                        XmlReader xdr = XmlReader.Create(rd);
                        StringBuilder BOObject = new StringBuilder();
                        while (xdr.Read())
                        {
                            if (xdr.NodeType == XmlNodeType.Element)
                            {
                                string elementName = xdr.Name;
                                if (elementName == "Name")
                                {
                                    while (xdr.Read())
                                    {
                                        entity.SYSTEMCODE = xdr.Value;
                                        break;
                                    }
                                }
                                if (elementName == "Object")
                                {
                                    try
                                    { //非手机的XML时没有表明和主键的
                                        strEntityType = xdr["Name"];
                                        strEntityKey = xdr["Key"];
                                    }
                                    catch
                                    {
                                        LogHelper.WriteLog("异常无法取得业务数据表,单据:" + entity.ORDERID + ":表:" + strEntityType + ":主键:" + strEntityKey + "");
                                    }
                                    while (xdr.Read())
                                    {
                                        if (xdr.Name == "Attribute")
                                        {
                                            if (xdr["Name"] != null)
                                            {
                                                BOObject.Append(xdr["Name"] + "|" + xdr["DataValue"] + "Г" + (xdr["DataText"] != null ? xdr["DataText"] : xdr["DataValue"]) + "Ё");
                                                #region
                                                if (xdr["Name"].ToUpper() == "OWNERID")
                                                {
                                                    entity.ORDERUSERID = xdr["DataValue"];
                                                }
                                                if (xdr["Name"].ToUpper() == "OWNERNAME")
                                                {
                                                    entity.ORDERUSERNAME = xdr["DataValue"];
                                                }
                                                if (xdr["Name"].ToUpper() == "CREATEUSERID")
                                                {
                                                    //有些特殊的模块需要改变接收人
                                                    if (CheckModelName(entity.MODELCODE) && entity.ORDERSTATUS == 2)
                                                    {
                                                        entity.RECEIVEUSERID = xdr["DataValue"];
                                                    }
                                                }

                                                #endregion
                                            }
                                           
                                        }
                                    }
                                }
                            }
                        }
                        entity.APPFIELDVALUE = _ConbinString.ToString() + BOObject.ToString().TrimEnd('Ё');

                    }
                    #endregion
                    #endregion
                    #endregion
                    #region 原有旧代码

                    //Byte[] bFlow = System.Text.UTF8Encoding.UTF8.GetBytes(strFlow);
                    //XElement xeFlow = XElement.Load(System.Xml.XmlReader.Create(new MemoryStream(bFlow)));
                    //entity.COMPANYID = XMLToAttribute(xeFlow, "COMPANYID");
                    //entity.MODELCODE = XMLToAttribute(xeFlow, "MODELCODE");
                    //entity.MODELNAME = XMLToAttribute(xeFlow, "ModelName");
                    //entity.ORDERID = XMLToAttribute(xeFlow, "FORMID");
                    //entity.ORDERSTATUS = int.Parse(XMLToAttribute(xeFlow, "CheckState"));
                    //entity.RECEIVEUSERID = XMLToAttribute(xeFlow, "APPUSERID");
                    //entity.FLOWXML = strFlow;
                    //entity.APPXML = strBusiness;
                    //IsTask = XMLToAttribute(xeFlow, "IsTask");
                    //if (!string.IsNullOrEmpty(XMLToAttribute(xeFlow, "OutTime")))
                    //{
                    //    entity.BEFOREPROCESSDATE = DateTime.Now.AddMinutes(int.Parse(XMLToAttribute(xeFlow, "OutTime")));
                    //}
                    //if (!string.IsNullOrEmpty(strBusiness))
                    //{
                    //    Byte[] BBusiness = System.Text.UTF8Encoding.UTF8.GetBytes(strBusiness);
                    //    XElement xeBusiness = XElement.Load(System.Xml.XmlReader.Create(new MemoryStream(BBusiness)));
                    //    entity.SYSTEMCODE = (from item in xeBusiness.Descendants("Name") select item).FirstOrDefault().Value;
                    //    try
                    //    { //非手机的XML时没有表明和主键的
                    //        strEntityType = (from item in xeBusiness.Descendants("Object") select item).FirstOrDefault().Attribute("Name").Value;
                    //        strEntityKey = (from item in xeBusiness.Descendants("Object") select item).FirstOrDefault().Attribute("Key").Value;
                    //    }
                    //    catch
                    //    {
                    //        LogHelper.WriteLog("异常无法取得业务数据表,单据:" + entity.ORDERID + ":表:" + strEntityType + ":主键:" + strEntityKey + "");
                    //    }
                    //    entity.ORDERUSERID = (from item in xeBusiness.Descendants("Object").Descendants("Attribute")
                    //                          where item.Attribute("Name").Value.ToUpper() == "OWNERID"
                    //                          select item).FirstOrDefault().Attribute("DataValue").Value;
                    //    entity.ORDERUSERNAME = (from item in xeBusiness.Descendants("Object").Descendants("Attribute")
                    //                            where item.Attribute("Name").Value.ToUpper() == "OWNERNAME"
                    //                            select item).FirstOrDefault().Attribute("DataValue").Value;
                    //    //有些特殊的模块需要改变接收人
                    //    if (CheckModelName(entity.MODELCODE) && entity.ORDERSTATUS == 2)
                    //    {
                    //        entity.RECEIVEUSERID = (from item in xeBusiness.Descendants("Object").Descendants("Attribute")
                    //                                where item.Attribute("Name").Value.ToUpper() == "CREATEUSERID"
                    //                                select item).FirstOrDefault().Attribute("DataValue").Value;
                    //    }
                    //    entity.APPFIELDVALUE = ConbinString(xeFlow) + BOObjectEscapeString(strBusiness);
                    //}
                    #endregion
                    LogHelper.WriteLog("结束消息解析");
                }
                catch (Exception ex)
                {
                    LogHelper.WriteLog("命名空间:SMT.FlowWFService.EnginFlowBLL 类方法SaveFlowTriggerData()解析XML出错" + ex.Message);

                    throw new Exception(ErroMessage);                   
                }
                if (string.IsNullOrEmpty(entity.SYSTEMCODE))
                {
                    entity.SYSTEMCODE = SystemCode;
                }
                bool IsExecute = EngineExecute(con, entity, IsTask, ref  ErroMessage);
                LogHelper.WriteLog("执行EngineExecute(" + con + ", " + entity + ", " + IsTask + ", ref  " + ErroMessage + ")返回值IsExecute=" + IsExecute.ToString());
                if (IsExecute)
                {
                    try
                    {
                        LogHelper.WriteLog("开始更新业务系统单据审核状态Config.IsNeedUpdateAudit=" + Config.IsNeedUpdateAudit.ToString());
                        /****************更新业务系统单据审核状态***********************/
                        if (Config.IsNeedUpdateAudit)//是否执行更新审核状态
                        {
                            if (!string.IsNullOrEmpty(entity.SYSTEMCODE) && !string.IsNullOrEmpty(strEntityType) && !string.IsNullOrEmpty(strEntityKey))
                            {
                               LogHelper.WriteLog("UpdateAuditStatus开始更新...FORMID=" + entity.ORDERID + "");
                               bool bol= UpdateAuditStatus(entity.SYSTEMCODE, strEntityType, strEntityKey, entity.ORDERID, entity.ORDERSTATUS.ToString(),ref ErroMessage);
                               LogHelper.WriteLog("UpdateAuditStatus结束更新...FORMID=" + entity.ORDERID + "");
                                if (!bol)
                               {
                                   throw new Exception(ErroMessage); //抛出异常终止执行流程 
                                  
                               }
                            }
                        }
                        LogHelper.WriteLog("结束更新业务系统单据审核状态");
                    }
                    catch (Exception ex)
                    {
                        LogHelper.WriteLog("命名空间:SMT.FlowWFService.EnginFlowBLL 类方法SaveFlowTriggerData()更新审核状态出现异常" + ex.Message);

                        throw new Exception(ErroMessage); 
                    }
                }
                //LogHelper.WriteLog("流程触发存储记录SaveFlowTriggerDataFlowXML:" + strFlow + "\r\n" + "AppXml:" + strBusiness + "\r\n");
                return IsExecute;
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("命名空间:SMT.FlowWFService.EnginFlowBLL 类方法SaveFlowTriggerData()" + ex.Message);
                throw new Exception(ErroMessage); //抛出异常终止执行流程                
                
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// 流程触发
        /// </summary>
        /// <param name="strFlow">流程数据</param>
        /// <param name="strBusiness">业务数据</param>    
        /// <returns></returns>
        public bool SaveFlowTriggerData( SubmitData submitData, string strFlow, string strBusiness, ref FlowUser sUser, ref string ErroMessage)
        {
            string tmpFlow = "";
            string tmpEngline = "";
            T_WF_DOTASK entity = new T_WF_DOTASK();
            string strEntityType = string.Empty;//EntityType (表名)
            string strEntityKey = string.Empty;//EntityKey (主键)
            string IsTask = "1";//是否任务

            #region 获取 SystemCode
            string SystemCode = "";
            //Byte[] bFlow = System.Text.UTF8Encoding.UTF8.GetBytes(strFlow);
            //XElement xeFlow = XElement.Load(System.Xml.XmlReader.Create(new MemoryStream(bFlow)));
            //var strReturn = from item in xeFlow.Descendants("SystemCode")
            //                   select item;
            //if (strReturn.FirstOrDefault() != null)
            //{
            //    SystemCode=strReturn.FirstOrDefault().Value.Replace("\"", "");
            //}
            SystemCode = string.Empty;
            string modeCode=string.Empty;
            string modeName=string.Empty;
            string msgOpen= string.Empty;

            SetFileFromBusinessXml(strBusiness, ref SystemCode, ref modeCode, ref modeName,ref strEntityKey, ref msgOpen);

            strEntityType = modeCode;
            entity.SYSTEMCODE = SystemCode;

            #endregion

            try
            {
                try
                {
                    //消息解析
                    //Tracer.Debug("strFlow:\r\n" + strFlow);
                    //Tracer.Debug("strBusiness:\r\n" + strBusiness);
                    string xmlred = "  开始消息解析XML\r\n";
                    xmlred += "FlowXML=" + strFlow+"\r\n";
                    xmlred += "AppXML=" + strBusiness + "\r\n";
                    #region 提莫科技新增

                    #region strFlow
                    StringReader strRdr = new StringReader(strFlow);
                    XmlReader xr = XmlReader.Create(strRdr);
                    StringBuilder _ConbinString = new StringBuilder();
                    while (xr.Read())
                    {
                        if (xr.NodeType == XmlNodeType.Element)
                        {
                            string elementName = xr.Name;
                            if (elementName == "Message")
                            {
                                while (xr.Read())
                                {
                                    string type = xr.NodeType.ToString();
                                    #region

                                    if (xr["Name"] != null)
                                    {
                                        _ConbinString.Append(xr["Name"] + "|" + xr["DataValue"] + "Ё");
                                        tmpFlow += xr["Name"] + "|" + xr["DataValue"] + "Ё\r\n";
                                        if (xr["Name"].ToUpper() == "COMPANYID")
                                        {
                                            entity.COMPANYID = xr["DataValue"];
                                        }
                                        if (xr["Name"].ToUpper() == "MODELCODE")
                                        {
                                            entity.MODELCODE = xr["DataValue"];
                                        }
                                        if (xr["Name"].ToUpper() == "MODELNAME")
                                        {
                                            entity.MODELNAME = xr["DataValue"];
                                        }
                                        if (xr["Name"].ToUpper() == "FORMID")
                                        {
                                            entity.ORDERID = xr["DataValue"];
                                        }
                                        if (xr["Name"].ToUpper() == "CHECKSTATE")
                                        {
                                            entity.ORDERSTATUS = int.Parse(xr["DataValue"]);
                                        }
                                        if (xr["Name"].ToUpper() == "APPUSERID")
                                        {
                                            entity.RECEIVEUSERID = xr["DataValue"];
                                        }
                                        if (xr["Name"].ToUpper() == "ISTASK")
                                        {
                                            IsTask = xr["DataValue"];
                                        }
                                        if (xr["Name"].ToUpper() == "OUTTIME")
                                        {

                                            if (!string.IsNullOrEmpty(xr["DataValue"]))
                                            {
                                                entity.BEFOREPROCESSDATE = DateTime.Now.AddMinutes(int.Parse(xr["DataValue"]));
                                            }
                                        }
                                    }
                                    #endregion
                                }
                            }
                        }
                    }
                    entity.FLOWXML = strFlow;
                    entity.APPXML = strBusiness;
                    #endregion

                    #region strBusiness
                    if (!string.IsNullOrEmpty(strBusiness))
                    {
                        StringReader rd = new StringReader(strBusiness);
                        XmlReader xdr = XmlReader.Create(rd);
                        StringBuilder BOObject = new StringBuilder();
                        while (xdr.Read())
                        {
                            if (xdr.NodeType == XmlNodeType.Element)
                            {
                                string elementName = xdr.Name;
                                if (elementName == "Object")
                                {
                                    while (xdr.Read())
                                    {
                                        if (xdr.Name == "Attribute")
                                        {
                                            if (xdr["Name"] != null)
                                            {
                                                BOObject.Append(xdr["Name"] + "|" + xdr["DataValue"] + "Г" + (xdr["DataText"] != null ? xdr["DataText"] : xdr["DataValue"]) + "Ё");
                                                tmpEngline += xdr["Name"] + "|" + xdr["DataValue"] + "Г" + (xdr["DataText"] != null ? xdr["DataText"] : xdr["DataValue"]) + "Ё\r\n";
                                                #region
                                                if (xdr["Name"].ToUpper() == "OWNERID")
                                                {
                                                    entity.ORDERUSERID = xdr["DataValue"];
                                                }
                                                if (xdr["Name"].ToUpper() == "OWNERNAME")
                                                {
                                                    entity.ORDERUSERNAME = xdr["DataValue"];
                                                }
                                                if (xdr["Name"].ToUpper() == "CREATEUSERID")
                                                {
                                                    //有些特殊的模块需要改变接收人
                                                    if (CheckModelName(entity.MODELCODE) && entity.ORDERSTATUS == 2)
                                                    {
                                                        entity.RECEIVEUSERID = xdr["DataValue"];
                                                    }
                                                }
                                                #endregion
                                            }

                                        }
                                    }
                                }
                            }
                        }
                        entity.APPFIELDVALUE = _ConbinString.ToString() + BOObject.ToString().TrimEnd('Ё');

                    }
                    #endregion

                    #endregion

                    xmlred+="FormID=" + entity.ORDERID+"  结束消息解析XML";
                    Tracer.Debug("FormID=" + entity.ORDERID + xmlred);
                }
                catch (Exception ex)
                {

                    sUser.ErrorMsg += "命名空间:SMT.FlowWFService.EnginFlowBLL 类方法SaveFlowTriggerData()解析XML出错!FORMID=" + sUser.FormID + " 异常信息:" + ex.ToString() + "\r\n";
                    ErroMessage = "命名空间:SMT.FlowWFService.EnginFlowBLL 类方法SaveFlowTriggerData()解析XML出错";
                    throw new Exception("命名空间:SMT.FlowWFService.EnginFlowBLL 类方法SaveFlowTriggerData()解析XML出错" + ex.Message);
                }
                if (string.IsNullOrEmpty(entity.SYSTEMCODE))
                {
                    entity.SYSTEMCODE = SystemCode;
                }
                //思路:
                //1、先检验流程的默认消息
                //2、调用业务系统更新
                //3、自动发起流程
                bool IsExecute = SendDotask(submitData.SumbitUserName,modeName,msgOpen, entity, IsTask,ref sUser, ref ErroMessage);
                if (IsExecute)
                {
                    bool isOK = CallBusinessSystem(submitData,entity, strEntityKey, ref ErroMessage);//调用业务系统
                    if (!isOK)
                    {
                        throw new Exception(ErroMessage);//把业务系统的错误信息给客户端
                    }
                    AutoCallFlow( dal, entity, dtFlowTrigger, sourceTable, ref  sUser, strAppFieldValue, ref ErroMessage);
                }
                else
                {
                    Tracer.Debug("没有默认消息,也调用业务系统更新(没有待办任务产生) FORMID=" + sUser.FormID + " 异常信息:" + ErroMessage);
                    CallBusinessSystem(submitData,entity, strEntityKey, ref ErroMessage);//调用业务系统
                }
                return IsExecute;
            }
            catch (Exception ex)
            {
                sUser.ErrorMsg += "命名空间:SMT.FlowWFService.EnginFlowBLL 类方法SaveFlowTriggerData()!FORMID=" + sUser.FormID + " 异常信息:" + ex.ToString() + "\r\n";
                throw new Exception("命名空间:SMT.FlowWFService.EnginFlowBLL 类方法SaveFlowTriggerData()" + ex.Message);
            }
        }
Exemplo n.º 18
0
 public void AddTask(T_WF_DOTASK dask)
 {
     try
     {
         EngineServicesDAL dal = new EngineServicesDAL();
         if (string.IsNullOrWhiteSpace(dask.DOTASKID))
         {
             dask.DOTASKID = Guid.NewGuid().ToString();
         }
         if (string.IsNullOrWhiteSpace(dask.ORDERID))
         {
             throw new Exception("单据ID不能为空");
         }
         if (string.IsNullOrWhiteSpace(dask.RECEIVEUSERID))
         {
             throw new Exception("接收人ID不能为空");
         }
         TaskCache.TaskCacheReflesh(dask.RECEIVEUSERID);
         dal.AddTask(dask);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message, ex);
     }
 }
Exemplo n.º 19
0
        /// <summary>
        /// 非默认消息时,自动发起流程
        /// </summary>
        private void AutoCallFlow( EnginFlowDAL dal, T_WF_DOTASK Entity, DataTable dtFlowTrigger, DataTable sourceTable, ref FlowUser sUser,string strAppFieldValue, ref string ErroMessage)
        {
            DataRow[] NotDefaultMsg = dtFlowTrigger.Select("ISDEFAULTMSG=0");//非默认消息,需要调用的WCF待办任务
            if (NotDefaultMsg != null && NotDefaultMsg.Count() > 0)
            {
                #region 非默认消息时,自动发起流程
                foreach (DataRow dr1 in NotDefaultMsg)
                {
                    string strAppMsg = string.Empty;
                    CallWCFService( dr1, sourceTable, ref sUser, ref strAppMsg, ref  ErroMessage);//调用WCF服务
                    if (!string.IsNullOrEmpty(strAppMsg))
                    {
                        #region 执行自动发起流程结果返回不为空
                        try
                        {
                            string IsNewFlow = "1";
                            string NewFormID = string.Empty;
                            string strFormTypes = string.Empty;//表单状态
                            DataRow DRNewTrigger = null;
                            if (ApplicationValueToDataTable( strAppMsg, string.Concat(Entity.COMPANYID), ref sourceTable, ref IsNewFlow, ref NewFormID, ref strFormTypes, ref DRNewTrigger))
                            {
                                //通过岗位查找用户,并且取第一个用户为发送消息的对像

                                //PersonnelServiceClient HRClient = new PersonnelServiceClient();
                                if (!string.IsNullOrEmpty(dr1["OWNERPOSTID"].ToString()))
                                {
                                    if (DRNewTrigger != null)
                                    {
                                        Tracer.Debug("自动发起流程 消息规则设置中 选定岗位=" + dr1["OWNERPOSTID"].ToString() + " ;消息=" + string.Concat(dr1["MESSAGEBODY"]) + ":MODELCODE=" + string.Concat(DRNewTrigger["MODELCODE"]) + ";AutoCallFlow() FORMID=" + sUser.FormID);
                                    }
                                    else
                                    {
                                        Tracer.Debug("DRNewTrigger=null 自动发起流程的第三方消息规则中没有设置没有消息规则,当前的模块消息规则设置中 选定岗位=" + dr1["OWNERPOSTID"].ToString() + " ;消息=" + string.Concat(dr1["MESSAGEBODY"]) + ":MODELCODE=null;AutoCallFlow() FORMID=" + sUser.FormID);
                                    }
                                    List<string> Employees = new List<string>();// HRClient.GetEmployeeIDsByPostID(dr1["OWNERPOSTID"].ToString());

                                    using (EmployeeBLL bll = new EmployeeBLL())
                                    {
                                        var q = bll.GetEmployeeIDsByPostID(dr1["OWNERPOSTID"].ToString());
                                        Employees= q.Count() > 0 ? q.ToList() : null;
                                    }
                                    if (Employees != null && Employees.Count() > 0)
                                    {
                                        Entity.SYSTEMCODE = dr1["SYSTEMCODE"].ToString();//解决傅意成遇到的问题(发起员工入职手续的待办,数据库中数据存在问题,系统代号是错误的RM代号,应是HR代号)
                                        dal.AddDoTask( Entity, dr1, sourceTable, Employees[0], NewFormID, strAppFieldValue, string.Concat(dr1["MESSAGEBODY"]), strFormTypes);//发送消息
                                        //FlowEngine.TaskCacheReflesh(Employees[0]);
                                    }
                                }
                                else
                                {
                                    string cMessage = "";
                                    if (DRNewTrigger != null)
                                    {
                                        cMessage = "SystemCode:" + string.Concat(DRNewTrigger["SYSTEMCODE"]) + " MODELCODE:" + string.Concat(DRNewTrigger["MODELCODE"]) + " ;消息=" + string.Concat(dr1["MESSAGEBODY"]) + " NewFormID:" + NewFormID;
                                    }
                                    else
                                    {
                                        cMessage = "DRNewTrigger=null 消息=" + string.Concat(dr1["MESSAGEBODY"]) + " NewFormID:" + NewFormID;
                                    }
                                    //string cMessage = "SystemCode:" + string.Concat(DRNewTrigger["SYSTEMCODE"]) + " MODELCODE:" + string.Concat(DRNewTrigger["MODELCODE"]) + " ;消息=" + string.Concat(dr1["MESSAGEBODY"]) + " NewFormID:" + NewFormID;
                                    ErroMessage = cMessage;

                                    if (DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_oa_businesstrip" ||
                                        DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_oa_businessreport" ||
                                        DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_hr_salaryrecordbatch" ||
                                        DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_hr_attendancesolutionasign" ||
                                        DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_hr_attendancesolution" ||
                                        DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_hr_employeesalaryrecord" ||
                                        DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_hr_employeeentry" ||
                                        DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_hr_leftoffice" ||
                                        DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_oa_travelreimbursement" ||
                                        DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_hr_leftofficeconfirm"
                                        )
                                    {//不需要接收岗位的:
                                        //出差申请	T_OA_BUSINESSTRIP
                                        //出差报告	T_OA_BUSINESSREPORT
                                        //月薪批量审核	T_HR_SALARYRECORDBATCH
                                        //考勤方案分配	T_HR_ATTENDANCESOLUTIONASIGN
                                        //考勤方案定义	T_HR_ATTENDANCESOLUTION
                                        //薪资记录	T_HR_EMPLOYEESALARYRECORD
                                        //员工入职	T_HR_EMPLOYEEENTRY
                                        //员工离职	T_HR_LEFTOFFICE
                                        //离职确认	T_HR_LEFTOFFICECONFIRM
                                        //出差报销 T_OA_TRAVELREIMBURSEMENT
                                        Tracer.Debug("自动发起流程 消息规则中非默认的设置中 不需要 选定岗位: AutoCallFlow() FORMID=" + sUser.FormID + "   " + cMessage);
                                    }
                                    else
                                    {
                                        Tracer.Debug("自动发起流程(失败) 消息规则中非默认的设置中没有选定岗位:AutoCallFlow() FORMID=" + sUser.FormID + "   " + cMessage);
                                        throw new Exception("自动发起流程(失败) 消息规则中非默认的设置中没有选定岗位 \r\n FORMID=" + sUser.FormID);
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Tracer.Debug("自动发起流程(失败):消息规则中非默认的设置中检查选定岗位出错 消息=" + string.Concat(dr1["MESSAGEBODY"]) + " AutoCallFlow() FORMID=" + sUser.FormID + " 异常信息:\r\n" + ex.Message);
                            throw new Exception("自动发起流程(失败):消息规则中非默认的设置中检查选定岗位出错 \r\n FORMID=" + sUser.FormID);
                        }
                        #endregion
                    }
                    else
                    {
                        Tracer.Debug("自动发起流程成功,但返回的结果为空 消息规则设置中 ;选定岗位=" + dr1["OWNERPOSTID"].ToString() + " ;消息=" + string.Concat(dr1["MESSAGEBODY"]) + ";MODELCODE=" + string.Concat(dr1["MODELCODE"]) + ":AutoCallFlow() FORMID=" + sUser.FormID);
                    }
                }
                #endregion
            }
        }
Exemplo n.º 20
0
        private bool EngineExecute(T_WF_DOTASK Entity, string IsTask)
        {
            bool result = false;
            EngineServicesDAL dal = new EngineServicesDAL();
            string strAppFieldValue = string.Empty;
            DataTable sourceTable = Common.FieldStringToDataTable(Entity.APPFIELDVALUE, ref strAppFieldValue);//将业务数据与流程数据转换成DataTable作为替换的源数据
            //通过系统代号,模块代号,企业ID,流程状态查到引擎配置内容

            DataTable dtFlowTrigger = dal.FlowTriggerTable(Entity.SYSTEMCODE, Entity.MODELCODE, Entity.ORDERSTATUS.ToString(), Entity.COMPANYID);
            if (dtFlowTrigger != null && dtFlowTrigger.Rows.Count > 0)
            {
                #region
                DataRow[] drs = dtFlowTrigger.Select("ISDEFAULTMSG=1");//发的是默认流程触发条件
                if (drs.Count() > 0)
                {
                    if (IsTask == "1")//新增待办任务
                    {
                        TaskCache.TaskCacheReflesh(Entity.RECEIVEUSERID);
                        dal.AddDoTask(Entity, drs[0], sourceTable, strAppFieldValue);//新增待办任务
                    }
                    else if (IsTask == "0")//消息
                    {
                        dal.AddDoTaskMessage(Entity, drs[0], sourceTable);
                    }
                }
                DataRow[] NotDefaultMsg = dtFlowTrigger.Select("ISDEFAULTMSG=0");//非默认消息,需要调用的WCF待办任务
                if (NotDefaultMsg != null && NotDefaultMsg.Count() > 0)
                {
                    foreach (DataRow dr1 in NotDefaultMsg)
                    {
                        string strAppMsg = string.Empty;
                        CallWCFService(dr1, sourceTable, ref strAppMsg);//调用WCF服务
                        if (!string.IsNullOrEmpty(strAppMsg))
                        {
                            try
                            {
                                string IsNewFlow = "1";
                                string NewFormID = string.Empty;
                                string strFormTypes = string.Empty;//表单状态
                                DataRow DRNewTrigger = null;
                                if (ApplicationValueToDataTable(strAppMsg, string.Concat(Entity.COMPANYID), ref sourceTable, ref IsNewFlow, ref NewFormID, ref strFormTypes, ref DRNewTrigger))
                                {
                                    //通过岗位查找用户,并且取第一个用户为发送消息的对像
                                    PersonnelWS.PersonnelServiceClient HRClient = new PersonnelWS.PersonnelServiceClient();
                                    if (!string.IsNullOrEmpty(dr1["OWNERPOSTID"].ToString()))
                                    {
                                        string[] Employees = HRClient.GetEmployeeIDsByPostID(dr1["OWNERPOSTID"].ToString());
                                        if (Employees != null && Employees.Count() > 0)
                                        {
                                            TaskCache.TaskCacheReflesh(NewFormID);
                                            dal.AddDoTask(Entity, dr1, sourceTable, Employees[0], NewFormID, strAppFieldValue, string.Concat(dr1["MESSAGEBODY"]), strFormTypes);//发送消息
                                        }
                                    }
                                    else
                                    {
                                        result = false;
                                        Tracer.Debug("命名空间:SMT.Workflow.Engine.Services.BLL类方法:EngineExecute()引擎调用新流程时没有选定岗位");
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                result = false;
                                Tracer.Debug("命名空间:SMT.Workflow.Engine.Services.BLL类方法:EngineExecute()" + ex.Message);
                            }
                        }
                    }
                }
                result = true;
                #endregion
            }
            else
            {

                string strMsg = "系统代号" + Entity.SYSTEMCODE + "\r\n" +
                                 "模块代号:" + Entity.MODELCODE + "\r\n" +
                                 "触发条件:" + Entity.ORDERSTATUS +
                                 "公司ID:" + Entity.COMPANYID + "\r\n" +
                                 "单据ID:" + Entity.ORDERID;
                Tracer.Debug("该单据所对应的引擎系统设置未找到,请先配置该模块引擎消息(审核通过、审核不通过、审核中)" + strMsg);
            }
            return result;
        }
Exemplo n.º 21
0
        /// <summary>
        /// 新增待办
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="dr1"></param>
        /// <param name="SourceValueDT"></param>
        /// <param name="strAPPFIELDVALUE"></param>
        public void AddDoTask(OracleConnection con, T_WF_DOTASK entity, DataRow dr1, DataTable SourceValueDT, string strAPPFIELDVALUE)
        {
            CloseDoTaskStatus(con, entity.SYSTEMCODE, entity.ORDERID, null);
            try
            {
                string[] strListUser;
                if (entity.RECEIVEUSERID.IndexOf('|') != -1)
                {
                    strListUser = entity.RECEIVEUSERID.ToString().Split('|');
                }
                else
                {
                    strListUser = new string[1];
                    strListUser[0] = entity.RECEIVEUSERID.ToString();
                }
                //dao.Open();
                foreach (string User in strListUser)
                {
                    string insSql = @"INSERT INTO T_WF_DOTASK (DOTASKID,COMPANYID,ORDERID,ORDERUSERID,ORDERUSERNAME,ORDERSTATUS,MESSAGEBODY,
                                     APPLICATIONURL,RECEIVEUSERID,BEFOREPROCESSDATE,DOTASKTYPE,DOTASKSTATUS,MAILSTATUS,
                                     RTXSTATUS,APPFIELDVALUE,FLOWXML,APPXML,SYSTEMCODE,MODELCODE,MODELNAME)
                                     VALUES (:DOTASKID,:COMPANYID,:ORDERID,:ORDERUSERID,:ORDERUSERNAME,:ORDERSTATUS,:MESSAGEBODY,:APPLICATIONURL,
                                    :RECEIVEUSERID,:BEFOREPROCESSDATE,:DOTASKTYPE,:DOTASKSTATUS,:MAILSTATUS,:RTXSTATUS,
                                    :APPFIELDVALUE,:FLOWXML,:APPXML,:SYSTEMCODE,:MODELCODE,:MODELNAME)";
                    OracleParameter[] pageparm =
                        {               
                            new OracleParameter(":DOTASKID",OracleType.NVarChar,100), 
                            new OracleParameter(":COMPANYID",OracleType.NVarChar,100), 
                            new OracleParameter(":ORDERID",OracleType.NVarChar,100), 
                            new OracleParameter(":ORDERUSERID",OracleType.NVarChar,100), 
                            new OracleParameter(":ORDERUSERNAME",OracleType.NVarChar,100), 
                            new OracleParameter(":ORDERSTATUS",OracleType.Number,22), 
                            new OracleParameter(":MESSAGEBODY",OracleType.NVarChar,4000), 
                            new OracleParameter(":APPLICATIONURL",OracleType.NVarChar,2000), 
                            new OracleParameter(":RECEIVEUSERID",OracleType.NVarChar,100), 
                            new OracleParameter(":BEFOREPROCESSDATE",OracleType.DateTime), 
                            new OracleParameter(":DOTASKTYPE",OracleType.Number,22),
                            new OracleParameter(":DOTASKSTATUS",OracleType.Number,22), 
                            new OracleParameter(":MAILSTATUS",OracleType.Number,22), 
                            new OracleParameter(":RTXSTATUS",OracleType.Number,22),                  
                            new OracleParameter(":APPFIELDVALUE",OracleType.Clob), 
                            new OracleParameter(":FLOWXML",OracleType.Clob), 
                            new OracleParameter(":APPXML",OracleType.Clob), 
                            new OracleParameter(":SYSTEMCODE",OracleType.NVarChar,100), 
                            new OracleParameter(":MODELCODE",OracleType.NVarChar,100), 
                            new OracleParameter(":MODELNAME",OracleType.NVarChar,200),                  

                        };
                    pageparm[0].Value = MsOracle.GetValue(Guid.NewGuid().ToString());//待办任务ID
                    pageparm[1].Value = MsOracle.GetValue(entity.COMPANYID);//公司ID
                    pageparm[2].Value = MsOracle.GetValue(entity.ORDERID);//单据ID
                    pageparm[3].Value = MsOracle.GetValue(entity.ORDERUSERID);//单据所属人ID
                    pageparm[4].Value = MsOracle.GetValue(entity.ORDERUSERNAME);//单据所属人名称
                    pageparm[5].Value = MsOracle.GetValue(entity.ORDERSTATUS);//单据状态
                    #region 消息体
                    string XmlTemplete = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "\r\n" +
                                  "<System>" + "\r\n" +
                                  "{0}" +
                                  "</System>";
                    if (dr1["MESSAGEBODY"].ToString() == "")//默认消息为空
                    {
                        string strMsgBody = string.Empty;
                        string strMsgUrl = string.Empty;
                        ModelMsgDefine(con, dr1["SYSTEMCODE"].ToString(), dr1["MODELCODE"].ToString(), entity.COMPANYID, ref strMsgBody, ref strMsgUrl);
                        if (string.IsNullOrEmpty(strMsgBody))
                        {
                            try
                            {
                                DataRow[] drvList = SourceValueDT.Select("ColumnName='ModelName'");
                                if (drvList.Count() == 1)
                                {
                                    string value = drvList[0]["ColumnValue"].ToString();
                                    if (string.IsNullOrWhiteSpace(value))
                                    {
                                        value = drvList[0]["ColumnText"].ToString();
                                    }         
                                    pageparm[6].Value = MsOracle.GetValue(value + "已审批通过");//消息体                                    
                                }
                                else
                                {
                                    pageparm[6].Value = MsOracle.GetValue(entity.ORDERID + "已审批通过");//消息体 

                                }
                            }
                            catch { }

                        }
                        else
                        {
                            pageparm[6].Value = MsOracle.GetValue(ReplaceMessageBody(strMsgBody, SourceValueDT));//消息体                             
                        }
                        string strUrl = string.Format(XmlTemplete, ReplaceValue(strMsgUrl, SourceValueDT));
                        LogHelper.WriteLog("查询到得消息链接:" + strUrl + "单据ID:" + entity.ORDERID);
                        pageparm[7].Value = MsOracle.GetValue(strUrl);//应用URL                         
                    }
                    else//在引擎配置界面定义了消息内容
                    {
                        LogHelper.WriteLog("Formid=" + entity.ORDERID + "开始 待办消息体:" + dr1["MESSAGEBODY"].ToString() + "\n\r 开始 打开待办连接的参数:" + dr1["APPLICATIONURL"].ToString());
                        string rowsValues = "Formid=" + entity.ORDERID + "\r\n";//每一行的值
                        for (int j = 0; j < SourceValueDT.Rows.Count; j++)
                        {
                            for (int i = 0; i < SourceValueDT.Columns.Count; i++)
                            {
                                string columnName = SourceValueDT.Columns[i].ColumnName;
                                rowsValues += columnName + "=" + SourceValueDT.Rows[j][columnName].ToString() + ";";
                            }
                            rowsValues += "\r\n";
                        }
                        LogHelper.WriteLog("SourceValueDT表数据:" + rowsValues);
                        pageparm[6].Value = MsOracle.GetValue(ReplaceMessageBody(dr1["MESSAGEBODY"].ToString(), SourceValueDT));//消息体
                        pageparm[7].Value = MsOracle.GetValue(string.Format(XmlTemplete, ReplaceValue(dr1["APPLICATIONURL"].ToString(), SourceValueDT)));//应用URL   
                        LogHelper.WriteLog("Formid=" + entity.ORDERID + "最后 待办消息体:" + pageparm[6].Value + "\n\r 最后 打开待办连接的参数:" + pageparm[7].Value);
                    }
                    #endregion                  
                    pageparm[8].Value =MsOracle.GetValue(User);// MsOracle.GetValue(entity.RECEIVEUSERID);//接收用户ID
                    if (entity.BEFOREPROCESSDATE != null)//流程过期时间属性
                    {
                        //sql += "to_date('" + entity.BEFOREPROCESSDATE + "','YYYY-MM-DD hh24:mi:ss')";
                        pageparm[9].Value = MsOracle.GetValue(entity.BEFOREPROCESSDATE);//可处理时间(主要针对KPI考核)
                    }
                    else
                    {
                        if (dr1["LASTDAYS"] != null)
                        {
                            if (string.IsNullOrEmpty(dr1["LASTDAYS"].ToString()))
                            {
                                pageparm[9].Value = MsOracle.GetValue(DateTime.Now.AddDays(3));//可处理时间(主要针对KPI考核)
                            }
                            else
                            {
                                pageparm[9].Value = MsOracle.GetValue(DateTime.Now.AddDays(int.Parse(dr1["LASTDAYS"].ToString())));//可处理时间(主要针对KPI考核)                             
                            }
                        }
                        else
                        {
                            pageparm[9].Value = MsOracle.GetValue(DateTime.Now.AddDays(3));
                        }
                    }
                    pageparm[10].Value = MsOracle.GetValue(0);//待办任务类型(0、待办任务、1、流程咨询、3 ) 
                    pageparm[11].Value = MsOracle.GetValue(0);//代办任务状态(0、未处理 1、已处理 、2、任务撤销 10、删除)
                    pageparm[12].Value = MsOracle.GetValue(0);//邮件状态(0、未发送 1、已发送、2、未知 )
                    pageparm[13].Value = MsOracle.GetValue(0);//RTX状态(0、未发送 1、已发送、2、未知 )
                    pageparm[14].Value = MsOracle.GetValue(strAPPFIELDVALUE);//应用字段值
                    pageparm[15].Value = MsOracle.GetValue(entity.FLOWXML);//流程XML
                    pageparm[16].Value = MsOracle.GetValue(entity.APPXML);//应用XML
                    pageparm[17].Value = MsOracle.GetValue(entity.SYSTEMCODE);//系统代码                  
                    pageparm[18].Value = MsOracle.GetValue(entity.MODELCODE);//模块代码
                    pageparm[19].Value = MsOracle.GetValue(entity.MODELNAME);//模块名称
                    //DataRow[] ModelCodeList = SourceValueDT.Select("ColumnName='ModelCode'");
                    //if (ModelCodeList.Count() == 1)
                    //{
                    //    sql += "'" + ModelCodeList[0]["ColumnValue"].ToString() + "')";
                    //}
                    //else
                    //{
                    //    sql += "'')";
                    //}
                    int result = MsOracle.ExecuteSQLByTransaction(con, insSql, pageparm);
                    if (result > 0)
                    {
                        LogHelper.WriteLog("A新增待办任务AddDoTask (成功)  FormID=" + entity.ORDERID + " 接收人ID=" + User);
                    }
                    else
                    {
                        LogHelper.WriteLog("A新增待办任务AddDoTask (失败)  FormID=" + entity.ORDERID + " 接收人ID=" + User); 
                    }
                }


            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("A新增待办任AddDoTask (失败) FormID=" + entity.ORDERID + " 命名空间: SMT.FlowDAL.EnginFlowDAL 类方法:AddDoTask()" + ex.Message);
                throw new Exception("新增待办任失败 FormID="+entity.ORDERID);
            }

        }