protected async Task SetRole() { OnClose?.Invoke(); var model = new SetUserRoleDto(); model.UserId = Guid.Parse(UserDto.UserId); if (SelectedRows != null && SelectedRows.Count() > 0) { SelectedRows.ToList().ForEach(x => { if (x != null) { model.RoleIds.Add(Guid.Parse(x.RoleId)); } }); } var result = await RoleService.SetUserRoleByUserIdAndRoleIds(model); if (result.status.code == ResultCode.Success) { await ToastService.Show(new ToastOption() { Title = "配置成功", Content = "配置成功,4 秒后自动关闭" }); } else { await ToastService.Show(new ToastOption() { Title = "配置失败", Content = $"配置失败,{result.status.text}" }); } }
protected override async Task OnInitializedAsync() { try { TemplateService = ScopedServices.GetRequiredService <ITemplateService>(); Template = await TemplateService.GetByIdAsync(TemplateId); if (Template == null) { throw new Exception("Template not found."); } ModalDialogService.OnCancel += OnCancelAsync; 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(); } }
public void ShowToast() { ToastService?.Show(new ToastOption() { Title = "友情提示", Content = "屏幕宽度过小,如果是手机请横屏观看" }); }
protected override async Task OnInitializedAsync() { try { WorkstationService = ScopedServices.GetRequiredService <IWorkstationService>(); OrgStructureService = ScopedServices.GetRequiredService <IOrgStructureService>(); 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); } Companies = await OrgStructureService.GetCompaniesAsync(); Departments = new List <Department>(); SetInitialized(); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogCancel(); } }
public void Process(OperationResult model) { Messages.Clear(); foreach (var errorMessage in model.Errors) { switch (errorMessage.Code) { case "Toast.Info": ToastService.ShowInfo(errorMessage.Text); break; case "Toast.Success": ToastService.ShowSuccess(errorMessage.Text); break; case "Toast.Error": ToastService.ShowError(errorMessage.Text); break; case "Toast.Warning": ToastService.ShowWarning(errorMessage.Text); break; default: Messages.Add(errorMessage); break; } } Show = true; StateHasChanged(); }
private async Task SetAsWorkstationAccountAsync() { try { await EmployeeService.SetAsPrimaryAccountAsync(Account.Employee.Id, Account.Id); var employee = await EmployeeService.GetEmployeeByIdAsync(Account.Employee.Id); RemoteDeviceConnectionsService.StartUpdateHardwareVaultAccounts(await EmployeeService.GetEmployeeVaultIdsAsync(employee.Id)); await Refresh.InvokeAsync(this); await ToastService.ShowToastAsync("Account setted as primary.", ToastType.Success); await SynchronizationService.UpdateEmployeeDetails(ExceptPageId, Account.EmployeeId); await ModalDialogService.CloseAsync(); } catch (Exception ex) { await ModalDialogService.CloseAsync(); Logger.LogError(ex.Message, ex); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); } }
protected override async Task OnInitializedAsync() { try { HardwareVaultService = ScopedServices.GetRequiredService <IHardwareVaultService>(); ModalDialogService.OnCancel += ModalDialogService_OnCancel; 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 ModalDialogService.CancelAsync(); } }
private static async Task <StorageFile> PrepareImageFileAsync(StorageFile resultFile) { if (!UserProfilePersonalizationSettings.IsSupported()) { ToastService.SendToast("Your device can't set wallpaper."); return(null); } if (resultFile != null) { StorageFile file = null; //WTF, the file should be copy to LocalFolder to make the setting wallpaer api work. var folder = ApplicationData.Current.LocalFolder; var oldFile = await folder.TryGetItemAsync(resultFile.Name) as StorageFile; if (oldFile != null) { await resultFile.CopyAndReplaceAsync(oldFile); file = oldFile; } else { file = await resultFile.CopyAsync(folder); } return(file); } return(null); }
public static async Task SetBothAsync(StorageFile savedFile) { var uc = new LoadingTextControl() { LoadingText = "Setting background and lockscreen..." }; await PopupService.Instance.ShowAsync(uc); var file = await PrepareImageFileAsync(savedFile); if (file != null) { var result1 = await UserProfilePersonalizationSettings.Current.TrySetWallpaperImageAsync(file); var result2 = await UserProfilePersonalizationSettings.Current.TrySetLockScreenImageAsync(file); //var task = file.DeleteAsync(StorageDeleteOption.PermanentDelete); if (result1 && result2) { ToastService.SendToast("Set as background and lock screen successfully."); } else { ToastService.SendToast("Fail to set both. #API ERROR."); } } PopupService.Instance.TryHide(500); }
private async Task GenerateAccountPasswordAsync() { try { if (LdapSettings?.Password == null) { throw new Exception("Active Directory credentials not set in parameters page."); } var accountPassword = new AccountPassword() { Password = PasswordGenerator.Generate() }; using (TransactionScope transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { await EmployeeService.EditPersonalAccountPwdAsync(Account, accountPassword); await LdapService.SetUserPasswordAsync(Account.EmployeeId, accountPassword.Password, LdapSettings); transactionScope.Complete(); } RemoteDeviceConnectionsService.StartUpdateHardwareVaultAccounts(await EmployeeService.GetEmployeeVaultIdsAsync(Account.EmployeeId)); await ToastService.ShowToastAsync("Account password updated.", ToastType.Success); await ModalDialogClose(); } 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>(); 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 ModalDialogCancel(); } }
protected override async Task OnInitializedAsync() { try { EmployeeService = ScopedServices.GetRequiredService <IEmployeeService>(); AccountService = ScopedServices.GetRequiredService <IAccountService>(); LdapService = ScopedServices.GetRequiredService <ILdapService>(); RemoteDeviceConnectionsService = ScopedServices.GetRequiredService <IRemoteDeviceConnectionsService>(); Account = await AccountService.GetAccountByIdAsync(AccountId); if (Account == null) { throw new HESException(HESCode.AccountNotFound); } EntityBeingEdited = MemoryCache.TryGetValue(Account.Id, out object _); if (!EntityBeingEdited) { MemoryCache.Set(Account.Id, Account); } LdapSettings = await AppSettingsService.GetLdapSettingsAsync(); SetInitialized(); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogCancel(); } }
private async Task SaveMainListDataAsync() { if (this.DataVM.DataList?.Count > 0) { var list = new List <UnsplashImage>(); foreach (var item in DataVM.DataList) { if (item is UnsplashImage) { list.Add(item as UnsplashImage); } } if (list.Count > 0) { ToastService.SendToast("Fetched :D"); var str = JsonConvert.SerializeObject(list, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All }); var file = await ApplicationData.Current.LocalFolder.CreateFileAsync(CachedFileNames.MainListFileName, CreationCollisionOption.OpenIfExists); await FileIO.WriteTextAsync(file, str); } } }
private async Task <bool> VerifyAdUserAsync() { try { await LdapService.VerifyAdUserAsync(Employee); return(true); } catch (HESException ex) when(ex.Code == HESCode.ActiveDirectoryUserNotFound) { await EmployeeService.RemoveFromHideezKeyOwnersAsync(Employee.Id); Employee = await EmployeeService.GetEmployeeByIdAsync(EmployeeId, asNoTracking : true); await ToastService.ShowToastAsync(ex.Message, ToastType.Notify); return(false); } catch (LdapException ex) when(ex.ResultCode == (LdapForNet.Native.Native.ResultCode) 81) { await ToastService.ShowToastAsync("The LDAP server is unavailable.", ToastType.Error); return(false); } catch (Exception ex) { await ToastService.ShowToastAsync(ex.Message, ToastType.Error); return(false); } }
/// <summary> /// Toast 调用警告信息快捷方法 /// </summary> /// <param name="service"></param> /// <param name="title"></param> /// <param name="content"></param> /// <param name="autoHide"></param> /// <returns></returns> public static Task Warning(this ToastService service, string?title = null, string?content = null, bool autoHide = true) => service.Show(new ToastOption() { Category = ToastCategory.Warning, IsAutoHide = autoHide, Title = title ?? "", Content = content ?? "" });
public async Task PublishProject() { project.IsPublished = true; await ProjectData.UpdatePublishStatus(project); ToastService.ShowSuccess("Project Published Successfully", "-"); }
protected override async Task OnInitializedAsync() { try { EmployeeService = ScopedServices.GetRequiredService <IEmployeeService>(); RemoteDeviceConnectionsService = ScopedServices.GetRequiredService <IRemoteDeviceConnectionsService>(); Account = await EmployeeService.GetAccountByIdAsync(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); SetLoadFailed(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogService.CancelAsync(); } }
public async Task UnpublishProject() { project.IsPublished = false; await ProjectData.UpdatePublishStatus(project); ToastService.ShowToast(ToastLevel.Success, "Done", "-"); }
private async Task AddQuickPrescription(string documentPath) { var ordannance = new Ordonnance() { Id = Guid.NewGuid().ToString(), CreatedAt = DateTime.UtcNow, IsSynced = false, UpdatedAt = null, First_Care_At = 0, Attachments = new List <string>() { documentPath }, Frequencies = new List <Frequency>(), Patient = Patient, PatientId = Patient.Id, PatientName = Patient.Fullname }; await new StorageService <Ordonnance>().AddAsync(ordannance); if (App.IsConnected()) { UserDialogs.Instance.ShowLoading("Chargement..."); new StorageService <Ordonnance>().PushOrdonnance(ordannance, true); UserDialogs.Instance.HideLoading(); } BindData(); await ToastService.Show("Votre ordonnance a bien été enregistrée !"); }
private async Task CreateTemplateAsync() { try { await ButtonSpinner.SpinAsync(async() => { await TemplateService.CreateTmplateAsync(Template); await ToastService.ShowToastAsync("Template created.", ToastType.Success); await SynchronizationService.UpdateTemplates(ExceptPageId); await ModalDialogService.CloseAsync(); }); } catch (AlreadyExistException ex) { ValidationErrorMessage.DisplayError(nameof(SharedAccount.Name), ex.Message); } catch (IncorrectUrlException ex) { ValidationErrorMessage.DisplayError(nameof(SharedAccount.Urls), ex.Message); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogService.CancelAsync(); } }
private async void DownloadBtn_Click(object sender, RoutedEventArgs e) { ToggleDownloadBtnAnimation(false); ToggleDownloadingBtnAnimation(true); try { _cts = new CancellationTokenSource(); await this.CurrentImage.DownloadFullImageAsync(_cts.Token); ToggleDownloadingBtnAnimation(false); //Still in this page if (IsShown) { ToggleOkBtnAnimation(true); ToastService.SendToast("Saved :D", TimeSpan.FromMilliseconds(1000)); } } catch (OperationCanceledException) { ToggleDownloadBtnAnimation(true); ToggleDownloadingBtnAnimation(false); ToggleOkBtnAnimation(false); ToastService.SendToast("Cancelled", TimeSpan.FromMilliseconds(1000)); } catch (Exception ex) { var task = Logger.LogAsync(ex); ToggleDownloadBtnAnimation(true); ToggleDownloadingBtnAnimation(false); ToggleOkBtnAnimation(false); ToastService.SendToast($"Exception throws.{ex.Message}", TimeSpan.FromMilliseconds(1000)); } }
/// <summary> /// Upload the given stream with all loaded providers. /// </summary> /// <param name="ext"></param> /// <param name="stream"></param> /// <returns></returns> private async Task <string> UploadAll(MemoryStream stream, string ext) { var name = $"{DateTime.Now:yyyy_MM_dd_HH_mm_ss}.{ext}"; var toast = ToastService.Create(string.Format(Resources.Uploading, $"{(double)stream.Length / (1024 * 1024):0.00} MB"), 0); // Try to load the saved providers (if load on startup is disabled) if (!ConfigService.Current.StartupRegister) { await RestoreProviders(); } // Save file locally if no providers were registered if (ProviderService.RegisteredProviders.Count == 0) { File.WriteAllBytes(name, stream.ToArray()); ToastService.Remove(toast); return(null); } var uploads = new Dictionary <string, Task <string> >(); string result = null; string last = null; // Run the uploads async foreach (var p in ProviderService.RegisteredProviders) { if (p.Value != null) { uploads[p.Key] = p.Value.Upload(name, stream); } } // Wait for the uploads to finish and get the chosen URL foreach (var p in uploads) { var url = await p.Value; if (string.IsNullOrEmpty(url)) { ToastService.Remove(toast); ToastService.Create(string.Format(Resources.ProviderUploadFailed, p.Key)); } else { last = url; if (p.Key == ConfigService.Current.CopyProvider) { result = url; } } } ToastService.Remove(toast); // If the chosen URL was not found (or null), use the URL of the last successful one return(string.IsNullOrEmpty(result) ? last : result); }
protected async void UpdatePassword(object sender, EventArgs e) { const string genericErrorMessage = "Sorry, an error occurred when updating your password. Try again later."; var currentPassword = txtCurrentPassword.Text; var newPassword = txtNewPassword.Text; var confirmNewPassword = txtConfirmNewPassword.Text; if (string.IsNullOrWhiteSpace(currentPassword)) { ToastService.Error("A current password is required."); return; } if (string.IsNullOrWhiteSpace(newPassword)) { ToastService.Error("A new password is required."); return; } if (string.IsNullOrWhiteSpace(confirmNewPassword)) { ToastService.Error("A password confirmation is required."); return; } if (newPassword != confirmNewPassword) { ToastService.Error("The password and confirmation don't match."); return; } prgUpdatePassword.IsVisible = true; btnUpdatePassword.IsVisible = false; try { var response = await _userService.UpdatePassword(currentPassword, newPassword); ToastService.Success(response.Message); } catch (ApiException ex) when(ex.IsValidationException()) { var error = await ex.GetContentAsAsync <ValidationErrorViewModel>(); ToastService.Error(error?.Message?.Length > 0 ? error.Message[0] : genericErrorMessage); } catch (ApiException ex) { var error = await ex.GetContentAsAsync <ErrorViewModel>(); ToastService.Error(error?.Message?.Length > 0 ? error.Message : genericErrorMessage); } finally { btnUpdatePassword.IsVisible = true; prgUpdatePassword.IsVisible = false; } }
protected async Task HandleValidSubmit() { await TaskDataService.AddTask(Task); await ModalInstance.CloseAsync(ModalResult.Ok(true)); ToastService.ShowSuccess($"{Task.Title} Added successfully.", "Success"); }
private void CopyURLBtn_Click(object sender, RoutedEventArgs e) { DataPackage dataPackage = new DataPackage(); dataPackage.SetText(CurrentImage.GetSaveImageUrlFromSettings()); Clipboard.SetContent(dataPackage); ToastService.SendToast("Copied."); }
private void TextBlock_Tapped(object sender, TappedRoutedEventArgs e) { DataPackage dataPackage = new DataPackage(); dataPackage.SetText("473967668"); Clipboard.SetContent(dataPackage); ToastService.SendToast("已复制到剪切板"); }
public TransactionDetailPopupController(ClipboardService clipboardService, ToastService toastService) { ClipboardService = clipboardService; ToastService = toastService; CopyTransactionHashCommand = new DelegateCommand(CopyTransactionHash); CopyBlockHashCommand = new DelegateCommand(CopyBlockHash); CloseCommand = new DelegateCommand(ClosePopup); }
private async Task OnDoubleClickCellCallback(string columnName, object row, object value) { var displayName = Utility.GetDisplayName(typeof(Foo), columnName); await ToastService.Show(new ToastOption() { Title = CellLocalizer["ToastTitle"], Content = $"{CellLocalizer["CurrentCellName"]}{displayName} {CellLocalizer["CurrentValue"]}{value}" }); }
protected async Task HandleValidSubmit() { await EmployeeDataService.AddEmployee(Employee); await ModalInstance.CloseAsync(ModalResult.Ok(true)); ToastService.ShowSuccess($"{Employee.FullName} Added successfully.", "Success"); }
private void Notify(object sender, RoutedEventArgs e) { XmlDocument xmlDoc = ToastService.CreateToast(); ToastNotifier notifier = ToastNotificationManager.CreateToastNotifier(); ToastNotification toast = new ToastNotification(xmlDoc); notifier.Show(toast); }