Ejemplo n.º 1
0
        public static LogTemplate Load(String FileName, String Templates)
        {
            LogTemplate aTemplate = new LogTemplate();
            XmlDocument Doc       = new XmlDocument();

            try
            {
                Doc.Load(Templates);
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.ToString());
            }

            XmlNodeList TemplateList = Doc.SelectNodes("Root/Template");

            foreach (XmlNode TemplateNode in TemplateList)
            {
                XmlNode FilePatternNode = TemplateNode.SelectSingleNode("FileNamePattern");

                if (FilePatternNode != null)
                {
                    if (Regex.Match(FileName, FilePatternNode.InnerXml).Success)
                    {
                        XmlNodeList TagList = TemplateNode.SelectNodes("Tag");

                        foreach (XmlNode TagNode in TagList)
                        {
                            String Name    = TagNode.SelectSingleNode("Name").InnerXml;
                            String Parent  = TagNode.SelectSingleNode("Parent").InnerXml;
                            String Pattern = TagNode.SelectSingleNode("Pattern").InnerXml;

                            String Extract = String.Empty;

                            XmlNode ExtractNode = TagNode.SelectSingleNode("Extract");
                            if (ExtractNode != null)
                            {
                                Extract = Tools.ConvertHTMLEntities(ExtractNode.InnerXml);
                            }

                            String Plot = String.Empty;

                            XmlNode PlotNode = TagNode.SelectSingleNode("Plot");
                            if (PlotNode != null)
                            {
                                Plot = Tools.ConvertHTMLEntities(PlotNode.InnerXml);
                            }

                            String BackColorText = TagNode.SelectSingleNode("BackColor").InnerXml;
                            String ForeColorText = TagNode.SelectSingleNode("ForeColor").InnerXml;

                            Color BackColor = GetColorFromWording(true, BackColorText);
                            Color ForeColor = GetColorFromWording(false, ForeColorText);

                            aTemplate.Tags.Add(new LogBlock(Name, Parent, Pattern, Extract, Plot, BackColor, ForeColor));
                        }

                        return(aTemplate);
                    }
                }
            }

            return(aTemplate);
        }