Exemplo n.º 1
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                EmployeeService = ScopedServices.GetRequiredService <IEmployeeService>();
                TemplateService = ScopedServices.GetRequiredService <ITemplateService>();
                LdapService     = ScopedServices.GetRequiredService <ILdapService>();
                RemoteDeviceConnectionsService = ScopedServices.GetRequiredService <IRemoteDeviceConnectionsService>();

                Employee = await EmployeeService.GetEmployeeByIdAsync(EmployeeId);

                Templates = await TemplateService.GetTemplatesAsync();

                PersonalAccount = new AccountAddModel()
                {
                    EmployeeId = EmployeeId
                };

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
                await ModalDialogCancel();
            }
        }
Exemplo n.º 2
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                WorkstationService = ScopedServices.GetRequiredService <IWorkstationService>();
                DataTableService   = ScopedServices.GetRequiredService <IDataTableService <Workstation, WorkstationFilter> >();
                SynchronizationService.UpdateWorkstationsPage += UpdateWorkstationsPage;

                switch (DashboardFilter)
                {
                case "NotApproved":
                    DataTableService.DataLoadingOptions.Filter.Approved = false;
                    break;

                case "Online":
                    //TODO
                    break;
                }

                await BreadcrumbsService.SetWorkstations();

                await DataTableService.InitializeAsync(WorkstationService.GetWorkstationsAsync, WorkstationService.GetWorkstationsCountAsync, StateHasChanged, nameof(Workstation.Name));

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                SetLoadFailed(ex.Message);
            }
        }
Exemplo n.º 3
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                EmployeeService                = ScopedServices.GetRequiredService <IEmployeeService>();
                HardwareVaultService           = ScopedServices.GetRequiredService <IHardwareVaultService>();
                RemoteDeviceConnectionsService = ScopedServices.GetRequiredService <IRemoteDeviceConnectionsService>();

                HardwareVault = await HardwareVaultService.GetVaultByIdAsync(HardwareVaultId);

                if (HardwareVault == null)
                {
                    throw new HESException(HESCode.HardwareVaultNotFound);
                }

                EntityBeingEdited = MemoryCache.TryGetValue(HardwareVault.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(HardwareVault.Id, HardwareVault);
                }

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
                await ModalDialogCancel();
            }
        }
Exemplo n.º 4
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                HardwareVaultService           = ScopedServices.GetRequiredService <IHardwareVaultService>();
                RemoteDeviceConnectionsService = ScopedServices.GetRequiredService <IRemoteDeviceConnectionsService>();

                HardwareVault = await HardwareVaultService.GetVaultByIdAsync(HardwareVaultId);

                if (HardwareVault == null)
                {
                    throw new Exception("HardwareVault not found.");
                }

                EntityBeingEdited = MemoryCache.TryGetValue(HardwareVault.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(HardwareVault.Id, HardwareVault);
                }

                VaultProfiles          = new SelectList(await HardwareVaultService.GetProfilesAsync(), nameof(HardwareVaultProfile.Id), nameof(HardwareVaultProfile.Name));
                SelectedVaultProfileId = VaultProfiles.First().Value;

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
                await ModalDialogCancel();
            }
        }
Exemplo n.º 5
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                ApplicationUserService = ScopedServices.GetRequiredService <IApplicationUserService>();

                var email = (await AuthenticationStateProvider.GetAuthenticationStateAsync()).User.Identity.Name;
                User = await ApplicationUserService.GetUserByEmailAsync(email);

                UserProfileModel = new UserProfileModel
                {
                    UserId      = User.Id,
                    FullName    = User.FullName,
                    PhoneNumber = User.PhoneNumber
                };

                ChangeEmailModel = new ChangeEmailModel
                {
                    CurrentEmail = User.Email
                };

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                SetLoadFailed(ex.Message);
            }
        }
Exemplo n.º 6
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                ApplicationUserService = ScopedServices.GetRequiredService <IApplicationUserService>();
                EmailSenderService     = ScopedServices.GetRequiredService <IEmailSenderService>();
                DataTableService       = ScopedServices.GetRequiredService <IDataTableService <ApplicationUser, ApplicationUserFilter> >();

                SynchronizationService.UpdateAdministratorsPage     += UpdateAdministratorsPage;
                SynchronizationService.UpdateAdministratorStatePage += UpdateAdministratorStatePage;

                AuthenticationState = await AuthenticationStateProvider.GetAuthenticationStateAsync();

                await BreadcrumbsService.SetAdministrators();

                await DataTableService.InitializeAsync(ApplicationUserService.GetAdministratorsAsync, ApplicationUserService.GetAdministratorsCountAsync, StateHasChanged, nameof(ApplicationUser.Email), ListSortDirection.Ascending);

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                SetLoadFailed(ex.Message);
            }
        }
Exemplo n.º 7
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                EmployeeService = ScopedServices.GetRequiredService <IEmployeeService>();

                Employee = await EmployeeService.GetEmployeeByIdAsync(EmployeeId);

                if (Employee == null)
                {
                    throw new HESException(HESCode.EmployeeNotFound);
                }

                EntityBeingEdited = MemoryCache.TryGetValue(Employee.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(Employee.Id, Employee);
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
                await ModalDialogCancel();
            }
        }
Exemplo n.º 8
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                DashboardService = ScopedServices.GetRequiredService <IDashboardService>();

                await BreadcrumbsService.SetDashboard();

                ServerdCard = await DashboardService.GetServerCardAsync();

                ServerdCard.RightAction = ShowHardwareVaultTaskAsync;
                if (ServerdCard.Notifications.FirstOrDefault(x => x.Page == "long-pending-tasks") != null)
                {
                    ServerdCard.Notifications.FirstOrDefault(x => x.Page == "long-pending-tasks").Action = ShowHardwareVaultTaskAsync;
                }
                EmployeesCard = await DashboardService.GetEmployeesCardAsync();

                HardwareVaultsCard = await DashboardService.GetHardwareVaultsCardAsync();

                WorkstationsCard = await DashboardService.GetWorkstationsCardAsync();

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                SetLoadFailed(ex.Message);
            }
        }
Exemplo n.º 9
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                HardwareVaultService = ScopedServices.GetRequiredService <IHardwareVaultService>();

                InputType = "Password";

                HardwareVault = await HardwareVaultService.GetVaultByIdAsync(HardwareVaultId);

                if (HardwareVault == null)
                {
                    throw new Exception("HardwareVault not found.");
                }

                Code = await HardwareVaultService.GetVaultActivationCodeAsync(HardwareVault.Id);
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CancelAsync();
            }
        }
Exemplo n.º 10
0
        protected async override Task OnInitializedAsync()
        {
            // return base.OnInitializedAsync();

            _newsService = (NewsService)ScopedServices.GetService(typeof(NewsService));
            Items        = await _newsService.GetAllVisibleNews().ToListAsync();
        }
        protected override async Task OnInitializedAsync()
        {
            try
            {
                WorkstationAuditService = ScopedServices.GetRequiredService <IWorkstationAuditService>();
                MainTableService        = ScopedServices.GetRequiredService <IMainTableService <WorkstationSession, WorkstationSessionFilter> >();

                switch (DashboardFilter)
                {
                case "NonHideezUnlock":
                    MainTableService.DataLoadingOptions.Filter.UnlockedBy = Hideez.SDK.Communication.SessionSwitchSubject.NonHideez;
                    break;

                case "LongOpenSession":
                    MainTableService.DataLoadingOptions.Filter.Query = WorkstationAuditService.SessionQuery().Where(x => x.StartDate <= DateTime.UtcNow.AddHours(-12) && x.EndDate == null);
                    break;

                case "OpenedSessions":
                    MainTableService.DataLoadingOptions.Filter.Query = WorkstationAuditService.SessionQuery().Where(x => x.EndDate == null);
                    break;
                }

                await BreadcrumbsService.SetAuditWorkstationSessions();

                await MainTableService.InitializeAsync(WorkstationAuditService.GetWorkstationSessionsAsync, WorkstationAuditService.GetWorkstationSessionsCountAsync, ModalDialogService, StateHasChanged, nameof(WorkstationSession.StartDate), ListSortDirection.Descending);

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                SetLoadFailed(ex.Message);
            }
        }
        protected override void OnInitialized()
        {
            base.OnInitialized();

            // setup the repo containing the mappings
            _repo = ScopedServices.GetService(typeof(FormGeneratorComponentsRepository)) as FormGeneratorComponentsRepository;
        }
        protected override async Task OnInitializedAsync()
        {
            // return base.OnInitializedAsync();

            _service = (AnswersService)ScopedServices.GetService(typeof(AnswersService));
            Items    = await _service.GetAllAsync();
        }
Exemplo n.º 14
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                HardwareVaultService = ScopedServices.GetRequiredService <IHardwareVaultService>();

                ModalDialogService.OnCancel += OnCancelAsync;

                AccessProfile = await HardwareVaultService.GetProfileByIdAsync(HardwareVaultProfileId);

                if (AccessProfile == null)
                {
                    throw new Exception("Hardware Vault Profile not found.");
                }

                InitPinExpirationValue = AccessProfile.PinExpirationConverted;
                InitPinLengthValue     = AccessProfile.PinLength;
                InitPinTryCountValue   = AccessProfile.PinTryCount;

                EntityBeingEdited = MemoryCache.TryGetValue(AccessProfile.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(AccessProfile.Id, AccessProfile);
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CancelAsync();
            }
        }
Exemplo n.º 15
0
        protected async override Task OnInitializedAsync()
        {
            // return base.OnInitializedAsync();

            _galleryService = (GalleryService)ScopedServices.GetService(typeof(GalleryService));
            Items           = await _galleryService.GetGalleries(true).ToListAsync();
        }
Exemplo n.º 16
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                TemplateService = ScopedServices.GetRequiredService <ITemplateService>();

                Template = await TemplateService.GetByIdAsync(TemplateId);

                if (Template == null)
                {
                    throw new Exception("Template not found.");
                }

                EntityBeingEdited = MemoryCache.TryGetValue(Template.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(Template.Id, Template);
                }

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CancelAsync();
            }
        }
Exemplo n.º 17
0
        protected override async Task OnInitializedAsync()
        {
            bookService    = (IBookService)ScopedServices.GetService(typeof(IBookService));
            profileService = (IProfileService)ScopedServices.GetService(typeof(IProfileService));

            profiles = await profileService.GetAllProfilesAsync();
        }
Exemplo n.º 18
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                LicenseService = ScopedServices.GetRequiredService <ILicenseService>();

                LicenseOrder = await LicenseService.GetLicenseOrderByIdAsync(LicenseOrderId);

                if (LicenseOrder == null)
                {
                    throw new Exception("License Order not found.");
                }

                EntityBeingEdited = MemoryCache.TryGetValue(LicenseOrder.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(LicenseOrder.Id, LicenseOrder);
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
                await ModalDialogCancel();
            }
        }
Exemplo n.º 19
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                EmployeeService    = ScopedServices.GetRequiredService <IEmployeeService>();
                AppSettingsService = ScopedServices.GetRequiredService <IAppSettingsService>();
                DataTableService   = ScopedServices.GetRequiredService <IDataTableService <Account, AccountFilter> >();
                LdapService        = ScopedServices.GetRequiredService <ILdapService>();

                SynchronizationService.UpdateEmployeeDetailsPage += UpdateEmployeeDetailsPage;
                SynchronizationService.UpdateHardwareVaultState  += UpdateHardwareVaultState;

                await LoadEmployeeAsync();

                await BreadcrumbsService.SetEmployeeDetails(Employee?.FullName);
                await LoadLdapSettingsAsync();

                await DataTableService.InitializeAsync(EmployeeService.GetAccountsAsync, EmployeeService.GetAccountsCountAsync, StateHasChanged, nameof(Account.Name), entityId : EmployeeId);

                await LoadEmployeeSsoState();

                SetInitialized();
            }
            catch (Exception ex)
            {
                SetLoadFailed(ex.Message);
                Logger.LogError(ex.Message);
            }
        }
Exemplo n.º 20
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                WorkstationService = ScopedServices.GetRequiredService <IWorkstationService>();
                RemoteWorkstationConnectionsService = ScopedServices.GetRequiredService <IRemoteWorkstationConnectionsService>();

                Workstation = await WorkstationService.GetWorkstationByIdAsync(WorkstationId);

                if (Workstation == null)
                {
                    throw new Exception("Workstation not found.");
                }

                EntityBeingEdited = MemoryCache.TryGetValue(Workstation.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(Workstation.Id, Workstation);
                }

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
                await ModalDialogCancel();
            }
        }
Exemplo n.º 21
0
        protected async override Task OnInitializedAsync()
        {
            // return base.OnInitializedAsync();

            _service = (QuestionsService)ScopedServices.GetService(typeof(QuestionsService));
            Items    = await _service.GetAllWithObjectsAsync();
        }
    private void InjectTransient()
    {
        _props = GetType().GetProperties()
                 .Where(property => property.GetCustomAttribute <InjectTransientAttribute>() != null)
                 .Where(property => {
            // We don't support set only, non public, or indexer properties
            if (property.GetMethod == null ||
                !property.GetMethod.IsPublic ||
                property.GetMethod.GetParameters().Length > 0)
            {
                return(false);
            }

            bool hasSetter = property.SetMethod is { IsPublic: true };

            if (!hasSetter)
            {
                return(false);
            }

            return(true);
        })
                 .ToList();

        foreach (PropertyInfo propertyInfo in _props)
        {
            object service = ScopedServices.GetRequiredService(propertyInfo.PropertyType);
            propertyInfo.SetValue(this, service);
        }
    }
Exemplo n.º 23
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                LicenseService       = ScopedServices.GetRequiredService <ILicenseService>();
                HardwareVaultService = ScopedServices.GetRequiredService <IHardwareVaultService>();

                _newLicenseOrder = new NewLicenseOrder()
                {
                    HardwareVaults = await HardwareVaultService.GetVaultsWithoutLicenseAsync()
                };

                _renewLicenseOrder = new RenewLicenseOrder()
                {
                    HardwareVaults = await HardwareVaultService.GetVaultsWithLicenseAsync()
                };

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CancelAsync();
            }
        }
Exemplo n.º 24
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                EmployeeService = ScopedServices.GetRequiredService <IEmployeeService>();
                LdapService     = ScopedServices.GetRequiredService <ILdapService>();
                RemoteDeviceConnectionsService = ScopedServices.GetRequiredService <IRemoteDeviceConnectionsService>();

                Account = await EmployeeService.GetAccountByIdAsync(AccountId);

                if (Account == null)
                {
                    throw new HESException(HESCode.AccountNotFound);
                }

                EntityBeingEdited = MemoryCache.TryGetValue(Account.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(Account.Id, Account);
                }

                Employee = await EmployeeService.GetEmployeeByIdAsync(Account.EmployeeId);

                LdapSettings = await AppSettingsService.GetLdapSettingsAsync();

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
                await ModalDialogCancel();
            }
        }
Exemplo n.º 25
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                LdapService  = ScopedServices.GetRequiredService <ILdapService>();
                GroupService = ScopedServices.GetRequiredService <IGroupService>();

                LdapSettings = await AppSettingsService.GetLdapSettingsAsync();

                if (LdapSettings == null)
                {
                    ActiveDirectoryInitialization = ActiveDirectoryInitialization.HostNotSet;
                }
                else if (LdapSettings?.Host != null && LdapSettings?.UserName == null && LdapSettings?.Password == null)
                {
                    ActiveDirectoryInitialization = ActiveDirectoryInitialization.CredentialsNotSet;
                }
                else
                {
                    await GetGroups(LdapSettings);
                }

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CancelAsync();
            }
        }
Exemplo n.º 26
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                HardwareVaultService = ScopedServices.GetRequiredService <IHardwareVaultService>();

                HardwareVault = await HardwareVaultService.GetVaultByIdAsync(HardwareVaultId);

                if (HardwareVault == null)
                {
                    throw new Exception("HardwareVault not found.");
                }

                EntityBeingEdited = MemoryCache.TryGetValue(HardwareVault.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(HardwareVault.Id, HardwareVault);
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
                await ModalDialogCancel();
            }
        }
Exemplo n.º 27
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                SharedAccountService           = ScopedServices.GetRequiredService <ISharedAccountService>();
                RemoteDeviceConnectionsService = ScopedServices.GetRequiredService <IRemoteDeviceConnectionsService>();

                ModalDialogService.OnCancel += OnCancelAsync;

                Account = await SharedAccountService.GetSharedAccountByIdAsync(AccountId);

                if (Account == null)
                {
                    throw new Exception("Account not found");
                }

                EntityBeingEdited = MemoryCache.TryGetValue(Account.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(Account.Id, Account);
                }

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CancelAsync();
            }
        }
Exemplo n.º 28
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                ApplicationUserService = ScopedServices.GetRequiredService <IApplicationUserService>();
                FidoService            = ScopedServices.GetRequiredService <IFido2Service>();

                CurrentUser = await ApplicationUserService.GetUserByEmailAsync(await GetCurrentUserEmailAsync());

                // Password
                ChangePasswordModel = new ChangePasswordModel()
                {
                    UserId = CurrentUser.Id
                };

                // Security Key
                await LoadStoredCredentialsAsync();

                // 2FA
                await GetTwoFactorInfoAsync();

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                SetLoadFailed(ex.Message);
            }
        }
Exemplo n.º 29
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                GroupService = ScopedServices.GetRequiredService <IGroupService>();

                Group = await GroupService.GetGroupByIdAsync(GroupId);

                if (Group == null)
                {
                    throw new Exception("Group not found");
                }

                EntityBeingEdited = MemoryCache.TryGetValue(Group.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(Group.Id, Group);
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CloseAsync();
            }
        }
Exemplo n.º 30
0
 protected override void OnInitialized()
 {
     AppSettingsService = ScopedServices.GetRequiredService <IAppSettingsService>();
     LdapSettings       = new LdapSettings()
     {
         Host = Host
     };
 }