Beispiel #1
0
        private void init(XElement xelement)
        {
            _directory = xelement.zXPathValue("Directory");

            Dictionary<string, RegexValuesModel> regexModels = new Dictionary<string, RegexValuesModel>();
            // zElements("FilenamesModel/FilenameModel")
            foreach (XElement xe in xelement.zXPathElements("FilenamesModel/FilenameModel"))
            {
                RegexValuesModel rvm = new RegexValuesModel(xe);
                regexModels.Add(rvm.key, rvm);
            }

            _regexModels = new Dictionary<string, RegexValuesModel>();
            // zElements("FilenameModels/FilenameModel")
            foreach (XElement xe in xelement.zXPathElements("FilenameModels/FilenameModel"))
            {
                RegexValuesModel rvm = new RegexValuesModel(xe);
                _regexModels.Add(rvm.key, rvm);
            }
            // zElements("FilenameDates/FilenameDate")
            _dateRegexList = new RegexValuesList(xelement.zXPathElements("FilenameDates/FilenameDate"));
            //if (_trace)
            //    Trace.CurrentTrace.WriteLine("_dateRegexList {0}", _dateRegexList.Count);

            _printRegexList = new RegexValuesList();
            _printRegexList2 = new RegexValuesList();
            _prints = new Dictionary<string, Print1>();
            // zElements("Prints/Print")
            foreach (XElement xe in xelement.zXPathElements("Prints/Print"))
            {
                Print1 print = null;
                switch (xe.zXPathValue("Class"))
                {
                    case "LeMonde":
                        print = new LeMonde(xe, _directory, _regexModels);
                        break;
                    case "LeParisien":
                        print = new LeParisien(xe, _directory, _regexModels);
                        break;
                    case "LeVifExpress":
                        print = new LeVifExpress(xe, _directory, _regexModels);
                        break;
                    default:
                        print = new Print1(xe, _directory, _regexModels);
                        break;
                }
                string name = print.Name;
                _prints.Add(name, print);
                int n = 1;
                // zElements("Filenames/Filename")
                foreach (XElement xe2 in xe.zXPathElements("Filenames/Filename"))
                {
                    string key = name + n++.ToString();
                    //string name = xe2.zExplicitAttributeValue("name");
                    //string model = xe2.zExplicitAttributeValue("model");
                    string model = xe2.zAttribValue("model");
                    if (model != null)
                    {
                        if (!regexModels.ContainsKey(model))
                            throw new PBException("unknow filename model \"{0}\"", model);
                        RegexValuesModel rvm = regexModels[model];
                        //Dictionary<string, string> attribs = (from xa in xe2.Attributes() where xa.Name.ToString().StartsWith("v_") select xa).zAttribs();
                        Dictionary<string, string> attribs = new Dictionary<string, string>();
                        attribs.zAdd(from xa in xe2.Attributes() where xa.Name.ToString().StartsWith("v_") select xa);
                        string pattern = rvm.pattern.zSetTextVariables(attribs, true);
                        //Trace.CurrentTrace.WriteLine("\"{0}\" - \"{1}\"", rvm.pattern, pattern);
                        //string values = xe2.zAttribValue("values");
                        //if (values != null)
                        //{
                        //    if (rvm.values != null && rvm.values != "")
                        //        values = rvm.values + ", " + values;
                        //}
                        //else
                        //    values = rvm.values;
                        string values = rvm.values;
                        if (values != null)
                            values = values.zSetTextVariables(attribs, true);
                        _printRegexList.Add(key, new RegexValues(key, name, pattern, rvm.options, values));
                    }
                    else
                    {
                        string regex = xe2.zExplicitAttribValue("regex");
                        string values = xe2.zExplicitAttribValue("values");
                        string options = xe2.zAttribValue("options");
                        _printRegexList.Add(key, new RegexValues(key, name, regex, options, values));
                    }
                }

                n = 1;
                // zElements("Filenames2/Filename")
                foreach (XElement xe2 in xe.zXPathElements("Filenames2/Filename"))
                {
                    string key = name + n++.ToString();
                    string regex = xe2.zExplicitAttribValue("regex");
                    string values = xe2.zAttribValue("values");
                    string options = xe2.zAttribValue("options");
                    _printRegexList2.Add(key, new RegexValues(key, name, regex, options, values));
                }
            }
        }
Beispiel #2
0
        private void init(XElement xelement)
        {
            _directory = xelement.zXPathValue("Directory");

            _regexModels = new Dictionary <string, RegexValuesModel>();
            // zElements("FilenameInfos/FilenameModel")
            foreach (XElement xe in xelement.zXPathElements("FilenameInfos/FilenameModel"))
            {
                RegexValuesModel rvm = new RegexValuesModel(xe);
                _regexModels.Add(rvm.key, rvm);
            }
            // zElements("FilenameInfos/FilenameDate")
            _dateRegexList = new RegexValuesList(xelement.zXPathElements("FilenameInfos/FilenameDate"));

            //XElement xe3 = xelement.zXPathElement("FilenameInfos/FilenameDay");
            //if (xe3 != null)
            //    _dayRegex = new RegexValues(xe3);
            // zElements("FilenameInfos/FilenameDay")
            _dayRegexList = new RegexValuesList(xelement.zXPathElements("FilenameInfos/FilenameDay"));

            // zElements("FilenameInfos/FilenameNumber")
            _numberRegexList = new RegexValuesList(xelement.zXPathElements("FilenameInfos/FilenameNumber"));

            //xe3 = xelement.zXPathElement("FilenameInfos/FilenameSpecial");
            //if (xe3 != null)
            //    _specialRegex = new RegexValues(xe3);
            // zElements("FilenameInfos/FilenameSpecial")
            _specialRegexList = new RegexValuesList(xelement.zXPathElements("FilenameInfos/FilenameSpecial"));

            _printRegexList = new RegexValuesList();
            _prints         = new Dictionary <string, Print>();
            // zElements("Prints/Print")
            foreach (XElement xe in xelement.zXPathElements("Prints/Print"))
            {
                Print print = null;
                switch (xe.zXPathValue("Class"))
                {
                case "LeMonde":
                    print = new PrintLeMonde(xe, _directory, _regexModels);
                    break;

                case "LeParisien":
                    print = new PrintLeParisien(xe, _directory, _regexModels);
                    break;

                case "LExpress":
                    print = new PrintLExpress(xe, _directory, _regexModels);
                    break;

                case "LeVifExpress":
                    print = new PrintLeVifExpress(xe, _directory, _regexModels);
                    break;

                default:
                    print = new Print(xe, _directory, _regexModels);
                    break;
                }
                string name = print.Name;
                _prints.Add(name, print);
                int n = 1;
                // zElements("Filename")
                foreach (XElement xe2 in xe.zXPathElements("Filename"))
                {
                    string key     = name + n++.ToString();
                    string regex   = xe2.zExplicitAttribValue("regex");
                    string values  = xe2.zAttribValue("values");
                    string options = xe2.zAttribValue("options");
                    _printRegexList.Add(key, new RegexValues(key, name, regex, options, values));
                }
            }
        }
Beispiel #3
0
        private void init(XElement xelement)
        {
            _directory = xelement.zXPathValue("Directory");

            _regexModels = new Dictionary<string, RegexValuesModel>();
            // zElements("FilenameInfos/FilenameModel")
            foreach (XElement xe in xelement.zXPathElements("FilenameInfos/FilenameModel"))
            {
                RegexValuesModel rvm = new RegexValuesModel(xe);
                _regexModels.Add(rvm.key, rvm);
            }
            // zElements("FilenameInfos/FilenameDate")
            _dateRegexList = new RegexValuesList(xelement.zXPathElements("FilenameInfos/FilenameDate"));

            //XElement xe3 = xelement.zXPathElement("FilenameInfos/FilenameDay");
            //if (xe3 != null)
            //    _dayRegex = new RegexValues(xe3);
            // zElements("FilenameInfos/FilenameDay")
            _dayRegexList = new RegexValuesList(xelement.zXPathElements("FilenameInfos/FilenameDay"));

            // zElements("FilenameInfos/FilenameNumber")
            _numberRegexList = new RegexValuesList(xelement.zXPathElements("FilenameInfos/FilenameNumber"));

            //xe3 = xelement.zXPathElement("FilenameInfos/FilenameSpecial");
            //if (xe3 != null)
            //    _specialRegex = new RegexValues(xe3);
            // zElements("FilenameInfos/FilenameSpecial")
            _specialRegexList = new RegexValuesList(xelement.zXPathElements("FilenameInfos/FilenameSpecial"));

            _printRegexList = new RegexValuesList();
            _prints = new Dictionary<string, Print>();
            // zElements("Prints/Print")
            foreach (XElement xe in xelement.zXPathElements("Prints/Print"))
            {
                Print print = null;
                switch (xe.zXPathValue("Class"))
                {
                    case "LeMonde":
                        print = new PrintLeMonde(xe, _directory, _regexModels);
                        break;
                    case "LeParisien":
                        print = new PrintLeParisien(xe, _directory, _regexModels);
                        break;
                    case "LExpress":
                        print = new PrintLExpress(xe, _directory, _regexModels);
                        break;
                    case "LeVifExpress":
                        print = new PrintLeVifExpress(xe, _directory, _regexModels);
                        break;
                    default:
                        print = new Print(xe, _directory, _regexModels);
                        break;
                }
                string name = print.Name;
                _prints.Add(name, print);
                int n = 1;
                // zElements("Filename")
                foreach (XElement xe2 in xe.zXPathElements("Filename"))
                {
                    string key = name + n++.ToString();
                    string regex = xe2.zExplicitAttribValue("regex");
                    string values = xe2.zAttribValue("values");
                    string options = xe2.zAttribValue("options");
                    _printRegexList.Add(key, new RegexValues(key, name, regex, options, values));
                }
            }
        }
Beispiel #4
0
        private void init(XElement xelement)
        {
            _directory = xelement.zXPathValue("Directory");

            Dictionary <string, RegexValuesModel> regexModels = new Dictionary <string, RegexValuesModel>();

            // zElements("FilenamesModel/FilenameModel")
            foreach (XElement xe in xelement.zXPathElements("FilenamesModel/FilenameModel"))
            {
                RegexValuesModel rvm = new RegexValuesModel(xe);
                regexModels.Add(rvm.key, rvm);
            }

            _regexModels = new Dictionary <string, RegexValuesModel>();
            // zElements("FilenameModels/FilenameModel")
            foreach (XElement xe in xelement.zXPathElements("FilenameModels/FilenameModel"))
            {
                RegexValuesModel rvm = new RegexValuesModel(xe);
                _regexModels.Add(rvm.key, rvm);
            }
            // zElements("FilenameDates/FilenameDate")
            _dateRegexList = new RegexValuesList(xelement.zXPathElements("FilenameDates/FilenameDate"));
            //if (_trace)
            //    Trace.CurrentTrace.WriteLine("_dateRegexList {0}", _dateRegexList.Count);

            _printRegexList  = new RegexValuesList();
            _printRegexList2 = new RegexValuesList();
            _prints          = new Dictionary <string, Print1>();
            // zElements("Prints/Print")
            foreach (XElement xe in xelement.zXPathElements("Prints/Print"))
            {
                Print1 print = null;
                switch (xe.zXPathValue("Class"))
                {
                case "LeMonde":
                    print = new LeMonde(xe, _directory, _regexModels);
                    break;

                case "LeParisien":
                    print = new LeParisien(xe, _directory, _regexModels);
                    break;

                case "LeVifExpress":
                    print = new LeVifExpress(xe, _directory, _regexModels);
                    break;

                default:
                    print = new Print1(xe, _directory, _regexModels);
                    break;
                }
                string name = print.Name;
                _prints.Add(name, print);
                int n = 1;
                // zElements("Filenames/Filename")
                foreach (XElement xe2 in xe.zXPathElements("Filenames/Filename"))
                {
                    string key = name + n++.ToString();
                    //string name = xe2.zExplicitAttributeValue("name");
                    //string model = xe2.zExplicitAttributeValue("model");
                    string model = xe2.zAttribValue("model");
                    if (model != null)
                    {
                        if (!regexModels.ContainsKey(model))
                        {
                            throw new PBException("unknow filename model \"{0}\"", model);
                        }
                        RegexValuesModel rvm = regexModels[model];
                        //Dictionary<string, string> attribs = (from xa in xe2.Attributes() where xa.Name.ToString().StartsWith("v_") select xa).zAttribs();
                        Dictionary <string, string> attribs = new Dictionary <string, string>();
                        attribs.zAdd(from xa in xe2.Attributes() where xa.Name.ToString().StartsWith("v_") select xa);
                        string pattern = rvm.pattern.zSetTextVariables(attribs, true);
                        //Trace.CurrentTrace.WriteLine("\"{0}\" - \"{1}\"", rvm.pattern, pattern);
                        //string values = xe2.zAttribValue("values");
                        //if (values != null)
                        //{
                        //    if (rvm.values != null && rvm.values != "")
                        //        values = rvm.values + ", " + values;
                        //}
                        //else
                        //    values = rvm.values;
                        string values = rvm.values;
                        if (values != null)
                        {
                            values = values.zSetTextVariables(attribs, true);
                        }
                        _printRegexList.Add(key, new RegexValues(key, name, pattern, rvm.options, values));
                    }
                    else
                    {
                        string regex   = xe2.zExplicitAttribValue("regex");
                        string values  = xe2.zExplicitAttribValue("values");
                        string options = xe2.zAttribValue("options");
                        _printRegexList.Add(key, new RegexValues(key, name, regex, options, values));
                    }
                }

                n = 1;
                // zElements("Filenames2/Filename")
                foreach (XElement xe2 in xe.zXPathElements("Filenames2/Filename"))
                {
                    string key     = name + n++.ToString();
                    string regex   = xe2.zExplicitAttribValue("regex");
                    string values  = xe2.zAttribValue("values");
                    string options = xe2.zAttribValue("options");
                    _printRegexList2.Add(key, new RegexValues(key, name, regex, options, values));
                }
            }
        }