예제 #1
0
        public static void Test_FindDate_04(FindDateManager findDateManager, string file)
        {
            file = zPath.Combine(GetDirectoryDate(), file);

            string traceFile = zpath.PathSetFileNameWithoutExtension(file, zPath.GetFileNameWithoutExtension(file) + "_new_out");
            string bsonFile = zpath.PathSetFileNameWithoutExtension(file, zPath.GetFileNameWithoutExtension(file) + "_new_bson");

            Trace.WriteLine("Test_FindDate \"{0}\" (nb date regex {1})", file, findDateManager.DateRegexList.Count);
            //Trace.CurrentTrace.DisableBaseLog();
            Trace.CurrentTrace.DisableViewer = true;
            //Trace.CurrentTrace.AddTraceFile(traceFile, LogOptions.RazLogFile);
            Trace.CurrentTrace.AddOnWrite("Test_FindDate_04", WriteToFile.Create(traceFile, FileOption.RazFile).Write);

            try
            {
                DateTime dt = DateTime.Now;
                TraceRegexValuesList(findDateManager.DateRegexList);
                Trace.WriteLine();

                zmongo.BsonRead<TestText>(file).zFindDateNew(findDateManager).zSave(bsonFile);
                zmongo.BsonRead<TestFindDate>(bsonFile).zTraceFindDate();
                Trace.WriteLine("test duration {0}", DateTime.Now - dt);
            }
            finally
            {
                //Trace.CurrentTrace.EnableBaseLog();
                //Trace.CurrentTrace.RemoveTraceFile(traceFile);
                Trace.CurrentTrace.RemoveOnWrite("Test_FindDate_04");
                Trace.CurrentTrace.DisableViewer = false;
            }
        }
예제 #2
0
 public static IEnumerable<TestFindDate> zFindDateNew(this IEnumerable<TestText> textList, FindDateManager findDateManager)
 {
     foreach (TestText text in textList)
     {
         //FindDate findDate = findDateManager.Find(text.text);
         //TestFindDate testFindDate = new TestFindDate();
         //testFindDate.text = text.text;
         //testFindDate.foundDate = findDate.found;
         //if (findDate.found)
         //{
         //    testFindDate.dateFound = findDate.regexValues.MatchValue.Value;
         //    testFindDate.date = findDate.date;
         //    testFindDate.dateType = findDate.dateType;
         //    testFindDate.remainText = findDate.regexValues.MatchReplace("_");
         //    testFindDate.namedValues = findDate.regexValues.GetValues();
         //}
         //yield return testFindDate;
         yield return FindDateNew(findDateManager, text.text);
     }
 }
예제 #3
0
 public static TestFindDate FindDateNew(FindDateManager findDateManager, string text)
 {
     //FindDate_old findDate = findDateManager.Find_old(text);
     FindDate findDate = findDateManager.Find(text);
     TestFindDate testFindDate = new TestFindDate();
     testFindDate.text = text;
     testFindDate.foundDate = findDate.Found;
     if (findDate.Found)
     {
         //testFindDate.dateFound = findDate.regexValues.MatchValue_old.Value;
         testFindDate.dateFound = findDate.matchValues.Match.Value;
         testFindDate.date = findDate.Date;
         testFindDate.dateType = findDate.DateType;
         //testFindDate.remainText = findDate.regexValues.MatchReplace_old("_");
         testFindDate.remainText = findDate.matchValues.Replace("_");
         //testFindDate.namedValues = findDate.regexValues.GetValues_old();
         testFindDate.namedValues = findDate.matchValues.GetValues();
     }
     return testFindDate;
 }
예제 #4
0
 //public static FindDateManager CreateFindDateManager(int version = 3, int gapDayBefore = 0, int gapDayAfter = 0)
 public FindDateManager CreateFindDateManager()
 {
     // version 5 : version 3 +  new find date
     //if (version < 3 || version > 6)
     //    throw new PBException("bad version {0}", version);
     FindDateManager findDateManager;
     if (_version < 5)
         findDateManager = new FindDateManager(_printList1Config.GetElements("FindPrints/Dates/Date"), compileRegex: true);
     else
     {
         findDateManager = new FindDateManager(_printList1Config.GetElements("FindPrints/Dates/Date2"), _printList1Config.GetElements("FindPrints/Dates/DigitDate"), compileRegex: true);
         findDateManager.MultipleSearch = true;
         findDateManager.GapDayBefore = _gapDayBefore;
         findDateManager.GapDayAfter = _gapDayAfter;
     }
     return findDateManager;
 }