private async void AddNewAsset() { string result = await MatDialogService.PromptAsync("Tilføj et nyt asset vha. serienummer:"); if (string.IsNullOrWhiteSpace(result)) { return; } Computer asset = new Computer(result) { PcName = "-" }; ComputerService.AddAsset(asset); bool assetIsInDatabase = ComputerService.GetAssetBySerialNumber(asset.SerialNumber) != null; if (assetIsInDatabase) { await MatDialogService.AlertAsync("Asset tilføjet."); } else { await MatDialogService.AlertAsync("Asset blev ikke tilføjet."); } }
protected async Task SendMail(EmailModel emailModel) { isLoadingFinished = false; await Task.Delay(1); try { var result = MailingService.SendMessage(emailModel); if (result) { await MatDialogService.AlertAsync("The message sent."); } } catch (Exception e) { Logger.LogError(e, $"{GetUserName()}*Error: Zugangsdaten/SendMail"); ErrorModel.IsOpen = true; ErrorModel.ErrorContext = e.StackTrace; ErrorModel.ErrorMessage = e.Message; IsFailed = true; StateHasChanged(); } finally { isLoadingFinished = true; StateHasChanged(); } }
private async Task OpenTask(Int32 taskId) { var task = await Http.GetFromJsonAsync <TaskDto>($"api/task/get-id/{taskId}"); await MatDialogService.AlertAsync(new StringBuilder() .Append($"[{task.Id}] ") .Append(task.Name) .ToString()); }
/// <summary> /// Opens the details page for an asset in a new page. /// </summary> /// <param name="asset">IAsset to open details for</param> private async Task NavigateToDetails(Computer asset) { if (ComputerService.GetAssetById(asset.Id) == null) { await MatDialogService.AlertAsync("Asset does not exist."); return; } string url = $"{NavigationManager.BaseUri}AssetDetails/{asset.Id}"; await JSRuntime.InvokeAsync <object>("open", new object[] { url, "_blank" }); }
public async Task ChooseTokens() { var act = headersDict.Where(x => x.Value == HeaderType.Activity); var caseId = headersDict.Where(x => x.Value == HeaderType.Case); if (!act.Any() || !caseId.Any()) { await MatDialogService.AlertAsync("You need at least 1 activity and 1 case!"); return; } var timetmpList = headersDict.Where(x => x.Value == HeaderType.Timestamp).Select(x => x.Key).ToList(); var time = timetmpList.Any() ? timetmpList[0] : null; var resources = headersDict.Where(x => x.Value == HeaderType.Resource).Select(x => x.Key).ToArray(); _imported.ChooseTokens(act.FirstOrDefault().Key, caseId.FirstOrDefault().Key, time, resources); }
private async Task Import() { var act = headersDict.Where(x => x.Value == HeaderType.Activity); var caseId = headersDict.Where(x => x.Value == HeaderType.Case); if (!act.Any() || !caseId.Any()) { await MatDialogService.AlertAsync("You need at least 1 activity and 1 case!"); return; } StateContainer.EventLogs.Add(_imported.BuildEventLog(LogName)); await _stream.DisposeAsync(); file = null; content = null; _imported = null; uploadMode = false; LogName = null; }
public async Task UploadLog(IMatFileUploadEntry[] files) { file = files.FirstOrDefault(); if (file is null) { return; } if (file.Type != "text/csv" && file.Type != "application/vnd.ms-excel") { await MatDialogService.AlertAsync("Log has to be in csv"); return; } try { _stream = new MemoryStream(); await file.WriteToStreamAsync(_stream); _stream.Seek(0, SeekOrigin.Begin); GetUploadContent(); _stream.Seek(0, SeekOrigin.Begin); _imported = CsvLogImporter.LoadLog(_stream); headersDict = _imported.Headers.ToDictionary(x => x, HeaderTypeSet); uploadMode = true; } catch { await MatDialogService.AlertAsync( "There was an error while uploading file. Check that file is .csv format"); } finally { await InvokeAsync(StateHasChanged); } }
protected async Task SubmitRequestAsync() { await MatDialogService.AlertAsync("Thank you, we're getting started with your request!"); }