Example #1
0
 public UnitAppController(
     IUsersService usersService,
     IActionLogsService actionLogsService,
     IDepartmentsService departmentsService,
     IUserProfileService userProfileService,
     IWebEventPublisher webEventPublisher,
     IUserStateService userStateService,
     IUnitsService unitsService,
     ICallsService callsService,
     IDepartmentGroupsService departmentGroupsService,
     IPersonnelRolesService personnelRolesService,
     ICustomStateService customStateService,
     IGeoLocationProvider geoLocationProvider,
     ICqrsProvider cqrsProvider
     )
 {
     _usersService            = usersService;
     _actionLogsService       = actionLogsService;
     _departmentsService      = departmentsService;
     _userProfileService      = userProfileService;
     _webEventPublisher       = webEventPublisher;
     _userStateService        = userStateService;
     _unitsService            = unitsService;
     _callsService            = callsService;
     _departmentGroupsService = departmentGroupsService;
     _personnelRolesService   = personnelRolesService;
     _customStateService      = customStateService;
     _geoLocationProvider     = geoLocationProvider;
     _cqrsProvider            = cqrsProvider;
 }
Example #2
0
 public TrainingsController(IDepartmentGroupsService departmentGroupsService, IDepartmentsService departmentService, ITrainingService trainingService, IPersonnelRolesService personnelRolesService)
 {
     _departmentGroupsService = departmentGroupsService;
     _departmentsService      = departmentService;
     _trainingService         = trainingService;
     _personnelRolesService   = personnelRolesService;
 }
Example #3
0
 public HomeController(IDepartmentsService departmentsService, IUsersService usersService, IActionLogsService actionLogsService,
                       IUserStateService userStateService, IDepartmentGroupsService departmentGroupsService, Resgrid.Model.Services.IAuthorizationService authorizationService,
                       IUserProfileService userProfileService, ICallsService callsService, IGeoLocationProvider geoLocationProvider, IDepartmentSettingsService departmentSettingsService,
                       IUnitsService unitsService, IAddressService addressService, IPersonnelRolesService personnelRolesService, IPushService pushService, ILimitsService limitsService,
                       ICustomStateService customStateService, IEventAggregator eventAggregator, IOptions <AppOptions> appOptionsAccessor, UserManager <IdentityUser> userManager)
 {
     _departmentsService        = departmentsService;
     _usersService              = usersService;
     _actionLogsService         = actionLogsService;
     _userStateService          = userStateService;
     _departmentGroupsService   = departmentGroupsService;
     _authorizationService      = authorizationService;
     _userProfileService        = userProfileService;
     _callsService              = callsService;
     _geoLocationProvider       = geoLocationProvider;
     _departmentSettingsService = departmentSettingsService;
     _unitsService              = unitsService;
     _addressService            = addressService;
     _personnelRolesService     = personnelRolesService;
     _pushService        = pushService;
     _limitsService      = limitsService;
     _customStateService = customStateService;
     _eventAggregator    = eventAggregator;
     _appOptionsAccessor = appOptionsAccessor;
     _userManager        = userManager;
 }
Example #4
0
 public CallsController(
     ICallsService callsService,
     IDepartmentsService departmentsService,
     IUserProfileService userProfileService,
     IGeoLocationProvider geoLocationProvider,
     IAuthorizationService authorizationService,
     IQueueService queueService,
     IUsersService usersService,
     IUnitsService unitsService,
     IActionLogsService actionLogsService,
     IDepartmentGroupsService departmentGroupsService,
     IPersonnelRolesService personnelRolesService
     )
 {
     _callsService            = callsService;
     _departmentsService      = departmentsService;
     _userProfileService      = userProfileService;
     _geoLocationProvider     = geoLocationProvider;
     _authorizationService    = authorizationService;
     _queueService            = queueService;
     _usersService            = usersService;
     _unitsService            = unitsService;
     _actionLogsService       = actionLogsService;
     _departmentGroupsService = departmentGroupsService;
     _personnelRolesService   = personnelRolesService;
 }
Example #5
0
 public BigBoardController(
     IUsersService usersService,
     IActionLogsService actionLogsService,
     IDepartmentsService departmentsService,
     IUserProfileService userProfileService,
     IUserStateService userStateService,
     IUnitsService unitsService,
     ICallsService callsService,
     IDepartmentGroupsService departmentGroupsService,
     IPersonnelRolesService personnelRolesService,
     ICustomStateService customStateService,
     IDepartmentSettingsService departmentSettingsService,
     IGeoLocationProvider geoLocationProvider
     )
 {
     _usersService              = usersService;
     _actionLogsService         = actionLogsService;
     _departmentsService        = departmentsService;
     _userProfileService        = userProfileService;
     _userStateService          = userStateService;
     _unitsService              = unitsService;
     _callsService              = callsService;
     _departmentGroupsService   = departmentGroupsService;
     _personnelRolesService     = personnelRolesService;
     _customStateService        = customStateService;
     _departmentSettingsService = departmentSettingsService;
     _geoLocationProvider       = geoLocationProvider;
 }
Example #6
0
 public DispatchController(
     IUsersService usersService,
     IActionLogsService actionLogsService,
     IDepartmentsService departmentsService,
     IUserProfileService userProfileService,
     IUserStateService userStateService,
     IUnitsService unitsService,
     ICallsService callsService,
     IDepartmentGroupsService departmentGroupsService,
     IPersonnelRolesService personnelRolesService,
     ICustomStateService customStateService,
     IGeoLocationProvider geoLocationProvider,
     ICqrsProvider cqrsProvider,
     IDepartmentSettingsService departmentSettingsService,
     ITemplatesService templatesService
     )
 {
     _usersService              = usersService;
     _actionLogsService         = actionLogsService;
     _departmentsService        = departmentsService;
     _userProfileService        = userProfileService;
     _userStateService          = userStateService;
     _unitsService              = unitsService;
     _callsService              = callsService;
     _departmentGroupsService   = departmentGroupsService;
     _personnelRolesService     = personnelRolesService;
     _customStateService        = customStateService;
     _geoLocationProvider       = geoLocationProvider;
     _cqrsProvider              = cqrsProvider;
     _departmentSettingsService = departmentSettingsService;
     _templatesService          = templatesService;
 }
Example #7
0
 public CoreDataController(
     IUsersService usersService,
     IDepartmentsService departmentsService,
     IUserProfileService userProfileService,
     IUnitsService unitsService,
     IDepartmentGroupsService departmentGroupsService,
     IPersonnelRolesService personnelRolesService,
     ICustomStateService customStateService,
     IPermissionsService permissionsService,
     ICallsService callsService,
     IFirebaseService firebaseService,
     IDepartmentSettingsService departmentSettingsService
     )
 {
     _usersService              = usersService;
     _departmentsService        = departmentsService;
     _userProfileService        = userProfileService;
     _unitsService              = unitsService;
     _departmentGroupsService   = departmentGroupsService;
     _personnelRolesService     = personnelRolesService;
     _customStateService        = customStateService;
     _permissionsService        = permissionsService;
     _callsService              = callsService;
     _firebaseService           = firebaseService;
     _departmentSettingsService = departmentSettingsService;
 }
Example #8
0
 /// <summary>
 /// Operations to perform against the security sub-system
 /// </summary>
 public SecurityController(IDepartmentsService departmentsService, IDepartmentGroupsService departmentGroupsService,
                           IPermissionsService permissionsService, IPersonnelRolesService personnelRolesService, IFirebaseService firebaseService)
 {
     _departmentsService      = departmentsService;
     _departmentGroupsService = departmentGroupsService;
     _permissionsService      = permissionsService;
     _personnelRolesService   = personnelRolesService;
     _firebaseService         = firebaseService;
 }
 public NotificationsController(INotificationService notificationService, IPersonnelRolesService personnelRolesService, IDepartmentGroupsService departmentGroupsService,
                                IUsersService usersService, IUnitsService unitsService, ICustomStateService customStateService)
 {
     _notificationService     = notificationService;
     _personnelRolesService   = personnelRolesService;
     _departmentGroupsService = departmentGroupsService;
     _usersService            = usersService;
     _unitsService            = unitsService;
     _customStateService      = customStateService;
 }
Example #10
0
 public MessagesController(IMessageService messageService, IDepartmentsService departmentsService, IUsersService usersService,
                           ICommunicationService communicationService, Model.Services.IAuthorizationService authorizationService, IDepartmentGroupsService departmentGroupsService,
                           IPersonnelRolesService personnelRolesService, IShiftsService shiftsService)
 {
     _messageService          = messageService;
     _departmentsService      = departmentsService;
     _usersService            = usersService;
     _communicationService    = communicationService;
     _authorizationService    = authorizationService;
     _departmentGroupsService = departmentGroupsService;
     _personnelRolesService   = personnelRolesService;
     _shiftsService           = shiftsService;
 }
        public ClaimsPrincipalFactory(UserManager <TUser> userManager, RoleManager <TRole> roleManager, IOptions <IdentityOptions> optionsAccessor,
                                      IUsersService usersService, IDepartmentsService departmentsService, IDepartmentGroupsService departmentGroupsService, IUserProfileService userProfileService,
                                      IPermissionsService permissionsService, IPersonnelRolesService personnelRolesService
                                      ) : base(userManager, roleManager, optionsAccessor)
        {
            _usersService            = usersService;
            _departmentsService      = departmentsService;
            _departmentGroupsService = departmentGroupsService;
            _userProfileService      = userProfileService;
            _permissionsService      = permissionsService;
            _personnelRolesService   = personnelRolesService;

            options = optionsAccessor.Value;
        }
Example #12
0
 public AccountController(IDepartmentsService departmentsService, IUsersService usersService, IActionLogsService actionLogsService,
                          IEmailService emailService, IUserProfileService userProfileService, IDeleteService deleteService, IAuthorizationService authorizationService,
                          ILimitsService limitsService, IPersonnelRolesService personnelRolesService)
 {
     _departmentsService    = departmentsService;
     _usersService          = usersService;
     _actionLogsService     = actionLogsService;
     _emailService          = emailService;
     _userProfileService    = userProfileService;
     _deleteService         = deleteService;
     _authorizationService  = authorizationService;
     _limitsService         = limitsService;
     _personnelRolesService = personnelRolesService;
 }
Example #13
0
 public LinksController(IDepartmentLinksService departmentLinksService, IDepartmentsService departmentsService, IEmailService emailService,
                        ICallsService callsService, IUnitsService unitsService, IActionLogsService actionLogsService, IDepartmentGroupsService departmentGroupsService,
                        IUserStateService userStateService, IPersonnelRolesService personnelRolesService, ILimitsService limitsService)
 {
     _departmentLinksService  = departmentLinksService;
     _departmentsService      = departmentsService;
     _emailService            = emailService;
     _callsService            = callsService;
     _unitsService            = unitsService;
     _actionLogsService       = actionLogsService;
     _departmentGroupsService = departmentGroupsService;
     _userStateService        = userStateService;
     _personnelRolesService   = personnelRolesService;
     _limitsService           = limitsService;
 }
Example #14
0
 public ShiftsController(
     IShiftsService shiftsService,
     IUsersService usersService,
     IDepartmentsService departmentsService,
     IUserProfileService userProfileService,
     IPersonnelRolesService personnelRolesService,
     IDepartmentGroupsService departmentGroupsService
     )
 {
     _usersService            = usersService;
     _shiftsService           = shiftsService;
     _departmentsService      = departmentsService;
     _userProfileService      = userProfileService;
     _personnelRolesService   = personnelRolesService;
     _departmentGroupsService = departmentGroupsService;
 }
Example #15
0
 public ShiftsService(IGenericDataRepository <Shift> shiftsRepository, IGenericDataRepository <ShiftPerson> shiftPersonRepository,
                      IGenericDataRepository <ShiftDay> shiftDaysRepository, IGenericDataRepository <ShiftGroup> shiftGroupsRepository,
                      IGenericDataRepository <ShiftSignup> shiftSignupRepository, IGenericDataRepository <ShiftSignupTrade> shiftSignupTradeRepository, IPersonnelRolesService personnelRolesService,
                      IGenericDataRepository <ShiftSignupTradeUser> shiftSignupTradeUserRepository, IGenericDataRepository <ShiftSignupTradeUserShift> shiftSignupTradeUserShiftsRepository,
                      IGenericDataRepository <ShiftStaffing> shiftStaffingRepository, IGenericDataRepository <ShiftStaffingPerson> shiftStaffingPersonRepository)
 {
     _shiftsRepository                     = shiftsRepository;
     _shiftPersonRepository                = shiftPersonRepository;
     _shiftDaysRepository                  = shiftDaysRepository;
     _shiftGroupsRepository                = shiftGroupsRepository;
     _shiftSignupRepository                = shiftSignupRepository;
     _shiftSignupTradeRepository           = shiftSignupTradeRepository;
     _personnelRolesService                = personnelRolesService;
     _shiftSignupTradeUserRepository       = shiftSignupTradeUserRepository;
     _shiftSignupTradeUserShiftsRepository = shiftSignupTradeUserShiftsRepository;
     _shiftStaffingRepository              = shiftStaffingRepository;
     _shiftStaffingPersonRepository        = shiftStaffingPersonRepository;
 }
Example #16
0
 public MappingController(IDepartmentSettingsService departmentSettingsService,
                          IGeoLocationProvider geoLocationProvider, ICallsService callsService,
                          IDepartmentsService departmentsService, IDepartmentGroupsService departmentGroupsService,
                          IActionLogsService actionLogsService, IUnitsService unitsService, IMappingService mappingService,
                          IKmlProvider kmlProvider, IPermissionsService permissionsService, IPersonnelRolesService personnelRolesService)
 {
     _departmentSettingsService = departmentSettingsService;
     _geoLocationProvider       = geoLocationProvider;
     _callsService            = callsService;
     _departmentsService      = departmentsService;
     _departmentGroupsService = departmentGroupsService;
     _actionLogsService       = actionLogsService;
     _unitsService            = unitsService;
     _mappingService          = mappingService;
     _kmlProvider             = kmlProvider;
     _permissionsService      = permissionsService;
     _personnelRolesService   = personnelRolesService;
 }
Example #17
0
 public AuthorizationService(IDepartmentsService departmentsService, IInvitesService invitesService,
                             ICallsService callsService, IMessageService messageService, IWorkLogsService workLogsService, ISubscriptionsService subscriptionsService,
                             IDepartmentGroupsService departmentGroupsService, IPersonnelRolesService personnelRolesService, IUnitsService unitsService,
                             IPermissionsService permissionsService, ICalendarService calendarService, IProtocolsService protocolsService)
 {
     _departmentsService      = departmentsService;
     _invitesService          = invitesService;
     _callsService            = callsService;
     _messageService          = messageService;
     _workLogsService         = workLogsService;
     _subscriptionsService    = subscriptionsService;
     _departmentGroupsService = departmentGroupsService;
     _personnelRolesService   = personnelRolesService;
     _unitsService            = unitsService;
     _permissionsService      = permissionsService;
     _calendarService         = calendarService;
     _protocolsService        = protocolsService;
 }
Example #18
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 #19
0
 public PersonnelController(
     IUsersService usersService,
     IActionLogsService actionLogsService,
     IDepartmentsService departmentsService,
     IUserProfileService userProfileService,
     IWebEventPublisher webEventPublisher,
     IUserStateService userStateService,
     IDepartmentGroupsService departmentGroupsService,
     IPersonnelRolesService personnelRolesService
     )
 {
     _usersService            = usersService;
     _actionLogsService       = actionLogsService;
     _departmentsService      = departmentsService;
     _userProfileService      = userProfileService;
     _webEventPublisher       = webEventPublisher;
     _userStateService        = userStateService;
     _departmentGroupsService = departmentGroupsService;
     _personnelRolesService   = personnelRolesService;
 }
Example #20
0
 public PersonnelController(
     IUsersService usersService,
     IActionLogsService actionLogsService,
     IDepartmentsService departmentsService,
     IUserProfileService userProfileService,
     IUserStateService userStateService,
     IDepartmentGroupsService departmentGroupsService,
     IPersonnelRolesService personnelRolesService,
     IDepartmentSettingsService departmentSettingsService
     )
 {
     _usersService              = usersService;
     _actionLogsService         = actionLogsService;
     _departmentsService        = departmentsService;
     _userProfileService        = userProfileService;
     _userStateService          = userStateService;
     _departmentGroupsService   = departmentGroupsService;
     _personnelRolesService     = personnelRolesService;
     _departmentSettingsService = departmentSettingsService;
 }
Example #21
0
 public MessagesController(
     ICallsService callsService,
     IDepartmentsService departmentsService,
     IUserProfileService userProfileService,
     IGeoLocationProvider geoLocationProvider,
     IAuthorizationService authorizationService,
     IMessageService messageService,
     IUsersService usersService,
     IDepartmentGroupsService departmentGroupsService,
     IPersonnelRolesService personnelRolesService)
 {
     _callsService            = callsService;
     _departmentsService      = departmentsService;
     _userProfileService      = userProfileService;
     _geoLocationProvider     = geoLocationProvider;
     _authorizationService    = authorizationService;
     _messageService          = messageService;
     _usersService            = usersService;
     _departmentGroupsService = departmentGroupsService;
     _personnelRolesService   = personnelRolesService;
 }
Example #22
0
 public DeleteService(IAuthorizationService authorizationService, IDepartmentsService departmentsService,
                      ICallsService callsService, IActionLogsService actionLogsService, IUsersService usersService,
                      IUserProfileService userProfileService, IMessageService messageService, IDepartmentGroupsService departmentGroupsService,
                      IWorkLogsService workLogsService, IUserStateService userStateService, IPersonnelRolesService personnelRolesService, IDistributionListsService distributionListsService,
                      IShiftsService shiftsService, IUnitsService unitsService, ICertificationService certificationService, ILogService logService)
 {
     _authorizationService     = authorizationService;
     _departmentsService       = departmentsService;
     _callsService             = callsService;
     _actionLogsService        = actionLogsService;
     _usersService             = usersService;
     _userProfileService       = userProfileService;
     _messageService           = messageService;
     _departmentGroupsService  = departmentGroupsService;
     _workLogsService          = workLogsService;
     _userStateService         = userStateService;
     _personnelRolesService    = personnelRolesService;
     _distributionListsService = distributionListsService;
     _shiftsService            = shiftsService;
     _unitsService             = unitsService;
     _certificationService     = certificationService;
     _logService = logService;
 }
Example #23
0
 public ShiftsService(IShiftsRepository shiftsRepository, IShiftPersonRepository shiftPersonRepository,
                      IShiftDaysRepository shiftDaysRepository, IShiftGroupsRepository shiftGroupsRepository,
                      IShiftSignupRepository shiftSignupRepository, IShiftSignupTradeRepository shiftSignupTradeRepository, IPersonnelRolesService personnelRolesService,
                      IShiftSignupTradeUserRepository shiftSignupTradeUserRepository, IShiftSignupTradeUserShiftsRepository shiftSignupTradeUserShiftsRepository,
                      IShiftStaffingRepository shiftStaffingRepository, IShiftStaffingPersonRepository shiftStaffingPersonRepository, IDepartmentsService departmentsService,
                      IDepartmentGroupsService departmentGroupsService, IShiftGroupAssignmentsRepository shiftGroupAssignmentsRepository, IShiftGroupRolesRepository shiftGroupRolesRepositor)
 {
     _shiftsRepository                     = shiftsRepository;
     _shiftPersonRepository                = shiftPersonRepository;
     _shiftDaysRepository                  = shiftDaysRepository;
     _shiftGroupsRepository                = shiftGroupsRepository;
     _shiftSignupRepository                = shiftSignupRepository;
     _shiftSignupTradeRepository           = shiftSignupTradeRepository;
     _personnelRolesService                = personnelRolesService;
     _shiftSignupTradeUserRepository       = shiftSignupTradeUserRepository;
     _shiftSignupTradeUserShiftsRepository = shiftSignupTradeUserShiftsRepository;
     _shiftStaffingRepository              = shiftStaffingRepository;
     _shiftStaffingPersonRepository        = shiftStaffingPersonRepository;
     _departmentsService                   = departmentsService;
     _departmentGroupsService              = departmentGroupsService;
     _shiftGroupAssignmentsRepository      = shiftGroupAssignmentsRepository;
     _shiftGroupRolesRepository            = shiftGroupRolesRepositor;
 }
Example #24
0
 public CommandAppController(
     IUsersService usersService,
     IDepartmentsService departmentsService,
     IUserProfileService userProfileService,
     IUnitsService unitsService,
     ICallsService callsService,
     IDepartmentGroupsService departmentGroupsService,
     IPersonnelRolesService personnelRolesService,
     ICustomStateService customStateService,
     IGeoLocationProvider geoLocationProvider,
     IIncidentService incidentService
     )
 {
     _usersService            = usersService;
     _departmentsService      = departmentsService;
     _userProfileService      = userProfileService;
     _unitsService            = unitsService;
     _callsService            = callsService;
     _departmentGroupsService = departmentGroupsService;
     _personnelRolesService   = personnelRolesService;
     _customStateService      = customStateService;
     _geoLocationProvider     = geoLocationProvider;
     _incidentService         = incidentService;
 }
Example #25
0
        private ClaimsPrincipal DressUpPrincipal(String userName)
        {
            if (String.IsNullOrWhiteSpace(userName))
            {
                return(null);
            }

            var identiy = new ResgridIdentity();

            _usersService = ServiceLocator.Current.GetInstance <IUsersService>();

            var user = _usersService.GetUserByName(userName);

            if (user == null)
            {
                return(null);
            }

            _departmentsService      = ServiceLocator.Current.GetInstance <IDepartmentsService>();
            _departmentGroupsService = ServiceLocator.Current.GetInstance <IDepartmentGroupsService>();
            _userProfileService      = ServiceLocator.Current.GetInstance <IUserProfileService>();
            _permissionsService      = ServiceLocator.Current.GetInstance <IPermissionsService>();
            _personnelRolesService   = ServiceLocator.Current.GetInstance <IPersonnelRolesService>();

            var profile = _userProfileService.GetProfileByUserId(user.UserId);

            string fullName = String.Empty;

            if (profile == null || String.IsNullOrWhiteSpace(profile.FirstName))
            {
                var pfile = ProfileBase.Create(user.UserName, true);
                fullName = pfile.GetPropertyValue("Name").ToString();
            }
            else
            {
                fullName = string.Format("{0} {1}", profile.FirstName, profile.LastName);
            }

            identiy.FullName = fullName;
            identiy.UserName = userName;
            identiy.UserId   = user.UserId;

            if (_usersService.IsUserInRole(user.UserId, _usersService.AdminRoleId))
            {
                identiy.AddSystemAdminClaims(userName, user.UserId, fullName);
            }
            else if (_usersService.IsUserInRole(user.UserId, _usersService.AffiliateRoleId))
            {
                identiy.AddAffiliteClaims(userName, user.UserId, fullName);
            }
            else
            {
                var department = _departmentsService.GetDepartmentForUser(userName);

                if (department == null)
                {
                    return(null);
                }

                var group           = _departmentGroupsService.GetGroupForUser(user.UserId, department.DepartmentId);
                var departmentAdmin = department.IsUserAnAdmin(user.UserId);
                var permissions     = _permissionsService.GetAllPermissionsForDepartment(department.DepartmentId);
                var roles           = _personnelRolesService.GetRolesForUser(user.UserId, department.DepartmentId);

                identiy.AddDepartmentClaim(department.DepartmentId, departmentAdmin);
                identiy.DepartmentName = department.Name;

                DateTime signupDate;
                if (department.CreatedOn.HasValue)
                {
                    signupDate = department.CreatedOn.Value;
                }
                else
                {
                    signupDate = DateTime.UtcNow;
                }

                identiy.DepartmentId = department.DepartmentId;

                string email = String.Empty;

                if (profile != null && !String.IsNullOrWhiteSpace(profile.MembershipEmail))
                {
                    email = profile.MembershipEmail;
                }
                else if (!String.IsNullOrWhiteSpace(user.Email))
                {
                    email = user.Email;
                }

                identiy.AddGeneralClaims(userName, user.UserId, fullName, department.DepartmentId, department.Name, email, signupDate);

                bool isGroupAdmin = false;

                if (group != null)
                {
                    isGroupAdmin = group.IsUserGroupAdmin(user.UserId);
                }

                if (departmentAdmin)
                {
                    var groups = _departmentGroupsService.GetAllGroupsForDepartment(department.DepartmentId);
                    if (groups != null)
                    {
                        foreach (var departmentGroup in groups)
                        {
                            identiy.AddGroupClaim(departmentGroup.DepartmentGroupId, true);
                        }
                    }
                }
                else
                {
                    if (group != null)
                    {
                        identiy.AddGroupClaim(group.DepartmentGroupId, isGroupAdmin);
                    }
                }

                identiy.AddCallClaims(departmentAdmin, permissions, isGroupAdmin, roles);
                identiy.AddActionClaims();
                identiy.AddLogClaims(departmentAdmin, permissions, isGroupAdmin, roles);
                identiy.AddStaffingClaims();
                identiy.AddPersonnelClaims(departmentAdmin);
                identiy.AddUnitClaims(departmentAdmin);
                identiy.AddUnitLogClaims();
                identiy.AddMessageClaims();
                identiy.AddRoleClaims(departmentAdmin);
                identiy.AddProfileClaims();
                identiy.AddReportsClaims();
                identiy.AddGenericGroupClaims(departmentAdmin);
                identiy.AddDocumentsClaims(departmentAdmin, permissions, isGroupAdmin, roles);
                identiy.AddNotesClaims(departmentAdmin, permissions, isGroupAdmin, roles);
                identiy.AddScheduleClaims(departmentAdmin, permissions, isGroupAdmin, roles);
                identiy.AddShiftClaims(departmentAdmin, permissions, isGroupAdmin, roles);
                identiy.AddTrainingClaims(departmentAdmin, permissions, isGroupAdmin, roles);
                identiy.AddPIIClaims(departmentAdmin, permissions, isGroupAdmin, roles);
                identiy.AddInventoryClaims(departmentAdmin, permissions, isGroupAdmin, roles);
            }

            return(new ClaimsPrincipal(identiy));
        }
Example #26
0
        public static async Task <bool> ProcessCallQueueItem(CallQueueItem cqi)
        {
            try
            {
                if (cqi != null && cqi.Call != null && cqi.Call.HasAnyDispatches())
                {
                    if (_communicationService == null)
                    {
                        _communicationService = Bootstrapper.GetKernel().Resolve <ICommunicationService>();
                    }

                    if (_callsService == null)
                    {
                        _callsService = Bootstrapper.GetKernel().Resolve <ICallsService>();
                    }

                    List <int> groupIds = new List <int>();

                    /* Trying to see if I can eek out a little perf here now that profiles are in Redis. Previously the
                     * the parallel operation would cause EF errors. This shouldn't be the case now because profiles are
                     * cached and GetProfileForUser operations will hit that first.
                     */
                    if (cqi.Profiles == null || !cqi.Profiles.Any())
                    {
                        if (_userProfilesService == null)
                        {
                            _userProfilesService = Bootstrapper.GetKernel().Resolve <IUserProfileService>();
                        }

                        cqi.Profiles = (await _userProfilesService.GetAllProfilesForDepartmentAsync(cqi.Call.DepartmentId)).Select(x => x.Value).ToList();
                    }

                    if (cqi.CallDispatchAttachmentId > 0)
                    {
                        //var callsService = Bootstrapper.GetKernel().Resolve<ICallsService>();
                        cqi.Call.ShortenedAudioUrl = await _callsService.GetShortenedAudioUrlAsync(cqi.Call.CallId, cqi.CallDispatchAttachmentId);
                    }

                    cqi.Call.ShortenedCallUrl = await _callsService.GetShortenedCallLinkUrl(cqi.Call.CallId);

                    try
                    {
                        cqi.Call.CallPriority = await _callsService.GetCallPrioritiesByIdAsync(cqi.Call.DepartmentId, cqi.Call.Priority, false);
                    }
                    catch { /* Doesn't matter */ }

                    var dispatchedUsers = new HashSet <string>();

                    // Dispatch Personnel
                    if (cqi.Call.Dispatches != null && cqi.Call.Dispatches.Any())
                    {
                        Parallel.ForEach(cqi.Call.Dispatches, d =>
                        {
                            dispatchedUsers.Add(d.UserId);

                            try
                            {
                                var profile = cqi.Profiles.FirstOrDefault(x => x.UserId == d.UserId);

                                if (profile != null)
                                {
                                    _communicationService.SendCallAsync(cqi.Call, d, cqi.DepartmentTextNumber, cqi.Call.DepartmentId, profile, cqi.Address);
                                }
                            }
                            catch (SocketException sex)
                            {
                            }
                        });
                    }

                    if (_departmentGroupsService == null)
                    {
                        _departmentGroupsService = Bootstrapper.GetKernel().Resolve <IDepartmentGroupsService>();
                    }

                    // Dispatch Groups
                    if (cqi.Call.GroupDispatches != null && cqi.Call.GroupDispatches.Any())
                    {
                        foreach (var d in cqi.Call.GroupDispatches)
                        {
                            if (!groupIds.Contains(d.DepartmentGroupId))
                            {
                                groupIds.Add(d.DepartmentGroupId);
                            }

                            var members = await _departmentGroupsService.GetAllMembersForGroupAsync(d.DepartmentGroupId);

                            foreach (var member in members)
                            {
                                if (!dispatchedUsers.Contains(member.UserId))
                                {
                                    dispatchedUsers.Add(member.UserId);
                                    try
                                    {
                                        var profile = cqi.Profiles.FirstOrDefault(x => x.UserId == member.UserId);
                                        await _communicationService.SendCallAsync(cqi.Call, new CallDispatch()
                                        {
                                            UserId = member.UserId
                                        }, cqi.DepartmentTextNumber, cqi.Call.DepartmentId, profile, cqi.Address);
                                    }
                                    catch (SocketException sex)
                                    {
                                    }
                                    catch (Exception ex)
                                    {
                                        Logging.LogException(ex);
                                    }
                                }
                            }
                        }
                    }

                    // Dispatch Units
                    if (cqi.Call.UnitDispatches != null && cqi.Call.UnitDispatches.Any())
                    {
                        if (_unitsService == null)
                        {
                            _unitsService = Bootstrapper.GetKernel().Resolve <IUnitsService>();
                        }

                        foreach (var d in cqi.Call.UnitDispatches)
                        {
                            var unit = await _unitsService.GetUnitByIdAsync(d.UnitId);

                            if (unit != null && unit.StationGroupId.HasValue)
                            {
                                if (!groupIds.Contains(unit.StationGroupId.Value))
                                {
                                    groupIds.Add(unit.StationGroupId.Value);
                                }
                            }

                            await _communicationService.SendUnitCallAsync(cqi.Call, d, cqi.DepartmentTextNumber, cqi.Address);

                            var unitAssignedMembers = await _unitsService.GetCurrentRolesForUnitAsync(d.UnitId);

                            if (unitAssignedMembers != null && unitAssignedMembers.Count() > 0)
                            {
                                foreach (var member in unitAssignedMembers)
                                {
                                    if (!dispatchedUsers.Contains(member.UserId))
                                    {
                                        dispatchedUsers.Add(member.UserId);
                                        try
                                        {
                                            var profile = cqi.Profiles.FirstOrDefault(x => x.UserId == member.UserId);
                                            await _communicationService.SendCallAsync(cqi.Call, new CallDispatch()
                                            {
                                                UserId = member.UserId
                                            }, cqi.DepartmentTextNumber, cqi.Call.DepartmentId, profile, cqi.Address);
                                        }
                                        catch (SocketException sex)
                                        {
                                        }
                                        catch (Exception ex)
                                        {
                                            Logging.LogException(ex);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (unit.StationGroupId.HasValue)
                                {
                                    var members = await _departmentGroupsService.GetAllMembersForGroupAsync(unit.StationGroupId.Value);

                                    foreach (var member in members)
                                    {
                                        if (!dispatchedUsers.Contains(member.UserId))
                                        {
                                            dispatchedUsers.Add(member.UserId);
                                            try
                                            {
                                                var profile = cqi.Profiles.FirstOrDefault(x => x.UserId == member.UserId);
                                                await _communicationService.SendCallAsync(cqi.Call, new CallDispatch()
                                                {
                                                    UserId = member.UserId
                                                }, cqi.DepartmentTextNumber, cqi.Call.DepartmentId, profile, cqi.Address);
                                            }
                                            catch (SocketException sex)
                                            {
                                            }
                                            catch (Exception ex)
                                            {
                                                Logging.LogException(ex);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    // Dispatch Roles
                    if (cqi.Call.RoleDispatches != null && cqi.Call.RoleDispatches.Any())
                    {
                        if (_rolesService == null)
                        {
                            _rolesService = Bootstrapper.GetKernel().Resolve <IPersonnelRolesService>();
                        }

                        foreach (var d in cqi.Call.RoleDispatches)
                        {
                            var members = await _rolesService.GetAllMembersOfRoleAsync(d.RoleId);

                            foreach (var member in members)
                            {
                                if (!dispatchedUsers.Contains(member.UserId))
                                {
                                    dispatchedUsers.Add(member.UserId);
                                    try
                                    {
                                        var profile = cqi.Profiles.FirstOrDefault(x => x.UserId == member.UserId);
                                        await _communicationService.SendCallAsync(cqi.Call, new CallDispatch()
                                        {
                                            UserId = member.UserId
                                        }, cqi.DepartmentTextNumber, cqi.Call.DepartmentId, profile, cqi.Address);
                                    }
                                    catch (SocketException sex)
                                    {
                                    }
                                    catch (Exception ex)
                                    {
                                        Logging.LogException(ex);
                                    }
                                }
                            }
                        }
                    }

                    // Send Call Print to Printer
                    if (_printerProvider == null)
                    {
                        _printerProvider = Bootstrapper.GetKernel().Resolve <IPrinterProvider>();
                    }

                    Dictionary <int, DepartmentGroup> fetchedGroups = new Dictionary <int, DepartmentGroup>();
                    if (cqi.Call.Dispatches != null && cqi.Call.Dispatches.Any())
                    {
                        foreach (var d in cqi.Call.Dispatches)
                        {
                            var group = await _departmentGroupsService.GetGroupForUserAsync(d.UserId, cqi.Call.DepartmentId);

                            if (group != null)
                            {
                                if (!groupIds.Contains(group.DepartmentGroupId))
                                {
                                    groupIds.Add(group.DepartmentGroupId);
                                }

                                if (!fetchedGroups.ContainsKey(group.DepartmentGroupId))
                                {
                                    fetchedGroups.Add(group.DepartmentGroupId, group);
                                }
                            }
                        }
                    }

                    foreach (var groupId in groupIds)
                    {
                        try
                        {
                            DepartmentGroup group = null;

                            if (fetchedGroups.ContainsKey(groupId))
                            {
                                group = fetchedGroups[groupId];
                            }
                            else
                            {
                                group = await _departmentGroupsService.GetGroupByIdAsync(groupId);
                            }

                            if (!String.IsNullOrWhiteSpace(group.PrinterData) && group.DispatchToPrinter)
                            {
                                var printerData = JsonConvert.DeserializeObject <DepartmentGroupPrinter>(group.PrinterData);
                                var apiKey      = SymmetricEncryption.Decrypt(printerData.ApiKey, Config.SystemBehaviorConfig.ExternalLinkUrlParamPassphrase);
                                var callUrl     = await _callsService.GetShortenedCallPdfUrl(cqi.Call.CallId, true, groupId);

                                var printJob = _printerProvider.SubmitPrintJob(apiKey, printerData.PrinterId, "CallPrint", callUrl);
                            }
                        }
                        catch (Exception ex)
                        {
                            Logging.LogException(ex);
                        }
                    }
                }
            }
            finally
            {
                _communicationService = null;
            }

            return(true);
        }