TASK:
- Fix gestione Task su multi-gruppo MacchineEnergy: - update gestione nuove view
This commit is contained in:
@@ -170,14 +170,13 @@ namespace MP.Data.Controllers
|
||||
/// Elenco da tabella Macchine con dati Energy
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<MacchineModel> MacchineEnergy()
|
||||
public List<MacchineStatModel> MacchineEnergy()
|
||||
{
|
||||
List<MacchineModel> dbResult = new List<MacchineModel>();
|
||||
List<MacchineStatModel> dbResult = new List<MacchineStatModel>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetMacchine
|
||||
.FromSqlRaw("EXEC stp_MaccEnergy")
|
||||
.DbSetMaccStat
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
|
||||
#nullable disable
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
namespace MP.Data.DbModels
|
||||
{
|
||||
public partial class MacchineStatModel
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
[Key]
|
||||
public string IdxMacchina { get; set; }
|
||||
/// <summary>
|
||||
/// Cod macchina
|
||||
/// </summary>
|
||||
public string CodMacchina { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Nome macchina
|
||||
/// </summary>
|
||||
public string Nome { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Descrizione macchina
|
||||
/// </summary>
|
||||
public string Descrizione { get; set; } = "";
|
||||
public bool Energy { get; set; } = false;
|
||||
public bool Deleted { get; set; } = false;
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ namespace MP.Data.DbModels
|
||||
/// <summary>
|
||||
/// Tipo Task
|
||||
/// </summary>
|
||||
public Task2ExeType TType { get; set; } = Task2ExeType.ND;
|
||||
public Task2ExeType TType { get; set; } = Task2ExeType.ALL;
|
||||
|
||||
/// <summary>
|
||||
/// Comando da invocare
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace MP.Data
|
||||
public virtual DbSet<TurniOee> DbSetTurniOee { get; set; }
|
||||
public virtual DbSet<UserActionLog> DbSetUserLog { get; set; }
|
||||
public virtual DbSet<VocabolarioModel> DbSetVocabolario { get; set; }
|
||||
public virtual DbSet<MacchineStatModel> DbSetMaccStat { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
@@ -176,55 +177,61 @@ namespace MP.Data
|
||||
entity.Property(e => e.Nome).HasMaxLength(50);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<MacchineStatModel>(entity =>
|
||||
{
|
||||
//entity.HasNoKey();
|
||||
|
||||
entity.ToView("v_UI_MaccEnergy");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<DdbTurni>(entity =>
|
||||
{
|
||||
entity.HasNoKey();
|
||||
{
|
||||
entity.HasNoKey();
|
||||
|
||||
entity.ToView("v_UI_DDB_Turni");
|
||||
entity.ToView("v_UI_DDB_Turni");
|
||||
|
||||
entity.Property(e => e.ClasseTempo).HasMaxLength(50);
|
||||
entity.Property(e => e.ClasseTempo).HasMaxLength(50);
|
||||
|
||||
entity.Property(e => e.CodArticolo)
|
||||
.IsRequired()
|
||||
.HasMaxLength(50);
|
||||
entity.Property(e => e.CodArticolo)
|
||||
.IsRequired()
|
||||
.HasMaxLength(50);
|
||||
|
||||
entity.Property(e => e.CodMacchina).HasMaxLength(50);
|
||||
entity.Property(e => e.CodMacchina).HasMaxLength(50);
|
||||
|
||||
entity.Property(e => e.DataRif).HasColumnType("datetime");
|
||||
entity.Property(e => e.DataRif).HasColumnType("datetime");
|
||||
|
||||
entity.Property(e => e.DataTurnoFine).HasColumnType("datetime");
|
||||
entity.Property(e => e.DataTurnoFine).HasColumnType("datetime");
|
||||
|
||||
entity.Property(e => e.DataTurnoInizio).HasColumnType("datetime");
|
||||
entity.Property(e => e.DataTurnoInizio).HasColumnType("datetime");
|
||||
|
||||
entity.Property(e => e.Descrizione).HasMaxLength(50);
|
||||
entity.Property(e => e.Descrizione).HasMaxLength(50);
|
||||
|
||||
entity.Property(e => e.FinePeriodo).HasColumnType("datetime");
|
||||
entity.Property(e => e.FinePeriodo).HasColumnType("datetime");
|
||||
|
||||
entity.Property(e => e.FineStato).HasColumnType("datetime");
|
||||
entity.Property(e => e.FineStato).HasColumnType("datetime");
|
||||
|
||||
entity.Property(e => e.IdxMacchina)
|
||||
.IsRequired()
|
||||
.HasMaxLength(50);
|
||||
entity.Property(e => e.IdxMacchina)
|
||||
.IsRequired()
|
||||
.HasMaxLength(50);
|
||||
|
||||
entity.Property(e => e.IdxOdl).HasColumnName("IdxODL");
|
||||
entity.Property(e => e.IdxOdl).HasColumnName("IdxODL");
|
||||
|
||||
entity.Property(e => e.InizioPeriodo).HasColumnType("datetime");
|
||||
entity.Property(e => e.InizioPeriodo).HasColumnType("datetime");
|
||||
|
||||
entity.Property(e => e.InizioStato).HasColumnType("datetime");
|
||||
entity.Property(e => e.InizioStato).HasColumnType("datetime");
|
||||
|
||||
entity.Property(e => e.KeyRichiesta).HasMaxLength(50);
|
||||
entity.Property(e => e.KeyRichiesta).HasMaxLength(50);
|
||||
|
||||
entity.Property(e => e.Pallet)
|
||||
.HasMaxLength(20)
|
||||
.HasColumnName("pallet");
|
||||
entity.Property(e => e.Pallet)
|
||||
.HasMaxLength(20)
|
||||
.HasColumnName("pallet");
|
||||
|
||||
entity.Property(e => e.TempoCicloBase).HasColumnType("decimal(18, 8)");
|
||||
entity.Property(e => e.TempoCicloBase).HasColumnType("decimal(18, 8)");
|
||||
|
||||
entity.Property(e => e.Turno)
|
||||
.IsRequired()
|
||||
.HasMaxLength(5);
|
||||
});
|
||||
entity.Property(e => e.Turno)
|
||||
.IsRequired()
|
||||
.HasMaxLength(5);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<AzioniUL>(entity =>
|
||||
{
|
||||
|
||||
@@ -8,7 +8,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Security.AccessControl;
|
||||
|
||||
namespace MP.Stats.Components
|
||||
{
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace MP.Stats.Controllers
|
||||
public async Task<List<TaskResultModel>> ExecuteAndReturnGet()
|
||||
{
|
||||
List<TaskResultModel> answ = new List<TaskResultModel>();
|
||||
List<TaskListModel> listTask = await DService.TaskListAll(TaskMan.Objects.Enums.Task2ExeType.ND, "");
|
||||
List<TaskListModel> listTask = await DService.TaskListAll(TaskMan.Objects.Enums.Task2ExeType.ALL, "");
|
||||
// verifico SE ci siano task in scadenza...
|
||||
DateTime adesso = DateTime.Now;
|
||||
var task2exe = listTask.Where(x => x.DtNextExec <= adesso).ToList();
|
||||
@@ -56,7 +56,7 @@ namespace MP.Stats.Controllers
|
||||
[HttpGet("GetList")]
|
||||
public async Task<List<TaskListModel>> GetList()
|
||||
{
|
||||
List<TaskListModel> answ = await DService.TaskListAll(TaskMan.Objects.Enums.Task2ExeType.ND, "");
|
||||
List<TaskListModel> answ = await DService.TaskListAll(TaskMan.Objects.Enums.Task2ExeType.ALL, "");
|
||||
return answ;
|
||||
}
|
||||
|
||||
|
||||
+111
-113
@@ -32,7 +32,7 @@ namespace MP.Stats.Data
|
||||
|
||||
// setup compoenti REDIS
|
||||
redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
|
||||
redisDb = redisConn.GetDatabase();
|
||||
redisDb = redisConn.GetDatabase();
|
||||
#endif
|
||||
|
||||
// conf DB
|
||||
@@ -250,6 +250,113 @@ namespace MP.Stats.Data
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero dati FluxLog secondo filtro + richiesta raggruppamento
|
||||
/// </summary>
|
||||
/// <param name="CurrFilter"></param>
|
||||
/// <param name="fluxType"></param>
|
||||
/// <param name="searchVal"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<FLModel>> FluxLogRawData(SelectData CurrFilter, string fluxType, string searchVal = "")
|
||||
{
|
||||
// setup parametri costanti
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<FLModel> result = new List<FLModel>();
|
||||
// cerco in redis...
|
||||
DateTime adesso = DateTime.Now;
|
||||
string currKey = getCacheKey($"{redisBaseKey}:FL_DATA:FT_{fluxType}", CurrFilter);
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<FLModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.FluxLogRawData(CurrFilter.IdxMacchina, CurrFilter.DateStart, CurrFilter.DateEnd, fluxType);
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, FastCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<FLModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"FluxLogRawData | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco di tipi flusso disponibili
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<string>> FluxTypeList()
|
||||
{
|
||||
// setup parametri costanti
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<string> result = new List<string>();
|
||||
// cerco in redis...
|
||||
DateTime adesso = DateTime.Now;
|
||||
string currKey = $"{redisBaseKey}:FTList";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<string>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.FluxTypeList();
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<string>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"FluxTypeList | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<MacchineStatModel> MacchineEnergy()
|
||||
{
|
||||
// setup parametri costanti
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<MacchineStatModel> result = new List<MacchineStatModel>();
|
||||
// cerco in redis...
|
||||
DateTime adesso = DateTime.Now;
|
||||
string currKey = $"{redisBaseKey}:Cache:MacchineEnergy";
|
||||
RedisValue rawData = redisDb.StringGet(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<MacchineStatModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.MacchineEnergy().ToList();
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, FastCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<MacchineStatModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"MacchineEnergy | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<MacchineModel> MacchineGetAll()
|
||||
{
|
||||
// setup parametri costanti
|
||||
@@ -282,38 +389,6 @@ namespace MP.Stats.Data
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<MacchineModel> MacchineEnergy()
|
||||
{
|
||||
// setup parametri costanti
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<MacchineModel> result = new List<MacchineModel>();
|
||||
// cerco in redis...
|
||||
DateTime adesso = DateTime.Now;
|
||||
string currKey = $"{redisBaseKey}:Cache:MacchineEnergy";
|
||||
RedisValue rawData = redisDb.StringGet(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<MacchineModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.MacchineEnergy().ToList();
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, FastCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<MacchineModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"MacchineEnergy | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
public Task<List<AutocompleteModel>> MachineList(bool onlyEnergy = false)
|
||||
{
|
||||
List<AutocompleteModel> answ = new List<AutocompleteModel>();
|
||||
@@ -480,83 +555,6 @@ namespace MP.Stats.Data
|
||||
return numRec;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Recupero dati FluxLog secondo filtro + richiesta raggruppamento
|
||||
/// </summary>
|
||||
/// <param name="CurrFilter"></param>
|
||||
/// <param name="fluxType"></param>
|
||||
/// <param name="searchVal"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<FLModel>> FluxLogRawData(SelectData CurrFilter, string fluxType, string searchVal = "")
|
||||
{
|
||||
// setup parametri costanti
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<FLModel> result = new List<FLModel>();
|
||||
// cerco in redis...
|
||||
DateTime adesso = DateTime.Now;
|
||||
string currKey = getCacheKey($"{redisBaseKey}:FL_DATA:FT_{fluxType}", CurrFilter);
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<FLModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.FluxLogRawData(CurrFilter.IdxMacchina, CurrFilter.DateStart, CurrFilter.DateEnd, fluxType);
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, FastCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<FLModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"FluxLogRawData | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco di tipi flusso disponibili
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<string>> FluxTypeList()
|
||||
{
|
||||
// setup parametri costanti
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<string> result = new List<string>();
|
||||
// cerco in redis...
|
||||
DateTime adesso = DateTime.Now;
|
||||
string currKey = $"{redisBaseKey}:FTList";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<string>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.FluxTypeList();
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<string>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"FluxTypeList | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Statistiche ODL
|
||||
/// </summary>
|
||||
@@ -787,6 +785,8 @@ namespace MP.Stats.Data
|
||||
/// </summary>
|
||||
protected static Dictionary<string, string> DictFluxUm = new Dictionary<string, string>();
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Oggetto per connessione a REDIS
|
||||
@@ -796,11 +796,9 @@ namespace MP.Stats.Data
|
||||
/// <summary>
|
||||
/// Oggetto DB redis da impiegare x chiamate R/W
|
||||
/// </summary>
|
||||
protected IDatabase redisDb = null!;
|
||||
protected IDatabase redisDb = null!;
|
||||
#endif
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected string getCacheKey(string TableName, SelectData CurrFilter)
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>MP.Stats</RootNamespace>
|
||||
<UserSecretsId>826e877c-ba70-4253-84cb-d0b1cafd4440</UserSecretsId>
|
||||
<Version>6.16.2507.0312</Version>
|
||||
<Version>6.16.2507.0312</Version>
|
||||
<Version>6.16.2507.0315</Version>
|
||||
<Version>6.16.2507.0315</Version>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace MP.Stats.Pages
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await StatService.FlushCache();
|
||||
await TServ.FlushCache();
|
||||
await TServ.FlushCacheAsync();
|
||||
await TradServ.FlushCache();
|
||||
await Task.Delay(500);
|
||||
NavManager.NavigateTo("", true);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo statistiche MAPO</i>
|
||||
<h4>Versione: 6.16.2507.0312</h4>
|
||||
<h4>Versione: 6.16.2507.0315</h4>
|
||||
<br />
|
||||
Note di rilascio:
|
||||
<ul>
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.16.2507.0312
|
||||
6.16.2507.0315
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>6.16.2507.0312</version>
|
||||
<version>6.16.2507.0315</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/MP.Stats.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -323,7 +323,7 @@ namespace MP.TaskMan.Controllers
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetTaskList
|
||||
.Where(x => (TType == Task2ExeType.ND || x.TType == TType))
|
||||
.Where(x => (TType == Task2ExeType.ALL || x.TType == TType))
|
||||
.OrderBy(x => x.Ordinal)
|
||||
.ToList();
|
||||
}
|
||||
@@ -388,6 +388,50 @@ namespace MP.TaskMan.Controllers
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Riordino record di un dato gruppo (da richiamare post cambio gruppo...)
|
||||
/// </summary>
|
||||
/// <param name="codGroup"></param>
|
||||
/// <returns></returns>
|
||||
public bool TaskListReorder(int codGroup)
|
||||
{
|
||||
bool done = false;
|
||||
using (var dbCtx = new TaskContext(_configuration))
|
||||
{
|
||||
// in primis recupero i record del gruppo ordinati
|
||||
var currList = dbCtx
|
||||
.DbSetTaskList
|
||||
.Where(x => x.Group == codGroup)
|
||||
.OrderBy(x => x.Ordinal)
|
||||
.ThenBy(x => x.TaskId)
|
||||
.ToList();
|
||||
int newIdx = 0;
|
||||
int numRec = currList.Count;
|
||||
// li verifico in base al loro id attuale...
|
||||
foreach (var item in currList)
|
||||
{
|
||||
newIdx++;
|
||||
// se va cambiato lo riassegno
|
||||
if (item.Ordinal != newIdx)
|
||||
{
|
||||
item.Ordinal = newIdx;
|
||||
dbCtx.Entry(item).State = EntityState.Modified;
|
||||
}
|
||||
}
|
||||
// salvo!
|
||||
try
|
||||
{
|
||||
dbCtx.SaveChanges();
|
||||
done = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in TaskListReorder{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Upsert record TaskList
|
||||
/// </summary>
|
||||
@@ -407,6 +451,7 @@ namespace MP.TaskMan.Controllers
|
||||
if (currData != null)
|
||||
{
|
||||
currData.Ordinal = rec2upd.Ordinal;
|
||||
currData.Group = rec2upd.Group;
|
||||
currData.Enabled = rec2upd.Enabled;
|
||||
currData.Name = rec2upd.Name;
|
||||
currData.Descript = rec2upd.Descript;
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace MP.TaskMan.Models
|
||||
/// <summary>
|
||||
/// Tipo Task
|
||||
/// </summary>
|
||||
public Task2ExeType TType { get; set; } = Task2ExeType.ND;
|
||||
public Task2ExeType TType { get; set; } = Task2ExeType.ALL;
|
||||
|
||||
/// <summary>
|
||||
/// Comando da invocare
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace MP.TaskMan.Objects
|
||||
/// <summary>
|
||||
/// Tipo indefinito / ALL
|
||||
/// </summary>
|
||||
ND,
|
||||
ALL,
|
||||
|
||||
/// <summary>
|
||||
/// Chiamata exe esterno
|
||||
|
||||
@@ -126,6 +126,7 @@ namespace MP.TaskMan.Services
|
||||
case Task2ExeType.SqlStored:
|
||||
answ = MLController.ExecuteSqlTask(TaskRec.TaskId, SchedNext);
|
||||
break;
|
||||
|
||||
case Task2ExeType.RestCallGet:
|
||||
DateTime dtStart = DateTime.Now;
|
||||
// in primis testo la chiamata al servizio Health
|
||||
@@ -149,11 +150,12 @@ namespace MP.TaskMan.Services
|
||||
answ = MLController.TaskExecSaveExecuted(TaskRec.TaskId, SchedNext, tExeMod);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// svuoto cache!
|
||||
await FlushCache();
|
||||
await FlushCacheAsync();
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
@@ -162,10 +164,10 @@ namespace MP.TaskMan.Services
|
||||
/// Pulizia cache Redis (tutta)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> FlushCache()
|
||||
public bool FlushCache()
|
||||
{
|
||||
RedisValue pattern = new RedisValue($"{RedisBaseKey}:*");
|
||||
bool answ = await ExecFlushRedisPattern(pattern);
|
||||
bool answ = ExecFlushRedisPattern(pattern);
|
||||
return answ;
|
||||
}
|
||||
|
||||
@@ -173,10 +175,32 @@ namespace MP.TaskMan.Services
|
||||
/// Pulizia cache Redis per chiave specifica (da RedisBaseKey...)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> FlushCache(string KeyReq)
|
||||
public bool FlushCache(string KeyReq)
|
||||
{
|
||||
RedisValue pattern = new RedisValue($"{RedisBaseKey}:{KeyReq}:*");
|
||||
bool answ = await ExecFlushRedisPattern(pattern);
|
||||
bool answ = ExecFlushRedisPattern(pattern);
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pulizia cache Redis (tutta) modalità Async
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> FlushCacheAsync()
|
||||
{
|
||||
RedisValue pattern = new RedisValue($"{RedisBaseKey}:*");
|
||||
bool answ = await ExecFlushRedisPatternAsync(pattern);
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pulizia cache Redis per chiave specifica (da RedisBaseKey...) modalità Async
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> FlushCacheAsync(string KeyReq)
|
||||
{
|
||||
RedisValue pattern = new RedisValue($"{RedisBaseKey}:{KeyReq}:*");
|
||||
bool answ = await ExecFlushRedisPatternAsync(pattern);
|
||||
return answ;
|
||||
}
|
||||
|
||||
@@ -292,7 +316,20 @@ namespace MP.TaskMan.Services
|
||||
bool dbResult = MLController.TaskListMove(rec2upd, moveUp);
|
||||
await Task.Delay(50);
|
||||
// svuoto cache!
|
||||
await FlushCache();
|
||||
await FlushCacheAsync();
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Riordino record di un dato gruppo (da richiamare post cambio gruppo...)
|
||||
/// </summary>
|
||||
/// <param name="codGroup"></param>
|
||||
/// <returns></returns>
|
||||
public bool TaskListReorder(int codGroup)
|
||||
{
|
||||
bool dbResult = MLController.TaskListReorder(codGroup);
|
||||
// svuoto cache!
|
||||
FlushCache();
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
@@ -306,7 +343,7 @@ namespace MP.TaskMan.Services
|
||||
bool dbResult = MLController.TaskListUpsert(rec2upd);
|
||||
await Task.Delay(50);
|
||||
// svuoto cache!
|
||||
await FlushCache();
|
||||
await FlushCacheAsync();
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
@@ -336,18 +373,17 @@ namespace MP.TaskMan.Services
|
||||
|
||||
private Dictionary<string, string> connStrParams = new Dictionary<string, string>();
|
||||
|
||||
private string DataBase { get; set; } = "";
|
||||
|
||||
private string DataSource { get; set; } = "";
|
||||
|
||||
private string RedisBaseKey { get; set; } = "MP:TASK";
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private string DataBase { get; set; } = "";
|
||||
|
||||
private string DataSource { get; set; } = "";
|
||||
|
||||
private MpTaskController MLController { get; set; } = null!;
|
||||
private RestCallService RCallService { get; set; } = null!;
|
||||
private string RedisBaseKey { get; set; } = "MP:TASK";
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
@@ -358,7 +394,35 @@ namespace MP.TaskMan.Services
|
||||
/// </summary>
|
||||
/// <param name="pattern"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<bool> ExecFlushRedisPattern(RedisValue pattern)
|
||||
private bool ExecFlushRedisPattern(RedisValue pattern)
|
||||
{
|
||||
bool answ = false;
|
||||
var listEndpoints = redisConn.GetEndPoints();
|
||||
foreach (var endPoint in listEndpoints)
|
||||
{
|
||||
//var server = redisConnAdmin.GetServer(listEndpoints[0]);
|
||||
var server = redisConn.GetServer(endPoint);
|
||||
if (server != null)
|
||||
{
|
||||
var keyList = server.Keys(redisDb.Database, pattern);
|
||||
foreach (var item in keyList)
|
||||
{
|
||||
redisDb.KeyDelete(item);
|
||||
}
|
||||
answ = true;
|
||||
}
|
||||
}
|
||||
// notifico update ai client in ascolto x reset cache
|
||||
NotifyReloadRequest($"FlushRedisCache | {pattern}");
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue flush memoria redis dato pattern modalità Async
|
||||
/// </summary>
|
||||
/// <param name="pattern"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<bool> ExecFlushRedisPatternAsync(RedisValue pattern)
|
||||
{
|
||||
bool answ = false;
|
||||
var listEndpoints = redisConn.GetEndPoints();
|
||||
|
||||
+97
-91
@@ -1,94 +1,100 @@
|
||||
@if (CurrRecord != null)
|
||||
@if (isProcessing)
|
||||
{
|
||||
<hr />
|
||||
<div class="row g-1">
|
||||
<div class="col-md-1">
|
||||
<div class="form-floating">
|
||||
<input type="number" class="form-control" @bind="@CurrRecord.Ordinal">
|
||||
<label class="small">Ordine Esec.</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<div class="form-floating">
|
||||
<div class="form-control">
|
||||
<div class="form-check form-switch small">
|
||||
<input class="form-check-input" type="checkbox" role="switch" title="Abilitato / Disabilitato" @bind-value="@CurrRecord.Enabled" checked="@CurrRecord.Enabled">
|
||||
</div>
|
||||
</div>
|
||||
<label class="small">Enabled</label>
|
||||
</div>
|
||||
</div>
|
||||
<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-4">
|
||||
<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">
|
||||
<input type="datetime-local" class="form-control" @bind="@CurrRecord.DtNextExec">
|
||||
<label class="small">Prossima Esecuzione</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<div class="form-floating">
|
||||
<select class="form-select" @bind="@CurrRecord.Freq">
|
||||
@foreach (var option in Enum.GetValues(typeof(MP.TaskMan.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-2">
|
||||
<div class="form-floating">
|
||||
<select class="form-select" @bind="@CurrRecord.TType">
|
||||
@foreach (var option in Enum.GetValues(typeof(MP.TaskMan.Objects.Enums.Task2ExeType)))
|
||||
{
|
||||
<option value="@option">
|
||||
@option
|
||||
</option>
|
||||
}
|
||||
</select>
|
||||
<label class="small">Tipo Task</label>
|
||||
</div>
|
||||
</div>
|
||||
<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-4">
|
||||
<div class="form-floating">
|
||||
<input type="text" class="form-control" @bind="@CurrRecord.Args">
|
||||
<label class="small">Parametri</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-1 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 class="col-md-1 pt-2">
|
||||
<button class="btn btn-lg w-100 btn-warning" @onclick="()=>doCancel()" title="Cancel"><i class="fas fa-ban"></i> Cancel</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<LoadingData DisplaySize="LoadingData.CtrlSize.Large" DisplayMode="LoadingData.SpinMode.Growl" Title="Processing"></LoadingData>
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CurrRecord != null)
|
||||
{
|
||||
<hr />
|
||||
<div class="row g-1">
|
||||
<div class="col-md-1">
|
||||
<div class="form-floating">
|
||||
<input type="number" class="form-control bg-info bg-opacity-25" @bind="@CurrRecord.Group" min="1" max="99">
|
||||
<label class="small bg-opacity-50">Gruppo</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<div class="form-floating">
|
||||
<div class="form-control">
|
||||
<div class="form-check form-switch small">
|
||||
<input class="form-check-input" type="checkbox" role="switch" title="Abilitato / Disabilitato" @bind-value="@CurrRecord.Enabled" checked="@CurrRecord.Enabled">
|
||||
</div>
|
||||
</div>
|
||||
<label class="small">Enabled</label>
|
||||
</div>
|
||||
</div>
|
||||
<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-4">
|
||||
<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">
|
||||
<input type="datetime-local" class="form-control" @bind="@CurrRecord.DtNextExec">
|
||||
<label class="small">Prossima Esecuzione</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<div class="form-floating">
|
||||
<select class="form-select" @bind="@CurrRecord.Freq">
|
||||
@foreach (var option in Enum.GetValues(typeof(MP.TaskMan.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-2">
|
||||
<div class="form-floating">
|
||||
<select class="form-select" @bind="@CurrRecord.TType">
|
||||
@foreach (var option in Enum.GetValues(typeof(MP.TaskMan.Objects.Enums.Task2ExeType)))
|
||||
{
|
||||
<option value="@option">
|
||||
@option
|
||||
</option>
|
||||
}
|
||||
</select>
|
||||
<label class="small">Tipo Task</label>
|
||||
</div>
|
||||
</div>
|
||||
<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-4">
|
||||
<div class="form-floating">
|
||||
<input type="text" class="form-control" @bind="@CurrRecord.Args">
|
||||
<label class="small">Parametri</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-1 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 class="col-md-1 pt-2">
|
||||
<button class="btn btn-lg w-100 btn-warning" @onclick="() => doCancel()" title="Cancel"><i class="fas fa-ban"></i> Cancel</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,13 @@ namespace MP.TaskMan
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
protected int oldGroup = 0;
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
oldGroup = CurrRecord != null ? CurrRecord.Group : 0;
|
||||
}
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
@@ -32,15 +39,26 @@ namespace MP.TaskMan
|
||||
|
||||
protected async Task doSave()
|
||||
{
|
||||
isProcessing = true;
|
||||
bool fatto = false;
|
||||
await Task.Delay(1);
|
||||
if (CurrRecord != null)
|
||||
{
|
||||
fatto = await TService.TaskListUpsert(CurrRecord);
|
||||
// se cambiato gruppo chiamo reorg gruppo old/new...
|
||||
if (CurrRecord.Group != oldGroup)
|
||||
{
|
||||
TService.TaskListReorder(oldGroup);
|
||||
TService.TaskListReorder(CurrRecord.Group);
|
||||
oldGroup = CurrRecord.Group;
|
||||
}
|
||||
}
|
||||
isProcessing = false;
|
||||
await EC_update.InvokeAsync(fatto);
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
private bool isProcessing= false;
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
</div>
|
||||
<div class="px-2">
|
||||
<div class="input-group">
|
||||
@if (TypeSel != MP.TaskMan.Objects.Enums.Task2ExeType.ND)
|
||||
@if (TypeSel != MP.TaskMan.Objects.Enums.Task2ExeType.ALL)
|
||||
{
|
||||
@if (currRecord == null)
|
||||
{
|
||||
@@ -21,7 +21,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<button class="btn btn-outline-secondary">Sel →</button>
|
||||
<button class="btn btn-outline-secondary">Tipo Task →</button>
|
||||
}
|
||||
<select class="form-select" @bind="@TypeSel">
|
||||
@foreach (var option in Enum.GetValues(typeof(MP.TaskMan.Objects.Enums.Task2ExeType)))
|
||||
@@ -46,12 +46,19 @@
|
||||
{
|
||||
<LoadingData></LoadingData>
|
||||
}
|
||||
else if (SearchRecords.Count==0)
|
||||
{
|
||||
<div class="alert alert-info fs-5">Nessun record trovato dati i criteri espressi</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<TaskListTable AllRecords="SearchRecords" EC_DoReset="DoReset" EC_ForceAll="ForceAll" EC_Cancel="DoCancel" EC_Clone="DoClone" EC_Select="DoSelect" EC_Edit="DoEdit" EC_Run="DoRun"></TaskListTable>
|
||||
|
||||
@foreach (var item in ListRecords)
|
||||
{
|
||||
<TaskListTable CodGroup="item.Key" AllRecords="item.Value" EC_DoReset="DoReset" EC_ForceAll="ForceAll" EC_Cancel="DoCancel" EC_Clone="DoClone" EC_Select="DoSelect" EC_Edit="DoEdit" EC_Run="DoRun" EC_Move="DoMove"></TaskListTable>
|
||||
}
|
||||
@* <TaskListTable AllRecords="SearchRecords" EC_DoReset="DoReset" EC_ForceAll="ForceAll" EC_Cancel="DoCancel" EC_Clone="DoClone" EC_Select="DoSelect" EC_Edit="DoEdit" EC_Run="DoRun" EC_Move="DoMove"></TaskListTable> *@
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
+11
-175
@@ -8,47 +8,6 @@ namespace MP.TaskMan
|
||||
{
|
||||
public partial class TaskList : ComponentBase
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
#if false
|
||||
protected string checkSelect(TaskListModel selRec)
|
||||
{
|
||||
string answ = "";
|
||||
if (currRecord != null)
|
||||
{
|
||||
answ = (currRecord.Equals(selRec)) ? "table-info" : "";
|
||||
}
|
||||
else if (detRecord != null)
|
||||
{
|
||||
answ = detRecord.Equals(selRec) ? "table-info" : "";
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if false
|
||||
protected string checkDis(TaskListModel selRec)
|
||||
{
|
||||
string answ = "";
|
||||
// verifico se sia disabilitato...
|
||||
if (!selRec.Enabled)
|
||||
{
|
||||
answ += " text-secondary text-opacity-75 textStriked";
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
#if false
|
||||
protected string fileName = "TaskList.csv";
|
||||
#endif
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
@@ -111,22 +70,6 @@ namespace MP.TaskMan
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
#if false
|
||||
protected string alCss(TaskListModel TaskRec)
|
||||
{
|
||||
return TaskRec.LastIsError ? "alert-danger" : "alert-success";
|
||||
}
|
||||
#endif
|
||||
|
||||
#if false
|
||||
protected string btnCss(TaskListModel TaskRec)
|
||||
{
|
||||
string answ = DetailTaskId != null && DetailTaskId.TaskId == TaskRec.TaskId ? "btn-" : "btn-outline-";
|
||||
answ += TaskRec.LastIsError ? "danger" : "success";
|
||||
return answ;
|
||||
}
|
||||
#endif
|
||||
|
||||
protected async Task DoCancel()
|
||||
{
|
||||
currRecord = null;
|
||||
@@ -163,9 +106,9 @@ namespace MP.TaskMan
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task DoMove(TaskListModel currRec, bool goUp)
|
||||
protected async Task DoMove(TaskListTable.ActionParam action)
|
||||
{
|
||||
await TService.TaskListMove(currRec, goUp);
|
||||
await TService.TaskListMove(action.CurrRec, action.GoUp);
|
||||
detRecord = null;
|
||||
currRecord = null;
|
||||
await ReloadData();
|
||||
@@ -175,7 +118,7 @@ namespace MP.TaskMan
|
||||
{
|
||||
detRecord = null;
|
||||
currRecord = null;
|
||||
await TService.FlushCache();
|
||||
await TService.FlushCacheAsync();
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
@@ -211,9 +154,6 @@ namespace MP.TaskMan
|
||||
{
|
||||
detRecord = null;
|
||||
currRecord = null;
|
||||
#if false
|
||||
DetailTaskId = null;
|
||||
#endif
|
||||
isLoading = true;
|
||||
detRecord = selRec;
|
||||
await ReloadData();
|
||||
@@ -237,44 +177,17 @@ namespace MP.TaskMan
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
#if false
|
||||
protected async Task ForceReload(int newNum)
|
||||
{
|
||||
numRecord = newNum;
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task ForceReloadPage(int newNum)
|
||||
{
|
||||
currPage = newNum;
|
||||
await ReloadData();
|
||||
}
|
||||
#endif
|
||||
|
||||
protected async Task ForceUpdate(bool doForce)
|
||||
{
|
||||
currRecord = null;
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
#if false
|
||||
protected string iconCss(TaskListModel TaskRec)
|
||||
{
|
||||
return TaskRec.LastIsError ? "fa-thumbs-down" : "fa-thumbs-up";
|
||||
}
|
||||
#endif
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
isLoading = true;
|
||||
MaxVal = 2;
|
||||
#if false
|
||||
CleanupDir();
|
||||
#endif
|
||||
await advStep(1);
|
||||
#if false
|
||||
numRecord = 10;
|
||||
#endif
|
||||
await ReloadData();
|
||||
await advStep(2);
|
||||
isLoading = false;
|
||||
@@ -282,9 +195,6 @@ namespace MP.TaskMan
|
||||
|
||||
protected void ResetData()
|
||||
{
|
||||
#if false
|
||||
CleanupDir();
|
||||
#endif
|
||||
TService.rollBackEdit(currRecord);
|
||||
currRecord = null;
|
||||
}
|
||||
@@ -299,41 +209,12 @@ namespace MP.TaskMan
|
||||
return answ;
|
||||
}
|
||||
|
||||
#if false
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if false
|
||||
protected void ToggleDetail(TaskListModel TaskRec)
|
||||
{
|
||||
if (DetailTaskId == null)
|
||||
{
|
||||
DetailTaskId = TaskRec;
|
||||
}
|
||||
else
|
||||
{
|
||||
DetailTaskId = (DetailTaskId.TaskId == TaskRec.TaskId) ? null : TaskRec;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private double currVal = 0;
|
||||
#if false
|
||||
private TaskListModel? DetailTaskId = null;
|
||||
#endif
|
||||
private List<TaskListModel> ListRecords = new List<TaskListModel>();
|
||||
private Dictionary<int, List<TaskListModel>> ListRecords = new Dictionary<int, List<TaskListModel>>();
|
||||
private int MaxVal = 10;
|
||||
private double nextVal = 0;
|
||||
private List<TaskListModel> SearchRecords = new List<TaskListModel>();
|
||||
@@ -346,68 +227,23 @@ namespace MP.TaskMan
|
||||
private TaskListModel? detRecord { get; set; } = null;
|
||||
private int expTimeMsec { get; set; } = 30000;
|
||||
|
||||
#if false
|
||||
private string fullPath
|
||||
{
|
||||
get => $"{Directory.GetCurrentDirectory()}\\temp\\{fileName}";
|
||||
}
|
||||
#endif
|
||||
|
||||
private bool isLoading { get; set; } = false;
|
||||
#if false
|
||||
private int currPage { get; set; } = 1;
|
||||
private int numRecord { get; set; } = 10;
|
||||
#endif
|
||||
private string SearchVal { get; set; } = "";
|
||||
private Task2ExeType typeSel { get; set; } = Task2ExeType.ND;
|
||||
private Task2ExeType typeSel { get; set; } = Task2ExeType.ALL;
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
#if false
|
||||
private string btnRunCss(DateTime dtNextExe)
|
||||
{
|
||||
DateTime adesso = DateTime.Now;
|
||||
string answ = dtNextExe < adesso ? "btn-success" : "btn-warning";
|
||||
return answ;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if false
|
||||
private async void CleanupDir()
|
||||
{
|
||||
var parentDir = Directory.GetParent(fullPath).FullName;
|
||||
if (!Directory.Exists(parentDir))
|
||||
{
|
||||
Directory.CreateDirectory(parentDir);
|
||||
}
|
||||
await Task.Run(() => File.Delete(fullPath));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if false
|
||||
private async Task ExportCsv()
|
||||
{
|
||||
isLoading = true;
|
||||
// salvo davvero!
|
||||
await Egw.Core.Utils.SaveToCsv(SearchRecords, fullPath, ';');
|
||||
isLoading = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
private async Task ReloadData()
|
||||
{
|
||||
SearchRecords = await TService.TaskListAll(TypeSel, SearchVal);
|
||||
// suddivido per gruppo e genero relativo display
|
||||
#if false
|
||||
totalCount = SearchRecords.Count;
|
||||
var firstRec = SearchRecords.OrderBy(x => x.Ordinal).FirstOrDefault();
|
||||
minOrdinal = firstRec != null ? firstRec.Ordinal : 0;
|
||||
var lastRec = SearchRecords.OrderByDescending(x => x.Ordinal).FirstOrDefault();
|
||||
maxOrdinal = lastRec != null ? lastRec.Ordinal : 9999;
|
||||
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
||||
#endif
|
||||
// suddivido per gruppo e genero relativo display raggruppato
|
||||
ListRecords = SearchRecords
|
||||
.OrderBy(x => x.Group)
|
||||
.ThenBy(x => x.Ordinal)
|
||||
.GroupBy(x => x.Group)
|
||||
.ToDictionary(g => g.Key, g => g.ToList());
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
+135
-130
@@ -1,133 +1,138 @@
|
||||
<table class="table table-sm table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<button class="btn btn-sm btn-info" @onclick="DoReset" title="Reset"><i class="fas fa-sync"></i></button>
|
||||
</th>
|
||||
<th>Ord</th>
|
||||
<th>Task</th>
|
||||
<th>Tipo</th>
|
||||
@if (detRecord == null)
|
||||
{
|
||||
<th>Command</th>
|
||||
}
|
||||
<th>Sched.</th>
|
||||
@if (detRecord == null)
|
||||
{
|
||||
<th class="text-end">Last</th>
|
||||
<th class="text-end">Next</th>
|
||||
<th class="text-end">Result</th>
|
||||
<th>
|
||||
<button class="btn btn-sm btn-danger me-1" @onclick="ForceAll" title="Force All"><i class="fas fa-play"></i></button>
|
||||
</th>
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var record in ListRecords)
|
||||
{
|
||||
<tr class="@checkSelect(@record)">
|
||||
<td class="text-nowrap">
|
||||
<button class="btn btn-sm btn-info" @onclick="() => DoSelect(record)" title="Select"><i class="fas fa-search"></i></button>
|
||||
@if (detRecord == null)
|
||||
{
|
||||
@if (currRecord == null)
|
||||
{
|
||||
<button class="btn btn-sm btn-primary ms-1" @onclick="() => DoEdit(record)" title="Edit"><i class="fas fa-pencil-alt"></i></button>
|
||||
<button class="btn btn-sm btn-success" @onclick="() => DoClone(record)" title="Clona"><i class="fas fa-magic"></i></button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button class="btn btn-sm btn-secondary ms-1" @onclick="() => DoCancel()" title="Cancel"><i class="fas fa-undo"></i></button>
|
||||
}
|
||||
}
|
||||
</td>
|
||||
<td class="text-nowrap">
|
||||
@if (detRecord == null)
|
||||
{
|
||||
@if (record.Ordinal == minOrdinal)
|
||||
{
|
||||
<button class="btn btn-sm btn-outline-secondary mx-1" disabled title="Cannot Move"><i class="fas fa-caret-up"></i></button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button class="btn btn-sm btn-outline-primary mx-1" @onclick="() => DoMove(record, true)" title="Move Up"><i class="fas fa-caret-up"></i></button>
|
||||
}
|
||||
}
|
||||
<b>@record.Ordinal</b>
|
||||
@if (detRecord == null)
|
||||
{
|
||||
@if (record.Ordinal == maxOrdinal)
|
||||
{
|
||||
<button class="btn btn-sm btn-outline-secondary mx-1" disabled title="Cannot Move"><i class="fas fa-caret-down"></i></button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button class="btn btn-sm btn-outline-primary mx-1" @onclick="() => DoMove(record, false)" title="Move Down"><i class="fas fa-caret-down"></i></button>
|
||||
}
|
||||
}
|
||||
</td>
|
||||
<td class="text-nowrap @checkDis(@record)">
|
||||
<div>@record.Name</div>
|
||||
<div class="small text-truncate">@record.Descript</div>
|
||||
</td>
|
||||
<td class="@checkDis(@record)">
|
||||
@record.TType
|
||||
</td>
|
||||
@if (detRecord == null)
|
||||
{
|
||||
<td class="small text-truncate text-break @checkDis(@record)">
|
||||
<div class="font-monospace fw-bold" title="@record.Command">@TextReduce(record.Command, 32)</div>
|
||||
<div class="small text-break" title="@record.Args">@TextReduce(record.Args, 40)</div>
|
||||
</td>
|
||||
}
|
||||
<td>@record.Freq × @record.Cad</td>
|
||||
@if (detRecord == null)
|
||||
{
|
||||
<td class="text-end text-nowrap @checkDis(@record)">
|
||||
<div>@($"{record.DtLastExec:yyyy-MM-dd}")</div>
|
||||
<div class="small">@($"{record.DtLastExec:ddd HH:mm:ss}")</div>
|
||||
</td>
|
||||
<td class="text-end text-nowrap @checkDis(@record)">
|
||||
<div>@($"{record.DtNextExec:yyyy-MM-dd}")</div>
|
||||
<div class="small">@($"{record.DtNextExec:ddd HH:mm:ss}")</div>
|
||||
</td>
|
||||
<td class="text-end @checkDis(@record)">
|
||||
<b>@($"{record.LastDuration:N3}")</b> <sub>sec</sub> <button class="btn btn-sm @btnCss(record)" @onclick="() => ToggleDetail(record)" title="Ultima esecuzione"><i class="far @iconCss(record)"></i></button>
|
||||
</td>
|
||||
<td>
|
||||
@if (record.Enabled)
|
||||
{
|
||||
<button class="btn btn-sm @btnRunCss(record.DtNextExec) me-1" @onclick="() => DoRun(record)" title="Run Now"><i class="fas fa-play"></i></button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button class="btn btn-sm btn-secondary me-1" title="Disabled / Cannot run!" disabled><i class="fas fa-play"></i></button>
|
||||
}
|
||||
</td>
|
||||
}
|
||||
</tr>
|
||||
@if (DetailTaskId != null && DetailTaskId.TaskId == record.TaskId)
|
||||
{
|
||||
<div class="card shadow my-2">
|
||||
<div class="card-header bg-primary bg-opacity-50 bg-gradient fs-5">
|
||||
Gruppo Task: @CodGroup
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-sm table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<td colspan="10 @checkDis(@record)">
|
||||
<div class="d-flex justify-content-end">
|
||||
<div class="p-1 small alert @alCss(record)">
|
||||
<div class="text-trim">@record.LastResult</div>
|
||||
</div>
|
||||
</div>
|
||||
<th>
|
||||
<button class="btn btn-sm btn-info" @onclick="DoReset" title="Reset"><i class="fas fa-sync"></i></button>
|
||||
</th>
|
||||
<th>Ord</th>
|
||||
<th>Task</th>
|
||||
<th>Tipo</th>
|
||||
@if (detRecord == null)
|
||||
{
|
||||
<th>Command</th>
|
||||
}
|
||||
<th>Sched.</th>
|
||||
@if (detRecord == null)
|
||||
{
|
||||
<th class="text-end">Last</th>
|
||||
<th class="text-end">Next</th>
|
||||
<th class="text-end">Result</th>
|
||||
<th>
|
||||
<button class="btn btn-sm btn-danger me-1" @onclick="ForceAll" title="Force All"><i class="fas fa-play"></i></button>
|
||||
</th>
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var record in ListRecords)
|
||||
{
|
||||
<tr class="@checkSelect(@record)">
|
||||
<td class="text-nowrap">
|
||||
<button class="btn btn-sm btn-info" @onclick="() => DoSelect(record)" title="Select"><i class="fas fa-search"></i></button>
|
||||
@if (detRecord == null)
|
||||
{
|
||||
@if (currRecord == null)
|
||||
{
|
||||
<button class="btn btn-sm btn-primary ms-1" @onclick="() => DoEdit(record)" title="Edit"><i class="fas fa-pencil-alt"></i></button>
|
||||
<button class="btn btn-sm btn-success" @onclick="() => DoClone(record)" title="Clona"><i class="fas fa-magic"></i></button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button class="btn btn-sm btn-secondary ms-1" @onclick="() => DoCancel()" title="Cancel"><i class="fas fa-undo"></i></button>
|
||||
}
|
||||
}
|
||||
</td>
|
||||
<td class="text-nowrap">
|
||||
@if (detRecord == null)
|
||||
{
|
||||
@if (record.Ordinal == minOrdinal)
|
||||
{
|
||||
<button class="btn btn-sm btn-outline-secondary mx-1" disabled title="Cannot Move"><i class="fas fa-caret-up"></i></button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button class="btn btn-sm btn-outline-primary mx-1" @onclick="() => DoMove(record, true)" title="Move Up"><i class="fas fa-caret-up"></i></button>
|
||||
}
|
||||
}
|
||||
<b>@record.Ordinal</b>
|
||||
@if (detRecord == null)
|
||||
{
|
||||
@if (record.Ordinal == maxOrdinal)
|
||||
{
|
||||
<button class="btn btn-sm btn-outline-secondary mx-1" disabled title="Cannot Move"><i class="fas fa-caret-down"></i></button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button class="btn btn-sm btn-outline-primary mx-1" @onclick="() => DoMove(record, false)" title="Move Down"><i class="fas fa-caret-down"></i></button>
|
||||
}
|
||||
}
|
||||
</td>
|
||||
<td class="text-nowrap @checkDis(@record)">
|
||||
<div>@record.Name</div>
|
||||
<div class="small text-truncate">@record.Descript</div>
|
||||
</td>
|
||||
<td class="@checkDis(@record)">
|
||||
@record.TType
|
||||
</td>
|
||||
@if (detRecord == null)
|
||||
{
|
||||
<td class="small text-truncate text-break @checkDis(@record)">
|
||||
<div class="font-monospace fw-bold" title="@record.Command">@TextReduce(record.Command, 32)</div>
|
||||
<div class="small text-break" title="@record.Args">@TextReduce(record.Args, 40)</div>
|
||||
</td>
|
||||
}
|
||||
<td>@record.Freq × @record.Cad</td>
|
||||
@if (detRecord == null)
|
||||
{
|
||||
<td class="text-end text-nowrap @checkDis(@record)">
|
||||
<div>@($"{record.DtLastExec:yyyy-MM-dd}")</div>
|
||||
<div class="small">@($"{record.DtLastExec:ddd HH:mm:ss}")</div>
|
||||
</td>
|
||||
<td class="text-end text-nowrap @checkDis(@record)">
|
||||
<div>@($"{record.DtNextExec:yyyy-MM-dd}")</div>
|
||||
<div class="small">@($"{record.DtNextExec:ddd HH:mm:ss}")</div>
|
||||
</td>
|
||||
<td class="text-end @checkDis(@record)">
|
||||
<b>@($"{record.LastDuration:N3}")</b> <sub>sec</sub> <button class="btn btn-sm @btnCss(record)" @onclick="() => ToggleDetail(record)" title="Ultima esecuzione"><i class="far @iconCss(record)"></i></button>
|
||||
</td>
|
||||
<td>
|
||||
@if (record.Enabled)
|
||||
{
|
||||
<button class="btn btn-sm @btnRunCss(record.DtNextExec) me-1" @onclick="() => DoRun(record)" title="Run Now"><i class="fas fa-play"></i></button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button class="btn btn-sm btn-secondary me-1" title="Disabled / Cannot run!" disabled><i class="fas fa-play"></i></button>
|
||||
}
|
||||
</td>
|
||||
}
|
||||
</tr>
|
||||
@if (DetailTaskId != null && DetailTaskId.TaskId == record.TaskId)
|
||||
{
|
||||
<tr>
|
||||
<td colspan="10 @checkDis(@record)">
|
||||
<div class="d-flex justify-content-end">
|
||||
<div class="p-1 small alert @alCss(record)">
|
||||
<div class="text-trim">@record.LastResult</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="10">
|
||||
<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="SetNumRec" numPageChanged="SetPage" totalCount="totalCount" />
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="10">
|
||||
<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="SetNumRec" numPageChanged="SetPage" totalCount="totalCount" />
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@@ -9,6 +9,9 @@ namespace MP.TaskMan
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
[Parameter]
|
||||
public int CodGroup { get; set; } = 0;
|
||||
|
||||
[Parameter]
|
||||
public List<TaskListModel> AllRecords { get; set; } = new List<TaskListModel>();
|
||||
|
||||
@@ -44,7 +47,7 @@ namespace MP.TaskMan
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
public TaskListModel? CurrRec { get; set; } = null;
|
||||
public TaskListModel CurrRec { get; set; } = null!;
|
||||
public bool GoUp { get; set; } = true;
|
||||
|
||||
#endregion Public Properties
|
||||
@@ -52,41 +55,13 @@ namespace MP.TaskMan
|
||||
|
||||
#endregion Public Classes
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected bool isLoading = false;
|
||||
protected List<TaskListModel> ListRecords = new List<TaskListModel>();
|
||||
protected int maxOrdinal = 999;
|
||||
protected int minOrdinal = 0;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected TaskService TService { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
protected string checkSelect(TaskListModel selRec)
|
||||
{
|
||||
string answ = "";
|
||||
if (currRecord != null)
|
||||
{
|
||||
answ = (currRecord.Equals(selRec)) ? "table-info" : "";
|
||||
}
|
||||
else if (detRecord != null)
|
||||
{
|
||||
answ = detRecord.Equals(selRec) ? "table-info" : "";
|
||||
}
|
||||
#if false
|
||||
// verifico se sia disabilitato...
|
||||
if (!selRec.Enabled)
|
||||
{
|
||||
answ += " text-secondary text-opacity-50 textStriked";
|
||||
}
|
||||
#endif
|
||||
return answ;
|
||||
}
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected string alCss(TaskListModel TaskRec)
|
||||
@@ -112,6 +87,27 @@ namespace MP.TaskMan
|
||||
return answ;
|
||||
}
|
||||
|
||||
protected string checkSelect(TaskListModel selRec)
|
||||
{
|
||||
string answ = "";
|
||||
if (currRecord != null)
|
||||
{
|
||||
answ = (currRecord.Equals(selRec)) ? "table-info" : "";
|
||||
}
|
||||
else if (detRecord != null)
|
||||
{
|
||||
answ = detRecord.Equals(selRec) ? "table-info" : "";
|
||||
}
|
||||
#if false
|
||||
// verifico se sia disabilitato...
|
||||
if (!selRec.Enabled)
|
||||
{
|
||||
answ += " text-secondary text-opacity-50 textStriked";
|
||||
}
|
||||
#endif
|
||||
return answ;
|
||||
}
|
||||
|
||||
protected async Task DoCancel()
|
||||
{
|
||||
await EC_Cancel.InvokeAsync(true);
|
||||
@@ -139,6 +135,8 @@ namespace MP.TaskMan
|
||||
|
||||
protected async Task DoReset()
|
||||
{
|
||||
detRecord = null;
|
||||
DetailTaskId = null;
|
||||
await EC_DoReset.InvokeAsync(true);
|
||||
}
|
||||
|
||||
@@ -149,6 +147,7 @@ namespace MP.TaskMan
|
||||
|
||||
protected async Task DoSelect(TaskListModel currRec)
|
||||
{
|
||||
detRecord = currRec;
|
||||
DetailTaskId = null;
|
||||
await EC_Select.InvokeAsync(currRec);
|
||||
}
|
||||
@@ -190,7 +189,7 @@ namespace MP.TaskMan
|
||||
return answ;
|
||||
}
|
||||
|
||||
protected async Task ToggleDetail(TaskListModel TaskRec)
|
||||
protected void ToggleDetail(TaskListModel TaskRec)
|
||||
{
|
||||
if (DetailTaskId == null)
|
||||
{
|
||||
@@ -208,9 +207,12 @@ namespace MP.TaskMan
|
||||
|
||||
private int currPage = 1;
|
||||
private TaskListModel? DetailTaskId = null;
|
||||
private int numRecord = 10;
|
||||
|
||||
private int totalCount = 10;
|
||||
private bool isLoading = false;
|
||||
private List<TaskListModel> ListRecords = new List<TaskListModel>();
|
||||
private int maxOrdinal = 999;
|
||||
private int minOrdinal = 0;
|
||||
private int numRecord = 5;
|
||||
private int totalCount = 0;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
|
||||
Reference in New Issue
Block a user