Inizio bozza aggiunta progetto gestione TaskMan
This commit is contained in:
@@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Egw.Core", "Egw.Core\Egw.Co
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MP.Data", "MP.Data\MP.Data.csproj", "{EE871AE5-9B5E-493E-8E59-F77234979AD7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MP.TaskMan", "MP.TaskMan\MP.TaskMan.csproj", "{8BBD39D5-9390-4EBA-979B-954DC8FFC850}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug_LiManDebug|Any CPU = Debug_LiManDebug|Any CPU
|
||||
@@ -42,6 +44,12 @@ Global
|
||||
{EE871AE5-9B5E-493E-8E59-F77234979AD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EE871AE5-9B5E-493E-8E59-F77234979AD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EE871AE5-9B5E-493E-8E59-F77234979AD7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8BBD39D5-9390-4EBA-979B-954DC8FFC850}.Debug_LiManDebug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8BBD39D5-9390-4EBA-979B-954DC8FFC850}.Debug_LiManDebug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8BBD39D5-9390-4EBA-979B-954DC8FFC850}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8BBD39D5-9390-4EBA-979B-954DC8FFC850}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8BBD39D5-9390-4EBA-979B-954DC8FFC850}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8BBD39D5-9390-4EBA-979B-954DC8FFC850}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<div class="my-component">
|
||||
This component is defined in the <strong>MP.TaskMan</strong> library.
|
||||
</div>
|
||||
@@ -0,0 +1,6 @@
|
||||
.my-component {
|
||||
border: 2px dashed red;
|
||||
padding: 1em;
|
||||
margin: 1em 0;
|
||||
background-image: url('background.png');
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using Microsoft.JSInterop;
|
||||
|
||||
namespace MP.TaskMan
|
||||
{
|
||||
// This class provides an example of how JavaScript functionality can be wrapped
|
||||
// in a .NET class for easy consumption. The associated JavaScript module is
|
||||
// loaded on demand when first needed.
|
||||
//
|
||||
// This class can be registered as scoped DI service and then injected into Blazor
|
||||
// components for use.
|
||||
|
||||
public class ExampleJsInterop : IAsyncDisposable
|
||||
{
|
||||
private readonly Lazy<Task<IJSObjectReference>> moduleTask;
|
||||
|
||||
public ExampleJsInterop(IJSRuntime jsRuntime)
|
||||
{
|
||||
moduleTask = new(() => jsRuntime.InvokeAsync<IJSObjectReference>(
|
||||
"import", "./_content/MP.TaskMan/exampleJsInterop.js").AsTask());
|
||||
}
|
||||
|
||||
public async ValueTask<string> Prompt(string message)
|
||||
{
|
||||
var module = await moduleTask.Value;
|
||||
return await module.InvokeAsync<string>("showPrompt", message);
|
||||
}
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
if (moduleTask.IsValueCreated)
|
||||
{
|
||||
var module = await moduleTask.Value;
|
||||
await module.DisposeAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="TaskEdit.razor.cs" />
|
||||
<Compile Remove="TaskExeList.razor.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="TaskEdit.razor" />
|
||||
<Content Remove="TaskExeList.razor" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<SupportedPlatform Include="browser" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.33" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="NLog" Version="5.3.4" />
|
||||
<PackageReference Include="RestSharp" Version="112.0.0" />
|
||||
<PackageReference Include="StackExchange.Redis" Version="2.8.16" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Services\" />
|
||||
<Folder Include="Models\" />
|
||||
<Folder Include="Migrations\" />
|
||||
<Folder Include="Controllers\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,101 @@
|
||||
@if (CurrRecord != null)
|
||||
{
|
||||
<hr />
|
||||
<div class="row g-1">
|
||||
<div class="col-md-2">
|
||||
<div class="form-floating">
|
||||
<input type="text" class="form-control" @bind="@CurrRecord.Name">
|
||||
<label class="small">Nome Task</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="form-floating">
|
||||
<select class="form-select" @bind="@CurrRecord.TType">
|
||||
@foreach (var option in Enum.GetValues(typeof(MP.Data.Objects.Enums.Task2ExeType)))
|
||||
{
|
||||
<option value="@option">
|
||||
@option
|
||||
</option>
|
||||
}
|
||||
</select>
|
||||
<label class="small">Tipo Task</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="form-floating">
|
||||
<input type="text" class="form-control" @bind="@CurrRecord.Descript">
|
||||
<label class="small">Descrizione Task</label>
|
||||
</div>
|
||||
</div>
|
||||
@* <div class="col-md-2">
|
||||
<div class="form-floating">
|
||||
<select class="form-select" @bind="@CurrRecord.Freq">
|
||||
@foreach (var option in Enum.GetValues(typeof(MP.Data.Objects.Enums.TaskFreqType)))
|
||||
{
|
||||
<option value="@option">
|
||||
@option
|
||||
</option>
|
||||
}
|
||||
</select>
|
||||
<label class="small">Frequenza</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<div class="form-floating">
|
||||
<input type="number" class="form-control" @bind="@CurrRecord.Cad">
|
||||
<label class="small">Cadenza</label>
|
||||
</div>
|
||||
</div> *@
|
||||
</div>
|
||||
<div class="row g-1">
|
||||
<div class="col-md-4">
|
||||
<div class="form-floating">
|
||||
<input type="text" class="form-control" @bind="@CurrRecord.Command">
|
||||
<label class="small">Comando</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="form-floating">
|
||||
<input type="text" class="form-control" @bind="@CurrRecord.Args">
|
||||
<label class="small">Parametri</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row g-1">
|
||||
<div class="col-md-3">
|
||||
<div class="form-floating">
|
||||
<input type="number" class="form-control" @bind="@CurrRecord.Ordinal">
|
||||
<label class="small">Ordine Esecuzione</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-floating">
|
||||
<input type="datetime-local" class="form-control" @bind="@CurrRecord.DtNextExec">
|
||||
<label class="small">Prossima Esecuzione</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="form-floating">
|
||||
<select class="form-select" @bind="@CurrRecord.Freq">
|
||||
@foreach (var option in Enum.GetValues(typeof(MP.Data.Objects.Enums.TaskFreqType)))
|
||||
{
|
||||
<option value="@option">
|
||||
@option
|
||||
</option>
|
||||
}
|
||||
</select>
|
||||
<label class="small">Frequenza</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="form-floating">
|
||||
<input type="number" class="form-control" @bind="@CurrRecord.Cad">
|
||||
<label class="small">Cadenza</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2 pt-2">
|
||||
<button class="btn btn-lg w-100 btn-success" @onclick="()=>doSave()" title="Save"><i class="far fa-save"></i> Save</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace MP.TaskMan
|
||||
{
|
||||
public partial class TaskEdit
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
[Parameter]
|
||||
public TaskListModel? CurrRecord { get; set; } = null;
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<bool> EC_update { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected TaskService TService { get; set; }
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected async Task doCancel()
|
||||
{
|
||||
await EC_update.InvokeAsync(false);
|
||||
}
|
||||
|
||||
protected async Task doSave()
|
||||
{
|
||||
bool fatto = false;
|
||||
await Task.Delay(1);
|
||||
if (CurrRecord != null)
|
||||
{
|
||||
fatto = await TService.TaskListUpsert(CurrRecord);
|
||||
}
|
||||
await EC_update.InvokeAsync(fatto);
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
|
||||
<div class="card text-bg-light shadow">
|
||||
<div class="card-header table-primary p-1">
|
||||
<div class="d-flex justify-content-between">
|
||||
<div class="ps-2 d-flex">
|
||||
<div class="px-0">
|
||||
<b class="fs-4">History</b>
|
||||
</div>
|
||||
<div class="px-2">
|
||||
@if (CurrRecord != null)
|
||||
{
|
||||
<div title="@CurrRecord.Command">@TextReduce(CurrRecord.Command, 40)</div>
|
||||
<div class="small text-break" title="@CurrRecord.Args">@TextReduce(CurrRecord.Args, 60)</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-2">
|
||||
<div class="input-group">
|
||||
<select class="form-select" @bind="@ShowErrorMode">
|
||||
<option value="0">--- ALL ---</option>
|
||||
<option value="1">Solo Errori</option>
|
||||
<option value="2">Solo OK</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body py-0 px-1">
|
||||
@if (ListRecords == null)
|
||||
{
|
||||
<LoadingData></LoadingData>
|
||||
}
|
||||
else if (totalCount == 0)
|
||||
{
|
||||
<div class="alert alert-warning text-center display-6">Nessun record trovato</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<table class="table table-sm table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Inizio</th>
|
||||
<th>Fine</th>
|
||||
<th class="text-right">Esito</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var record in ListRecords)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@record.TaskExecId
|
||||
</td>
|
||||
<td>
|
||||
@($"{record.DtStart:HH:mm:ss.fff}")
|
||||
<div class="small">@($"{record.DtStart:yyyy-MM.dd ddd}")</div>
|
||||
</td>
|
||||
<td>
|
||||
@($"{record.DtEnd:HH:mm:ss.fff}")
|
||||
<div class="small">@($"{record.DtEnd:yyyy-MM.dd ddd}")</div>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<div class="d-flex justify-content-between">
|
||||
<div class="px-0">
|
||||
@if (@record.IsError)
|
||||
{
|
||||
<i class="far fa-thumbs-down text-danger"></i>
|
||||
}
|
||||
else
|
||||
{
|
||||
<i class="far fa-thumbs-up text-success"></i>
|
||||
}
|
||||
</div>
|
||||
<div class="px-0">
|
||||
<b>@($"{record.Duration:N3}")</b> <sub>sec</sub>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<div class="p-1 small text-truncate alert @alCss(record) mb-0" style="max-width: 60rem;">
|
||||
<pre>@record.Result</pre>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="card-footer py-1">
|
||||
<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" exportEnabled="false" totalCount="totalCount" showLoading="isLoading" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,134 @@
|
||||
using MailKit;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MongoDB.Bson;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.TaskMan
|
||||
{
|
||||
public partial class TaskExeList
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
[Parameter]
|
||||
public TaskListModel? CurrRecord { get; set; } = null;
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected bool isLoading = false;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected NavigationManager NavManager { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Show error mode: 0 = tutti 1 = solo errori 2 = solo ok
|
||||
/// </summary>
|
||||
protected int ShowErrorMode
|
||||
{
|
||||
get => showErrorMode;
|
||||
set
|
||||
{
|
||||
if (showErrorMode != value)
|
||||
{
|
||||
showErrorMode = value;
|
||||
var pUpd = Task.Run(async () => await ReloadData());
|
||||
pUpd.Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected int totalCount { get; set; } = 0;
|
||||
|
||||
[Inject]
|
||||
protected TaskService TService { get; set; }
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected string alCss(TaskExecModel TaskRec)
|
||||
{
|
||||
return TaskRec.IsError ? "alert-danger" : "alert-success";
|
||||
}
|
||||
|
||||
protected async Task ForceReload(int newNum)
|
||||
{
|
||||
numRecord = newNum;
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task ForceReloadPage(int newNum)
|
||||
{
|
||||
currPage = newNum;
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected string TextReduce(string textOriginal, int maxChar)
|
||||
{
|
||||
string answ = textOriginal;
|
||||
if (answ.Length > maxChar)
|
||||
{
|
||||
answ = $"{textOriginal.Substring(0, maxChar / 2)} ... {textOriginal.Substring(answ.Length - maxChar / 2)}";
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private List<TaskExecModel> ListRecords;
|
||||
private List<TaskExecModel> SearchRecords;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private int currPage { get; set; } = 1;
|
||||
private int numRecord { get; set; } = 10;
|
||||
private int showErrorMode { get; set; } = 0;
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private async Task ReloadData()
|
||||
{
|
||||
SearchRecords = await TService.TaskExecGetFilt(CurrRecord.TaskId, 1000, "");
|
||||
// se non tutti filtro...
|
||||
if (ShowErrorMode != 0)
|
||||
{
|
||||
if (ShowErrorMode == 1)
|
||||
{
|
||||
SearchRecords = SearchRecords.FindAll(x => x.IsError);
|
||||
}
|
||||
else if (ShowErrorMode == 2)
|
||||
{
|
||||
SearchRecords = SearchRecords.FindAll(x => !x.IsError);
|
||||
}
|
||||
}
|
||||
totalCount = SearchRecords.Count;
|
||||
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 378 B |
@@ -0,0 +1,6 @@
|
||||
// This is a JavaScript module that is loaded on demand. It can export any number of
|
||||
// functions, and may import other JavaScript modules if required.
|
||||
|
||||
export function showPrompt(message) {
|
||||
return prompt(message, 'Type anything here');
|
||||
}
|
||||
Reference in New Issue
Block a user