Review AppUrl base x siti CORE
Divisione aree Redis tra app (x TaskMan in particolare) Test apertura app
This commit is contained in:
@@ -11,16 +11,20 @@ using static MP.TaskMan.Objects.Enums;
|
||||
|
||||
namespace MP.TaskMan.Controllers
|
||||
{
|
||||
public class MpTaskController: IDisposable
|
||||
public class MpTaskController : IDisposable
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public MpTaskController(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
Log.Info("Avviato MpTaskController");
|
||||
}
|
||||
private static IConfiguration _configuration;
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public DateTime CalcNextExe(TaskListModel taskRec)
|
||||
{
|
||||
DateTime dtNext = DateTime.Today;
|
||||
@@ -77,8 +81,9 @@ namespace MP.TaskMan.Controllers
|
||||
{
|
||||
_configuration = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Chiamata esecuzione di un singolo task programmato
|
||||
/// Chiamata esecuzione di un singolo task programmato, SE in stato abilitato
|
||||
/// </summary>
|
||||
/// <param name="TaskId"></param>
|
||||
/// <param name="SchedNext">Se true rischedula successiva chiamata</param>
|
||||
@@ -97,7 +102,7 @@ namespace MP.TaskMan.Controllers
|
||||
// recupero i dati da richiamare...
|
||||
var currRec = dbCtx
|
||||
.DbSetTaskList
|
||||
.Where(x => x.TaskId == TaskId)
|
||||
.Where(x => x.TaskId == TaskId && x.Enabled)
|
||||
.FirstOrDefault();
|
||||
if (currRec != null)
|
||||
{
|
||||
@@ -151,7 +156,6 @@ namespace MP.TaskMan.Controllers
|
||||
return callRes;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Annulla modifiche su una specifica entity (cancel update)
|
||||
/// </summary>
|
||||
@@ -164,7 +168,7 @@ namespace MP.TaskMan.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
if (dbCtx.Entry(item).State == Microsoft.EntityFrameworkCore.EntityState.Deleted || dbCtx.Entry(item).State == Microsoft.EntityFrameworkCore.EntityState.Modified)
|
||||
if (dbCtx.Entry(item).State == EntityState.Deleted || dbCtx.Entry(item).State == EntityState.Modified)
|
||||
{
|
||||
dbCtx.Entry(item).Reload();
|
||||
}
|
||||
@@ -198,6 +202,58 @@ namespace MP.TaskMan.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue registrazione di un Task generico (NON SQL)
|
||||
/// </summary>
|
||||
/// <param name="TaskId"></param>
|
||||
/// <param name="SchedNext">Se true rischedula successiva chiamata</param>
|
||||
/// <param name="ResRec">Record esecuzione task esterno</param>
|
||||
/// <returns></returns>
|
||||
public TaskResultModel TaskExecSaveExecuted(int TaskId, bool SchedNext, TaskExecModel ResRec)
|
||||
{
|
||||
TaskResultModel callRes = new TaskResultModel();
|
||||
using (var dbCtx = new TaskContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
// recupero i dati da richiamare...
|
||||
var currRec = dbCtx
|
||||
.DbSetTaskList
|
||||
.Where(x => x.TaskId == TaskId)
|
||||
.FirstOrDefault();
|
||||
if (currRec != null)
|
||||
{
|
||||
// registro task ricevuto
|
||||
dbCtx
|
||||
.DbSetTaskExe
|
||||
.Add(ResRec);
|
||||
|
||||
// aggiorno record chiamata...
|
||||
currRec.DtLastExec = ResRec.DtStart;
|
||||
currRec.LastResult = ResRec.Result;
|
||||
currRec.LastIsError = ResRec.IsError;
|
||||
currRec.LastDuration = ResRec.DtEnd.Subtract(ResRec.DtStart).TotalSeconds;
|
||||
// solo se richiesto rischedulazione ricalcola chiamata
|
||||
if (SchedNext)
|
||||
{
|
||||
// calcolo prossima esecuzione...
|
||||
currRec.DtNextExec = CalcNextExe(currRec);
|
||||
}
|
||||
// segno modificato
|
||||
dbCtx.Entry(currRec).State = EntityState.Modified;
|
||||
|
||||
// salvo modifiche!
|
||||
dbCtx.SaveChanges();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in TaskExecSaveExecuted{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return callRes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Upsert record TaskExec
|
||||
/// </summary>
|
||||
@@ -259,58 +315,6 @@ namespace MP.TaskMan.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Esegue registrazione di un Task generico (NON SQL)
|
||||
/// </summary>
|
||||
/// <param name="TaskId"></param>
|
||||
/// <param name="SchedNext">Se true rischedula successiva chiamata</param>
|
||||
/// <param name="ResRec">Record esecuzione task esterno</param>
|
||||
/// <returns></returns>
|
||||
public TaskResultModel TaskExecSaveExecuted(int TaskId, bool SchedNext, TaskExecModel ResRec)
|
||||
{
|
||||
TaskResultModel callRes = new TaskResultModel();
|
||||
using (var dbCtx = new TaskContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
// recupero i dati da richiamare...
|
||||
var currRec = dbCtx
|
||||
.DbSetTaskList
|
||||
.Where(x => x.TaskId == TaskId)
|
||||
.FirstOrDefault();
|
||||
if (currRec != null)
|
||||
{
|
||||
// registro task ricevuto
|
||||
dbCtx
|
||||
.DbSetTaskExe
|
||||
.Add(ResRec);
|
||||
|
||||
// aggiorno record chiamata...
|
||||
currRec.DtLastExec = ResRec.DtStart;
|
||||
currRec.LastResult = ResRec.Result;
|
||||
currRec.LastIsError = ResRec.IsError;
|
||||
currRec.LastDuration = ResRec.DtEnd.Subtract(ResRec.DtStart).TotalSeconds;
|
||||
// solo se richiesto rischedulazione ricalcola chiamata
|
||||
if (SchedNext)
|
||||
{
|
||||
// calcolo prossima esecuzione...
|
||||
currRec.DtNextExec = CalcNextExe(currRec);
|
||||
}
|
||||
// segno modificato
|
||||
dbCtx.Entry(currRec).State = EntityState.Modified;
|
||||
|
||||
// salvo modifiche!
|
||||
dbCtx.SaveChanges();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in TaskExecSaveExecuted{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return callRes;
|
||||
}
|
||||
/// <summary>
|
||||
/// Update ordinamento task
|
||||
/// </summary>
|
||||
@@ -388,6 +392,7 @@ namespace MP.TaskMan.Controllers
|
||||
if (currData != null)
|
||||
{
|
||||
currData.Ordinal = rec2upd.Ordinal;
|
||||
currData.Enabled = rec2upd.Enabled;
|
||||
currData.Name = rec2upd.Name;
|
||||
currData.Descript = rec2upd.Descript;
|
||||
currData.Command = rec2upd.Command;
|
||||
@@ -416,5 +421,19 @@ namespace MP.TaskMan.Controllers
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private static IConfiguration _configuration { get; set; } = null!;
|
||||
|
||||
#endregion Private Properties
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using MP.TaskMan;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MP.TaskMan.Migrations
|
||||
{
|
||||
[DbContext(typeof(TaskContext))]
|
||||
[Migration("20241028131648_AddTaskStatus")]
|
||||
partial class AddTaskStatus
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.UseCollation("SQL_Latin1_General_CP1_CI_AS")
|
||||
.HasAnnotation("ProductVersion", "6.0.33")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
|
||||
|
||||
modelBuilder.Entity("MP.TaskMan.Models.TaskExecModel", b =>
|
||||
{
|
||||
b.Property<int>("TaskExecId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("TaskExecId"), 1L, 1);
|
||||
|
||||
b.Property<DateTime>("DtEnd")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime>("DtStart")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<bool>("IsError")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("Result")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("TaskId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("TaskExecId");
|
||||
|
||||
b.HasIndex("TaskId");
|
||||
|
||||
b.ToTable("TaskExec");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MP.TaskMan.Models.TaskListModel", b =>
|
||||
{
|
||||
b.Property<int>("TaskId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("TaskId"), 1L, 1);
|
||||
|
||||
b.Property<string>("Args")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Cad")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Command")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Descript")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("DtLastExec")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime>("DtNextExec")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<bool>("Enabled")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<int>("Freq")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("LastDuration")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<bool>("LastIsError")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("LastResult")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Ordinal")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("TType")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("TaskId");
|
||||
|
||||
b.ToTable("TaskList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MP.TaskMan.Models.TaskExecModel", b =>
|
||||
{
|
||||
b.HasOne("MP.TaskMan.Models.TaskListModel", "TaskListNav")
|
||||
.WithMany()
|
||||
.HasForeignKey("TaskId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("TaskListNav");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MP.TaskMan.Migrations
|
||||
{
|
||||
public partial class AddTaskStatus : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "Enabled",
|
||||
table: "TaskList",
|
||||
type: "bit",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Enabled",
|
||||
table: "TaskList");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,6 +79,9 @@ namespace MP.TaskMan.Migrations
|
||||
b.Property<DateTime>("DtNextExec")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<bool>("Enabled")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<int>("Freq")
|
||||
.HasColumnType("int");
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Drawing.Printing;
|
||||
using static MP.TaskMan.Objects.Enums;
|
||||
|
||||
#nullable disable
|
||||
@@ -23,6 +24,11 @@ namespace MP.TaskMan.Models
|
||||
/// </summary>
|
||||
public int Ordinal { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Stato Task abilitato / disabilitato
|
||||
/// </summary>
|
||||
public bool Enabled { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Nome Task
|
||||
/// </summary>
|
||||
@@ -83,5 +89,26 @@ namespace MP.TaskMan.Models
|
||||
public string LastResult { get; set; } = "";
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Equals solo su chiave!
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is TaskListModel item))
|
||||
return false;
|
||||
|
||||
if (TaskId != item.TaskId)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,6 +61,7 @@ namespace MP.TaskMan.Services
|
||||
// sistemo
|
||||
DataSource = connStrParams["Server"];
|
||||
DataBase = connStrParams["Database"];
|
||||
RedisBaseKey= $"MP:TaskMan:{DataSource}:{DataBase}";
|
||||
}
|
||||
|
||||
// conf rest call service
|
||||
@@ -101,46 +102,50 @@ namespace MP.TaskMan.Services
|
||||
{
|
||||
Task = $"TaskId: {TaskRec.TaskId} | {TaskRec.TType}",
|
||||
ExecResult = -1,
|
||||
TextResult = "Task Not recognized"
|
||||
TextResult = TaskRec.Enabled ? "Task Not Recognized" : "Task Not Enabled for Execution"
|
||||
};
|
||||
// verifico tipo di task ed eseguo di conseguenza...
|
||||
switch (TaskRec.TType)
|
||||
// in primis verifica che SIA abilitato...
|
||||
if (TaskRec.Enabled)
|
||||
{
|
||||
//case Task2ExeType.ND:
|
||||
// break;
|
||||
//case Task2ExeType.Exe:
|
||||
// break;
|
||||
//case Task2ExeType.SqlCommand:
|
||||
// break;
|
||||
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
|
||||
string rAnsw = await RCallService.CheckServer();
|
||||
// se ok effettuo vera chiamata...
|
||||
if (rAnsw.ToUpper() == "OK")
|
||||
{
|
||||
var callResp = await RCallService.CallRestGet(TaskRec.Command, TaskRec.Args);
|
||||
DateTime dtEnd = DateTime.Now;
|
||||
TaskExecModel tExeMod = new TaskExecModel()
|
||||
// verifico tipo di task ed eseguo di conseguenza...
|
||||
switch (TaskRec.TType)
|
||||
{
|
||||
//case Task2ExeType.ND:
|
||||
// break;
|
||||
//case Task2ExeType.Exe:
|
||||
// break;
|
||||
//case Task2ExeType.SqlCommand:
|
||||
// break;
|
||||
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
|
||||
string rAnsw = await RCallService.CheckServer();
|
||||
// se ok effettuo vera chiamata...
|
||||
if (rAnsw.ToUpper() == "OK")
|
||||
{
|
||||
DtEnd = dtEnd,
|
||||
DtStart = dtStart,
|
||||
IsError = callResp.StatusCode != System.Net.HttpStatusCode.OK,
|
||||
TaskId = TaskRec.TaskId,
|
||||
Result = $"{callResp.Content}".Replace("\"", ""),
|
||||
};
|
||||
// salvo su DB
|
||||
answ = MLController.TaskExecSaveExecuted(TaskRec.TaskId, SchedNext, tExeMod);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
var callResp = await RCallService.CallRestGet(TaskRec.Command, TaskRec.Args);
|
||||
DateTime dtEnd = DateTime.Now;
|
||||
TaskExecModel tExeMod = new TaskExecModel()
|
||||
{
|
||||
DtEnd = dtEnd,
|
||||
DtStart = dtStart,
|
||||
IsError = callResp.StatusCode != System.Net.HttpStatusCode.OK,
|
||||
TaskId = TaskRec.TaskId,
|
||||
Result = $"{callResp.Content}".Replace("\"", ""),
|
||||
};
|
||||
// salvo su DB
|
||||
answ = MLController.TaskExecSaveExecuted(TaskRec.TaskId, SchedNext, tExeMod);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// svuoto cache!
|
||||
await FlushCache();
|
||||
}
|
||||
// svuoto cache!
|
||||
await FlushCache("Task");
|
||||
return answ;
|
||||
}
|
||||
|
||||
@@ -150,18 +155,18 @@ namespace MP.TaskMan.Services
|
||||
/// <returns></returns>
|
||||
public async Task<bool> FlushCache()
|
||||
{
|
||||
RedisValue pattern = new RedisValue($"{redisBaseKey}:*");
|
||||
RedisValue pattern = new RedisValue($"{RedisBaseKey}:*");
|
||||
bool answ = await ExecFlushRedisPattern(pattern);
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pulizia cache Redis per chiave specifica (da redisBaseKey...)
|
||||
/// Pulizia cache Redis per chiave specifica (da RedisBaseKey...)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> FlushCache(string KeyReq)
|
||||
{
|
||||
RedisValue pattern = new RedisValue($"{redisBaseKey}:{KeyReq}:*");
|
||||
RedisValue pattern = new RedisValue($"{RedisBaseKey}:{KeyReq}:*");
|
||||
bool answ = await ExecFlushRedisPattern(pattern);
|
||||
return answ;
|
||||
}
|
||||
@@ -199,7 +204,7 @@ namespace MP.TaskMan.Services
|
||||
List<TaskExecModel> result = new List<TaskExecModel>();
|
||||
// cerco in redis...
|
||||
DateTime adesso = DateTime.Now;
|
||||
string currKey = $"{redisBaseKey}:Task:ExecList:{TaskId}:{adesso:yyMMdd}:{adesso:HHmm}:{maxRec}";
|
||||
string currKey = $"{RedisBaseKey}:Task:ExecList:{TaskId}:{adesso:yyMMdd}:{adesso:HHmm}:{maxRec}";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
@@ -237,7 +242,7 @@ namespace MP.TaskMan.Services
|
||||
List<TaskListModel> result = new List<TaskListModel>();
|
||||
// cerco in redis...
|
||||
DateTime adesso = DateTime.Now;
|
||||
string currKey = $"{redisBaseKey}:Task:List:{TType}";
|
||||
string currKey = $"{RedisBaseKey}:Task:List:{TType}";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
@@ -277,7 +282,7 @@ namespace MP.TaskMan.Services
|
||||
{
|
||||
bool dbResult = MLController.TaskListMove(rec2upd, moveUp);
|
||||
// svuoto cache!
|
||||
await FlushCache("Task");
|
||||
await FlushCache();
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
@@ -290,7 +295,7 @@ namespace MP.TaskMan.Services
|
||||
{
|
||||
bool dbResult = MLController.TaskListUpsert(rec2upd);
|
||||
// svuoto cache!
|
||||
await FlushCache("Task");
|
||||
await FlushCache();
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
@@ -320,11 +325,11 @@ namespace MP.TaskMan.Services
|
||||
|
||||
private Dictionary<string, string> connStrParams = new Dictionary<string, string>();
|
||||
|
||||
private string DataBase = "";
|
||||
private string DataBase { get; set; } = "";
|
||||
|
||||
private string DataSource = "";
|
||||
private string DataSource { get; set; } = "";
|
||||
|
||||
private string redisBaseKey = "MP:TASK";
|
||||
private string RedisBaseKey { get; set; } = "MP:TASK";
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
|
||||
@@ -95,11 +95,19 @@ namespace MP.TaskMan
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Stringa di connessione impiegata
|
||||
/// </summary>
|
||||
private string connString { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Ovewrride setup gestione stringa di connessione
|
||||
/// </summary>
|
||||
/// <param name="optionsBuilder"></param>
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (!optionsBuilder.IsConfigured)
|
||||
{
|
||||
string connString = "";
|
||||
if (DesignTime)
|
||||
{
|
||||
connString = "Server=SQL2016DEV; Database=MoonPro_PROG; Trusted_Connection=True;";
|
||||
|
||||
+55
-62
@@ -2,12 +2,61 @@
|
||||
{
|
||||
<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">
|
||||
@@ -21,81 +70,25 @@
|
||||
<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.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-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="col-md-4">
|
||||
<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.TaskMan.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">
|
||||
<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>
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
<tbody>
|
||||
@foreach (var record in ListRecords)
|
||||
{
|
||||
<tr class="@checkSelect(@record.TaskId)">
|
||||
<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)
|
||||
@@ -110,7 +110,7 @@
|
||||
<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>
|
||||
}
|
||||
}
|
||||
@record.Ordinal
|
||||
<b>@record.Ordinal</b>
|
||||
@if (detRecord == null)
|
||||
{
|
||||
@if (record.Ordinal == maxOrdinal)
|
||||
@@ -148,11 +148,18 @@
|
||||
<div>@($"{record.DtNextExec:yyyy-MM-dd}")</div>
|
||||
<div class="small">@($"{record.DtNextExec:ddd HH:mm:ss}")</div>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<td class="text-end">
|
||||
<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>
|
||||
|
||||
@@ -10,21 +10,21 @@ namespace MP.TaskMan
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
public string checkSelect(int TaskId)
|
||||
public string checkSelect(TaskListModel selRec)
|
||||
{
|
||||
string answ = "";
|
||||
if (currRecord != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
answ = (currRecord.TaskId == TaskId) ? "table-info" : "";
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
answ = (currRecord.Equals(selRec)) ? "table-info" : "";
|
||||
}
|
||||
else if (detRecord != null)
|
||||
{
|
||||
answ = (detRecord.TaskId == TaskId) ? "table-info" : "";
|
||||
answ = detRecord.Equals(selRec) ? "table-info" : "";
|
||||
}
|
||||
// verifico se sia disabilitato...
|
||||
if(!selRec.Enabled)
|
||||
{
|
||||
answ += " text-secondary textStriked";
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user