示例#1
0
 public bool FindNext()
 {
     _found       = false;
     _day         = null;
     _matchValues = null;
     while (_enumerator.MoveNext())
     {
         RegexValues rv          = _enumerator.Current;
         MatchValues matchValues = rv.Match(_text);
         if (matchValues.Success)
         {
             int day;
             if (zDay.TryGetDay(matchValues.GetValues(), out day))
             {
                 //return new FindDay { Found = true, Day = day, MatchValues = matchValues };
                 _found       = true;
                 _day         = day;
                 _matchValues = matchValues;
                 return(true);
             }
         }
     }
     //return new FindDay { Found = false, Day = null, MatchValues = null };
     return(false);
 }
示例#2
0
 public bool FindNext()
 {
     _found = false;
     _day = null;
     _matchValues = null;
     while (_enumerator.MoveNext())
     {
         RegexValues rv = _enumerator.Current;
         MatchValues matchValues = rv.Match(_text);
         if (matchValues.Success)
         {
             int day;
             if (zDay.TryGetDay(matchValues.GetValues(), out day))
             {
                 //return new FindDay { Found = true, Day = day, MatchValues = matchValues };
                 _found = true;
                 _day = day;
                 _matchValues = matchValues;
                 return true;
             }
         }
     }
     //return new FindDay { Found = false, Day = null, MatchValues = null };
     return false;
 }
示例#3
0
        //public PrintIssue Match(RegexValues rv, string filename)
        public GClass2 <PrintIssue, MatchValues> Match(RegexValues rv, string filename)
        {
            //PrintIssue issue = null;
            //Match match = rv.Match_old(filename);
            MatchValues matchValues = rv.Match(filename);

            //if (match.Success)
            if (matchValues.Success)
            {
                Print      print = GetPrint(rv.Name);
                PrintIssue issue = print.NewPrintIssue();
                //NamedValues<ZValue> values = rv.GetValues_old();
                NamedValues <ZValue> values = matchValues.GetValues();
                if (_trace)
                {
                    WriteLine("found {0}", print.Name);
                    WriteLine("pattern \"{0}\"", rv.Pattern);
                    values.zTrace();
                }
                issue.TrySetValues(values);
                return(new GClass2 <PrintIssue, MatchValues> {
                    Value1 = issue, Value2 = matchValues
                });
            }
            else
            {
                //return issue;
                return(null);
            }
        }
示例#4
0
        //public Print Find2(string filename, out string error)
        //{
        //    error = null;
        //    if (_trace)
        //        Trace.CurrentTrace.WriteLine("search \"{0}\"", filename);
        //    foreach (RegexValues rv in _printRegexList2.Values)
        //    {
        //        Match match = rv.Match(filename);
        //        if (match.Success)
        //        {
        //            Print print = Get(rv.Name);
        //            print.NewIssue();
        //            NamedValues values = rv.GetValues();
        //            if (_trace)
        //            {
        //                Trace.CurrentTrace.WriteLine("found {0}", print.Name);
        //                values.zTrace();
        //            }
        //            if (!print.TrySetValues(values))
        //            {
        //                error = string.Format("find \"{0}\" error \"{1}\"", print.Name, values.Error);
        //                continue;
        //            }

        //            if (MatchRegexValues(print, print.NormalizedFilename, filename, out error))
        //                return print;
        //            if (MatchRegexValues(print, print.NormalizedSpecialFilename, filename, out error))
        //                return print;
        //            string filename2 = filename.Substring(0, match.Index) + filename.Substring(match.Index + match.Length);
        //            if (_trace)
        //                Trace.CurrentTrace.WriteLine("search date \"{0}\" (\"{1}\")", filename2, filename);
        //            foreach (RegexValues rv2 in _dateRegexList.Values)
        //            {
        //                match = rv.Match(filename2);
        //                if (match.Success)
        //                {
        //                    values = rv2.GetValues();
        //                    if (date.IsDateValid(values))
        //                    {
        //                        //print.SetValues(values);
        //                        if (!print.TrySetValues(values))
        //                        {
        //                            error = string.Format("find \"{0}\" error \"{1}\"", print.Name, values.Error);
        //                            continue;
        //                        }
        //                        return print;
        //                    }
        //                }
        //            }
        //            //return print;
        //        }
        //    }
        //    if (_trace)
        //        Trace.CurrentTrace.WriteLine("print not found \"{0}\"", filename);
        //    return null;
        //    //foreach (Print print in _prints.Values)
        //    //{
        //    //    Match match = print.MatchFilename(filename);
        //    //    //if (print.IsMatchFilename(filename))
        //    //    if (match != null && match.Success)
        //    //    {
        //    //        if (_trace)
        //    //            Trace.CurrentTrace.WriteLine("found {0}", print.Name);
        //    //        if (MatchRegexValues(print, print.NormalizedFilename, filename, out error))
        //    //            return print;
        //    //        if (MatchRegexValues(print, print.NormalizedSpecialFilename, filename, out error))
        //    //            return print;
        //    //        string filename2 = filename.Substring(0, match.Index) + filename.Substring(match.Index + match.Length);
        //    //        if (_trace)
        //    //            Trace.CurrentTrace.WriteLine("search date \"{0}\" (\"{1}\")", filename2, filename);
        //    //        //RegexValues rv = _dateRegexList.Find(filename2);
        //    //        foreach (RegexValues rv in _dateRegexList.Values)
        //    //        {
        //    //            match = rv.Match(filename2);
        //    //            if (match.Success)
        //    //            {
        //    //                Dictionary<string, object> values = rv.GetValues();
        //    //                if (date.IsValidDate(values))
        //    //                {
        //    //                    print.SetValues(values);
        //    //                    return print;
        //    //                }
        //    //            }
        //    //        }
        //    //    }
        //    //}
        //    //return null;
        //}

        private bool MatchRegexValues(Print1 print, RegexValues rv, string filename, out string error)
        {
            error = null;
            //Match match = rv.Match_old(filename);
            MatchValues matchValues = rv.Match(filename);

            //if (!match.Success)
            if (!matchValues.Success)
            {
                return(false);
            }
            //NamedValues<ZValue> values = rv.GetValues_old();
            NamedValues <ZValue> values = matchValues.GetValues();

            if (_trace)
            {
                values.zTrace();
            }

            if (!print.TrySetValues(values))
            {
                error = string.Format("find \"{0}\" error \"{1}\"", print.Name, values.Error);
                return(false);
            }
            return(true);
        }
示例#5
0
        public static void FindDate(RegexValuesList dateRegexList, string title)
        {
            bool found = false;

            foreach (RegexValues rv in dateRegexList.Values)
            {
                //rv.Match_old(title);
                MatchValues matchValues = rv.Match(title);
                //if (rv.Success_old)
                if (matchValues.Success)
                {
                    //NamedValues<ZValue> values = rv.GetValues_old();
                    NamedValues <ZValue> values = matchValues.GetValues();
                    Date     date;
                    DateType dateType;
                    //Trace.Write(" date ");
                    //found = zdate.TryCreateDate(values, out date);
                    //if (found)
                    //    Trace.Write("{0:dd-MM-yyyy}", date);
                    //else
                    //    Trace.Write("not found ");
                    //Trace.Write("   ");
                    //values.zTrace();

                    //Trace.WriteLine("    found date  : {0}", rv.MatchValue_old);
                    Trace.WriteLine("    found date  : {0}", matchValues.Match.Value);

                    //Trace.WriteLine("    remain text : {0}", rv.MatchReplace_old("_"));
                    Trace.WriteLine("    remain text : {0}", matchValues.Replace("_"));

                    Trace.Write("    date        : ");
                    found = zdate.TryCreateDate(values, out date, out dateType);
                    if (found)
                    {
                        Trace.Write("{0:dd-MM-yyyy} type {1}", date, dateType);
                    }
                    else
                    {
                        Trace.Write("not found ");
                    }
                    Trace.WriteLine();

                    Trace.Write("    values      : ");
                    values.zTrace();
                    Trace.WriteLine();

                    if (found)
                    {
                        break;
                    }
                }
            }
            if (!found)
            {
                Trace.WriteLine("    date not found ");
            }
        }
示例#6
0
        private string FindNumber(string title)
        {
            FindNumber findNumber = _printTitleManager.FindNumberManager.Find(title);

            if (findNumber.found)
            {
                _number      = findNumber.number;
                _numberMatch = findNumber.matchValues;
                title        = findNumber.matchValues.Replace(" $$number$$ ");
            }
            return(title);
        }
示例#7
0
        private string FindDate(string title)
        {
            FindDate findDate = _printTitleManager.FindDateManager.Find(title, _expectedDate);

            if (findDate.Found)
            {
                _date      = findDate.Date;
                _dateType  = findDate.DateType;
                _dateMatch = findDate.matchValues;
                title      = findDate.matchValues.Replace(" $$date$$ ");
                _foundDate = true;
            }
            //_dateOtherMatchList = findDate.matchValuesList;
            return(title);
        }
示例#8
0
 private bool FindSpecial(PrintIssue issue, ref string filename)
 {
     foreach (RegexValues rv in _specialRegexList.Values)
     {
         //if (issue.Match(rv, filename))
         MatchValues matchValues = issue.Match(rv, filename);
         if (matchValues != null)
         {
             //filename = rv.MatchReplace_old("_");
             filename = matchValues.Replace("_");
             return(true);
         }
     }
     return(false);
 }
示例#9
0
 private bool FindDate(PrintIssue issue, ref string filename)
 {
     foreach (RegexValues rv in _dateRegexList.Values)
     {
         //if (issue.Match(rv, filename, v => zdate.IsDateValid(v)))
         MatchValues matchValues = issue.Match(rv, filename, v => zdate.IsDateValid(v));
         if (matchValues != null)
         {
             //filename = rv.MatchReplace_old("_");
             filename = matchValues.Replace("_");
             if (!issue.Special)
             {
                 return(true);
             }
             break;
         }
     }
     return(false);
 }
示例#10
0
 private bool FindDay(PrintIssue issue, string filename)
 {
     foreach (RegexValues rv in _dayRegexList.Values)
     {
         //Match match = rv.Match_old(filename);
         MatchValues matchValues = rv.Match(filename);
         //while (match.Success)
         while (matchValues.Success)
         {
             //if (issue.MatchSetValues(rv, v => zdate.IsDayValid(v)))
             if (issue.MatchSetValues(matchValues, v => zdate.IsDayValid(v)))
             {
                 return(true);
             }
             //match = rv.Next_old();
             matchValues = matchValues.Next();
         }
     }
     return(false);
 }
示例#11
0
 private bool FindNumber(PrintIssue issue, string filename)
 {
     foreach (RegexValues rv in _numberRegexList.Values)
     {
         //Match match = rv.Match_old(filename);
         MatchValues matchValues = rv.Match(filename);
         //while (match.Success)
         while (matchValues.Success)
         {
             //if (issue.MatchSetValues(rv, v => PrintIssue.IsNumberValid(v)))
             if (issue.MatchSetValues(matchValues, v => PrintIssue.IsNumberValid(v)))
             {
                 if (issue.Control())
                 {
                     return(true);
                 }
             }
             //match = rv.Next_old();
             matchValues = matchValues.Next();
         }
     }
     return(false);
 }
示例#12
0
        public Print1 Find(string filename, out string error)
        {
            error = null;
            if (_trace)
            {
                Trace.CurrentTrace.WriteLine("search \"{0}\"", filename);
            }
            foreach (RegexValues rv in _printRegexList.Values)
            {
                //Match match = rv.Match_old(filename);
                MatchValues matchValues = rv.Match(filename);
                //if (match.Success)
                if (matchValues.Success)
                {
                    Print1 print = Get(rv.Name);
                    print.NewIssue();
                    //NamedValues<ZValue> values = rv.GetValues_old();
                    NamedValues <ZValue> values = matchValues.GetValues();
                    if (_trace)
                    {
                        values.zTrace();
                    }
                    if (!print.TrySetValues(values))
                    {
                        error = string.Format("find \"{0}\" error \"{1}\"", print.Name, values.Error);
                        continue;
                    }
                    return(print);
                }
            }

            if (_trace)
            {
                Trace.CurrentTrace.WriteLine("print not found \"{0}\"", filename);
            }
            return(null);
        }
示例#13
0
 private string FindDate(string title)
 {
     FindDate findDate = _printTitleManager.FindDateManager.Find(title, _expectedDate);
     if (findDate.Found)
     {
         _date = findDate.Date;
         _dateType = findDate.DateType;
         _dateMatch = findDate.matchValues;
         title = findDate.matchValues.Replace(" $$date$$ ");
         _foundDate = true;
     }
     //_dateOtherMatchList = findDate.matchValuesList;
     return title;
 }
示例#14
0
 private string FindNumber(string title)
 {
     FindNumber findNumber = _printTitleManager.FindNumberManager.Find(title);
     if (findNumber.found)
     {
         _number = findNumber.number;
         _numberMatch = findNumber.matchValues;
         title = findNumber.matchValues.Replace(" $$number$$ ");
     }
     return title;
 }
示例#15
0
 private string FindSpecial(string title)
 {
     FindText findSpecial = _printTitleManager.FindSpecial.Find(title);
     if (findSpecial.Found)
     {
         _special = true;
         _specialMatch = findSpecial.matchValues;
         title = findSpecial.matchValues.Replace(" $$special$$ ");
     }
     return title;
 }
示例#16
0
        public PrintIssue Find(string filename)
        {
            WriteLine("search \"{0}\"", filename);
            PrintIssue issue          = null;
            PrintIssue lastIssueError = null;
            //List<GClass2<PrintIssue, RegexValues>> issues = new List<GClass2<PrintIssue,RegexValues>>();
            List <GClass2 <PrintIssue, MatchValues> > issues = new List <GClass2 <PrintIssue, MatchValues> >();
            bool foundIssue = false;

            filename = zstr.ReplaceUTF8Code(filename);
            filename = filename.Replace('\u0430', 'a');
            filename = filename.Replace('\u0435', 'e');
            filename = filename.Replace('\u043E', 'o');
            WriteLine("search \"{0}\"", filename);
            foreach (RegexValues rv in _printRegexList.Values)
            {
                //issue = Match(rv, filename);
                GClass2 <PrintIssue, MatchValues> gc = Match(rv, filename);
                //if (issue != null && issue.Error == null)
                if (gc.Value1 != null && gc.Value1.Error == null)
                {
                    Print print = issue.Print;

                    //if (issue.Match(print.NormalizedFilename, filename))
                    MatchValues matchValues = issue.Match(print.NormalizedFilename, filename);
                    if (matchValues != null)
                    {
                        foundIssue = true;
                        break;
                    }
                    //if (issue.Match(print.NormalizedSpecialFilename, filename))
                    matchValues = issue.Match(print.NormalizedSpecialFilename, filename);
                    if (matchValues != null)
                    {
                        foundIssue = true;
                        break;
                    }

                    //issues.Add(new GClass2<PrintIssue, RegexValues>(issue, rv));
                    issues.Add(new GClass2 <PrintIssue, MatchValues>(issue, gc.Value2));
                }

                //if (issue != null && issue.Error != null)
                if (gc.Value1 != null && gc.Value1.Error != null)
                {
                    lastIssueError = issue;
                }
            }

            if (!foundIssue)
            {
                //foreach (GClass2<PrintIssue, RegexValues> issue2 in issues)
                foreach (GClass2 <PrintIssue, MatchValues> issue2 in issues)
                {
                    issue = issue2.Value1;
                    //RegexValues rv = issue2.Value2;
                    MatchValues matchValues = issue2.Value2;
                    Print       print       = issue.Print;
                    //string filename2 = filename = rv.MatchReplace_old("_");
                    string filename2 = filename = matchValues.Replace("_");

                    FindSpecial(issue, ref filename2);

                    if (print.Frequency != PrintFrequency.Daily && print.Frequency != PrintFrequency.Weekly)
                    {
                        if (FindNumber(issue, filename2))
                        {
                            foundIssue = true;
                        }
                        //if (issue.Error != null)
                        //    lastIssueError = issue;
                    }


                    bool foundDate = false;
                    if (!foundIssue)
                    {
                        if (FindDate(issue, ref filename2))
                        {
                            foundDate = true;
                        }
                        //if (issue.Error != null)
                        //    lastIssueError = issue;
                    }

                    if (!foundIssue && print.Frequency != PrintFrequency.Daily)
                    {
                        if (FindNumber(issue, filename2))
                        {
                            foundIssue = true;
                        }
                        //if (issue.Error != null)
                        //    lastIssueError = issue;
                    }

                    if (foundDate)
                    {
                        foundIssue = true;
                    }

                    if (!foundIssue && (print.Frequency == PrintFrequency.Daily || print.Frequency == PrintFrequency.Weekly))
                    {
                        if (FindDay(issue, filename2))
                        {
                            foundIssue = true;
                        }
                        //if (issue.Error != null)
                        //    lastIssueError = issue;
                    }

                    if (issue.Error != null)
                    {
                        lastIssueError = issue;
                    }

                    if (foundIssue)
                    {
                        break;
                    }
                }
            }

            if (!foundIssue)
            {
                if (_trace)
                {
                    WriteLine("print not found \"{0}\"", filename);
                }
                return(lastIssueError);
            }

            issue.Control();
            return(issue);
        }