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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
private async Task LoadDataAsync() { var filter = new HardwareVaultFilter() { Status = VaultStatus.Ready }; TotalRecords = await HardwareVaultService.GetVaultsCountAsync(new DataLoadingOptions <HardwareVaultFilter> { SearchText = SearchText, Filter = filter }); HardwareVaults = await HardwareVaultService.GetVaultsAsync(new DataLoadingOptions <HardwareVaultFilter> { Take = TotalRecords, SortedColumn = nameof(HardwareVault.Id), SortDirection = ListSortDirection.Ascending, SearchText = SearchText, Filter = filter }); SelectedHardwareVault = null; StateHasChanged(); }
protected override async Task OnInitializedAsync() { try { LicenseService = ScopedServices.GetRequiredService <ILicenseService>(); HardwareVaultService = ScopedServices.GetRequiredService <IHardwareVaultService>(); 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); } if (!LicenseOrder.ProlongExistingLicenses) { _newLicenseOrder = new NewLicenseOrder() { ContactEmail = LicenseOrder.ContactEmail, Note = LicenseOrder.Note, StartDate = LicenseOrder.StartDate.Value, EndDate = LicenseOrder.EndDate, HardwareVaults = await HardwareVaultService.GetVaultsWithoutLicenseAsync() }; _newLicenseOrder.HardwareVaults.ForEach(x => x.Checked = LicenseOrder.HardwareVaultLicenses.Any(d => d.HardwareVaultId == x.Id)); } else { _renewLicenseOrder = new RenewLicenseOrder() { ContactEmail = LicenseOrder.ContactEmail, Note = LicenseOrder.Note, EndDate = LicenseOrder.EndDate, HardwareVaults = await HardwareVaultService.GetVaultsWithLicenseAsync() }; _renewLicenseOrder.HardwareVaults.ForEach(x => x.Checked = LicenseOrder.HardwareVaultLicenses.Any(d => d.HardwareVaultId == x.Id)); } SetInitialized(); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogService.CancelAsync(); } }
protected override async Task OnInitializedAsync() { HardwareVaultService = ScopedServices.GetRequiredService <IHardwareVaultService>(); AccessProfile = await HardwareVaultService.ProfileQuery().AsNoTracking().FirstOrDefaultAsync(x => x.Id == "default"); AccessProfile.Id = null; AccessProfile.Name = null; InitPinExpirationValue = AccessProfile.PinExpirationConverted; InitPinLengthValue = AccessProfile.PinLength; InitPinTryCountValue = AccessProfile.PinTryCount; }
private async Task ImportVaultsAsync() { try { await HardwareVaultService.ImportVaultsAsync(); await DataTableService.LoadTableDataAsync(); await ToastService.ShowToastAsync("Vaults imported.", ToastType.Success); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); } }
private async Task DeleteProfileAsync() { try { await HardwareVaultService.DeleteProfileAsync(AccessProfile.Id); await ToastService.ShowToastAsync("Hardware vault profile deleted.", ToastType.Success); await ModalDialogClose(); } catch (Exception ex) { Logger.LogError(ex.Message, ex); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogCancel(); } }
private async Task ChangeProfileAsync() { try { await HardwareVaultService.ChangeVaultProfileAsync(HardwareVault.Id, SelectedVaultProfileId); RemoteDeviceConnectionsService.StartUpdateHardwareVaultAccounts(HardwareVault.Id); await ToastService.ShowToastAsync("Vault profile updated", ToastType.Success); await ModalDialogClose(); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogCancel(); } }
private async Task ChangeStatusAsync() { try { switch (VaultStatus) { case VaultStatus.Active: await HardwareVaultService.ActivateVaultAsync(HardwareVault.Id); await ToastService.ShowToastAsync("Vault pending activate.", ToastType.Success); break; case VaultStatus.Suspended: await HardwareVaultService.SuspendVaultAsync(HardwareVault.Id, StatusDescription); await ToastService.ShowToastAsync("Vault pending suspend.", ToastType.Success); break; case VaultStatus.Compromised: if (CompromisedIsDisabled) { return; } await HardwareVaultService.VaultCompromisedAsync(HardwareVault.Id, StatusReason, StatusDescription); await ToastService.ShowToastAsync("Vault compromised.", ToastType.Success); break; } await SynchronizationService.UpdateHardwareVaults(ExceptPageId); RemoteDeviceConnectionsService.StartUpdateHardwareVaultStatus(HardwareVault.Id); await ModalDialogService.CloseAsync(); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogService.CancelAsync(); } }
private async Task EditAsync() { try { await ButtonSpinner.SpinAsync(async() => { await HardwareVaultService.UpdateRfidAsync(HardwareVault); await ToastService.ShowToastAsync("RFID updated.", ToastType.Success); await ModalDialogClose(); }); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogCancel(); } }
private async Task CreateProfileAsync() { try { await Button.SpinAsync(async() => { await HardwareVaultService.CreateProfileAsync(AccessProfile); await ToastService.ShowToastAsync("Hardware vault profile created.", ToastType.Success); await ModalDialogClose(); }); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogCancel(); } }
private async Task CreateProfileAsync() { try { await ButtonSpinner.SpinAsync(async() => { await HardwareVaultService.CreateProfileAsync(AccessProfile); await ToastService.ShowToastAsync("Hardware vault profile created.", ToastType.Success); await SynchronizationService.UpdateHardwareVaultProfiles(ExceptPageId); await ModalDialogService.CloseAsync(); }); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogService.CancelAsync(); } }
private async Task LoadDataAsync() { var filter = new HardwareVaultFilter() { Status = VaultStatus.Active }; TotalRecords = await HardwareVaultService.GetVaultsCountAsync(new DataLoadingOptions <HardwareVaultFilter> { SearchText = SearchText, Filter = filter }); HardwareVaults = await HardwareVaultService.GetVaultsAsync(new DataLoadingOptions <HardwareVaultFilter> { Take = TotalRecords, SortedColumn = nameof(HardwareVault.Id), SortDirection = ListSortDirection.Ascending, SearchText = SearchText, Filter = filter }); var count = await WorkstationService.GetProximityVaultsCountAsync(new DataLoadingOptions <WorkstationDetailsFilter>() { EntityId = WorkstationId }); var proximityVaultFilter = new DataLoadingOptions <WorkstationDetailsFilter>() { Take = count, SortedColumn = nameof(WorkstationProximityVault.HardwareVaultId), SortDirection = ListSortDirection.Ascending, EntityId = WorkstationId }; var proximityVaults = await WorkstationService.GetProximityVaultsAsync(proximityVaultFilter); AlreadyAdded = proximityVaults.Count > 0; HardwareVaults = HardwareVaults.Where(x => !proximityVaults.Select(s => s.HardwareVaultId).Contains(x.Id)).ToList(); SelectedHardwareVault = null; StateHasChanged(); }
protected override async Task ModalDialogCancel() { await HardwareVaultService.UnchangedProfileAsync(AccessProfile); await base.ModalDialogCancel(); }
private async Task Next() { switch (WizardStep) { case WizardStep.Profile: var employeeNameExist = await EmployeeService.CheckEmployeeNameExistAsync(Employee); if (employeeNameExist) { EmployeeValidationErrorMessage.DisplayError(nameof(Core.Entities.Employee.FirstName), $"{Employee.FirstName} {Employee.LastName} already exists."); return; } var employeeIsValid = EmployeeContext.Validate(); if (!employeeIsValid) { return; } WizardStep = WizardStep.HardwareVault; break; case WizardStep.HardwareVault: if (SelectedHardwareVault == null) { WarningMessage = "Please, select a vault."; break; } WizardStep = WizardStep.WorkstationAccount; break; case WizardStep.WorkstationAccount: if (AccountType == AccountType.Personal) { var accountIsValid = PersonalAccountContext.Validate(); if (!accountIsValid) { return; } } WizardStep = WizardStep.Overview; break; case WizardStep.Overview: await CreateAsync(); if (SelectedHardwareVault == null) { await ToastService.ShowToastAsync("Employee created.", ToastType.Success); await ModalDialogClose(); break; } Code = await HardwareVaultService.GetVaultActivationCodeAsync(SelectedHardwareVault.Id); Email = Employee.Email; WizardStep = WizardStep.Activation; break; case WizardStep.Activation: await ToastService.ShowToastAsync("Employee created.", ToastType.Success); await ModalDialogClose(); break; } }
private async Task ModalDialogService_OnCancel() { await HardwareVaultService.UnchangedVaultAsync(HardwareVault); }
private async Task OnCancelAsync() { await HardwareVaultService.UnchangedProfileAsync(AccessProfile); }
protected override async Task ModalDialogCancel() { await HardwareVaultService.UnchangedVaultAsync(HardwareVault); await base.ModalDialogCancel(); }