optimization update, web scheduler test-integration
This commit is contained in:
parent
3c9ccaafeb
commit
1591618c2c
103 changed files with 4826 additions and 1502 deletions
|
|
@ -0,0 +1,70 @@
|
|||
using Insight.Infrastructure.Entities;
|
||||
using Insight.Web.Constants;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MongoDB.Driver;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Insight.Web.Pages.Management.Scheduler.Tasks;
|
||||
|
||||
public partial class TaskEditDialog
|
||||
{
|
||||
[Parameter] public EventCallback OnChanges { get; set; }
|
||||
|
||||
[Inject] private IMongoDatabase Database { get; init; } = default!;
|
||||
[Inject] private ISnackbar Snackbar { get; init; } = default!;
|
||||
[Inject] private ILogger<TaskEditDialog> Logger { get; init; } = default!;
|
||||
|
||||
private TaskEntity? _model;
|
||||
|
||||
public async void ToggleAsync(string? id)
|
||||
{
|
||||
if (id is null) return;
|
||||
|
||||
try
|
||||
{
|
||||
_model = await Database.Task().Find(p => p.Id == id).FirstAsync();
|
||||
_visible = !_visible;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Notification.Error(Snackbar);
|
||||
}
|
||||
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private async Task SubmitAsync()
|
||||
{
|
||||
if (_model is null) return;
|
||||
|
||||
try
|
||||
{
|
||||
await Database.Task()
|
||||
.UpdateOneAsync(Builders<TaskEntity>
|
||||
.Filter
|
||||
.Eq(p => p.Id, _model.Id), Builders<TaskEntity>
|
||||
.Update
|
||||
.Set(p => p.Update, DateTime.Now)
|
||||
.Set(p => p.Name, _model.Name), default);
|
||||
|
||||
Notification.Success(Snackbar);
|
||||
|
||||
if (OnChanges.HasDelegate)
|
||||
{
|
||||
await InvokeAsync(async () =>
|
||||
{
|
||||
await OnChanges.InvokeAsync(this);
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Notification.Error(Snackbar);
|
||||
Logger.LogError(ex.ToString());
|
||||
}
|
||||
finally
|
||||
{
|
||||
_visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue