public UnitOfWork(GeneratorSurveillanceDBEntities context) { _context = context; GeneratorUsage = new GeneratorUsageRepository(_context); GeneratorInformation = new GeneratorInformationRepository(_context); GeneratorScheduler = new GeneratorSchedulerRepository(_context); GeneratorRunningHr = new GeneratorRunningHrsRepository(_context); GeneratorMaintenance = new GeneratorMaintenanceRepository(_context); GeneratorFuelling = new GeneratorFuellingRepository(_context); ConsumptionSetting = new ConsumptionSettingRepository(_context); AuthoriserSetting = new AuthorisersSettingRepository(_context); ActionPartySetting = new ActionPartySettingRepository(_context); ReminderSetting = new ReminderSettingRepository(_context); }
public ReminderSettingRepository(GeneratorSurveillanceDBEntities context) : base(context) { }
public GeneratorSchedulerRepository(GeneratorSurveillanceDBEntities context) : base(context) { }
public ConsumptionSettingRepository(GeneratorSurveillanceDBEntities context) : base(context) { }
public GeneratorMaintenanceRepository(GeneratorSurveillanceDBEntities context) : base(context) { }
public GeneratorRunningHrsRepository(GeneratorSurveillanceDBEntities context) : base(context) { }
public ActionPartySettingRepository(GeneratorSurveillanceDBEntities context) : base(context) { }
public GeneratorFuellingRepository(GeneratorSurveillanceDBEntities context) : base(context) { }
public static async void Initialise() { GeneratorSurveillanceDBEntities GSE = container.Resolve <GeneratorSurveillanceDBEntities>(); GeneratorSchedulerRepository GSR = new GeneratorSchedulerRepository(GSE); TimeSpan CheckDuration = NotificationTimerInterval.Interval; GeneratorSchedulerRepository = GSR; AllGeneratorSchedules = GSR.GetAllGeneratorSchedules(); GetAllGeneratorMaintenances = GMR.GetAllGeneratorMaintenances(); if (GetAllGeneratorMaintenances.Count != 0 && GeneratorName != null) { MaintenanceDeliverable = GetAllGeneratorMaintenances .Where(x => x.GeneratorName == GeneratorName) .OrderByDescending(x => x.Date).FirstOrDefault().Comments; } DateTime dateTime = DateTime.Now; List <GeneratorScheduler> NextGeneratorForNotifications = AllGeneratorSchedules .Where(x => x.IsActive == "Yes") .Where(x => x.ReminderDateTimeProfile > dateTime) .Where(x => x.ReminderDateTimeProfile < dateTime + CheckDuration) .OrderBy(x => x.ReminderDateTimeProfile - dateTime) .ToList(); int NextGeneratorForNotificationsCount = NextGeneratorForNotifications.Count(); if (NextGeneratorForNotificationsCount != 0) { List <Task> NotificationTasks = new List <Task>(); foreach (var item in NextGeneratorForNotifications) { int GenID = GeneratorID; string GenName = GeneratorName; string RemLevel = ReminderLevel; int FstID = FirstID; int LstID = LastID; DateTime FlNotfnDate = FinalNotificationDate; TimeSpan NtNotfnDate = NextNotificationDuration; NotificationTasks.Add(Task.Run (async() => { int GeneratorID = item.SN; string GeneratorName = item.GeneratorName; string ReminderLevel = item.ReminderLevel; int FirstID = AllGeneratorSchedules .Where(x => x.GeneratorName == item.GeneratorName) .Where(x => x.IsActive == "Yes") .OrderBy(x => x.SN) .FirstOrDefault().SN; int LastID = AllGeneratorSchedules .Where(x => x.GeneratorName == item.GeneratorName) .Where(x => x.IsActive == "Yes") .OrderBy(x => x.SN) .LastOrDefault().SN; DateTime FinalNotificationDate = AllGeneratorSchedules .Where(x => x.GeneratorName == item.GeneratorName) .Where(x => x.IsActive == "Yes") .Where(x => x.ReminderDateTimeProfile > dateTime) .OrderByDescending(x => dateTime - x.ReminderDateTimeProfile) .LastOrDefault().ReminderDateTimeProfile; TimeSpan NextNotificationDuration = item.ReminderDateTimeProfile - dateTime; double SecondsFromNextNotification = NextNotificationDuration.TotalSeconds; await Task.Delay (Convert.ToInt32(SecondsFromNextNotification) * 1000); SendNotification(GeneratorName, ReminderLevel, NextNotificationDuration, FinalNotificationDate, FirstID, LastID, GeneratorID, MaintenanceDeliverable); Debug.Print(Convert.ToString(GeneratorID)); Debug.Print(Convert.ToString(FirstID)); Debug.Print(Convert.ToString(LastID)); Debug.Print(Convert.ToString(GeneratorName)); Debug.Print(Convert.ToString(ReminderLevel)); Debug.Print(Convert.ToString(FinalNotificationDate)); Debug.Print(Convert.ToString(NextNotificationDuration)); } )); } await Task.WhenAll(NotificationTasks); } }
public AuthorisersSettingRepository(GeneratorSurveillanceDBEntities context) : base(context) { }
public GeneratorInformationRepository(GeneratorSurveillanceDBEntities context) : base(context) { }