Пример #1
0
 private static void CheckForEfficiency()
 {
     if (!File.Exists(Management.GetPath("Efficiency")))
     {
         using (File.Create(Management.GetPath("Efficiency"))) { }
         StatsManagement.AddNewWeekIntoEfficiency(2);
     }
 }
Пример #2
0
        public static void CheckWeekRelevance()
        {
            StatsManagement stats      = new StatsManagement();
            string          commonFile = Management.GetPath("Common");
            int             fileWeekNumber;
            int             fileYear;
            int             numberOfWeeks = 0;

            string[] commonFileArr = File.ReadAllLines(commonFile);

            for (int i = 0; i < commonFileArr.Length; i++)
            {
                if (Management.GetValueByIndex(commonFileArr[i], 0) == "Week Number")
                {
                    fileYear       = Convert.ToInt32(Management.GetValueByIndex(commonFileArr[i], 2));
                    fileWeekNumber = Convert.ToInt32(Management.GetValueByIndex(commonFileArr[i], 1));

                    if (fileWeekNumber != WeekNumber || fileYear != DateTime.Now.Year)
                    {
                        if (DateTime.Now.Year - fileYear == 1 && weekNumber == 52 || DateTime.Now.Year == fileYear)
                        {
                            numberOfWeeks = weekNumber - fileWeekNumber;
                        }
                        else
                        {
                            numberOfWeeks  = (DateTime.Now.Year - fileYear - 1) * 54; //разница между годами
                            numberOfWeeks += 52 - fileWeekNumber;                     //пропущенные недели года последнего использования
                            numberOfWeeks += weekNumber;                              //недели этого года
                        }

                        StatsManagement.AddNewWeekIntoEfficiency(numberOfWeeks);
                        commonFileArr[i] = $"Week Number!{WeekNumber}!{DateTime.Now.Year}";
                        File.WriteAllLines(commonFile, commonFileArr);
                        break;
                    }
                }
            }
        }