public async Task OnStart(TasksQzDto model) { var result = await Http.GetFromJsonAsync <MessageModel <TasksQzDto> >($"api/TasksQz/start/{model.Id}"); if (result.success) { var index = datas.IndexOf(model); result.response.AppName = _appItems.Find(a => a.Id == result.response.AppId)?.Name; datas[index] = result.response; MsgSvr.Success($"{model.Name} 启动成功"); } else { MsgSvr.Error($"{model.Name} 启动失败,错误:{result.msg}"); } }
public async Task OnDelete(TasksQzDto model) { if (await ConfirmSvr.Show($"是否删除任务 {model.Name}", "停止", ConfirmButtons.YesNo, ConfirmIcon.Question) == ConfirmResult.Yes) { var result = await Http.DeleteFromJsonAsync <MessageModel <bool> >($"api/TasksQz/{model.Id}"); if (result.success) { await OnQuery(); MsgSvr.Success($"{model.Name} 删除成功"); } else { MsgSvr.Error($"{model.Name} 删除失败,错误:{result.msg}"); } } }
public async void OnDelete(IndexLibraryDto model) { if (await ConfirmSvr.Show($"是否删除指标 {model.Name}", "删除", ConfirmButtons.YesNo, ConfirmIcon.Question) == ConfirmResult.Yes) { var result = await Http.DeleteFromJsonAsync <ResultMsg>($"api/IndexLibrary/Delete?id={model.IndexLibraryId}"); if (result.IsSuccess) { datas.Remove(model); MsgSvr.Success($"{model.Name} 删除成功"); await InvokeAsync(StateHasChanged); } else { MsgSvr.Error($"{model.Name} 删除失败,错误:{result.Msg}"); } } }
public async Task OnStop(TasksQzDto model) { if (await ConfirmSvr.Show($"是否停止任务 {model.Name}", "停止", ConfirmButtons.YesNo, ConfirmIcon.Question) == ConfirmResult.Yes) { var result = await Http.GetFromJsonAsync <MessageModel <TasksQzDto> >($"api/TasksQz/stop/{model.Id}"); if (result.success) { var index = datas.IndexOf(model); result.response.AppName = _appItems.Find(a => a.Id == result.response.AppId)?.Name; datas[index] = result.response; MsgSvr.Success($"{model.Name} 停止成功"); //await InvokeAsync(StateHasChanged); } else { MsgSvr.Error($"{model.Name} 停止失败,错误:{result.msg}"); } } }
async void OnLogin() { isLoading = true; var httpResponse = await Http.PostAsJsonAsync <LoginDto>($"api/Auth/Login", model); UserDto result = await httpResponse.Content.ReadFromJsonAsync <UserDto>(); if (string.IsNullOrWhiteSpace(result?.Token) == false) { MsgSvr.Success($"登录成功"); Http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", result.Token); ((AuthProvider)AuthProvider).MarkUserAsAuthenticated(result); } else { MsgSvr.Error($"用户名或密码错误"); } isLoading = false; InvokeAsync(StateHasChanged); }