Exemplo n.º 1
0
        /// <summary>
        /// 
        /// Description: 得到发送内容
        /// Author:Liudpc
        /// Create Date: 2010-6-12 17:50:39
        /// </summary>
        /// <param name="sXmlId"></param>
        /// <param name="sParmsContent"></param>
        /// <returns></returns>
        public List<DoSendEmailEntityCRF> GetSendList(string sXmlId, string sParmsContent)
        {
            List<DoSendEmailEntityCRF> doSend = new List<DoSendEmailEntityCRF>();

            ReplaceFileEntityCRF replaceEntity = new ReplaceFileEntityCRF();

            replaceEntity.TempleteXml = replace.GetTempleteXml(ReplaceFileConfigCCC.Config.XmlFileDirectory + sXmlId + ".xml");
            replaceEntity.ReplaceParms = sParmsContent;
            replaceEntity.ReplaceFileId = sXmlId;
            replaceEntity.DataServer = ReplaceFileConfigCCC.Config.DataServerList.SingleOrDefault(t => t.Id == replaceEntity.TempleteXml.Code.Config.DataServerId);

            DataReplaceEntityCRF dataReplace = replace.GetDataReplace(replaceEntity);

            if (dataReplace.ResultFlag)
            {
                if (replaceEntity.TempleteXml.Design.ItemRule.Count > 0)
                {
                    foreach (ItemRuleEntityAtCRF itemRule in replaceEntity.TempleteXml.Design.ItemRule)
                    {
                        if (itemRule.RuleType == ItemRuleType.RuleExpression)
                        {
                            ItemRuleExpressionEntityCRF ruleExpress = itemRule as ItemRuleExpressionEntityCRF;
                            string sResult =string.IsNullOrEmpty(ruleExpress.Expression)?"true": EvalFunctionCCF.Eval(replace.ReplaceParmsByDict(ruleExpress.Expression, dataReplace.MainParms)).ToLower();
                            if (sResult == "true")
                            {
                                doSend.Add(new DoSendEmailEntityCRF() { TempleteId = ruleExpress.TempleteGuid, ToEmail = replace.ReplaceParmsByDict(ruleExpress.ExpressionParm, dataReplace.MainParms) });

                            }
                        }
                    }
                }

                if (doSend.Count > 0)
                {

                    foreach (DoSendEmailEntityCRF send in doSend)
                    {

                        ItemTempleteEmailInfoEntityCRF emailEntity = replaceEntity.TempleteXml.Design.ItemTemplete.SingleOrDefault(t => t.Guid == send.TempleteId) as ItemTempleteEmailInfoEntityCRF;
                        send.Title = replace.ReplaceParmsByDict(emailEntity.Title, dataReplace.MainParms);

                        send.Content = replace.GetReplaceContentFromDatabase(emailEntity.Content, dataReplace);

                        send.EmailServerId = replaceEntity.TempleteXml.Code.Config.EmailServerId;
                    }
                }
            }

            return doSend;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 
        /// Description: 从数据库中匹配出内容
        /// Author:Liudpc
        /// Create Date: 2010-6-11 16:38:03
        /// </summary>
        /// <param name="rfe"></param>
        /// <returns></returns>
        public DataReplaceEntityCRF GetDataReplace(ReplaceFileEntityCRF rfe)
        {
            DataReplaceEntityCRF dre = new DataReplaceEntityCRF();
            dre.ResultFlag = true;

            dre.MainParms = new Dictionary<string, string>();

            string sMainReplace = ReplaceFileConfigCCC.Config.MainParmReplace;

            List<SqlParameter> sqlParmList = new List<SqlParameter>();

            DataHelper.DataTableAutoHelperCDH dtah = new DataTableAutoHelperCDH();

            #region 开始进行输入参数的处理
            if (!string.IsNullOrEmpty(rfe.ReplaceParms))
            {

                string[] strParms = Regex.Split(rfe.ReplaceParms, ReplaceFileConfigCCC.Config.SplitString);

                List<ItemPramEntityCRF> parmList = rfe.TempleteXml.Code.Parm;
                for (int i = 0, j = strParms.Length; i < j; i++)
                {
                    int iIndex=strParms[i].IndexOf("=");
                    if(iIndex>0)
                    {
                        ItemPramEntityCRF  ipe= parmList.Single(t => t.ParmName == strParms[i].Substring(0, iIndex));
                        sqlParmList.Add(new SqlParameter("@"+ipe.ParmName,strParms[i].Substring(iIndex+1)));

                        if (ipe != null)
                        {
                            dre.MainParms.Add(string.Format(sMainReplace, ipe.ParmText), strParms[i].Substring(iIndex + 1));

                        }
                    }
                }

            }
            #endregion

            #region 开始进行主sql取出
            if (rfe.TempleteXml.Code.MainSql.Count > 0)
            {
                SqlParameter[] sp=sqlParmList.ToArray();

                foreach(ItemMainSqlEntityCRF imse in rfe.TempleteXml.Code.MainSql)
                {
                    if (dre.ResultFlag)
                    {

                        DataTable dt = dtah.GetDataTable(rfe.DataServer, ReplaceParmsByDict(imse.SqlString, dre.MainParms), sp);
                        if (dt.Rows.Count > 0)
                        {
                            for (int i = 0, j = dt.Columns.Count; i < j; i++)
                            {
                                dre.MainParms.Add(string.Format(sMainReplace, dt.Columns[i].ColumnName), dt.Rows[0][i].ToString().Trim());
                            }
                        }
                        else
                        {
                            dre.ResultFlag = false;
                        }
                    }

                }
            }

            #endregion

            #region 开始进行循环表格取出
            if (rfe.TempleteXml.Code.ListSql.Count > 0)
            {
                dre.ListParms = new List<DataTable>();
                SqlParameter[] sp=sqlParmList.ToArray();
                foreach (ItemListSqlEntityCRF ilse in rfe.TempleteXml.Code.ListSql)
                {
                    dre.ListParms.Add(dtah.GetDataTable(rfe.DataServer, ReplaceParmsByDict(ilse.SqlString,dre.MainParms), sp));
                }
            }
            #endregion

            return dre;
        }