/// <summary> /// משנה עונה לעונה מוגדרת כאשר יש מספיק מידע המוכיח את השוני המשמעותי בעונה /// </summary> /// <param name="seasonType"></param> /// <param name="num"></param> public static void DefineSeasonInfo(int seasonType, int num) { Hospital_DBEntities2 db = new Hospital_DBEntities2(); List <Seasons> tempSeasons = new List <Seasons>(); Seasons tempLongSeasons = new Seasons(); switch (seasonType) { case 1: { db.Seasons.Add(new Seasons { Date = DateTime.Today.Date, IsDefined = true, NumOfDays = 1 }); db.SaveChanges(); tempSeasons = BLManager.GetCurrentDate(false); tempLongSeasons = BLManager.GetLongDateSeason(); BLManager.CurrentDate = db.Seasons.Last(); } break; case 2: { db.Seasons.Add(new Seasons { HebrewDate = DateTime.Today.Date, IsDefined = true, NumOfDays = 1 }); db.SaveChanges(); tempSeasons = BLManager.GetCurrentHeberewDate(false); tempLongSeasons = BLManager.GetLongHeberewDateSeason(); BLManager.CurrentHeberewDate = db.Seasons.Last(); } break; case 3: { db.Seasons.Add(new Seasons { DayOfWeek = (int)DateTime.Today.DayOfWeek, IsDefined = true, NumOfDays = 1 }); tempSeasons = BLManager.GetCurrentDayOfWeek(false); BLManager.CurrentDayOfWeek = db.Seasons.Last(); } break; } db.SaveChanges(); List <SeasonInformation> seasonTempInfo = new List <SeasonInformation>(); if (tempLongSeasons == null) { //מקבץ את כל המידע לתקופה של תקופת יום בשבוע מסויימת לא מוגדרות CombineSeasons(GetInfoForSeasonList(tempSeasons), num, db.Seasons.ToList().Last().SeasonCode); } else { if (seasonType == 1) { BLManager.CurrentDate = tempLongSeasons; } else { BLManager.CurrentHeberewDate = tempLongSeasons; } CombineSeasons(GetInfoForSeasonList(tempSeasons), 5, tempLongSeasons.SeasonCode); db.Seasons.Remove(db.Seasons.Last()); } db.SeasonInformation.ToList().ForEach(se => tempSeasons.ForEach(s => { if (se.SeasonCode == s.SeasonCode) { seasonTempInfo.Add(se); } })); db.SeasonInformation.RemoveRange(seasonTempInfo); db.SaveChanges(); List <int> listCode = tempSeasons.Select(i => i.SeasonCode).ToList(); db.Seasons.RemoveRange(db.Seasons.Where(item => listCode.Any(item2 => item2 == item.SeasonCode))); }
/// <summary> /// אם הממוצע היומי שונה משמעותית מהמידע הכללי ולא מופיע לתאריך זה מידע שהוגדר /// נוצר מופע חדש של עונה לא מוגדרת המכילה את כל הנתונים- תאריך עברי לועזי ויום בשבוע לצורך בדיקה /// </summary> public void AddSeason() { List <Seasons> seasonToCheck = new List <Seasons>(); Hospital_DBEntities2 db = new Hospital_DBEntities2(); if (BLManager.CurrentDate != null) { seasonToCheck.Add(BLManager.CurrentDate); } if (BLManager.CurrentHeberewDate != null) { seasonToCheck.Add(BLManager.CurrentHeberewDate); } else if (BLManager.CurrentDate == null) { seasonToCheck.Add(new Seasons { Date = DateTime.Today, DayOfWeek = ((int)DateTime.Today.DayOfWeek) + 1, HebrewDate = DateTime.Today, IsDefined = false, NumOfDays = 1 }); db.Seasons.Add(seasonToCheck[0]); db.SaveChanges(); } seasonToCheck.ForEach(s => { db.SeasonInformation.Add(new SeasonInformation { AddingDate = DateTime.Today, DepartmentCode = DepartmentCode, Ishistory = false, StaffAvg = StaffAvg, WaitersAvg = WaitersAvg, WaitingTimeAvg = DayWaitingAvg, Whidnesstochange = 1, SeasonCode = s.SeasonCode }); }); db.SaveChanges(); if (BLManager.GetCurrentDate(false).Count() == 10) { DefineSeasonInfo(1, 5); } if (BLManager.GetCurrentHeberewDate(false).Count() == 10) { DefineSeasonInfo(2, 5); } if (BLManager.GetCurrentDayOfWeek(false).Count() == 100) { DefineSeasonInfo(3, 52); } }