public async Task ProcessAsync(SystemQueueProcessorCommand command, IQuidjiboProgress progress, CancellationToken cancellationToken) { if (progress != null) { progress.Report(1, $"Starting the {Name} Task"); } RabbitInboundQueueProvider queue = new RabbitInboundQueueProvider(); queue.CqrsEventQueueReceived += OnCqrsEventQueueReceived; await queue.Start(); while (!cancellationToken.IsCancellationRequested) { Thread.Sleep(500); } //await Task.Factory.StartNew(() => //{ // // Keep alive // while (_running) // { // Thread.Sleep(1000); // } //}, cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Default); if (progress != null) { progress.Report(100, $"Finishing the {Name} Task"); } }
public async Task ProcessAsync(QueuesProcessorCommand command, IQuidjiboProgress progress, CancellationToken cancellationToken) { progress.Report(1, $"Starting the {Name} Task"); RabbitInboundQueueProvider queue = new RabbitInboundQueueProvider(); queue.CallQueueReceived += OnCallQueueReceived; queue.MessageQueueReceived += OnMessageQueueReceived; queue.DistributionListQueueReceived += OnDistributionListQueueReceived; queue.NotificationQueueReceived += OnNotificationQueueReceived; queue.ShiftNotificationQueueReceived += OnShiftNotificationQueueReceived; queue.Start(); await Task.Factory.StartNew(() => { // Keep alive while (_running) { Thread.Sleep(1000); } }, cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Default); progress.Report(100, $"Finishing the {Name} Task"); }
public async Task ProcessAsync(Command command, IQuidjiboProgress progress, CancellationToken cancellationToken) { progress.Report(1, $"Starting item {command.Id}"); await _simpleService.DoWorkAsync(cancellationToken); progress.Report(100, $"Finished item {command.Id}"); }
public async Task ProcessAsync(Commands.StaffingScheduleCommand command, IQuidjiboProgress progress, CancellationToken cancellationToken) { progress.Report(1, $"Starting the {Name} Task"); await Task.Factory.StartNew(() => { var _departmentsService = Bootstrapper.GetKernel().Resolve <IDepartmentsService>(); var _scheduledTasksService = Bootstrapper.GetKernel().Resolve <IScheduledTasksService>(); var logic = new StaffingScheduleLogic(); var allItems = _scheduledTasksService.GetAllUpcomingStaffingScheduledTaks(); if (allItems != null && allItems.Any()) { // Filter only the past items and ones that are 5 minutes 30 seconds in the future var items = (from st in allItems let department = _departmentsService.GetDepartmentByUserId(st.UserId) let runTime = st.WhenShouldJobBeRun(TimeConverterHelper.TimeConverter(DateTime.UtcNow, department)) where runTime.HasValue && runTime.Value >= TimeConverterHelper.TimeConverter(DateTime.UtcNow, department) && runTime.Value <= TimeConverterHelper.TimeConverter(DateTime.UtcNow, department).AddMinutes(5).AddSeconds(30) select new { ScheduledTask = st, Department = department }).ToList(); if (items != null && items.Any()) { _logger.LogInformation("StaffingSchedule::Staffing Levels to Change: " + items.Count()); foreach (var i in items) { var qi = new StaffingScheduleQueueItem(); qi.ScheduledTask = i.ScheduledTask; qi.Department = i.Department; _logger.LogInformation("StaffingSchedule::Processing Staffing Schedule:" + qi.ScheduledTask.ScheduledTaskId); var result = logic.Process(qi); if (result.Item1) { _logger.LogInformation($"StaffingSchedule::Processed Staffing Schedule {qi.ScheduledTask.ScheduledTaskId} successfully."); } else { _logger.LogInformation($"StaffingSchedule::Failed to Process staffing schedule {qi.ScheduledTask.ScheduledTaskId} error {result.Item2}"); } } } } }, cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Default); progress.Report(100, $"Finishing the {Name} Task"); }
public async Task DispatchAsync(IQuidjiboCommand command, IQuidjiboProgress progress, CancellationToken cancellationToken) { var type = typeof(IQuidjiboHandler <>).MakeGenericType(command.GetType()); var resolved = _resolver.Resolve(type); var method = type.GetMethod("ProcessAsync"); await(Task) method.Invoke(resolved, new object[] { command, progress, cancellationToken }); }
public async Task ProcessAsync(CalendarNotificationCommand command, IQuidjiboProgress progress, CancellationToken cancellationToken) { try { progress.Report(1, $"Starting the {Name} Task"); //await Task.Run(async () => //{ var _calendarService = Bootstrapper.GetKernel().Resolve <ICalendarService>(); var logic = new CalendarNotifierLogic(); var calendarItems = await _calendarService.GetCalendarItemsToNotifyAsync(DateTime.UtcNow); if (calendarItems != null) { _logger.LogInformation("CalendarNotification::Calendar Items to Notify: " + calendarItems.Count); foreach (var calendarItem in calendarItems) { var qi = new CalendarNotifierQueueItem(); qi.CalendarItem = calendarItem; _logger.LogInformation("CalendarNotification::Processing Notification for CalendarId:" + qi.CalendarItem.CalendarItemId); var result = await logic.Process(qi); if (result.Item1) { _logger.LogInformation($"CalendarNotification::Processed Calendar Notification {qi.CalendarItem.CalendarItemId} successfully."); } else { _logger.LogInformation($"CalendarNotification::Failed to Processed Calendar Notification {qi.CalendarItem.CalendarItemId} error {result.Item2}"); } } } else { progress.Report(6, "CalendarNotification::No Calendar Items to Notify"); } //}, cancellationToken); progress.Report(100, $"Finishing the {Name} Task"); } catch (Exception ex) { Resgrid.Framework.Logging.LogException(ex); _logger.LogError(ex.ToString()); } }
public async Task ProcessAsync(CallPruneCommand command, IQuidjiboProgress progress, CancellationToken cancellationToken) { try { progress.Report(1, $"Starting the {Name} Task"); //await Task.Run(async () => //{ var _departmentsService = Bootstrapper.GetKernel().Resolve <IDepartmentsService>(); var logic = new CallPruneLogic(); var items = await _departmentsService.GetAllDepartmentCallPruningsAsync(); if (items != null) { _logger.LogInformation("CallPrune::Call Pruning To Process: " + items.Count); foreach (var i in items) { var item = new CallPruneQueueItem(); item.PruneSettings = i; _logger.LogInformation("CallPrune::Pruning Calls for DepartmentId:" + item.PruneSettings.DepartmentId); item.PruneSettings.Department = await _departmentsService.GetDepartmentByIdAsync(item.PruneSettings.DepartmentId); var result = await logic.Process(item); if (result.Item1) { _logger.LogInformation($"CallPrune::Pruned Calls for Department {item.PruneSettings.DepartmentId} successfully."); } else { _logger.LogInformation($"CallPrune::Failed to Process Calls for Department {item.PruneSettings.DepartmentId} error {result.Item2}"); } } } //}, cancellationToken); progress.Report(100, $"Finishing the {Name} Task"); } catch (Exception ex) { Resgrid.Framework.Logging.LogException(ex); _logger.LogError(ex.ToString()); } }
public async Task ProcessAsync(CallEmailImportCommand command, IQuidjiboProgress progress, CancellationToken cancellationToken) { progress.Report(1, $"Starting the {Name} Task"); try { //await Task.Run(async () => //{ var _departmentsService = Bootstrapper.GetKernel().Resolve <IDepartmentsService>(); var logic = new CallEmailImporterLogic(); //var items = await _departmentsService.GetAllDepartmentEmailSettingsAsync(); var items = new List <DepartmentCallEmail>(); if (items != null) { _logger.LogInformation("CallEmailImport::Email Import Settings: " + items.Count); foreach (var i in items) { var cqi = new CallEmailQueueItem(); cqi.EmailSettings = i; _logger.LogInformation("CallEmailImport::Processing Email for DepartmentCallEmailId:" + cqi.EmailSettings.DepartmentCallEmailId); var result = await logic.Process(cqi); if (result.Item1) { _logger.LogInformation($"CallEmailImport::Processed Email Import {cqi.EmailSettings.DepartmentCallEmailId} successfully."); } else { _logger.LogInformation($"CallEmailImport::Failed to Processed Email Import {cqi.EmailSettings.DepartmentCallEmailId} error {result.Item2}"); } } } //}, cancellationToken); progress.Report(100, $"Finishing the {Name} Task"); } catch (Exception ex) { Resgrid.Framework.Logging.LogException(ex); _logger.LogError(ex.ToString()); } }
public async Task ProcessAsync(TrainingNotiferCommand command, IQuidjiboProgress progress, CancellationToken cancellationToken) { try { progress.Report(1, $"Starting the {Name} Task"); //await Task.Run(async () => //{ var _trainingService = Bootstrapper.GetKernel().Resolve <ITrainingService>(); var logic = new TrainingNotifierLogic(); var trainings = await _trainingService.GetTrainingsToNotifyAsync(DateTime.UtcNow); if (trainings != null && trainings.Any()) { _logger.LogInformation("TrainingNotifer::Trainings to Notify: " + trainings.Count()); foreach (var training in trainings) { var qi = new TrainingNotifierQueueItem(); qi.Training = training; progress.Report(3, "TrainingNotifer::Processing Training Notification: " + qi.Training.TrainingId); var result = await logic.Process(qi); if (result.Item1) { _logger.LogInformation($"TrainingNotifer::Processed Training Notification {qi.Training.TrainingId} successfully."); } else { _logger.LogInformation($"TrainingNotifer::Failed to Process Training Notification {qi.Training.TrainingId} error {result.Item2}"); } } } //}, cancellationToken); progress.Report(100, $"Finishing the {Name} Task"); } catch (Exception ex) { Resgrid.Framework.Logging.LogException(ex); _logger.LogError(ex.ToString()); } }
public async Task ProcessAsync(CalendarNotificationCommand command, IQuidjiboProgress progress, CancellationToken cancellationToken) { progress.Report(1, $"Starting the {Name} Task"); await Task.Factory.StartNew(() => { var _calendarService = Bootstrapper.GetKernel().Resolve <ICalendarService>(); var logic = new CalendarNotifierLogic(); var calendarItems = _calendarService.GetV2CalendarItemsToNotify(DateTime.UtcNow); if (calendarItems != null) { _logger.LogInformation("CalendarNotification::Calendar Items to Notify: " + calendarItems.Count); foreach (var calendarItem in calendarItems) { var qi = new CalendarNotifierQueueItem(); qi.CalendarItem = calendarItem; _logger.LogInformation("CalendarNotification::Processing Notification for CalendarId:" + qi.CalendarItem.CalendarItemId); var result = logic.Process(qi); if (result.Item1) { _logger.LogInformation($"CalendarNotification::Processed Calendar Notification {qi.CalendarItem.CalendarItemId} successfully."); } else { _logger.LogInformation($"CalendarNotification::Failed to Processed Calendar Notification {qi.CalendarItem.CalendarItemId} error {result.Item2}"); } } } else { progress.Report(6, "CalendarNotification::No Calendar Items to Notify"); } }, cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Default); progress.Report(100, $"Finishing the {Name} Task"); }
public async Task ProcessAsync(CallPruneCommand command, IQuidjiboProgress progress, CancellationToken cancellationToken) { progress.Report(1, $"Starting the {Name} Task"); await Task.Factory.StartNew(() => { var _departmentsService = Bootstrapper.GetKernel().Resolve <IDepartmentsService>(); var logic = new CallPruneLogic(); var items = _departmentsService.GetAllDepartmentCallPrunings(); if (items != null) { _logger.LogInformation("CallPrune::Call Pruning To Process: " + items.Count); foreach (var i in items) { var item = new CallPruneQueueItem(); item.PruneSettings = i; _logger.LogInformation("CallPrune::Processing Calls for DepartmentId:" + item.PruneSettings.DepartmentId); var result = logic.Process(item); if (result.Item1) { _logger.LogInformation($"CallPrune::Processing Calls for Department {item.PruneSettings.DepartmentId} successfully."); } else { _logger.LogInformation($"CallPrune::Failed to Process Calls for Department {item.PruneSettings.DepartmentId} error {result.Item2}"); } } } }, cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Default); progress.Report(100, $"Finishing the {Name} Task"); }
public async Task ProcessAsync(PaymentQueueProcessorCommand command, IQuidjiboProgress progress, CancellationToken cancellationToken) { if (progress != null) { progress.Report(1, $"Starting the {Name} Task"); } RabbitInboundQueueProvider queue = new RabbitInboundQueueProvider(); queue.PaymentEventQueueReceived += OnPaymentEventQueueReceived; await queue.Start(); while (!cancellationToken.IsCancellationRequested) { Thread.Sleep(500); } if (progress != null) { progress.Report(100, $"Finishing the {Name} Task"); } }
public async Task ProcessAsync(TrainingNotiferCommand command, IQuidjiboProgress progress, CancellationToken cancellationToken) { progress.Report(1, $"Starting the {Name} Task"); await Task.Factory.StartNew(() => { var _trainingService = Bootstrapper.GetKernel().Resolve <ITrainingService>(); var logic = new TrainingNotifierLogic(); var trainings = _trainingService.GetTrainingsToNotify(DateTime.UtcNow); if (trainings != null && trainings.Any()) { _logger.LogInformation("TrainingNotifer::Trainings to Notify: " + trainings.Count()); foreach (var training in trainings) { var qi = new TrainingNotifierQueueItem(); qi.Training = training; progress.Report(3, "TrainingNotifer::Processing Training Notification: " + qi.Training.TrainingId); var result = logic.Process(qi); if (result.Item1) { _logger.LogInformation($"TrainingNotifer::Processed Training Notification {qi.Training.TrainingId} successfully."); } else { _logger.LogInformation($"TrainingNotifer::Failed to Process Training Notification {qi.Training.TrainingId} error {result.Item2}"); } } } }, cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Default); progress.Report(100, $"Finishing the {Name} Task"); }
public async Task ProcessAsync(ShiftNotiferCommand command, IQuidjiboProgress progress, CancellationToken cancellationToken) { try { progress.Report(1, $"Starting the {Name} Task"); //await Task.Run(async () => //{ IUserProfileService _userProfileService = null; ILogService _logsService = null; var _shiftsService = Bootstrapper.GetKernel().Resolve <IShiftsService>(); var logic = new ShiftNotifierLogic(); var shifts = await _shiftsService.GetShiftsStartingNextDayAsync(DateTime.UtcNow); if (shifts != null && shifts.Any()) { _logger.LogInformation("ShiftNotifer::Shifts to Notify: " + shifts.Count()); _userProfileService = Bootstrapper.GetKernel().Resolve <IUserProfileService>(); _logsService = Bootstrapper.GetKernel().Resolve <ILogService>(); foreach (var shift in shifts) { var qi = new ShiftNotifierQueueItem(); var processLog = await _logsService.GetProcessLogForTypeTimeAsync(ProcessLogTypes.ShiftNotifier, shift.ShiftId, shift.StartDay); if (processLog != null) { await _logsService.SetProcessLogAsync(ProcessLogTypes.ShiftNotifier, shift.ShiftId, shift.StartDay); if (shift.Personnel != null && shift.Personnel.Any()) { qi.Profiles = await _userProfileService.GetSelectedUserProfilesAsync(shift.Personnel.Select(x => x.UserId).ToList()); } qi.Day = shift.GetShiftDayforDateTime(DateTime.UtcNow.AddDays(1)); if (qi.Day != null) { if (qi.Profiles == null) { qi.Profiles = new List <UserProfile>(); } qi.Signups = await _shiftsService.GetShiftSignpsForShiftDayAsync(qi.Day.ShiftDayId); if (qi.Signups != null && qi.Signups.Any()) { qi.Profiles.AddRange(await _userProfileService.GetSelectedUserProfilesAsync(qi.Signups.Select(x => x.UserId).ToList())); var users = new List <string>(); foreach (var signup in qi.Signups) { if (signup.Trade != null) { if (!String.IsNullOrWhiteSpace(signup.Trade.UserId)) { users.Add(signup.Trade.UserId); } else if (signup.Trade.TargetShiftSignup != null) { users.Add(signup.Trade.TargetShiftSignup.UserId); } } } if (users.Any()) { qi.Profiles.AddRange(await _userProfileService.GetSelectedUserProfilesAsync(users)); } } } qi.Shift = shift; _logger.LogInformation("ShiftNotifer::Processing Shift Notification: " + qi.Shift.ShiftId); var result = await logic.Process(qi); if (result.Item1) { _logger.LogInformation($"ShiftNotifer::Processed Shift Notification {qi.Shift.ShiftId} successfully."); } else { _logger.LogInformation($"ShiftNotifer::Failed to Process shift notification {qi.Shift.ShiftId} error {result.Item2}"); } } } } //}, cancellationToken); progress.Report(100, $"Finishing the {Name} Task"); } catch (Exception ex) { Resgrid.Framework.Logging.LogException(ex); _logger.LogError(ex.ToString()); } }
public Task ProcessAsync(BasicCommand command, IQuidjiboProgress progress, CancellationToken cancellationToken) { throw new NotImplementedException(); }
public async Task ProcessAsync(Commands.StatusScheduleCommand command, IQuidjiboProgress progress, CancellationToken cancellationToken) { try { progress.Report(1, $"Starting the {Name} Task"); //await Task.Run(async () => //{ var _departmentsService = Bootstrapper.GetKernel().Resolve <IDepartmentsService>(); var _scheduledTasksService = Bootstrapper.GetKernel().Resolve <IScheduledTasksService>(); var logic = new StaffingScheduleLogic(); var allDepartments = await _departmentsService.GetAllAsync(); var allItems = await _scheduledTasksService.GetAllUpcomingStatusScheduledTasksAsync(); if (allItems != null && allItems.Any()) { // Filter only the past items and ones that are 5 minutes 30 seconds in the future var items = (from st in allItems let department = allDepartments.FirstOrDefault(x => x.DepartmentId == st.DepartmentId) let runTime = st.WhenShouldJobBeRun(TimeConverterHelper.TimeConverter(DateTime.UtcNow, department)) where runTime.HasValue && runTime.Value >= TimeConverterHelper.TimeConverter(DateTime.UtcNow, department) && runTime.Value <= TimeConverterHelper.TimeConverter(DateTime.UtcNow, department).AddMinutes(5).AddSeconds(30) select new { ScheduledTask = st, Department = department }).ToList(); if (items != null && items.Any()) { _logger.LogInformation("StatusSchedule::Status Levels to Change: " + items.Count()); foreach (var i in items) { var qi = new StaffingScheduleQueueItem(); qi.ScheduledTask = i.ScheduledTask; qi.Department = i.Department; _logger.LogInformation("StatusSchedule::Processing Status Schedule:" + qi.ScheduledTask.ScheduledTaskId); var result = await logic.Process(qi); if (result.Item1) { _logger.LogInformation($"StatusSchedule::Processed Status Schedule {qi.ScheduledTask.ScheduledTaskId} successfully."); } else { _logger.LogInformation($"StatusSchedule::Failed to Process status schedule {qi.ScheduledTask.ScheduledTaskId} error {result.Item2}"); } } } } //}, cancellationToken); progress.Report(100, $"Finishing the {Name} Task"); } catch (Exception ex) { Resgrid.Framework.Logging.LogException(ex); _logger.LogError(ex.ToString()); } }
public async Task ProcessAsync(ReportDeliveryTaskCommand command, IQuidjiboProgress progress, CancellationToken cancellationToken) { progress.Report(1, $"Starting the {Name} Task"); await Task.Factory.StartNew(() => { var _departmentsService = Bootstrapper.GetKernel().Resolve <IDepartmentsService>(); var _scheduledTasksService = Bootstrapper.GetKernel().Resolve <IScheduledTasksService>(); var _usersService = Bootstrapper.GetKernel().Resolve <IUsersService>(); var logic = new ReportDeliveryLogic(); var allItems = _scheduledTasksService.GetUpcomingScheduledTaks(); if (allItems != null) { // Filter only the past items and ones that are 5 minutes 30 seconds in the future var items = from st in allItems let department = _departmentsService.GetDepartmentByUserId(st.UserId) let email = _usersService.GetMembershipByUserId(st.UserId).Email let runTime = st.WhenShouldJobBeRun(TimeConverterHelper.TimeConverter(DateTime.UtcNow, department)) where st.TaskType == (int)TaskTypes.ReportDelivery && runTime.HasValue && runTime.Value >= TimeConverterHelper.TimeConverter(DateTime.UtcNow, department) && runTime.Value <= TimeConverterHelper.TimeConverter(DateTime.UtcNow, department).AddMinutes(5).AddSeconds(30) select new { ScheduledTask = st, Department = department, Email = email }; if (items != null && items.Count() > 0) { _logger.LogInformation("ReportDelivery::Reports to Deliver: " + items.Count()); foreach (var i in items) { var qi = new ReportDeliveryQueueItem(); qi.ScheduledTask = i.ScheduledTask; qi.Department = i.Department; qi.Email = i.Email; _logger.LogInformation("ReportDelivery::Processing Report:" + qi.ScheduledTask.ScheduledTaskId); var result = logic.Process(qi); if (result.Item1) { _logger.LogInformation($"ReportDelivery::Processed Report {qi.ScheduledTask.ScheduledTaskId} successfully."); } else { _logger.LogInformation($"ReportDelivery::Failed to Process report {qi.ScheduledTask.ScheduledTaskId} error {result.Item2}"); } } } } }, cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Default); progress.Report(100, $"Finishing the {Name} Task"); }
public async Task ProcessAsync(DependentCommand command, IQuidjiboProgress progress, CancellationToken cancellationToken) { await Task.CompletedTask; }