Exemplo n.º 1
0
 //
 // Initalisation
 //
 internal Issue(StreamWriter StreamWriterLog, String StrMetsFile, String StrMetsIssue, String StrMetsVolume, String StrMetsDate, String StrModsTitle)
 {
     this.StrMetsFile   = StrMetsFile;
     this.StrMetsIssue  = StrMetsIssue;
     this.StrMetsVolume = StrMetsVolume;
     this.StrMetsDate   = StrMetsDate;
     this.StrModsTitle  = StrModsTitle;
     //
     // Error Flag
     //
     IssueErrorThis = IssueError.None;
     //
     // Convert To Numbers If Possible
     //
     iIssue        = GetNumber(StrMetsIssue);
     iVolume       = GetNumber(StrMetsVolume);
     DateTimeIssue = GetDate(StrMetsDate);
     //
     // Parse FileName For Date
     //
     DateTimeFileName = GetFileNameDate(StrMetsFile);
     //
     // Compare Year, Month & Day
     //
     if ((DateTimeIssue.Year != DateTimeFileName.Year) ||
         (DateTimeIssue.Month != DateTimeFileName.Month) ||
         (DateTimeIssue.Day != DateTimeFileName.Day))
     {
         Console.Out.WriteLine("Error: Date Mismatch Between Mods Filename: " + StrMetsFile + " and Mods File Content: " + DateTimeIssue.ToString());
         StreamWriterLog.WriteLine("Error: Date Mismatch Between Mods Filename: " + StrMetsFile + " and Mods File Content: " + DateTimeIssue.ToString());
     }
     //
 }
Exemplo n.º 2
0
        //
        // Report Assume Sorted
        //
        internal void Report(StreamWriter StreamWriterLog)
        {
            int   iIssue    = -1;
            int   iIssueOld = -1;
            Issue IssueThis = null;
            Issue IssueOld  = null;

            double[] dDaysOfWeek = new double[7];
            for (int iListInx = 0; iListInx < ArrayListIssues.Count; iListInx += 1)
            {
                //
                // Get Issue
                //
                IssueOld  = IssueThis;
                IssueThis = (Issue)ArrayListIssues[iListInx];
                dDaysOfWeek[(int )IssueThis.GetIssueDate().DayOfWeek] += 1.0;
                //
                // Check Issue Sequence If Year Difference Is Equal Or Less Than 1
                //
                if ((IssueThis != null) && (IssueOld != null) &&
                    ((Math.Abs(IssueThis.GetIssueDate().Year - IssueOld.GetIssueDate().Year) <= 1)))
                {
                    iIssueOld = iIssue;
                    iIssue    = IssueThis.GetIssue();
                    if ((iIssueOld != -1) && ((iIssueOld + 1) != iIssue))
                    {
                        IssueOld.SetErrorFlag(IssueError.IssueSequence);
                    }
                }
                //
            }
            //
            // Output Issues Data
            //
            Issue IssueGood     = null;
            bool  fTimeGapError = false;

            for (int iListInx = 0; iListInx < ArrayListIssues.Count; iListInx += 1)
            {
                //
                // Get Issue
                //
                IssueOld  = IssueThis;
                IssueThis = (Issue)ArrayListIssues[iListInx];
                DateTime DateTimeThis = IssueThis.GetIssueDate();
                //
                // Write Output
                //
                Write(StreamWriterLog, IssueThis.GetNLP());
                if (fTimeGapError == true)
                {
                    WriteLine(StreamWriterLog, " " + IssueThis.GetStrDate() + " Publication Pattern Error - Issue Not Expected On This Date");
                }
                else
                {
                    WriteLine(StreamWriterLog, " " + IssueThis.GetStrDate() + " ok");
                    IssueGood = IssueThis;
                }
                fTimeGapError = false;
                IssueError IssueErrorThis = IssueThis.GetErrorFlag();
                if (IssueErrorThis == (IssueError.Gap | IssueError.IssueSequence))
                {
                    //
                    // Number Of Issues Missing
                    //
                    Issue    IssueNext       = (Issue)ArrayListIssues[iListInx + 1];
                    DateTime DateTimeNext    = IssueNext.GetIssueDate();
                    int      iIssuesToInsert = IssueNext.GetIssue() - IssueThis.GetIssue() - 1;
                    //
                    // Average Number Of Days Between Publications
                    //
                    double dAverageDays = IssueThis.GetAverageDays();
                    if (dAverageDays < 6.0)
                    {
                        //
                        // Day Of The Week For Valid Publication
                        //
                        int iDayOfWeek = (int )DateTimeThis.DayOfWeek;
                        //
                        // Threshold Number Of Publications To Make This Day Of The Week A Legitimate Publication Day
                        //
                        double   dDayOfWeekThreshold = dDaysOfWeek[iDayOfWeek] * 0.6;
                        DateTime DateTimeGood        = IssueGood.GetIssueDate();
                        int      iDayCount           = 0;
                        for (int iInsertInx = 0; iInsertInx < iIssuesToInsert; iInsertInx += 1)
                        {
                            iDayOfWeek = (iDayOfWeek + 1) % 7;
                            iDayCount += 1;
                            if (dDaysOfWeek[iDayOfWeek] > dDayOfWeekThreshold)
                            {
                                DateTime DateTimeNew = DateTimeGood.AddDays((double)iDayCount);
                                if (DateTimeNew < DateTimeNext)
                                {
                                    //
                                    // Write Additional Record
                                    //
                                    Write(StreamWriterLog, IssueThis.GetNLP());
                                    WriteLine(StreamWriterLog, " " + DateTimeNew.ToString("yyyy-MM-dd") + " Inserted Entry Date and Issue Number Gap Found");
                                    //
                                }
                            }
                        }
                    }
                    else
                    {
                        int      iWeekGap     = (int)((dAverageDays + 4) / 7);
                        DateTime DateTimeGood = IssueGood.GetIssueDate();
                        DateTime DateTimeNew  = DateTimeGood.AddDays((double)(iWeekGap * 7));
                        while (DateTimeNew < DateTimeNext)
                        {
                            //
                            // Write Additional Record
                            //
                            Write(StreamWriterLog, IssueThis.GetNLP());
                            WriteLine(StreamWriterLog, " " + DateTimeNew.ToString("yyyy-MM-dd") + " Inserted Entry Date and Issue Number Gap Found");
                            DateTimeNew = DateTimeNew.AddDays((double)(iWeekGap * 7));
                            //
                        }
                        //
                        // Get Next Date - Set Error Flag If Not Next Issue Date
                        //
                        TimeSpan TimeSpanDays = DateTimeNext - DateTimeNew;
                        if (TimeSpanDays.Days != 0)
                        {
                            fTimeGapError = true;
                        }
                    }
                }
                //
            }
            //
            return;
        }
Exemplo n.º 3
0
 //
 // Set Error Flag
 //
 internal void SetErrorFlag(IssueError IssueErrorThis)
 {
     this.IssueErrorThis |= IssueErrorThis;
     return;
 }
Exemplo n.º 4
0
 //
 // Set Error Flag
 //
 internal void SetErrorFlag(IssueError IssueErrorThis)
 {
     this.IssueErrorThis |= IssueErrorThis;
     return;
 }
Exemplo n.º 5
0
 //
 // Initalisation
 //
 internal Issue(StreamWriter StreamWriterLog, String StrMetsFile, String StrMetsIssue, String StrMetsVolume, String StrMetsDate, String StrModsTitle)
 {
     this.StrMetsFile = StrMetsFile;
     this.StrMetsIssue = StrMetsIssue;
     this.StrMetsVolume = StrMetsVolume;
     this.StrMetsDate = StrMetsDate;
     this.StrModsTitle = StrModsTitle;
     //
     // Error Flag
     //
     IssueErrorThis = IssueError.None;
     //
     // Convert To Numbers If Possible
     //
     iIssue = GetNumber(StrMetsIssue);
     iVolume = GetNumber(StrMetsVolume);
     DateTimeIssue = GetDate(StrMetsDate);
     //
     // Parse FileName For Date
     //
     DateTimeFileName = GetFileNameDate(StrMetsFile);
     //
     // Compare Year, Month & Day
     //
     if ((DateTimeIssue.Year != DateTimeFileName.Year) ||
         (DateTimeIssue.Month != DateTimeFileName.Month) ||
         (DateTimeIssue.Day != DateTimeFileName.Day))
     {
         Console.Out.WriteLine("Error: Date Mismatch Between Mods Filename: " + StrMetsFile + " and Mods File Content: " + DateTimeIssue.ToString());
         StreamWriterLog.WriteLine("Error: Date Mismatch Between Mods Filename: " + StrMetsFile + " and Mods File Content: " + DateTimeIssue.ToString());
     }
     //
 }