Example #1
0
 public ShiftNotifierLogic()
 {
     _shiftsService             = Bootstrapper.GetKernel().Resolve <IShiftsService>();
     _communicationService      = Bootstrapper.GetKernel().Resolve <ICommunicationService>();
     _departmentSettingsService = Bootstrapper.GetKernel().Resolve <IDepartmentSettingsService>();
 }
Example #2
0
 public GroupsController(IDepartmentsService departmentsService, IUsersService usersService, IDepartmentGroupsService departmentGroupsService,
                         Model.Services.IAuthorizationService authorizationService, ILimitsService limitsService, IGeoLocationProvider geoLocationProvider, IDeleteService deleteService,
                         IEventAggregator eventAggregator, IUserProfileService userProfileService, IUnitsService unitsService, IShiftsService shiftsService)
 {
     _departmentsService      = departmentsService;
     _usersService            = usersService;
     _departmentGroupsService = departmentGroupsService;
     _authorizationService    = authorizationService;
     _limitsService           = limitsService;
     _geoLocationProvider     = geoLocationProvider;
     _deleteService           = deleteService;
     _eventAggregator         = eventAggregator;
     _userProfileService      = userProfileService;
     _unitsService            = unitsService;
     _shiftsService           = shiftsService;
 }
Example #3
0
        public void PopulateQueue()
        {
            if (!_isLocked)
            {
                _isLocked = true;

                _shiftsService      = Bootstrapper.GetKernel().Resolve <IShiftsService>();
                _userProfileService = Bootstrapper.GetKernel().Resolve <IUserProfileService>();

                var t1 = new Task(async() =>
                {
                    try
                    {
                        var shifts = await _shiftsService.GetShiftsStartingNextDayAsync(DateTime.UtcNow);

                        foreach (var shift in shifts)
                        {
                            var qi = new ShiftNotifierQueueItem();

                            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;

                            _queue.Enqueue(qi);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logging.LogException(ex);
                    }
                    finally
                    {
                        _isLocked = false;
                        _cleared  = false;

                        _shiftsService      = null;
                        _userProfileService = null;
                    }
                });

                t1.Start();
            }
        }
 public ShiftsController(IShiftsService service, IHttpContextAccessor httpContextAccessor) : base(httpContextAccessor)
 {
     _service = service;
 }
Example #5
0
 public NotificationService(IDepartmentNotificationRepository departmentNotificationRepository, IDepartmentsService departmentsService,
                            IUnitsService unitsService, IUserStateService userStateService, IDepartmentGroupsService departmentGroupsService, IActionLogsService actionLogsService,
                            IPersonnelRolesService personnelRolesService, IUserProfileService userProfileService, ICalendarService calendarService, IDocumentsService documentsService,
                            INotesService notesService, IWorkLogsService workLogsService, IShiftsService shiftsService, ICustomStateService customStateService)
 {
     _departmentNotificationRepository = departmentNotificationRepository;
     _departmentsService      = departmentsService;
     _unitsService            = unitsService;
     _userStateService        = userStateService;
     _departmentGroupsService = departmentGroupsService;
     _actionLogsService       = actionLogsService;
     _personnelRolesService   = personnelRolesService;
     _userProfileService      = userProfileService;
     _calendarService         = calendarService;
     _documentsService        = documentsService;
     _notesService            = notesService;
     _workLogsService         = workLogsService;
     _shiftsService           = shiftsService;
     _customStateService      = customStateService;
 }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ShiftsController"/> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="shiftsService">The shifts service.</param>
 public ShiftsController(ILogger <ShiftsController> logger, IShiftsService shiftsService)
 {
     _logger        = logger ?? throw new ArgumentNullException(nameof(logger));
     _shiftsService = shiftsService ?? throw new ArgumentNullException(nameof(shiftsService));
 }
 public GoalsService(IGoalsRepository repo, IShiftsService shifts, IUsersRepository users)
 {
     _repo   = repo;
     _shifts = shifts;
     _users  = users;
 }