Пример #1
0
        /// <summary>
        /// 
        /// Description: 添加元素
        /// Author:Liudpc
        /// Create Date: 2010-6-13 14:23:06
        /// </summary>
        /// <param name="edi"></param>
        /// <returns></returns>
        public bool AddItemToXml(EmailDesignItem edi)
        {
            TempleteDesignEntityCRF design = GetTempleteDesign(edi.XmlId);

            string sGuid=Guid.NewGuid().ToString();

            ItemRuleExpressionEntityCRF ire = new ItemRuleExpressionEntityCRF();
            ire.Expression = edi.RuleExpress;
            ire.ExpressionParm = edi.ToEmail;
            ire.TempleteGuid = sGuid;

            design.ItemRule.Add(ire);

            ItemTempleteEmailInfoEntityCRF itee = new ItemTempleteEmailInfoEntityCRF();
            itee.Content = edi.Content;
            itee.Guid = sGuid;
            itee.Title = edi.Title;

            design.ItemTemplete.Add(itee);

            return replace.SaveTempleteDesign(design, GetXmlPathDesignByXmlId(edi.XmlId));
        }
Пример #2
0
        /// <summary>
        /// 
        /// Description: 得到设计实体
        /// Author:Liudpc
        /// Create Date: 2010-6-9 17:01:54
        /// </summary>
        /// <param name="sFilePath"></param>
        /// <returns></returns>
        public TempleteDesignEntityCRF GetTempleteDesign(string sFilePath)
        {
            TempleteDesignEntityCRF returnDesignEntity = new TempleteDesignEntityCRF();

            if (File.Exists(sFilePath))
            {
                XmlDocument xd = new XmlDocument();
                xd.Load(sFilePath);
                XmlNode xnDesign = xd.SelectSingleNode("ReplaceFileRoot/ReplaceFile/ReplaceFileDesign");

                returnDesignEntity.ItemRule = new List<ItemRuleEntityAtCRF>();
                XmlNode xnRule = xnDesign.SelectSingleNode("RuleItem/Rule");
                if (xnRule != null)
                {
                    foreach (XmlNode xnRuleInfo in xnRule.ChildNodes)
                    {
                        if (xnRuleInfo.Name == "RuleExpression")
                        {
                            foreach (XmlNode xn in xnRuleInfo.SelectNodes("ExpressionInfo"))
                            {
                                ItemRuleExpressionEntityCRF iree = new ItemRuleExpressionEntityCRF();
                                iree.Expression = xn.SelectSingleNode("Expression").InnerText.Trim();
                                iree.TempleteGuid = xn.SelectSingleNode("TempleteGuid").InnerText.Trim();
                                iree.ExpressionParm = xn.SelectSingleNode("ExpressionParm").InnerText.Trim();
                                returnDesignEntity.ItemRule.Add(iree);
                            }
                        }

                    }
                }

                returnDesignEntity.ItemTemplete = new List<ItemTempleteEntityIfCRF>();
                XmlNode xnTempleteItem = xnDesign.SelectSingleNode("TempleteItem");
                if (xnTempleteItem != null)
                {
                    foreach (XmlNode xnTemplete in xnTempleteItem)
                    {

                        foreach (XmlNode xnTempleteInfo in xnTemplete.ChildNodes)
                        {
                            if (xnTempleteInfo.Name == "EmailInfo")
                            {

                                ItemTempleteEmailInfoEntityCRF itee = new ItemTempleteEmailInfoEntityCRF();

                                itee.Guid = XmlStaticCCF.GetAttValueByName(xnTemplete, "guid");
                                itee.Title = XmlStaticCCF.GetChildValueByName(xnTempleteInfo,"Title");
                                itee.Content =  XmlStaticCCF.GetChildValueByName(xnTempleteInfo, "Content");

                                returnDesignEntity.ItemTemplete.Add(itee);
                            }

                        }
                    }
                }

            }
            else
            {
                AddLog(20010015, sFilePath);
            }

            return returnDesignEntity;
        }