/// <summary> /// scan the table unusual to check if there is unusual that return and if so create new activity-time with the update data /// </summary> /// <param name="unusual"></param> private static void scanUnusuals(DAL.unusual unusual) { //כרגע אין פה התיחסות לחריגות של משמרות מיוחדות var servicesUnusuals = DAL.UnusualDal.GetUnusuals(unusual.activityTime.serviceId).Where(u => u.kindOfUnusual == unusual.kindOfUnusual); var weeklyUnusuals = servicesUnusuals.Where(u => u.activityTime.dayInWeek == unusual.activityTime.dayInWeek).ToList(); var monthlyyUnusuals = servicesUnusuals.Where(u => u.startTime.Value.Day == unusual.startTime.Value.Day); var yearUnusuals = servicesUnusuals.Where(u => u.startTime.Value.DayOfYear == unusual.startTime.Value.DayOfYear); //todo: לטפל בחריגות הפוכה //חריגות הפוכה // weeklyUnusuals = servicesUnusuals.Where(u => u.activityTime.dayInWeek == unusual.activityTime.dayInWeek).ToList(); // monthlyyUnusuals = servicesUnusuals.Where(u => DateTime.Today.Day == DateTime.Today.Day); // yearUnusuals = servicesUnusuals.Where(u => u.activityTime.dayInWeek == unusual.activityTime.dayInWeek); if (weeklyUnusuals.Count() > 10) { TimeSpan startTime = weeklyUnusuals.Max(u => u.startTime.Value.TimeOfDay); TimeSpan endTime = weeklyUnusuals.Min(u => u.endTime.Value); for (int i = 0; i < weeklyUnusuals.Count(); i++) { if (weeklyUnusuals.ElementAt(i).startTime.Value.TimeOfDay > endTime || weeklyUnusuals.ElementAt(i).endTime.Value < startTime) { weeklyUnusuals.RemoveAt(i--); } } if (weeklyUnusuals.Count() > 10) { } } }
public static void AddUnUsual(unusual unusual) { try { using (onLineEntities1 entities1 = new onLineEntities1()) { entities1.unusuals.Add(unusual); entities1.SaveChanges(); } } catch (Exception) { throw; } }