Merge branch 'Release/TaskExecMan02'

This commit is contained in:
Samuele Locatelli
2024-10-28 11:11:02 +01:00
100 changed files with 2383 additions and 2557 deletions
+32
View File
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Egw.Core
{
public class Utils
{
/// <summary>
/// Effettua salvataggio in file di un generico oggetto in formato CSV
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="reportData"></param>
/// <param name="path"></param>
/// <param name="separator">Separatore da impiegare</param>
/// <returns></returns>
public static async Task SaveToCsv<T>(List<T> reportData, string path, char separator)
{
var lines = new List<string>();
IEnumerable<PropertyDescriptor> props = TypeDescriptor.GetProperties(typeof(T)).OfType<PropertyDescriptor>();
var header = string.Join(";", props.ToList().Select(x => x.Name));
lines.Add(header);
var valueLines = reportData.Select(row => string.Join(separator, header.Split(separator).Select(a => row.GetType().GetProperty(a).GetValue(row, null))));
//var valueLines = reportData.Select(row => string.Join(";", header.Split(';').Select(a => row.GetType().GetProperty(a).GetValue(row, null))));
lines.AddRange(valueLines);
await Task.Run(() => File.WriteAllLines(path, lines.ToArray()));
}
}
}
+8
View File
@@ -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
+12
View File
@@ -7,6 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MP.Prog", "MP.Prog\MP.Prog.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MP.FileData", "MP.FileData\MP.FileData.csproj", "{48693321-1FA6-4DBB-A730-B8EF3E0B68D2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MP.TaskMan", "MP.TaskMan\MP.TaskMan.csproj", "{EF0CF5FC-2451-4184-AAA4-B17236DEE41B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Egw.Core", "Egw.Core\Egw.Core.csproj", "{3EE72B27-C44F-40F5-B4E8-E43ECA6F39B1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -21,6 +25,14 @@ Global
{48693321-1FA6-4DBB-A730-B8EF3E0B68D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48693321-1FA6-4DBB-A730-B8EF3E0B68D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48693321-1FA6-4DBB-A730-B8EF3E0B68D2}.Release|Any CPU.Build.0 = Release|Any CPU
{EF0CF5FC-2451-4184-AAA4-B17236DEE41B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EF0CF5FC-2451-4184-AAA4-B17236DEE41B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EF0CF5FC-2451-4184-AAA4-B17236DEE41B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EF0CF5FC-2451-4184-AAA4-B17236DEE41B}.Release|Any CPU.Build.0 = Release|Any CPU
{3EE72B27-C44F-40F5-B4E8-E43ECA6F39B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3EE72B27-C44F-40F5-B4E8-E43ECA6F39B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3EE72B27-C44F-40F5-B4E8-E43ECA6F39B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3EE72B27-C44F-40F5-B4E8-E43ECA6F39B1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
+12
View File
@@ -7,6 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MP.Stats", "MP.Stats\MP.Sta
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MP.Data", "MP.Data\MP.Data.csproj", "{10BA8450-301D-49C7-8E1E-21B7469C225C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MP.TaskMan", "MP.TaskMan\MP.TaskMan.csproj", "{D334DE4B-1F54-4F30-899B-9ECB79C9F527}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Egw.Core", "Egw.Core\Egw.Core.csproj", "{BC94E319-A622-497C-BEE1-BB3D77170A6D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -21,6 +25,14 @@ Global
{10BA8450-301D-49C7-8E1E-21B7469C225C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10BA8450-301D-49C7-8E1E-21B7469C225C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{10BA8450-301D-49C7-8E1E-21B7469C225C}.Release|Any CPU.Build.0 = Release|Any CPU
{D334DE4B-1F54-4F30-899B-9ECB79C9F527}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D334DE4B-1F54-4F30-899B-9ECB79C9F527}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D334DE4B-1F54-4F30-899B-9ECB79C9F527}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D334DE4B-1F54-4F30-899B-9ECB79C9F527}.Release|Any CPU.Build.0 = Release|Any CPU
{BC94E319-A622-497C-BEE1-BB3D77170A6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BC94E319-A622-497C-BEE1-BB3D77170A6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BC94E319-A622-497C-BEE1-BB3D77170A6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BC94E319-A622-497C-BEE1-BB3D77170A6D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
+1 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<Version>6.16.2410.1815</Version>
<Version>6.16.2410.2810</Version>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP_TAB3</RootNamespace>
</PropertyGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 6.16.2410.1815</h4>
<h4>Versione: 6.16.2410.2810</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
6.16.2410.1815
6.16.2410.2810
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2410.1815</version>
<version>6.16.2410.2810</version>
<url>https://nexus.steamware.net/repository/SWS/MP-TAB3/stable/LAST/MP-TAB3.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-TAB3/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+16 -25
View File
@@ -58,19 +58,6 @@
}
]
},
"OptConf": {
"msRefresh": "1100",
"CodModulo": "MP-TAB3",
"CodModuloParam": "MoonPro"
},
"ServerConf": {
"BaseAddr": "https://localhost:7295/MP/TAB3/",
"BasePathDisegni": "\\\\iis01\\W$\\Files\\Disegni",
"BaseUrlTab": "/MP/TAB3",
"ImgBasePath": "https://iis01.egalware.com/MP/macchine/small/",
"MpIoNS": "MoonPro:SQL2016DEV:MoonPro",
"maxChar4Scroll": 21
},
"AlarmDest": "samuele.locatelli@egalware.com, ceo@steamware.net",
"MailKitMailSettings": {
"DisplayName": "MAPO EgalWare Email BOT",
@@ -81,17 +68,21 @@
"UserName": "steamwarebot@outlook.it",
"UseSSL": false,
"UseStartTls": true
},
"OptConf": {
"msRefresh": "1001"
},
"ServerConf": {
"BaseAddr": "https://localhost:7295/MP/TAB3/",
"BasePathDisegni": "\\\\iis01\\W$\\Files\\Disegni",
"BaseUrlTab": "/MP/TAB3",
"ImgBasePath": "https://iis01.egalware.com/MP/macchine/small/",
"MpIoNS": "MoonPro:SQL2016DEV:MoonPro",
"maxChar4Scroll": 21
},
"SpecialConf": {
"CodApp": "MP-LAND",
"CodModulo": "MP-TAB3",
"CodModuloParam": "MoonPro"
}
//"ExternalProviders": {
// "MailKit": {
// "SMTP": {
// "Address": "smtp.gmail.com",
// "Port": "465",
// "Account": "steamwarebot@gmail.com",
// "Password": "drmfsls16",
// "SenderEmail": "steamwarebot@gmail.com",
// "SenderName": "Steamware Email BOT"
// }
// }
//}
}
+4 -4
View File
@@ -6,19 +6,19 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.33" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.33" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.33" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NLog" Version="5.3.3" />
<PackageReference Include="NLog" Version="5.3.4" />
<PackageReference Include="RestSharp" Version="112.0.0" />
<PackageReference Include="SharpZipLib" Version="1.4.2" />
</ItemGroup>
+3 -367
View File
@@ -13,6 +13,9 @@ using static MP.Data.Objects.Enums;
namespace MP.Data.Controllers
{
/// <summary>
/// Controller specifico x LAND FixMe ToDo !!! è ancora necessario con obj task estratti?!?!?
/// </summary>
public class MpLandController : IDisposable
{
#region Public Constructors
@@ -27,58 +30,6 @@ namespace MP.Data.Controllers
#region Public Methods
public DateTime CalcNextExe(TaskListModel taskRec)
{
DateTime dtNext = DateTime.Today;
try
{
// calcolo next exec da tipo...
switch (taskRec.Freq)
{
case TaskFreqType.ND:
dtNext = taskRec.DtLastExec.AddDays(taskRec.Cad);
break;
case TaskFreqType.Sec:
dtNext = taskRec.DtLastExec.AddSeconds(taskRec.Cad);
break;
case TaskFreqType.Min:
dtNext = taskRec.DtLastExec.AddMinutes(taskRec.Cad);
break;
case TaskFreqType.Hour:
dtNext = taskRec.DtLastExec.AddHours(taskRec.Cad);
break;
case TaskFreqType.Day:
dtNext = taskRec.DtLastExec.AddDays(taskRec.Cad);
break;
case TaskFreqType.Week:
dtNext = taskRec.DtLastExec.AddDays(7 * taskRec.Cad);
break;
case TaskFreqType.Month:
dtNext = taskRec.DtLastExec.AddMonths(taskRec.Cad);
break;
case TaskFreqType.Year:
dtNext = taskRec.DtLastExec.AddYears(taskRec.Cad);
break;
default:
dtNext = taskRec.DtLastExec.AddDays(taskRec.Cad);
break;
}
}
catch (Exception exc)
{
Log.Error($"Eccezione in CalcNextExe{Environment.NewLine}{exc}");
}
return dtNext;
}
/// <summary>
/// Elenco da tabella Config
/// </summary>
@@ -121,81 +72,6 @@ namespace MP.Data.Controllers
return dbResult;
}
/// <summary>
/// Chiamata esecuzione di un singolo task programmato
/// </summary>
/// <param name="TaskId"></param>
/// <param name="SchedNext">Se true rischedula successiva chiamata</param>
/// <returns></returns>
public TaskResultModel ExecuteSqlTask(int TaskId, bool SchedNext)
{
TaskResultModel callRes = new TaskResultModel();
using (var dbCtx = new MoonPro_STATSContext(_configuration))
{
// imposto timeout a 5 min
//var currTimeout = dbCtx.Database.GetCommandTimeout();
dbCtx.Database.SetCommandTimeout(TimeSpan.FromMinutes(5));
try
{
DateTime dtStart = DateTime.Now;
// recupero i dati da richiamare...
var currRec = dbCtx
.DbSetTaskList
.Where(x => x.TaskId == TaskId)
.FirstOrDefault();
if (currRec != null)
{
// recupero comando
string sqlCommand = currRec.Command;
string rawParams = currRec.Args;
callRes = dbCtx
.DbSetTaskResult
.FromSqlRaw($"EXEC {sqlCommand} {rawParams}")
.AsNoTracking()
.AsEnumerable()
.FirstOrDefault();
DateTime dtEnd = DateTime.Now;
// preparo record esecuzione...
TaskExecModel resRec = new TaskExecModel()
{
TaskId = TaskId,
DtStart = dtStart,
DtEnd = dtEnd,
IsError = callRes.ExecResult < 0,
Result = callRes.TextResult
};
dbCtx
.DbSetTaskExe
.Add(resRec);
// aggiorno record chiamata...
currRec.DtLastExec = dtStart;
currRec.LastResult = resRec.Result;
currRec.LastIsError = resRec.IsError;
currRec.LastDuration = dtEnd.Subtract(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 ExecuteSqlCommand{Environment.NewLine}{exc}");
}
}
return callRes;
}
/// <summary>
/// Annulla modifiche su una specifica entity (cancel update)
/// </summary>
@@ -221,246 +97,6 @@ namespace MP.Data.Controllers
return answ;
}
/// <summary>
/// Ricerca task dato tipo + num max (desc)
/// </summary>
/// <param name="TaskId">TaskId da cui deriva</param>
/// <returns></returns>
public List<TaskExecModel> TaskExecGetFilt(int TaskId, int maxRec)
{
List<TaskExecModel> dbResult = new List<TaskExecModel>();
using (var dbCtx = new MoonProContext(_configuration))
{
dbResult = dbCtx
.DbSetTaskExe
.Include(x => x.TaskListNav)
.Where(x => (x.TaskId == TaskId))
.OrderByDescending(x => x.DtStart)
.Take(maxRec)
.ToList();
}
return dbResult;
}
/// <summary>
/// Upsert record TaskExec
/// </summary>
/// <param name="rec2upd">Record da aggiornare/inserire</param>
/// <returns></returns>
public bool TaskExecUpsert(TaskExecModel rec2upd)
{
bool done = false;
using (var dbCtx = new MoonProContext(_configuration))
{
try
{
var currData = dbCtx
.DbSetTaskExe
.Where(x => x.TaskExecId == rec2upd.TaskExecId)
.FirstOrDefault();
if (currData != null)
{
currData.TaskId = rec2upd.TaskId;
currData.DtStart = rec2upd.DtStart;
currData.DtEnd = rec2upd.DtEnd;
currData.IsError = rec2upd.IsError;
currData.Result = rec2upd.Result;
dbCtx.Entry(currData).State = EntityState.Modified;
}
else
{
dbCtx
.DbSetTaskExe
.Add(rec2upd);
}
dbCtx.SaveChanges();
done = true;
}
catch (Exception exc)
{
Log.Error($"Eccezione in TaskExecUpsert{Environment.NewLine}{exc}");
}
}
return done;
}
/// <summary>
/// Ricerca task dato tipo e
/// </summary>
/// <param name="TType"></param>
/// <returns></returns>
public List<TaskListModel> TaskListGetAll(Task2ExeType TType)
{
List<TaskListModel> dbResult = new List<TaskListModel>();
using (var dbCtx = new MoonProContext(_configuration))
{
dbResult = dbCtx
.DbSetTaskList
.Where(x => (TType == Task2ExeType.ND || x.TType == TType))
.OrderBy(x => x.Ordinal)
.ToList();
}
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 MoonProContext(_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>
/// <param name="rec2upd">Record da spostare x priorità</param>
/// <returns></returns>
public bool TaskListMove(TaskListModel rec2upd, bool moveUp)
{
bool done = false;
using (var dbCtx = new MoonProContext(_configuration))
{
try
{
var currData = dbCtx
.DbSetTaskList
.Where(x => x.TaskId == rec2upd.TaskId)
.FirstOrDefault();
if (currData != null)
{
int actOrdinal = currData.Ordinal;
TaskListModel? otherRec = null;
// cerco, secondo richiesta, precedente o successivo
if (moveUp)
{
otherRec = dbCtx
.DbSetTaskList
.Where(x => x.Ordinal < currData.Ordinal)
.OrderByDescending(x => x.Ordinal)
.FirstOrDefault();
}
else
{
otherRec = dbCtx
.DbSetTaskList
.Where(x => x.Ordinal > currData.Ordinal)
.OrderBy(x => x.Ordinal)
.FirstOrDefault();
}
// inverto ordinale SE ho record
if (otherRec != null)
{
currData.Ordinal = otherRec.Ordinal;
otherRec.Ordinal = actOrdinal;
dbCtx.Entry(currData).State = EntityState.Modified;
dbCtx.Entry(otherRec).State = EntityState.Modified;
}
}
//salvo
dbCtx.SaveChanges();
done = true;
}
catch (Exception exc)
{
Log.Error($"Eccezione in TaskListUpsert{Environment.NewLine}{exc}");
}
}
return done;
}
/// <summary>
/// Upsert record TaskList
/// </summary>
/// <param name="rec2upd">Record da aggiornare/inserire</param>
/// <returns></returns>
public bool TaskListUpsert(TaskListModel rec2upd)
{
bool done = false;
using (var dbCtx = new MoonProContext(_configuration))
{
try
{
var currData = dbCtx
.DbSetTaskList
.Where(x => x.TaskId == rec2upd.TaskId && rec2upd.TaskId > 0)
.FirstOrDefault();
if (currData != null)
{
currData.Ordinal = rec2upd.Ordinal;
currData.Name = rec2upd.Name;
currData.Descript = rec2upd.Descript;
currData.Command = rec2upd.Command;
currData.Args = rec2upd.Args;
currData.Freq = rec2upd.Freq;
currData.Cad = rec2upd.Cad;
currData.DtLastExec = rec2upd.DtLastExec;
currData.DtNextExec = rec2upd.DtNextExec;
currData.LastDuration = rec2upd.LastDuration;
currData.LastResult = rec2upd.LastResult;
dbCtx.Entry(currData).State = EntityState.Modified;
}
else
{
dbCtx
.DbSetTaskList
.Add(rec2upd);
}
dbCtx.SaveChanges();
done = true;
}
catch (Exception exc)
{
Log.Error($"Eccezione in TaskListUpsert{Environment.NewLine}{exc}");
}
}
return done;
}
#endregion Public Methods
#region Private Fields
-314
View File
@@ -63,58 +63,6 @@ namespace MP.Data.Controllers
return dbResult;
}
public DateTime CalcNextExe(TaskListModel taskRec)
{
DateTime dtNext = DateTime.Today;
try
{
// calcolo next exec da tipo...
switch (taskRec.Freq)
{
case TaskFreqType.ND:
dtNext = taskRec.DtLastExec.AddDays(taskRec.Cad);
break;
case TaskFreqType.Sec:
dtNext = taskRec.DtLastExec.AddSeconds(taskRec.Cad);
break;
case TaskFreqType.Min:
dtNext = taskRec.DtLastExec.AddMinutes(taskRec.Cad);
break;
case TaskFreqType.Hour:
dtNext = taskRec.DtLastExec.AddHours(taskRec.Cad);
break;
case TaskFreqType.Day:
dtNext = taskRec.DtLastExec.AddDays(taskRec.Cad);
break;
case TaskFreqType.Week:
dtNext = taskRec.DtLastExec.AddDays(7 * taskRec.Cad);
break;
case TaskFreqType.Month:
dtNext = taskRec.DtLastExec.AddMonths(taskRec.Cad);
break;
case TaskFreqType.Year:
dtNext = taskRec.DtLastExec.AddYears(taskRec.Cad);
break;
default:
dtNext = taskRec.DtLastExec.AddDays(taskRec.Cad);
break;
}
}
catch (Exception exc)
{
Log.Error($"Eccezione in CalcNextExe{Environment.NewLine}{exc}");
}
return dtNext;
}
/// <summary>
/// Elenco tabella Articoli da filtro
/// </summary>
@@ -140,80 +88,6 @@ namespace MP.Data.Controllers
{
}
/// <summary>
/// Chiamata esecuzione di un singolo task programmato
/// </summary>
/// <param name="TaskId"></param>
/// <param name="SchedNext">Se true rischedula successiva chiamata</param>
/// <returns></returns>
public TaskResultModel ExecuteTask(int TaskId, bool SchedNext)
{
TaskResultModel callRes = new TaskResultModel();
using (var dbCtx = new MoonPro_STATSContext(_configuration))
{
// imposto timeout a 5 min
//var currTimeout = dbCtx.Database.GetCommandTimeout();
dbCtx.Database.SetCommandTimeout(TimeSpan.FromMinutes(5));
try
{
DateTime dtStart = DateTime.Now;
// recupero i dati da richiamare...
var currRec = dbCtx
.DbSetTaskList
.Where(x => x.TaskId == TaskId)
.FirstOrDefault();
if (currRec != null)
{
// recupero comando
string sqlCommand = currRec.Command;
string rawParams = currRec.Args;
callRes = dbCtx
.DbSetTaskResult
.FromSqlRaw($"EXEC {sqlCommand} {rawParams}")
.AsNoTracking()
.AsEnumerable()
.FirstOrDefault();
DateTime dtEnd = DateTime.Now;
// preparo record esecuzione...
TaskExecModel resRec = new TaskExecModel()
{
TaskId = TaskId,
DtStart = dtStart,
DtEnd = dtEnd,
IsError = callRes.ExecResult < 0,
Result = callRes.TextResult
};
dbCtx
.DbSetTaskExe
.Add(resRec);
// aggiorno record chiamata...
currRec.DtLastExec = dtStart;
currRec.LastResult = resRec.Result;
currRec.LastIsError = resRec.IsError;
currRec.LastDuration = dtEnd.Subtract(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 ExecuteSqlCommand{Environment.NewLine}{exc}");
}
}
return callRes;
}
/// <summary>
/// Elenco da tabella Macchine
/// </summary>
@@ -477,194 +351,6 @@ namespace MP.Data.Controllers
return dbResult;
}
/// <summary>
/// Ricerca task dato tipo + num max (desc)
/// </summary>
/// <param name="TaskId">TaskId da cui deriva</param>
/// <returns></returns>
public List<TaskExecModel> TaskExecGetFilt(int TaskId, int maxRec)
{
List<TaskExecModel> dbResult = new List<TaskExecModel>();
using (var dbCtx = new MoonPro_STATSContext(_configuration))
{
dbResult = dbCtx
.DbSetTaskExe
.Include(x => x.TaskListNav)
.Where(x => (x.TaskId == TaskId))
.OrderByDescending(x => x.DtStart)
.Take(maxRec)
.ToList();
}
return dbResult;
}
/// <summary>
/// Upsert record TaskExec
/// </summary>
/// <param name="rec2upd">Record da aggiornare/inserire</param>
/// <returns></returns>
public bool TaskExecUpsert(TaskExecModel rec2upd)
{
bool done = false;
using (var dbCtx = new MoonPro_STATSContext(_configuration))
{
try
{
var currData = dbCtx
.DbSetTaskExe
.Where(x => x.TaskExecId == rec2upd.TaskExecId)
.FirstOrDefault();
if (currData != null)
{
currData.TaskId = rec2upd.TaskId;
currData.DtStart = rec2upd.DtStart;
currData.DtEnd = rec2upd.DtEnd;
currData.IsError = rec2upd.IsError;
currData.Result = rec2upd.Result;
dbCtx.Entry(currData).State = EntityState.Modified;
}
else
{
dbCtx
.DbSetTaskExe
.Add(rec2upd);
}
dbCtx.SaveChanges();
done = true;
}
catch (Exception exc)
{
Log.Error($"Eccezione in TaskExecUpsert{Environment.NewLine}{exc}");
}
}
return done;
}
/// <summary>
/// Ricerca task dato tipo
/// </summary>
/// <param name="TType"></param>
/// <returns></returns>
public List<TaskListModel> TaskListGetAll(Task2ExeType TType)
{
List<TaskListModel> dbResult = new List<TaskListModel>();
using (var dbCtx = new MoonPro_STATSContext(_configuration))
{
dbResult = dbCtx
.DbSetTaskList
.Where(x => (TType == Task2ExeType.ND || x.TType == TType))
.OrderBy(x => x.Ordinal)
.ToList();
}
return dbResult;
}
/// <summary>
/// Update ordinamento task
/// </summary>
/// <param name="rec2upd">Record da spostare x priorità</param>
/// <returns></returns>
public bool TaskListMove(TaskListModel rec2upd, bool moveUp)
{
bool done = false;
using (var dbCtx = new MoonPro_STATSContext(_configuration))
{
try
{
var currData = dbCtx
.DbSetTaskList
.Where(x => x.TaskId == rec2upd.TaskId)
.FirstOrDefault();
if (currData != null)
{
int actOrdinal = currData.Ordinal;
TaskListModel? otherRec = null;
// cerco, secondo richiesta, precedente o successivo
if (moveUp)
{
otherRec = dbCtx
.DbSetTaskList
.Where(x => x.Ordinal < currData.Ordinal)
.OrderByDescending(x => x.Ordinal)
.FirstOrDefault();
}
else
{
otherRec = dbCtx
.DbSetTaskList
.Where(x => x.Ordinal > currData.Ordinal)
.OrderBy(x => x.Ordinal)
.FirstOrDefault();
}
// inverto ordinale SE ho record
if (otherRec != null)
{
currData.Ordinal = otherRec.Ordinal;
otherRec.Ordinal = actOrdinal;
dbCtx.Entry(currData).State = EntityState.Modified;
dbCtx.Entry(otherRec).State = EntityState.Modified;
}
}
//salvo
dbCtx.SaveChanges();
done = true;
}
catch (Exception exc)
{
Log.Error($"Eccezione in TaskListUpsert{Environment.NewLine}{exc}");
}
}
return done;
}
/// <summary>
/// Upsert record TaskList
/// </summary>
/// <param name="rec2upd">Record da aggiornare/inserire</param>
/// <returns></returns>
public bool TaskListUpsert(TaskListModel rec2upd)
{
bool done = false;
using (var dbCtx = new MoonPro_STATSContext(_configuration))
{
try
{
var currData = dbCtx
.DbSetTaskList
.Where(x => x.TaskId == rec2upd.TaskId)
.FirstOrDefault();
if (currData != null)
{
currData.Ordinal = rec2upd.Ordinal;
currData.Name = rec2upd.Name;
currData.Descript = rec2upd.Descript;
currData.Command = rec2upd.Command;
currData.Args = rec2upd.Args;
currData.Freq = rec2upd.Freq;
currData.Cad = rec2upd.Cad;
currData.DtLastExec = rec2upd.DtLastExec;
currData.DtNextExec = rec2upd.DtNextExec;
currData.LastDuration = rec2upd.LastDuration;
currData.LastResult = rec2upd.LastResult;
dbCtx.Entry(currData).State = EntityState.Modified;
}
else
{
dbCtx
.DbSetTaskList
.Add(rec2upd);
}
dbCtx.SaveChanges();
done = true;
}
catch (Exception exc)
{
Log.Error($"Eccezione in TaskListUpsert{Environment.NewLine}{exc}");
}
}
return done;
}
#endregion Public Methods
#region Private Fields
+5
View File
@@ -7,10 +7,15 @@
</PropertyGroup>
<ItemGroup>
<Compile Remove="DatabaseModels\TaskExecModel.cs" />
<Compile Remove="DatabaseModels\TaskListModel.cs" />
<Compile Remove="DatabaseModels\TaskResultModel.cs" />
<Compile Remove="DatabaseModels\TurniPareto.cs" />
<Compile Remove="DatabaseModels\TurniParetoOdl.cs" />
<Compile Remove="MailKitEmailSender.cs" />
<Compile Remove="MailKitEmailSenderOptions.cs" />
<Compile Remove="Services\RestCallService.cs" />
<Compile Remove="Services\TaskService.cs" />
</ItemGroup>
<ItemGroup>
-7
View File
@@ -58,13 +58,6 @@ namespace MP.Data.MgModels
#region Public Properties
#if false
/// <summary>
/// Ricetta in formato calcolato (string)
/// </summary>
public string CalcRecipe { get; set; } = "";
#endif
/// <summary>
/// Configurazione ricetta x header
/// </summary>
-6
View File
@@ -98,12 +98,6 @@ namespace MP.Data
public virtual DbSet<vSelCauScartoModel> DbSetVSCS { get; set; }
public virtual DbSet<ParetoFluxLogDTO> DbSetParetoFluxLog { get; set; }
public virtual DbSet<TaskListModel> DbSetTaskList { get; set; }
public virtual DbSet<TaskExecModel> DbSetTaskExe { get; set; }
public virtual DbSet<TaskResultModel> DbSetTaskResult { get; set; }
#endregion Public Properties
#region Private Methods
-3
View File
@@ -46,9 +46,6 @@ namespace MP.Data
public virtual DbSet<TurniOee> DbSetTurniOee { get; set; }
public virtual DbSet<UserActionLog> DbSetUserLog { get; set; }
public virtual DbSet<OdlEnergyModel> DbSetOdlEnergy { get; set; }
public virtual DbSet<TaskListModel> DbSetTaskList { get; set; }
public virtual DbSet<TaskExecModel> DbSetTaskExe { get; set; }
public virtual DbSet<TaskResultModel> DbSetTaskResult { get; set; }
#endregion Public Properties
-78
View File
@@ -250,84 +250,6 @@ namespace MP.Data.Objects
SS
}
//[JsonConverter(typeof(StringEnumConverter))]
public enum Task2ExeType
{
/// <summary>
/// Tipo indefinito / ALL
/// </summary>
ND,
/// <summary>
/// Chiamata exe esterno
/// </summary>
Exe,
/// <summary>
/// Chiamata a SQL Command
/// </summary>
SqlCommand,
/// <summary>
/// Chiamata a SQL Stored Procedure
/// </summary>
SqlStored,
/// <summary>
/// Chiamata REST tipo Get
/// </summary>
RestCallGet,
///// <summary>
///// Chiamata REST tipo Post
///// </summary>
//RestCallPost
}
//[JsonConverter(typeof(StringEnumConverter))]
public enum TaskFreqType
{
/// <summary>
/// Tipo indefinito / ALL
/// </summary>
ND,
/// <summary>
/// Secondi
/// </summary>
Sec,
/// <summary>
/// Minuti
/// </summary>
Min,
/// <summary>
/// Ore
/// </summary>
Hour,
/// <summary>
/// Giorni
/// </summary>
Day,
/// <summary>
/// Settimane
/// </summary>
Week,
/// <summary>
/// Mesi
/// </summary>
Month,
/// <summary>
/// Anni
/// </summary>
Year
}
/// <summary>
/// Elenco task ammessi (x IOB-WIN da eseguire...)
/// </summary>
+4
View File
@@ -6,6 +6,10 @@ using System.Threading.Tasks;
namespace MP.Data.Services
{
/// <summary>
/// Gestione eventi reload da forzare via mesaggio
/// FixMe ToDo !!! è ancora necessario con obj task estratti?!?!?
/// </summary>
public class ReloadEventArgs : EventArgs
{
#region Public Constructors
+2 -2
View File
@@ -53,8 +53,8 @@ namespace MP.Data.Services
sb.AppendLine($"TabDataService | MpInveController OK");
Log.Info(sb.ToString());
// sistemo i parametri x redHas...
CodModulo = _configuration.GetValue<string>("OptConf:CodModulo");
CodModuloParam = _configuration.GetValue<string>("OptConf:CodModuloParam");
CodModulo = _configuration.GetValue<string>("SpecialConf:CodModulo");
CodModuloParam = _configuration.GetValue<string>("SpecialConf:CodModuloParam");
MpIoNS = _configuration.GetValue<string>("ServerConf:MpIoNS");
var cstringArray = ConnStr.Split(";");
foreach (var item in cstringArray)
-20
View File
@@ -127,26 +127,6 @@ namespace MP.Data
return (RedisValue)$"{redisBaseAddr}{keyName}";
}
/// <summary>
/// Effettua salvataggio in file di un generico oggetto in formato CSV
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="reportData"></param>
/// <param name="path"></param>
/// <param name="separator">Separatore da impiegare</param>
/// <returns></returns>
public static async Task SaveToCsv<T>(List<T> reportData, string path, char separator)
{
var lines = new List<string>();
IEnumerable<PropertyDescriptor> props = TypeDescriptor.GetProperties(typeof(T)).OfType<PropertyDescriptor>();
var header = string.Join(";", props.ToList().Select(x => x.Name));
lines.Add(header);
var valueLines = reportData.Select(row => string.Join(separator, header.Split(separator).Select(a => row.GetType().GetProperty(a).GetValue(row, null))));
//var valueLines = reportData.Select(row => string.Join(";", header.Split(';').Select(a => row.GetType().GetProperty(a).GetValue(row, null))));
lines.AddRange(valueLines);
await Task.Run(() => File.WriteAllLines(path, lines.ToArray()));
}
#endregion Public Methods
#region Public Classes
+1 -1
View File
@@ -18,7 +18,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NLog" Version="5.3.3" />
<PackageReference Include="NLog" Version="5.3.4" />
</ItemGroup>
<ItemGroup>
+2 -2
View File
@@ -7,7 +7,7 @@
@inject MessageService MService
@inject LicenseService LicServ
@if (authOk()) // disegno box cliccabile e programma attivato
@if (authOk())
{
<div class="card">
<div class="card-header">
@@ -32,7 +32,7 @@
</div>
</div>
}
else // disegno box cliccabile e licenza ASSISTENZA mancante
else
{
<div class="card">
<div class="card-header">
+1 -4
View File
@@ -6,10 +6,7 @@
<div class="input-group input-group-sm">
<DebounceInput id="sVal" class="form-control" placeholder="@("Ricerca libera")" autocomplete="off" @ref="debInput" @bind-Value="@_searchVal" @bind-Value:event="OnInput" DebounceTime="@_debMsec" MinLength="@_minChar" OnValueChanged="e => { searchVal = e; }" ForceNotifyByEnter="true" ForceNotifyOnBlur="true" />
<div class="input-group-append">
<button @onclick="reset" class="btn btn-success input-group-text">reset</button>
</div>
<button @onclick="reset" class="btn btn-success input-group-text">reset</button>
</div>
@code {
+1 -1
View File
@@ -34,7 +34,7 @@ namespace MP.Land.Data
_configuration = configuration;
// cod app
CodApp = _configuration.GetValue<string>("ServerConf:CodApp");
CodApp = _configuration.GetValue<string>("SpecialConf:CodApp");
Modulo = _configuration.GetValue<string>("ServerConf:Modulo");
// Conf cache
+6 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>MP.Land</RootNamespace>
<Version>6.16.2410.2519</Version>
<Version>6.16.2410.2810</Version>
<Configurations>Debug;Release;Debug_LiManDebug</Configurations>
</PropertyGroup>
@@ -11,6 +11,8 @@
<Compile Remove="Components\ArchiveStatus.razor.cs" />
<Compile Remove="Components\FileEditor.razor.cs" />
<Compile Remove="Components\TagSearch.razor.cs" />
<Compile Remove="Components\TaskEdit.razor.cs" />
<Compile Remove="Components\TaskExeList.razor.cs" />
<Compile Remove="Data\FileArchDataService.cs" />
<Compile Remove="Pages\Archive.razor.cs" />
<Compile Remove="Pages\Setup.razor.cs" />
@@ -21,6 +23,8 @@
<Content Remove="Components\CodArtSelector.razor" />
<Content Remove="Components\FileEditor.razor" />
<Content Remove="Components\TagSearch.razor" />
<Content Remove="Components\TaskEdit.razor" />
<Content Remove="Components\TaskExeList.razor" />
<Content Remove="Pages\Archive.razor" />
<Content Remove="Pages\Setup.razor" />
</ItemGroup>
@@ -63,6 +67,7 @@
<ItemGroup>
<ProjectReference Include="..\MP.AppAuth\MP.AppAuth.csproj" />
<ProjectReference Include="..\MP.Data\MP.Data.csproj" />
<ProjectReference Include="..\MP.TaskMan\MP.TaskMan.csproj" />
</ItemGroup>
<ItemGroup>
+2 -2
View File
@@ -25,7 +25,7 @@
</div>
<div class="card shadow">
<div class="card-body">
<div class="card-body py-2">
@if (ListRecords == null)
{
<LoadingData></LoadingData>
@@ -39,7 +39,7 @@
<div class="row">
@foreach (var item in ListRecords)
{
<div class="col-12 col-sm-6 col-xl-4 my-1">
<div class="col-12 col-sm-6 col-lg-4 col-xl-3 px-1 my-0">
<HomeLink CurrItem="@item"></HomeLink>
</div>
}
+1 -189
View File
@@ -1,191 +1,3 @@
@page "/TaskScheduler"
<div class="row">
<div class="@mainCss">
<div class="card shadow">
<div class="card-header table-primary p-1">
<div class="d-flex justify-content-between">
<div class="px-2">
<b class="fs-4">TaskList</b>
</div>
<div class="px-2">
<div class="input-group">
@if (TypeSel != MP.Data.Objects.Enums.Task2ExeType.ND)
{
@if (currRecord == null)
{
<button class="btn btn-success" @onclick="addNew" title="Add New"><i class="fas fa-plus"></i> Add New</button>
}
else
{
<button class="btn btn-secondary" @onclick="doCancel" title="Cancel"><i class="fas fa-undo"></i> Cancel</button>
}
}
else
{
<button class="btn btn-outline-secondary">Sel &rarr;</button>
}
<select class="form-select" @bind="@TypeSel">
@foreach (var option in Enum.GetValues(typeof(MP.Data.Objects.Enums.Task2ExeType)))
{
<option value="@option">
@option
</option>
}
</select>
</div>
</div>
</div>
<TaskEdit CurrRecord="@currRecord" EC_update="forceUpdate"></TaskEdit>
</div>
<div class="card-body py-0 px-1">
@if (isLoading)
{
<ProgressDisplay DisplaySize="ProgressDisplay.ModalSize.Medium" ExpTimeMSec="@expTimeMsec" CurrVal="@currVal" NextVal="@nextVal" MaxVal="@MaxVal" Title="Task Processing" RefreshInterval="200"></ProgressDisplay>
<LoadingData Title="Elaborazione..." DisplayMode="LoadingData.SpinMode.BounceLine" DisplaySize="LoadingData.CtrlSize.Large"></LoadingData>
}
else if (ListRecords == null)
{
<LoadingData></LoadingData>
}
else if (totalCount == 0)
{
<div class="alert alert-warning text-center display-4">Nessun record trovato</div>
}
else
{
<div class="row">
<div class="col-12">
<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.TaskId)">
<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>
}
}
@record.Ordinal
@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">
<div>@record.Name</div>
<div class="small text-truncate">@record.Descript</div>
</td>
<td>
@record.TType
</td>
@if (detRecord == null)
{
<td class="small text-truncate text-break">
<div 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 &times; @record.Cad</td>
@if (detRecord == null)
{
<td class="text-end text-nowrap">
<div>@($"{record.DtLastExec:yyyy-MM-dd}")</div>
<div class="small">@($"{record.DtLastExec:ddd HH:mm:ss}")</div>
</td>
<td class="text-end text-nowrap">
<div>@($"{record.DtNextExec:yyyy-MM-dd}")</div>
<div class="small">@($"{record.DtNextExec:ddd HH:mm:ss}")</div>
</td>
<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>
<button class="btn btn-sm @btnRunCss(record.DtNextExec) me-1" @onclick="()=>doRun(record)" title="Run Now"><i class="fas fa-play"></i></button>
</td>
}
</tr>
@if (DetailTaskId != null && DetailTaskId.TaskId == record.TaskId)
{
<tr>
<td colspan="10">
<div class="d-flex justify-content-end">
<div class="p-1 small alert @alCss(record)">
<pre>@record.LastResult</pre>
</div>
</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" exportRequested="ExportCsv" fileName="@fileName" totalCount="totalCount" showLoading="isLoading" />
</div>
</div>
</div>
@if (detRecord != null && !isLoading)
{
<div class="col-6">
<TaskExeList CurrRecord="detRecord"></TaskExeList>
</div>
}
</div>
<TaskList></TaskList>
+6 -385
View File
@@ -1,404 +1,25 @@
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using MP.Data.DatabaseModels;
using MP.Land.Data;
using static MP.Data.Objects.Enums;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using System;
using System.Linq;
using MP.Data.Services;
using DnsClient.Protocol;
namespace MP.Land.Pages
{
public partial class TaskScheduler : ComponentBase, IDisposable
public partial class TaskScheduler : ComponentBase
{
#region Public Methods
public string checkSelect(int TaskId)
{
string answ = "";
if (currRecord != null)
{
try
{
answ = (currRecord.TaskId == TaskId) ? "table-info" : "";
}
catch
{ }
}
else if (detRecord != null)
{
answ = (detRecord.TaskId == TaskId) ? "table-info" : "";
}
return answ;
}
public void Dispose()
{
MessageService.EA_SearchUpdated -= OnSeachUpdated;
}
public async void OnSeachUpdated()
{
await InvokeAsync(() =>
{
Task task = ReloadData();
StateHasChanged();
});
}
#endregion Public Methods
#region Protected Fields
protected string fileName = "TaskList.csv";
#endregion Protected Fields
#region Protected Properties
[Inject]
protected IJSRuntime JSRuntime { get; set; }
protected string mainCss
{
get => detRecord == null ? "col-12" : "col-6";
}
protected int maxOrdinal { get; set; } = 999;
[Inject]
protected Data.MessageService MessageService { get; set; }
protected int minOrdinal { get; set; } = 0;
[Inject]
protected NavigationManager NavManager { get; set; }
protected int totalCount { get; set; } = 0;
[Inject]
protected TaskService TService { get; set; }
protected Task2ExeType TypeSel
{
get => typeSel;
set
{
if (typeSel != value)
{
typeSel = value;
var pUpd = Task.Run(async () =>
{
await ReloadData();
});
pUpd.Wait();
}
}
}
protected Data.MessageService MServ { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected async Task addNew()
protected override void OnInitialized()
{
currRecord = new TaskListModel()
{
Name = "Nuovo Task",
TType = TypeSel,
Descript = "Descrizione Task",
DtLastExec = DateTime.Today,
DtNextExec = DateTime.Today.AddDays(1)
};
await ReloadData();
}
/// <summary>
/// Gestione display avanzamento step
/// </summary>
/// <param name="currStep"></param>
protected async Task advStep(int currStep)
{
currVal = currStep;
nextVal = currVal + 1;
await InvokeAsync(StateHasChanged);
}
protected string alCss(TaskListModel TaskRec)
{
return TaskRec.LastIsError ? "alert-danger" : "alert-success";
}
protected string btnCss(TaskListModel TaskRec)
{
string answ = DetailTaskId != null && DetailTaskId.TaskId == TaskRec.TaskId ? "btn-" : "btn-outline-";
answ += TaskRec.LastIsError ? "danger" : "success";
return answ;
}
protected async Task doCancel()
{
currRecord = null;
detRecord = null;
await ReloadData();
}
protected async Task doClone(TaskListModel selRec)
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Confermi di voler duplicare il record selezionato?"))
return;
currRecord = new TaskListModel()
{
Args = selRec.Args,
Name = $"Copia di {selRec.Name}",
Cad = selRec.Cad,
Command = selRec.Command,
Descript = $"Copia di {selRec.Descript}",
DtNextExec = DateTime.Today.AddDays(1),
DtLastExec = DateTime.Today.AddYears(-10),
Freq = selRec.Freq,
LastDuration = 0,
LastIsError = false,
LastResult = "",
TType = selRec.TType,
Ordinal = SearchRecords.Count + 1,
};
await ReloadData();
}
protected async Task doEdit(TaskListModel selRec)
{
currRecord = selRec;
await ReloadData();
}
protected async Task doMove(TaskListModel currRec, bool goUp)
{
await TService.TaskListMove(currRec, goUp);
detRecord = null;
currRecord = null;
await ReloadData();
}
protected async Task doReset()
{
detRecord = null;
currRecord = null;
await TService.FlushCache();
await ReloadData();
}
protected async Task doRun(TaskListModel selRec)
{
// SE non è ancora scaduto chiedo conferma
if (selRec.DtNextExec > DateTime.Now)
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Confermi esecuzione forzata task non scaduto?{Environment.NewLine}[{selRec.TaskId}]: {selRec.Name} - {selRec.Descript}{Environment.NewLine}Prossima schedulazione: {selRec.DtNextExec:yyyy-MM-dd HH:mm:ss}"))
return;
}
// imposto tempo atteso esecuzione da ultimo...
isLoading = true;
MaxVal = 4;
int currStep = 0;
await advStep(currStep);
expTimeMsec = (int)(1000 * selRec.LastDuration) / 4;
detRecord = null;
await advStep(currStep++);
await Task.Delay(100);
await advStep(currStep++);
// chiama esecuzione task
var result = await TService.ExecuteTask(selRec, false);
await advStep(currStep++);
isLoading = false;
await Task.Delay(100);
await advStep(currStep++);
await ReloadData();
}
protected async Task doSelect(TaskListModel selRec)
{
detRecord = null;
currRecord = null;
DetailTaskId = null;
isLoading = true;
detRecord = selRec;
await ReloadData();
isLoading = false;
}
protected async Task forceAll()
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Confermi esecuzione forzata di tutti i task?"))
return;
isLoading = true;
detRecord = null;
await Task.Delay(100);
foreach (var taskRec in SearchRecords)
{
var result = await TService.ExecuteTask(taskRec, false);
}
isLoading = false;
await Task.Delay(100);
await ReloadData();
}
protected async Task ForceReload(int newNum)
{
numRecord = newNum;
await ReloadData();
}
protected async Task ForceReloadPage(int newNum)
{
currPage = newNum;
await ReloadData();
}
protected async Task forceUpdate(bool doForce)
{
currRecord = null;
await ReloadData();
}
protected string iconCss(TaskListModel TaskRec)
{
return TaskRec.LastIsError ? "fa-thumbs-down" : "fa-thumbs-up";
}
protected override async Task OnInitializedAsync()
{
clearFile();
numRecord = 10;
MessageService.ShowSearch = false;
MessageService.PageName = "Task Scheduler";
MessageService.PageIcon = "oi oi-clock";
MessageService.EA_SearchUpdated += OnSeachUpdated;
await ReloadData();
}
protected void ResetData()
{
clearFile();
TService.rollBackEdit(currRecord);
currRecord = null;
}
protected async Task ResetFilter(SelectData newFilter)
{
clearFile();
detRecord = null;
currRecord = null;
SearchRecords = null;
ListRecords = null;
await ReloadData();
}
protected double righDiv(double num, double den)
{
if (den == 0)
{
den = 1;
}
double answ = num / den;
return answ;
}
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;
}
protected void ToggleDetail(TaskListModel TaskRec)
{
if (DetailTaskId == null)
{
DetailTaskId = TaskRec;
}
else
{
DetailTaskId = (DetailTaskId.TaskId == TaskRec.TaskId) ? null : TaskRec;
}
MServ.ShowSearch = true;
MServ.PageName = "Task Scheduler";
MServ.PageIcon = "oi oi-clock";
}
#endregion Protected Methods
#region Private Fields
private double currVal = 0;
private TaskListModel? DetailTaskId = null;
private List<TaskListModel> ListRecords;
private int MaxVal = 10;
private double nextVal = 0;
private List<TaskListModel> SearchRecords;
#endregion Private Fields
#region Private Properties
private int currPage { get; set; } = 1;
private TaskListModel currRecord { get; set; } = null;
private TaskListModel detRecord { get; set; } = null;
private int expTimeMsec { get; set; } = 30000;
private string fullPath
{
get => $"{Directory.GetCurrentDirectory()}\\temp\\{fileName}";
}
private bool isLoading { get; set; } = false;
private int numRecord { get; set; } = 10;
private Task2ExeType typeSel { get; set; } = Task2ExeType.ND;
#endregion Private Properties
#region Private Methods
private string btnRunCss(DateTime dtNextExe)
{
DateTime adesso = DateTime.Now;
string answ = dtNextExe < adesso ? "btn-success" : "btn-warning";
return answ;
}
private async void clearFile()
{
await Task.Run(() => File.Delete(fullPath));
}
private async Task ExportCsv()
{
isLoading = true;
// salvo davvero!
await MP.Data.Utils.SaveToCsv(SearchRecords, fullPath, ';');
isLoading = false;
}
private async Task ReloadData()
{
SearchRecords = await TService.TaskListAll(TypeSel, "");
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();
}
#endregion Private Methods
}
}
+1 -1
View File
@@ -19,7 +19,7 @@ using System.Threading.Tasks;
namespace MP.Land.Pages
{
public partial class UpdateManager : IDisposable
public partial class UpdateManager : ComponentBase, IDisposable
{
#region Public Methods
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo Tablet MAPO - DotNet6</i>
<h4>Versione: 6.16.2410.2519</h4>
<h4>Versione: 6.16.2410.2810</h4>
<br />
Note di rilascio:
<ul>
+1 -1
View File
@@ -1 +1 @@
6.16.2410.2519
6.16.2410.2810
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2410.2519</version>
<version>6.16.2410.2810</version>
<url>https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/MP.Land.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+1 -2
View File
@@ -45,7 +45,7 @@ namespace MP.Land.Shared
protected override async Task OnInitializedAsync()
{
await ReloadData();
}
}
protected List<PermessiModel> UserPerm { get; set; } = new List<PermessiModel>();
protected List<UserDirittiModel> UserRight { get; set; } = new List<UserDirittiModel>();
@@ -111,7 +111,6 @@ namespace MP.Land.Shared
private async Task ReloadData()
{
isLoading = true;
await Task.Delay(1);
// sistemo elenco pagine safe...
SafePages = ConfMan.GetValue<string>("Application:SafePages").ToLower();
var authState = await AuthStateProvider.GetAuthenticationStateAsync();
+2 -1
View File
@@ -13,6 +13,7 @@ using Microsoft.Extensions.Hosting;
using MP.AppAuth.Services;
using MP.Data.Services;
using MP.Land.Data;
using MP.TaskMan.Services;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
@@ -136,9 +137,9 @@ namespace MP.Land
services.AddSingleton<LicenseService>();
services.AddSingleton<SyncService>();
services.AddSingleton<RestCallService>();
services.AddSingleton<TaskService>();
services.AddScoped<AppAuthService>();
services.AddScoped<TaskService>();
services.AddScoped<Data.MessageService>();
services.AddSingleton<IConnectionMultiplexer>(redisMultiplexer);
+1
View File
@@ -9,6 +9,7 @@
@using MP.Land
@using MP.Land.Components
@using MP.Land.Shared
@using MP.TaskMan
@using EgwCoreLib
@using EgwCoreLib.Razor
@using EgwCoreLib.Razor.Data
+6 -4
View File
@@ -60,7 +60,6 @@
"MP.All": "Server=SQL2016DEV;Database=MoonPro;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=MP.Land;",
"MP.Land": "Server=SQL2016DEV;Database=MoonPro;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=MP.Land;",
"MP.Land.Auth": "Server=SQL2016DEV;Database=MoonPro_Anagrafica;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=MP.Land;",
//"MP.Land": "Server=SQL2016DEV;Database=MoonPro_ONE;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=MP.Land;",
"Redis": "localhost:26379, serviceName=devel, defaultDatabase=1, keepAlive=180, connectTimeout=5000, syncTimeout=5000, asyncTimeout=5000, abortConnect=false, ssl=false, allowAdmin=true"
},
"Application": {
@@ -68,11 +67,14 @@
},
"ServerConf": {
"BaseUrl": "https://localhost:44309/",
"CodApp": "MP-LAND",
"CodModulo": "MP-LAND",
"downloadPath": "C:\\Steamware\\installers\\MP",
"IobUploadPath": "C:\\inetpub\\wwwroot\\MP\\fileUpload",
"Modulo": "MoonPro",
"downloadPath": "C:\\Steamware\\installers\\MP",
"Prog.ApiUrl": "https://office.egalware.com/MP/PROG"
},
"SpecialConf": {
"TaskManConn": "MP.Land",
"CodApp": "MP-LAND",
"CodModulo": "MP-LAND"
}
}
+5 -4
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>MP.Prog</RootNamespace>
<Version>6.16.2410.2318</Version>
<Version>6.16.2410.2811</Version>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
@@ -19,15 +19,15 @@
<ItemGroup>
<PackageReference Include="DiffMatchPatch" Version="1.0.3" />
<PackageReference Include="EgwCoreLib.Razor" Version="1.5.2409.2607" />
<PackageReference Include="EgwCoreLib.Utils" Version="1.5.2402.2411" />
<PackageReference Include="EgwCoreLib.Utils" Version="1.5.2409.2607" />
<PackageReference Include="Majorsoft.Blazor.Components.Debounce" Version="1.5.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Negotiate" Version="6.0.35" />
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="6.0.35" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.17" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NLog" Version="5.3.3" />
<PackageReference Include="NLog" Version="5.3.4" />
<PackageReference Include="NLog.Web.AspNetCore" Version="5.3.12" />
<PackageReference Include="StackExchange.Redis" Version="2.8.12" />
<PackageReference Include="StackExchange.Redis" Version="2.8.16" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.9.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.9.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.9.0" />
@@ -35,6 +35,7 @@
<ItemGroup>
<ProjectReference Include="..\MP.FileData\MP.FileData.csproj" />
<ProjectReference Include="..\MP.TaskMan\MP.TaskMan.csproj" />
</ItemGroup>
<ItemGroup>
+3
View File
@@ -0,0 +1,3 @@
@page "/TaskScheduler"
<TaskList></TaskList>
+25
View File
@@ -0,0 +1,25 @@
using Microsoft.AspNetCore.Components;
namespace MP.Prog.Pages
{
public partial class TaskScheduler : ComponentBase
{
#region Protected Properties
[Inject]
protected Data.MessageService MServ { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected override void OnInitialized()
{
MServ.ShowSearch = true;
MServ.PageName = "Task Scheduler";
MServ.PageIcon = "oi oi-clock";
}
#endregion Protected Methods
}
}
+2 -2
View File
@@ -27,7 +27,7 @@ namespace MP.Prog
logging.ClearProviders();
logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Error);
})
// importante per eseguire la conf regike logging
// importante per eseguire la conf logging
.UseNLog(new NLogAspNetCoreOptions() { RemoveLoggerFactoryFilter = false });
//.UseNLog();
@@ -49,7 +49,7 @@ namespace MP.Prog
}
finally
{
NLog.LogManager.Shutdown();
LogManager.Shutdown();
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo gestione Programmi MAPO</i>
<h4>Versione: 6.16.2410.2318</h4>
<h4>Versione: 6.16.2410.2811</h4>
<br />
Note di rilascio:
<ul>
+1 -1
View File
@@ -1 +1 @@
6.16.2410.2318
6.16.2410.2811
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2410.2318</version>
<version>6.16.2410.2811</version>
<url>https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/MP.Prog.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+6
View File
@@ -22,6 +22,12 @@
<span class="fas fa-wrench fa-2x pe-2" aria-hidden="true"></span> Setup
</NavLink>
</li>
<li class="nav-item px-3">
<NavLink class="nav-link" href="TaskScheduler">
<span class="fas fa-stopwatch fa-2x pe-2" aria-hidden="true"></span> Task Scheduler
</NavLink>
</li>
<li class="nav-item px-3">
<NavLink class="nav-link" href="ForceReload">
<span class="fas fa-rotate fa-2x pe-2" aria-hidden="true"></span> ForceReload
+4 -2
View File
@@ -10,6 +10,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
using MP.Prog.Data;
using MP.TaskMan.Services;
using NLog;
using StackExchange.Redis;
using System;
@@ -182,9 +183,10 @@ namespace MP.Prog
services.AddServerSideBlazor();
services.AddSingleton<IConfiguration>(Configuration);
//services.AddTransient<Services.BlazorTimer>();
services.AddSingleton<RestCallService>();
services.AddSingleton<TaskService>();
//services.AddSingleton<FileArchDataService>();
services.AddScoped<FileArchDataService>();
services.AddScoped<MessageService>();
services.AddSingleton<IConnectionMultiplexer>(redisMultiplexer);
+1
View File
@@ -9,3 +9,4 @@
@using MP.Prog
@using MP.Prog.Shared
@using MP.Prog.Components
@using MP.TaskMan
+10 -7
View File
@@ -1,10 +1,13 @@
{
"DetailedErrors": true,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
"DetailedErrors": true,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"ServerConf": {
"Prog.ApiUrl": "https://iis01.egalware.com/MP/PROG"
}
}
+17 -12
View File
@@ -1,15 +1,20 @@
{
"DetailedErrors": true,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "Server=localhost\\SQLEXPRESS;Database=MoonPro_PROG;Trusted_Connection=True;MultipleActiveResultSets=true",
"MP.Prog": "Server=localhost\\SQLEXPRESS;Database=MoonPro_PROG;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=MP.PROG;"
"DetailedErrors": true,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "Server=localhost\\SQLEXPRESS;Database=MoonPro_PROG;Trusted_Connection=True;MultipleActiveResultSets=true",
"MP.Prog": "Server=localhost\\SQLEXPRESS;Database=MoonPro_PROG;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=MP.PROG;"
},
"ServerConf": {
"BaseUrl": "/MP/PROG",
"FolderBasePath": "\\\\stor01",
"Prog.ApiUrl": "https://localhost/MP/PROG"
}
}
+14 -9
View File
@@ -1,15 +1,20 @@
{
"DetailedErrors": true,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"DetailedErrors": true,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "Server=W2019-SQL-STEAM;Database=MoonPro_PROG;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=MP.Prog;",
"MP.Prog": "Server=W2019-SQL-STEAM;Database=MoonPro_PROG;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=MP.Prog;"
},
"ServerConf": {
"BaseUrl": "/MP/PROG",
"FolderBasePath": "\\\\stor01",
"Prog.ApiUrl": "https://office.egalware.com/MP/PROG"
}
}
+17 -12
View File
@@ -1,15 +1,20 @@
{
"DetailedErrors": true,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "Server=localhost\\SQLEXPRESS;Database=MoonPro_PROG;Trusted_Connection=True;MultipleActiveResultSets=true",
"MP.Prog": "Server=localhost\\SQLEXPRESS;Database=MoonPro_PROG;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=MP.PROG;"
"DetailedErrors": true,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "Server=localhost\\SQLEXPRESS;Database=MoonPro_PROG;Trusted_Connection=True;MultipleActiveResultSets=true",
"MP.Prog": "Server=localhost\\SQLEXPRESS;Database=MoonPro_PROG;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=MP.PROG;"
},
"ServerConf": {
"BaseUrl": "/MP/PROG",
"FolderBasePath": "\\\\stor01",
"Prog.ApiUrl": "https://localhost/MP/PROG"
}
}
+7 -1
View File
@@ -60,6 +60,12 @@
},
"ServerConf": {
"BaseUrl": "/MP/PROG",
"FolderBasePath": "\\\\stor01"
"FolderBasePath": "\\\\stor01",
"Prog.ApiUrl": "https://iis01.egalware.com/MP/PROG"
},
"SpecialConf": {
"TaskManConn": "MP.Prog",
"CodApp": "MP-PROG",
"CodModulo": "MP-PROG"
}
}
-7
View File
@@ -1,7 +0,0 @@
<div class="text-end">
<b>@($"{CurrRecord.LastDuration:N3}")</b> <sub>sec</sub> <button class="btn btn-sm @btnCss" @onclick="toggleDetail" title="Ultima esecuzione"><i class="far @iconCss"></i></button>
</div>
@if (showDetail)
{
<div class="small alert @alCss py-1">@CurrRecord.LastResult</div>
}
-56
View File
@@ -1,56 +0,0 @@
using Microsoft.AspNetCore.Components;
using MP.Data.DatabaseModels;
using System.Threading.Tasks;
namespace MP.Stats.Components
{
public partial class TLResult
{
#region Public Properties
[Parameter]
public TaskListModel CurrRecord { get; set; } = null!;
#endregion Public Properties
#region Protected Properties
protected string alCss
{
get => CurrRecord.LastIsError ? "alert-danger" : "alert-success";
}
protected string btnCss
{
get
{
string answ = showDetail ? "btn-" : "btn-outline-";
answ += CurrRecord.LastIsError ? "danger" : "success";
return answ;
}
}
protected string iconCss
{
get => CurrRecord.LastIsError ? "fa-thumbs-down" : "fa-thumbs-up";
}
#endregion Protected Properties
#region Protected Methods
protected async Task toggleDetail()
{
showDetail = !showDetail;
await InvokeAsync(StateHasChanged);
}
#endregion Protected Methods
#region Private Properties
private bool showDetail { get; set; } = false;
#endregion Private Properties
}
}
-101
View File
@@ -1,101 +0,0 @@
@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>
}
-50
View File
@@ -1,50 +0,0 @@
using DnsClient.Protocol;
using Microsoft.AspNetCore.Components;
using MP.Data.DatabaseModels;
using MP.Stats.Data;
using System.Threading.Tasks;
namespace MP.Stats.Components
{
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 MpStatsService StatService { 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)
{
//var nextDt = StatService.CalcNextExe(CurrRecord);
//CurrRecord.DtNextExec = nextDt;
fatto = await StatService.TaskListUpsert(CurrRecord);
}
await EC_update.InvokeAsync(fatto);
}
#endregion Protected Methods
}
}
-85
View File
@@ -1,85 +0,0 @@

<div class="card text-bg-light shadow">
<div class="card-header table-primary p-1">
<div class="d-flex justify-content-between">
<div class="px-2">
<b class="fs-4">History</b>
</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>
<div class="small">@record.Result</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>
-113
View File
@@ -1,113 +0,0 @@
using Microsoft.AspNetCore.Components;
using MP.Data.DatabaseModels;
using MP.Stats.Data;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace MP.Stats.Components
{
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();
}
}
}
[Inject]
protected MpStatsService StatService { get; set; }
protected int totalCount { get; set; } = 0;
#endregion Protected Properties
#region Protected Methods
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();
}
#endregion Protected Methods
#region Private Fields
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 StatService.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
}
}
+37 -23
View File
@@ -1,10 +1,8 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using MP.Data.DatabaseModels;
using MP.Stats.Data;
using MP.TaskMan.Models;
using MP.TaskMan.Services;
using NLog;
using NLog.Fluent;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -16,7 +14,9 @@ namespace MP.Stats.Controllers
[ApiController]
public class TaskController : ControllerBase
{
public TaskController(IConfiguration configuration, MpStatsService DataService)
#region Public Constructors
public TaskController(IConfiguration configuration, TaskService DataService)
{
Log.Trace("Starting TaskController");
_configuration = configuration;
@@ -24,16 +24,9 @@ namespace MP.Stats.Controllers
Log.Trace("Avviato TaskController");
}
/// <summary>
/// List of available task and last execution data
/// </summary>
/// <returns></returns>
[HttpGet("GetList")]
public async Task<List<TaskListModel>> GetList()
{
List<TaskListModel> answ = await DService.TaskListAll(MP.Data.Objects.Enums.Task2ExeType.ND, "");
return answ;
}
#endregion Public Constructors
#region Public Methods
/// <summary>
/// Call for execution of due task and report state
@@ -43,26 +36,47 @@ namespace MP.Stats.Controllers
public async Task<List<TaskResultModel>> ExecuteAndReturnGet()
{
List<TaskResultModel> answ = new List<TaskResultModel>();
List<TaskListModel> listTask = await DService.TaskListAll(MP.Data.Objects.Enums.Task2ExeType.ND, "");
List<TaskListModel> listTask = await DService.TaskListAll(TaskMan.Objects.Enums.Task2ExeType.ND, "");
// verifico SE ci siano task in scadenza...
DateTime adesso = DateTime.Now;
var task2exe = listTask.Where(x => x.DtNextExec <= adesso).ToList();
foreach (var taskRec in task2exe)
{
TaskResultModel result = await DService.ExecuteTask(taskRec.TaskId, true);
TaskResultModel result = await DService.ExecuteTask(taskRec, true);
answ.Add(result);
}
// resituisco
return answ;
}
/// <summary>
/// List of available task and last execution data
/// </summary>
/// <returns></returns>
[HttpGet("GetList")]
public async Task<List<TaskListModel>> GetList()
{
List<TaskListModel> answ = await DService.TaskListAll(TaskMan.Objects.Enums.Task2ExeType.ND, "");
return answ;
}
#endregion Public Methods
#region Protected Properties
/// <summary>
/// Dataservice x accesso DB
/// </summary>
protected TaskService DService { get; set; }
#endregion Protected Properties
#region Private Fields
private static IConfiguration _configuration = null!;
private static Logger Log = LogManager.GetCurrentClassLogger();
/// <summary>
/// Dataservice x accesso DB
/// </summary>
protected MpStatsService DService { get; set; }
#endregion Private Fields
}
}
}
+6 -110
View File
@@ -127,6 +127,7 @@ namespace MP.Stats.Data
return Task.FromResult(answ);
}
#if false
/// <summary>
/// Aggiorna record calcolando prossima scadenza dato ultima esecuzione
/// </summary>
@@ -140,7 +141,8 @@ namespace MP.Stats.Data
dtNext = dbController.CalcNextExe(taskRec);
}
return dtNext;
}
}
#endif
public Task<List<AutocompleteModel>> CommesseGetSearch(int numRecord, string searchVal = "")
{
@@ -162,6 +164,7 @@ namespace MP.Stats.Data
redisDb = null;
}
#if false
/// <summary>
/// Chiamata esecuzione di un singolo task programmato
/// </summary>
@@ -174,7 +177,8 @@ namespace MP.Stats.Data
// svuoto cache!
await FlushCache("Task");
return await Task.FromResult(dbResult);
}
}
#endif
/// <summary>
/// Pulizia cache Redis (tutta)
@@ -559,114 +563,6 @@ namespace MP.Stats.Data
return result;
}
/// <summary>
/// Ricerca task dato tipo + num max (desc)
/// </summary>
/// <param name="TaskId">TaskId da cui deriva</param>
/// <returns></returns>
public async Task<List<TaskExecModel>> TaskExecGetFilt(int TaskId, int maxRec, string searchVal)
{
// setup parametri costanti
string source = "DB";
Stopwatch sw = new Stopwatch();
sw.Start();
List<TaskExecModel> result = new List<TaskExecModel>();
// cerco in redis...
DateTime adesso = DateTime.Now;
string currKey = $"{redisBaseKey}:Task:ExecList:{TaskId}:{adesso:yyMMdd}:{adesso:HHmm}:{maxRec}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
{
result = JsonConvert.DeserializeObject<List<TaskExecModel>>($"{rawData}");
source = "REDIS";
}
else
{
result = dbController.TaskExecGetFilt(TaskId, maxRec);
// serializzp e salvo...
rawData = JsonConvert.SerializeObject(result);
await redisDb.StringSetAsync(currKey, rawData, FastCache);
}
if (result == null)
{
result = new List<TaskExecModel>();
}
sw.Stop();
_logger.LogDebug($"TaskExecGetFilt | {source} | {sw.Elapsed.TotalMilliseconds}ms");
return result;
}
/// <summary>
/// Elenco TaskList gestiti
/// </summary>
/// <param name="CurrFilter"></param>
/// <param name="searchVal"></param>
/// <returns></returns>
public async Task<List<TaskListModel>> TaskListAll(Task2ExeType TType, string searchVal = "")
{
// setup parametri costanti
string source = "DB";
Stopwatch sw = new Stopwatch();
sw.Start();
List<TaskListModel> result = new List<TaskListModel>();
// cerco in redis...
DateTime adesso = DateTime.Now;
string currKey = $"{redisBaseKey}:Task:List:{TType}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
{
result = JsonConvert.DeserializeObject<List<TaskListModel>>($"{rawData}");
source = "REDIS";
}
else
{
result = dbController.TaskListGetAll(TType);
// serializzp e salvo...
rawData = JsonConvert.SerializeObject(result);
await redisDb.StringSetAsync(currKey, rawData, FastCache);
}
if (result == null)
{
result = new List<TaskListModel>();
}
// se necessario filtro..
if (!string.IsNullOrEmpty(searchVal))
{
result = result
.Where(x => x.Name.Contains(searchVal, StringComparison.InvariantCultureIgnoreCase)
|| x.Descript.Contains(searchVal, StringComparison.InvariantCultureIgnoreCase))
.ToList();
}
sw.Stop();
_logger.LogDebug($"TaskListAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
return result;
}
/// <summary>
/// Update ordinamento task
/// </summary>
/// <param name="rec2upd">Record da spostare x priorità</param>
/// <returns></returns>
public async Task<bool> TaskListMove(TaskListModel rec2upd, bool moveUp)
{
bool dbResult = dbController.TaskListMove(rec2upd, moveUp);
// svuoto cache!
await FlushCache("Task");
return await Task.FromResult(dbResult);
}
/// <summary>
/// Update/Insert record TaskList
/// </summary>
/// <param name="rec2upd"></param>
/// <returns></returns>
public async Task<bool> TaskListUpsert(TaskListModel rec2upd)
{
bool dbResult = dbController.TaskListUpsert(rec2upd);
// svuoto cache!
await FlushCache("Task");
return await Task.FromResult(dbResult);
}
#endregion Public Methods
+10 -3
View File
@@ -4,18 +4,24 @@
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>MP.Stats</RootNamespace>
<UserSecretsId>826e877c-ba70-4253-84cb-d0b1cafd4440</UserSecretsId>
<Version>6.16.2410.2318</Version>
<Version>6.16.2410.2318</Version>
<Version>6.16.2410.2810</Version>
<Version>6.16.2410.2810</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Components\TaskEdit.razor.cs" />
<Compile Remove="Components\TaskExeList.razor.cs" />
<Compile Remove="Components\TLResult.razor.cs" />
<Compile Remove="Pages\UserDecl.razor.cs" />
</ItemGroup>
<ItemGroup>
<Content Remove="compilerconfig.json" />
<Content Remove="Components\TaskEdit.razor" />
<Content Remove="Components\TaskExeList.razor" />
<Content Remove="Components\TLResult.razor" />
<Content Remove="Pages\UserDecl.razor" />
</ItemGroup>
@@ -32,6 +38,7 @@
<ItemGroup>
<ProjectReference Include="..\MP.Data\MP.Data.csproj" />
<ProjectReference Include="..\MP.TaskMan\MP.TaskMan.csproj" />
</ItemGroup>
<ItemGroup>
@@ -188,7 +195,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="EgwCoreLib.Razor" Version="1.5.2408.2710" />
<PackageReference Include="EgwCoreLib.Razor" Version="1.5.2409.2607" />
<PackageReference Include="ElmahCore" Version="2.1.2" />
<PackageReference Include="ElmahCore.Common" Version="2.1.2" />
<PackageReference Include="ElmahCore.Sql" Version="2.1.2" />
+1 -1
View File
@@ -123,7 +123,7 @@ namespace MP.Stats.Pages
{
isLoading = true;
// salvo davvero!
await MP.Data.Utils.SaveToCsv(SearchRecords, fullPath, ';');
await Egw.Core.Utils.SaveToCsv(SearchRecords, fullPath, ';');
isLoading = false;
}
+1 -1
View File
@@ -100,7 +100,7 @@ namespace MP.Stats.Pages
// recupero TUTTI i dati
var allRecords = await StatService.StatDdbGetAllExport(currFilter, MessageService.SearchVal);
// salvo davvero!
await MP.Data.Utils.SaveToCsv(allRecords, fullPath, ';');
await Egw.Core.Utils.SaveToCsv(allRecords, fullPath, ';');
isLoading = false;
}
+1 -1
View File
@@ -92,7 +92,7 @@ namespace MP.Stats.Pages
{
isLoading = true;
// salvo davvero!
await MP.Data.Utils.SaveToCsv(SearchRecords, fullPath, ';');
await Egw.Core.Utils.SaveToCsv(SearchRecords, fullPath, ';');
isLoading = false;
}
+1 -1
View File
@@ -124,7 +124,7 @@ namespace MP.Stats.Pages
isLoading = true;
// calcolo nome file
// salvo davvero!
await MP.Data.Utils.SaveToCsv(SearchRecords, fullPath, ';');
await Egw.Core.Utils.SaveToCsv(SearchRecords, fullPath, ';');
isLoading = false;
}
+1 -1
View File
@@ -92,7 +92,7 @@ namespace MP.Stats.Pages
{
isLoading = true;
// salvo davvero!
await MP.Data.Utils.SaveToCsv(SearchRecords, fullPath, ';');
await Egw.Core.Utils.SaveToCsv(SearchRecords, fullPath, ';');
isLoading = false;
}
+1 -1
View File
@@ -123,7 +123,7 @@ namespace MP.Stats.Pages
{
isLoading = true;
// salvo davvero!
await MP.Data.Utils.SaveToCsv(SearchRecords, fullPath, ';');
await Egw.Core.Utils.SaveToCsv(SearchRecords, fullPath, ';');
isLoading = false;
}
+1 -164
View File
@@ -1,166 +1,3 @@
@page "/TaskScheduler"
<div class="row">
<div class="@mainCss">
<div class="card shadow">
<div class="card-header table-primary p-1">
<div class="d-flex justify-content-between">
<div class="px-2">
<b class="fs-4">TaskList</b>
</div>
<div class="px-2">
<div class="input-group">
@if (currRecord == null)
{
<button class="btn btn-success" @onclick="addNew" title="Add New"><i class="fas fa-plus"></i> Add New</button>
}
else
{
<button class="btn btn-secondary" @onclick="doCancel" title="Cancel"><i class="fas fa-undo"></i> Cancel</button>
}
<select class="form-select" @bind="@TypeSel">
@foreach (var option in Enum.GetValues(typeof(MP.Data.Objects.Enums.Task2ExeType)))
{
<option value="@option">
@option
</option>
}
</select>
</div>
</div>
</div>
<TaskEdit CurrRecord="@currRecord" EC_update="forceUpdate"></TaskEdit>
</div>
<div class="card-body py-0 px-1">
@if (isLoading)
{
<ProgressDisplay DisplaySize="ProgressDisplay.ModalSize.Medium" ExpTimeMSec="@expTimeMsec" CurrVal="@currVal" NextVal="@nextVal" MaxVal="@MaxVal" Title="Task Processing" RefreshInterval="200"></ProgressDisplay>
<LoadingData Title="Elaborazione..." DisplayMode="LoadingData.SpinMode.BounceLine" DisplaySize="LoadingData.CtrlSize.Large"></LoadingData>
}
else if (ListRecords == null)
{
<LoadingData></LoadingData>
}
else if (totalCount == 0)
{
<div class="alert alert-warning text-center display-4">Nessun record trovato</div>
}
else
{
<div class="row">
<div class="col-12">
<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>
<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.TaskId)">
<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>
}
}
@record.Ordinal
@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">
<div>@record.Name</div>
<div class="small">@record.Descript</div>
</td>
<td>
@record.TType
</td>
<td>
<div>@record.Command</div>
<div class="small text-break">@record.Args</div>
</td>
<td>@record.Freq &times; @record.Cad</td>
@if (detRecord == null)
{
<td class="text-end text-nowrap">
<div>@($"{record.DtLastExec:yyyy-MM-dd}")</div>
<div class="small">@($"{record.DtLastExec:ddd HH:mm:ss}")</div>
</td>
<td class="text-end text-nowrap">
<div>@($"{record.DtNextExec:yyyy-MM-dd}")</div>
<div class="small">@($"{record.DtNextExec:ddd HH:mm:ss}")</div>
</td>
<td>
<TLResult CurrRecord="@record"></TLResult>
</td>
<td>
<button class="btn btn-sm @btnRunCss(record.DtNextExec) me-1" @onclick="()=>doRun(record)" title="Run Now"><i class="fas fa-play"></i></button>
</td>
}
</tr>
}
</tbody>
</table>
</div>
</div>
}
</div>
<div class="card-footer py-1">
<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" exportEnabled="false" exportRequested="ExportCsv" fileName="@fileName" totalCount="totalCount" showLoading="isLoading" />
</div>
</div>
</div>
@if (detRecord != null && !isLoading)
{
<div class="col-6">
<TaskExeList CurrRecord="detRecord"></TaskExeList>
</div>
}
</div>
<TaskList></TaskList>
+8 -326
View File
@@ -8,350 +8,32 @@ using System;
using System.Linq;
using StackExchange.Redis;
using MP.Data.DatabaseModels;
using static MP.Data.Objects.Enums;
using Microsoft.AspNetCore.DataProtection;
using MP.TaskMan.Models;
using static MP.TaskMan.Objects.Enums;
namespace MP.Stats.Pages
{
public partial class TaskScheduler : ComponentBase, IDisposable
public partial class TaskScheduler : ComponentBase
{
#region Public Methods
public string checkSelect(int TaskId)
{
string answ = "";
if (currRecord != null)
{
try
{
answ = (currRecord.TaskId == TaskId) ? "table-info" : "";
}
catch
{ }
}
else if (detRecord != null)
{
answ = (detRecord.TaskId == TaskId) ? "table-info" : "";
}
return answ;
}
public void Dispose()
{
MessageService.EA_SearchUpdated -= OnSeachUpdated;
}
public async void OnSeachUpdated()
{
await InvokeAsync(() =>
{
Task task = ReloadData();
StateHasChanged();
});
}
#endregion Public Methods
#region Protected Fields
protected string fileName = "TaskList.csv";
#endregion Protected Fields
#region Protected Properties
[Inject]
protected IJSRuntime JSRuntime { get; set; }
protected string mainCss
{
get => detRecord == null ? "col-12" : "col-6";
}
protected int maxOrdinal { get; set; } = 999;
[Inject]
protected MessageService MessageService { get; set; }
protected int minOrdinal { get; set; } = 0;
[Inject]
protected NavigationManager NavManager { get; set; }
[Inject]
protected MpStatsService StatService { get; set; }
protected int totalCount { get; set; } = 0;
protected Task2ExeType TypeSel
{
get => typeSel;
set
{
if (typeSel != value)
{
typeSel = value;
var pUpd = Task.Run(async () =>
{
await ReloadData();
});
pUpd.Wait();
}
}
}
protected MessageService MServ { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected async Task addNew()
protected override void OnInitialized()
{
currRecord = new TaskListModel() { Name = "Nuovo Task", Descript = "Descrizione", DtLastExec = DateTime.Today, DtNextExec = DateTime.Today.AddDays(1) };
await ReloadData();
}
/// <summary>
/// Gestione display avanzamento step
/// </summary>
/// <param name="currStep"></param>
protected async Task advStep(int currStep)
{
currVal = currStep;
nextVal = currVal + 1;
await InvokeAsync(StateHasChanged);
}
protected async Task doCancel()
{
currRecord = null;
detRecord = null;
await ReloadData();
}
protected async Task doEdit(TaskListModel selRec)
{
currRecord = selRec;
await ReloadData();
}
protected async Task doClone(TaskListModel selRec)
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Confermi di voler duplicare il record selezionato?"))
return;
currRecord = new TaskListModel()
{
Args = selRec.Args,
Name = $"Copia di {selRec.Name}",
Cad = selRec.Cad,
Command = selRec.Command,
Descript = $"Copia di {selRec.Descript}",
DtNextExec = DateTime.Today.AddDays(1),
DtLastExec = DateTime.MinValue,
Freq = selRec.Freq,
LastDuration = 0,
LastIsError = false,
LastResult = "",
TType = selRec.TType,
Ordinal = SearchRecords.Count + 1,
};
await ReloadData();
}
protected async Task doMove(TaskListModel currRec, bool goUp)
{
await StatService.TaskListMove(currRec, goUp);
detRecord = null;
currRecord = null;
await ReloadData();
}
protected async Task doReset()
{
detRecord = null;
currRecord = null;
await StatService.FlushCache();
await ReloadData();
}
protected async Task doRun(TaskListModel selRec)
{
// SE non è ancora scaduto chiedo conferma
if (selRec.DtNextExec > DateTime.Now)
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Confermi esecuzione forzata task non scaduto?{Environment.NewLine}[{selRec.TaskId}]: {selRec.Name} - {selRec.Descript}{Environment.NewLine}Prossima schedulazione: {selRec.DtNextExec:yyyy-MM-dd HH:mm:ss}"))
return;
}
// imposto tempo atteso esecuzione da ultimo...
isLoading = true;
MaxVal = 4;
int currStep = 0;
await advStep(currStep);
expTimeMsec = (int)(1000 * selRec.LastDuration) / 4;
detRecord = null;
await advStep(currStep++);
await Task.Delay(100);
await advStep(currStep++);
// chiama esecuzione task
var result = await StatService.ExecuteTask(selRec.TaskId, false);
await advStep(currStep++);
isLoading = false;
await Task.Delay(100);
await advStep(currStep++);
await ReloadData();
}
protected async Task doSelect(TaskListModel selRec)
{
detRecord = null;
currRecord = null;
isLoading = true;
detRecord = selRec;
await ReloadData();
isLoading = false;
}
protected async Task forceAll()
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Confermi esecuzione forzata di tutti i task?"))
return;
isLoading = true;
detRecord = null;
await Task.Delay(100);
foreach (var taskRec in SearchRecords)
{
var result = await StatService.ExecuteTask(taskRec.TaskId, false);
}
isLoading = false;
await Task.Delay(100);
await ReloadData();
}
protected async Task ForceReload(int newNum)
{
numRecord = newNum;
await ReloadData();
}
protected async Task ForceReloadPage(int newNum)
{
currPage = newNum;
await ReloadData();
}
protected async Task forceUpdate(bool doForce)
{
currRecord = null;
await ReloadData();
}
protected override async Task OnInitializedAsync()
{
clearFile();
numRecord = 10;
MessageService.ShowSearch = false;
MessageService.PageName = "Task Scheduler";
MessageService.PageIcon = "oi oi-clock";
MessageService.EA_SearchUpdated += OnSeachUpdated;
await ReloadData();
}
protected void ResetData()
{
clearFile();
StatService.rollBackEdit(currRecord);
currRecord = null;
}
protected async Task ResetFilter(SelectData newFilter)
{
clearFile();
detRecord = null;
currRecord = null;
SearchRecords = null;
ListRecords = null;
await ReloadData();
}
protected double righDiv(double num, double den)
{
if (den == 0)
{
den = 1;
}
double answ = num / den;
return answ;
MServ.ShowSearch = true;
MServ.PageName = "Task Scheduler";
MServ.PageIcon = "oi oi-clock";
}
#endregion Protected Methods
#region Private Fields
private double currVal = 0;
private List<TaskListModel> ListRecords;
private int MaxVal = 10;
private double nextVal = 0;
private List<TaskListModel> SearchRecords;
#endregion Private Fields
#region Private Properties
private int currPage { get; set; } = 1;
private TaskListModel currRecord { get; set; } = null;
private TaskListModel detRecord { get; set; } = null;
private int expTimeMsec { get; set; } = 30000;
private string fullPath
{
get => $"{Directory.GetCurrentDirectory()}\\temp\\{fileName}";
}
private bool isLoading { get; set; } = false;
private int numRecord { get; set; } = 10;
private Task2ExeType typeSel { get; set; } = Task2ExeType.ND;
#endregion Private Properties
#region Private Methods
private string btnRunCss(DateTime dtNextExe)
{
DateTime adesso = DateTime.Now;
string answ = dtNextExe < adesso ? "btn-success" : "btn-warning";
return answ;
}
private async void clearFile()
{
await Task.Run(() => File.Delete(fullPath));
}
private async Task ExportCsv()
{
isLoading = true;
// salvo davvero!
await MP.Data.Utils.SaveToCsv(SearchRecords, fullPath, ';');
isLoading = false;
}
private async Task ReloadData()
{
SearchRecords = await StatService.TaskListAll(TypeSel, "");
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();
}
#endregion Private Methods
}
}
+1 -1
View File
@@ -118,7 +118,7 @@ namespace MP.Stats.Pages
{
isLoading = true;
// salvo davvero!
await MP.Data.Utils.SaveToCsv(SearchRecords, fullPath, ';');
await Egw.Core.Utils.SaveToCsv(SearchRecords, fullPath, ';');
isLoading = false;
}
+3 -3
View File
@@ -25,9 +25,9 @@ namespace MP.Stats
{
logging.ClearProviders();
logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Information);
//logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
})
.UseNLog();
// importante per eseguire la conf logging
.UseNLog(new NLogAspNetCoreOptions() { RemoveLoggerFactoryFilter = false });
public static void Main(string[] args)
{
@@ -47,7 +47,7 @@ namespace MP.Stats
}
finally
{
NLog.LogManager.Shutdown();
LogManager.Shutdown();
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo statistiche MAPO</i>
<h4>Versione: 6.16.2410.2318</h4>
<h4>Versione: 6.16.2410.2810</h4>
<br />
Note di rilascio:
<ul>
+1 -1
View File
@@ -1 +1 @@
6.16.2410.2318
6.16.2410.2810
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2410.2318</version>
<version>6.16.2410.2810</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>
+3
View File
@@ -7,6 +7,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
using MP.Stats.Data;
using MP.TaskMan.Services;
using StackExchange.Redis;
using System;
using System.Globalization;
@@ -142,6 +143,8 @@ namespace MP.Stats
services.AddSingleton<IConfiguration>(Configuration);
services.AddSingleton<MpStatsService>();
services.AddSingleton<TaskService>();
services.AddScoped<MessageService>();
}
+2
View File
@@ -10,4 +10,6 @@
@using MP.Stats.Shared
@using MP.Stats.Components
@using MP.Stats.Components.ChartJs
@using MP.TaskMan
@using MP.TaskMan.Models
@using EgwCoreLib.Razor
+7 -1
View File
@@ -55,5 +55,11 @@
"DefaultConnection": "Server=SQL2016DEV;Database=MoonPro_STATS;Trusted_Connection=True;MultipleActiveResultSets=true",
"MP.Stats": "Server=SQL2016DEV;Database=MoonPro_STATS;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=MP.STATS;"
},
"FormatDur": "HH:mm.ss.ff"
"FormatDur": "HH:mm.ss.ff",
"SpecialConf": {
"TaskManConn": "MP.Stats"
},
"ServerConf": {
"Prog.ApiUrl": "https://localhost/MP/STATS"
}
}
+420
View File
@@ -0,0 +1,420 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using MP.TaskMan.Models;
using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static MP.TaskMan.Objects.Enums;
namespace MP.TaskMan.Controllers
{
public class MpTaskController: IDisposable
{
public MpTaskController(IConfiguration configuration)
{
_configuration = configuration;
Log.Info("Avviato MpTaskController");
}
private static IConfiguration _configuration;
private static Logger Log = LogManager.GetCurrentClassLogger();
public DateTime CalcNextExe(TaskListModel taskRec)
{
DateTime dtNext = DateTime.Today;
try
{
// calcolo next exec da tipo...
switch (taskRec.Freq)
{
case TaskFreqType.ND:
dtNext = taskRec.DtLastExec.AddDays(taskRec.Cad);
break;
case TaskFreqType.Sec:
dtNext = taskRec.DtLastExec.AddSeconds(taskRec.Cad);
break;
case TaskFreqType.Min:
dtNext = taskRec.DtLastExec.AddMinutes(taskRec.Cad);
break;
case TaskFreqType.Hour:
dtNext = taskRec.DtLastExec.AddHours(taskRec.Cad);
break;
case TaskFreqType.Day:
dtNext = taskRec.DtLastExec.AddDays(taskRec.Cad);
break;
case TaskFreqType.Week:
dtNext = taskRec.DtLastExec.AddDays(7 * taskRec.Cad);
break;
case TaskFreqType.Month:
dtNext = taskRec.DtLastExec.AddMonths(taskRec.Cad);
break;
case TaskFreqType.Year:
dtNext = taskRec.DtLastExec.AddYears(taskRec.Cad);
break;
default:
dtNext = taskRec.DtLastExec.AddDays(taskRec.Cad);
break;
}
}
catch (Exception exc)
{
Log.Error($"Eccezione in CalcNextExe{Environment.NewLine}{exc}");
}
return dtNext;
}
public void Dispose()
{
_configuration = null;
}
/// <summary>
/// Chiamata esecuzione di un singolo task programmato
/// </summary>
/// <param name="TaskId"></param>
/// <param name="SchedNext">Se true rischedula successiva chiamata</param>
/// <returns></returns>
public TaskResultModel ExecuteSqlTask(int TaskId, bool SchedNext)
{
TaskResultModel callRes = new TaskResultModel();
using (var dbCtx = new TaskContext(_configuration))
{
// imposto timeout a 5 min
//var currTimeout = dbCtx.Database.GetCommandTimeout();
dbCtx.Database.SetCommandTimeout(TimeSpan.FromMinutes(5));
try
{
DateTime dtStart = DateTime.Now;
// recupero i dati da richiamare...
var currRec = dbCtx
.DbSetTaskList
.Where(x => x.TaskId == TaskId)
.FirstOrDefault();
if (currRec != null)
{
// recupero comando
string sqlCommand = currRec.Command;
string rawParams = currRec.Args;
callRes = dbCtx
.DbSetTaskResult
.FromSqlRaw($"EXEC {sqlCommand} {rawParams}")
.AsNoTracking()
.AsEnumerable()
.FirstOrDefault();
DateTime dtEnd = DateTime.Now;
// preparo record esecuzione...
TaskExecModel resRec = new TaskExecModel()
{
TaskId = TaskId,
DtStart = dtStart,
DtEnd = dtEnd,
IsError = callRes.ExecResult < 0,
Result = callRes.TextResult
};
dbCtx
.DbSetTaskExe
.Add(resRec);
// aggiorno record chiamata...
currRec.DtLastExec = dtStart;
currRec.LastResult = resRec.Result;
currRec.LastIsError = resRec.IsError;
currRec.LastDuration = dtEnd.Subtract(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 ExecuteSqlCommand{Environment.NewLine}{exc}");
}
}
return callRes;
}
/// <summary>
/// Annulla modifiche su una specifica entity (cancel update)
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public bool RollBackEntity(object item)
{
bool answ = false;
using (var dbCtx = new TaskContext(_configuration))
{
try
{
if (dbCtx.Entry(item).State == Microsoft.EntityFrameworkCore.EntityState.Deleted || dbCtx.Entry(item).State == Microsoft.EntityFrameworkCore.EntityState.Modified)
{
dbCtx.Entry(item).Reload();
}
}
catch (Exception exc)
{
Log.Error($"Eccezione in rollBackEntity{Environment.NewLine}{exc}");
}
}
return answ;
}
/// <summary>
/// Ricerca task dato tipo + num max (desc)
/// </summary>
/// <param name="TaskId">TaskId da cui deriva</param>
/// <returns></returns>
public List<TaskExecModel> TaskExecGetFilt(int TaskId, int maxRec)
{
List<TaskExecModel> dbResult = new List<TaskExecModel>();
using (var dbCtx = new TaskContext(_configuration))
{
dbResult = dbCtx
.DbSetTaskExe
.Include(x => x.TaskListNav)
.Where(x => (x.TaskId == TaskId))
.OrderByDescending(x => x.DtStart)
.Take(maxRec)
.ToList();
}
return dbResult;
}
/// <summary>
/// Upsert record TaskExec
/// </summary>
/// <param name="rec2upd">Record da aggiornare/inserire</param>
/// <returns></returns>
public bool TaskExecUpsert(TaskExecModel rec2upd)
{
bool done = false;
using (var dbCtx = new TaskContext(_configuration))
{
try
{
var currData = dbCtx
.DbSetTaskExe
.Where(x => x.TaskExecId == rec2upd.TaskExecId)
.FirstOrDefault();
if (currData != null)
{
currData.TaskId = rec2upd.TaskId;
currData.DtStart = rec2upd.DtStart;
currData.DtEnd = rec2upd.DtEnd;
currData.IsError = rec2upd.IsError;
currData.Result = rec2upd.Result;
dbCtx.Entry(currData).State = EntityState.Modified;
}
else
{
dbCtx
.DbSetTaskExe
.Add(rec2upd);
}
dbCtx.SaveChanges();
done = true;
}
catch (Exception exc)
{
Log.Error($"Eccezione in TaskExecUpsert{Environment.NewLine}{exc}");
}
}
return done;
}
/// <summary>
/// Ricerca task dato tipo e
/// </summary>
/// <param name="TType"></param>
/// <returns></returns>
public List<TaskListModel> TaskListGetAll(Task2ExeType TType)
{
List<TaskListModel> dbResult = new List<TaskListModel>();
using (var dbCtx = new TaskContext(_configuration))
{
dbResult = dbCtx
.DbSetTaskList
.Where(x => (TType == Task2ExeType.ND || x.TType == TType))
.OrderBy(x => x.Ordinal)
.ToList();
}
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>
/// <param name="rec2upd">Record da spostare x priorità</param>
/// <returns></returns>
public bool TaskListMove(TaskListModel rec2upd, bool moveUp)
{
bool done = false;
using (var dbCtx = new TaskContext(_configuration))
{
try
{
var currData = dbCtx
.DbSetTaskList
.Where(x => x.TaskId == rec2upd.TaskId)
.FirstOrDefault();
if (currData != null)
{
int actOrdinal = currData.Ordinal;
TaskListModel? otherRec = null;
// cerco, secondo richiesta, precedente o successivo
if (moveUp)
{
otherRec = dbCtx
.DbSetTaskList
.Where(x => x.Ordinal < currData.Ordinal)
.OrderByDescending(x => x.Ordinal)
.FirstOrDefault();
}
else
{
otherRec = dbCtx
.DbSetTaskList
.Where(x => x.Ordinal > currData.Ordinal)
.OrderBy(x => x.Ordinal)
.FirstOrDefault();
}
// inverto ordinale SE ho record
if (otherRec != null)
{
currData.Ordinal = otherRec.Ordinal;
otherRec.Ordinal = actOrdinal;
dbCtx.Entry(currData).State = EntityState.Modified;
dbCtx.Entry(otherRec).State = EntityState.Modified;
}
}
//salvo
dbCtx.SaveChanges();
done = true;
}
catch (Exception exc)
{
Log.Error($"Eccezione in TaskListUpsert{Environment.NewLine}{exc}");
}
}
return done;
}
/// <summary>
/// Upsert record TaskList
/// </summary>
/// <param name="rec2upd">Record da aggiornare/inserire</param>
/// <returns></returns>
public bool TaskListUpsert(TaskListModel rec2upd)
{
bool done = false;
using (var dbCtx = new TaskContext(_configuration))
{
try
{
var currData = dbCtx
.DbSetTaskList
.Where(x => x.TaskId == rec2upd.TaskId && rec2upd.TaskId > 0)
.FirstOrDefault();
if (currData != null)
{
currData.Ordinal = rec2upd.Ordinal;
currData.Name = rec2upd.Name;
currData.Descript = rec2upd.Descript;
currData.Command = rec2upd.Command;
currData.Args = rec2upd.Args;
currData.Freq = rec2upd.Freq;
currData.Cad = rec2upd.Cad;
currData.DtLastExec = rec2upd.DtLastExec;
currData.DtNextExec = rec2upd.DtNextExec;
currData.LastDuration = rec2upd.LastDuration;
currData.LastResult = rec2upd.LastResult;
dbCtx.Entry(currData).State = EntityState.Modified;
}
else
{
dbCtx
.DbSetTaskList
.Add(rec2upd);
}
dbCtx.SaveChanges();
done = true;
}
catch (Exception exc)
{
Log.Error($"Eccezione in TaskListUpsert{Environment.NewLine}{exc}");
}
}
return done;
}
}
}
+37
View File
@@ -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();
}
}
}
}
+46
View File
@@ -0,0 +1,46 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<SupportedPlatform Include="browser" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="EgwCoreLib.Razor" Version="1.5.2409.2607" />
<PackageReference Include="EgwCoreLib.Utils" Version="1.5.2409.2607" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.33" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.33" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.33">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.33" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.33" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
<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="Migrations\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Egw.Core\Egw.Core.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="TaskList.razor">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
</ItemGroup>
</Project>
@@ -0,0 +1,123 @@
// <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("20241028095512_InitTaskMan")]
partial class InitTaskMan
{
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<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,75 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace MP.TaskMan.Migrations
{
public partial class InitTaskMan : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "TaskList",
columns: table => new
{
TaskId = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Ordinal = table.Column<int>(type: "int", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
Descript = table.Column<string>(type: "nvarchar(max)", nullable: true),
TType = table.Column<int>(type: "int", nullable: false),
Command = table.Column<string>(type: "nvarchar(max)", nullable: true),
Args = table.Column<string>(type: "nvarchar(max)", nullable: true),
Freq = table.Column<int>(type: "int", nullable: false),
Cad = table.Column<int>(type: "int", nullable: false),
DtLastExec = table.Column<DateTime>(type: "datetime2", nullable: false),
DtNextExec = table.Column<DateTime>(type: "datetime2", nullable: false),
LastDuration = table.Column<double>(type: "float", nullable: false),
LastIsError = table.Column<bool>(type: "bit", nullable: false),
LastResult = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_TaskList", x => x.TaskId);
});
migrationBuilder.CreateTable(
name: "TaskExec",
columns: table => new
{
TaskExecId = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
TaskId = table.Column<int>(type: "int", nullable: false),
DtStart = table.Column<DateTime>(type: "datetime2", nullable: false),
DtEnd = table.Column<DateTime>(type: "datetime2", nullable: false),
IsError = table.Column<bool>(type: "bit", nullable: false),
Result = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_TaskExec", x => x.TaskExecId);
table.ForeignKey(
name: "FK_TaskExec_TaskList_TaskId",
column: x => x.TaskId,
principalTable: "TaskList",
principalColumn: "TaskId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_TaskExec_TaskId",
table: "TaskExec",
column: "TaskId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "TaskExec");
migrationBuilder.DropTable(
name: "TaskList");
}
}
}
@@ -0,0 +1,121 @@
// <auto-generated />
using System;
using MP.TaskMan;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace MP.TaskMan.Migrations
{
[DbContext(typeof(TaskContext))]
partial class TaskContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(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<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
}
}
}
+63
View File
@@ -0,0 +1,63 @@
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.TaskMan.Models
{
[Table("TaskExec")]
public partial class TaskExecModel
{
#region Public Properties
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int TaskExecId { get; set; } = 0;
/// <summary>
/// task Id di riferimento
/// </summary>
public int TaskId { get; set; } = 0;
/// <summary>
/// DataOra inizio
/// </summary>
public DateTime DtStart { get; set; } = DateTime.Now;
/// <summary>
/// DataOra fine
/// </summary>
public DateTime DtEnd { get; set; } = DateTime.Now.AddDays(-1);
/// <summary>
/// Durata ultima esecuzione in secondi
/// </summary>
[NotMapped]
public double Duration
{
get => DtEnd.Subtract(DtStart).TotalSeconds;
}
/// <summary>
/// Esito in Errore
/// </summary>
public bool IsError { get; set; } = false;
/// <summary>
/// Ultimo risultato registrato
/// </summary>
public string Result { get; set; } = "";
/// <summary>
/// Navigazione oggetto TaskList
/// </summary>
[ForeignKey("TaskId")]
public virtual TaskListModel TaskListNav { get; set; } = null!;
#endregion Public Properties
}
}
+87
View File
@@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using static MP.TaskMan.Objects.Enums;
#nullable disable
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
namespace MP.TaskMan.Models
{
[Table("TaskList")]
public partial class TaskListModel
{
#region Public Properties
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int TaskId { get; set; } = 0;
/// <summary>
/// Ordinale x esecuzione
/// </summary>
public int Ordinal { get; set; } = 0;
/// <summary>
/// Nome Task
/// </summary>
public string Name { get; set; } = "";
/// <summary>
/// Descrizione Task
/// </summary>
public string Descript { get; set; } = "";
/// <summary>
/// Tipo Task
/// </summary>
public Task2ExeType TType { get; set; } = Task2ExeType.ND;
/// <summary>
/// Comando da invocare
/// </summary>
public string Command { get; set; } = "";
/// <summary>
/// Elenco argomenti (json)
/// </summary>
public string Args { get; set; } = "";
/// <summary>
/// Frequenza esecuzione da enum
/// </summary>
public TaskFreqType Freq { get; set; } = TaskFreqType.ND;
/// <summary>
/// Cadenza esecuzione
/// </summary>
public int Cad { get; set; } = 1;
/// <summary>
/// DataOra ultima esecuzione
/// </summary>
public DateTime DtLastExec { get; set; } = DateTime.Today.AddYears(-10);
/// <summary>
/// DataOra ultima esecuzione
/// </summary>
public DateTime DtNextExec { get; set; } = DateTime.Today.AddYears(-9);
/// <summary>
/// Durata ultima esecuzione in secondi
/// </summary>
public double LastDuration { get; set; } = 0;
/// <summary>
/// Esito ultima esecuzione in Errore
/// </summary>
public bool LastIsError { get; set; } = false;
/// <summary>
/// Ultimo risultato registrato
/// </summary>
public string LastResult { get; set; } = "";
#endregion Public Properties
}
}
+37
View File
@@ -0,0 +1,37 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using static MP.TaskMan.Objects.Enums;
#nullable disable
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
namespace MP.TaskMan.Models
{
[NotMapped]
public partial class TaskResultModel
{
#region Public Properties
/// <summary>
/// Tipo di task eseguito
/// </summary>
public string Task { get; set; } = "";
/// <summary>
/// Risultato: >0 = successo, <0 = errore
/// </summary>
public int ExecResult { get; set; } = 0;
/// <summary>
/// Risultato esecuzione testuale
/// </summary>
public string TextResult { get; set; } = "";
#endregion Public Properties
}
}
+216
View File
@@ -0,0 +1,216 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace MP.TaskMan.Objects
{
public class Enums
{
#region Public Enums
/// <summary>
/// Intervallo dati (es per definizione quanti dati FluxLog tenere x intervallo
/// </summary>
public enum DataInterval
{
minute,
hour,
day
}
public enum DataItemCategory
{
CONDITION = 0,
EVENT = 1,
SAMPLE = 2
}
/// <summary>
/// Tipo di esito (generico)
/// </summary>
public enum esitoExec
{
undone,
ok,
error
}
//[JsonConverter(typeof(StringEnumConverter))]
public enum Task2ExeType
{
/// <summary>
/// Tipo indefinito / ALL
/// </summary>
ND,
/// <summary>
/// Chiamata exe esterno
/// </summary>
Exe,
/// <summary>
/// Chiamata a SQL Command
/// </summary>
SqlCommand,
/// <summary>
/// Chiamata a SQL Stored Procedure
/// </summary>
SqlStored,
/// <summary>
/// Chiamata REST tipo Get
/// </summary>
RestCallGet,
///// <summary>
///// Chiamata REST tipo Post
///// </summary>
//RestCallPost
}
//[JsonConverter(typeof(StringEnumConverter))]
public enum TaskFreqType
{
/// <summary>
/// Tipo indefinito / ALL
/// </summary>
ND,
/// <summary>
/// Secondi
/// </summary>
Sec,
/// <summary>
/// Minuti
/// </summary>
Min,
/// <summary>
/// Ore
/// </summary>
Hour,
/// <summary>
/// Giorni
/// </summary>
Day,
/// <summary>
/// Settimane
/// </summary>
Week,
/// <summary>
/// Mesi
/// </summary>
Month,
/// <summary>
/// Anni
/// </summary>
Year
}
/// <summary>
/// Elenco task ammessi (x IOB-WIN da eseguire...)
/// </summary>
public enum taskType
{
/// <summary>
/// Task nullo / fake
/// </summary>
nihil,
/// <summary>
/// Rimanda a PLC eventuale segnale NON in setup (MA NON RESETTA)
/// </summary>
fixStopSetup,
/// <summary>
/// Indica al PLC di forzare il reset del contapezzi
/// </summary>
forceResetPzCount,
/// <summary>
/// Indica al PLC di forzare il NUOVO valore di contapezzi (impostato come value)
/// </summary>
forceSetPzCount,
/// <summary>
/// Imposta Articolo su PLC
/// </summary>
setArt,
/// <summary>
/// Imposta Commessa su PLC
/// </summary>
setComm,
/// <summary>
/// Set di un PARAMETRO su PLC (in value avremo un JSON object)
/// </summary>
setParameter,
/// <summary>
/// Set Programma CNC su PLC
/// </summary>
setProg,
/// <summary>
/// Indica al PLC di impostare il numero di pezzi da produrre per la commessa (impostato
/// come value)
/// </summary>
setPzComm,
/// <summary>
/// Indica al PLC iniziato setup (e secondo casi ferma contapezzi /resetta)
/// </summary>
startSetup,
/// <summary>
/// Indica al PLC finito setup (e secondo casi ferma contapezzi /resetta)
/// </summary>
stopSetup,
/// <summary>
/// Richiesta invio watchdog a PLC
/// </summary>
sendWatchDogMes2Plc,
/// <summary>
/// Indica che è FINITA la produzione (e quindi cancello dati backup)
/// </summary>
endProd,
/// <summary>
/// Richiesta esecuzione di un sync dei dati DB di frontiera
/// </summary>
syncDbData,
/// <summary>
/// Imposta Fornitore (es grower x ICOEL)
/// </summary>
setSupplier,
/// <summary>
/// Effettua processing other info (es ritorno consumi x ricette FIMAT)
/// </summary>
processOtherInfo
}
/// <summary>
/// Finestra temporale di aggregazione dati VC
/// </summary>
public enum timeWindow
{
free,
hour,
day,
week,
month
}
#endregion Public Enums
}
}
+70
View File
@@ -0,0 +1,70 @@
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MP.TaskMan.Services
{
/// <summary>
/// Classe di partenza x costruzione servizi di accesso dati + cache
/// </summary>
public class BaseServ
{
#region Protected Properties
/// <summary>
/// Durata cache breve (1 min circa + perturbazione percentuale +/-10%)
/// </summary>
protected TimeSpan FastCache
{
get => TimeSpan.FromSeconds(cacheTtlShort * rnd.Next(900, 1100) / 1000);
}
/// <summary>
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
/// </summary>
protected TimeSpan LongCache
{
get => TimeSpan.FromSeconds(cacheTtlLong * rnd.Next(900, 1100) / 1000);
}
/// <summary>
/// Durata cache MOLTO breve (10 sec circa + perturbazione percentuale +/-10%)
/// </summary>
protected TimeSpan UltraFastCache
{
get => TimeSpan.FromSeconds(cacheTtlShort / 6 * rnd.Next(900, 1100) / 1000);
}
/// <summary>
/// Durata cache MOLTO lunga (+ perturbazione percentuale +/-10%)
/// </summary>
protected TimeSpan UltraLongCache
{
get => TimeSpan.FromSeconds(cacheTtlLong * 10 * rnd.Next(900, 1100) / 1000);
}
#endregion Protected Properties
protected static IConfiguration _configuration = null!;
#region Private Fields
/// <summary>
/// Durata cache lunga IN SECONDI
/// </summary>
private int cacheTtlLong = 60 * 5;
/// <summary>
/// Durata cache breve IN SECONDI
/// </summary>
private int cacheTtlShort = 60 * 1;
private Random rnd = new Random();
#endregion Private Fields
}
}
+26
View File
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MP.TaskMan.Services
{
public class ReloadEventArgs : EventArgs
{
#region Public Constructors
public ReloadEventArgs(string messaggio)
{
this.ReloadMessage = messaggio;
}
#endregion Public Constructors
#region Public Properties
public string ReloadMessage { get; set; } = "";
#endregion Public Properties
}
}
@@ -11,7 +11,7 @@ using System.Threading.Tasks;
using System.Web;
using static System.Net.Mime.MediaTypeNames;
namespace MP.AppAuth.Services
namespace MP.TaskMan.Services
{
public class RestCallService
{
@@ -1,8 +1,7 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
using MP.AppAuth.Services;
using MP.Data.Controllers;
using MP.Data.DatabaseModels;
using MP.TaskMan.Controllers;
using MP.TaskMan.Models;
using Newtonsoft.Json;
using NLog;
using StackExchange.Redis;
@@ -12,9 +11,9 @@ using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static MP.Data.Objects.Enums;
using static MP.TaskMan.Objects.Enums;
namespace MP.Data.Services
namespace MP.TaskMan.Services
{
public class TaskService : BaseServ, IDisposable
{
@@ -32,8 +31,9 @@ namespace MP.Data.Services
redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
redisDb = redisConn.GetDatabase();
// conf DB
ConnStr = _configuration.GetConnectionString("MP.All");
// ConnString del DB x gestione task
string taskDbCS = _configuration.GetValue<string>("SpecialConf:TaskManConn");
ConnStr = _configuration.GetConnectionString(taskDbCS);
if (string.IsNullOrEmpty(ConnStr))
{
Log.Error("ConnString empty!");
@@ -41,11 +41,11 @@ namespace MP.Data.Services
else
{
StringBuilder sb = new StringBuilder();
MLController = new MpLandController(configuration);
sb.AppendLine($"TaskService | MpLandController OK");
MLController = new MpTaskController(configuration);
sb.AppendLine($"TaskService | MpTaskController OK");
Log.Info(sb.ToString());
// sistemo i parametri x redHas...
CodModulo = _configuration.GetValue<string>("ServerConf:CodModulo");
CodModulo = _configuration.GetValue<string>("SpecialConf:CodModulo");
var cstringArray = ConnStr.Split(";");
foreach (var item in cstringArray)
{
@@ -330,7 +330,7 @@ namespace MP.Data.Services
#region Private Properties
private static MpLandController MLController { get; set; } = null!;
private static MpTaskController MLController { get; set; } = null!;
private RestCallService RCallService { get; set; } = null!;
#endregion Private Properties
+133
View File
@@ -0,0 +1,133 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.Extensions.Configuration;
using MP.TaskMan.Models;
using NLog;
#nullable disable
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
namespace MP.TaskMan
{
public partial class TaskContext : DbContext
{
#region Private Fields
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
private IConfiguration _configuration;
#endregion Private Fields
#region Public Constructors
private bool DesignTime = false;
[Obsolete("Impiegato solo x DB migrations", false)]
public TaskContext()
{
#if DEBUG
DesignTime = true;
#endif
}
public TaskContext(IConfiguration configuration)
{
_configuration = configuration;
}
public TaskContext(DbContextOptions<TaskContext> options) : base(options)
{
}
#endregion Public Constructors
#region Public Properties
public virtual DbSet<TaskListModel> DbSetTaskList { get; set; }
public virtual DbSet<TaskExecModel> DbSetTaskExe { get; set; }
public virtual DbSet<TaskResultModel> DbSetTaskResult { get; set; }
#endregion Public Properties
#region Private Methods
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
#endregion Private Methods
#region Protected Methods
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
string connString = "";
if (DesignTime)
{
connString = "Server=SQL2016DEV; Database=MoonPro_PROG; Trusted_Connection=True;";
}
else
{
// recupero la connString tra i candidati...
connString = ConnStringGetFirst();
}
// avvio con stringa connessione trovata
optionsBuilder.UseSqlServer(connString);
//optionsBuilder.UseSqlServer("Server=SQL2016DEV; Database=MoonPro_PROG; Trusted_Connection=True;");
}
}
/// <summary>
/// Cerca la connString del DB usato da stats basandosi sull'elenco dei nomi delle chaivi da cercare, dalle + specifiche alle più generiche
/// </summary>
/// <returns></returns>
private string ConnStringGetFirst()
{
// in primis cerco se c'è la conf di quale connString usare per il programma specifico
string scTaskConn = _configuration.GetValue<string>("SpecialConf:TaskManConn");
string connString = _configuration.GetConnectionString(scTaskConn);
// altrimenti ciclo tra le conf alternative standard la + specifica
if (string.IsNullOrEmpty(connString))
{
foreach (var keyName in ConnStringList)
{
connString = _configuration.GetConnectionString(keyName);
if (!string.IsNullOrEmpty(connString))
{
break;
}
}
}
return connString;
}
/// <summary>
/// Elenco dei nomi delle connString da provare x il DB di riferimento qualora non specificato in conf
/// </summary>
protected List<string> ConnStringList { get; set; } = new List<string>()
{
"MP.TaskMan",
"MP.STATS",
"MP.SPEC",
"MP.Land",
"MP.Mon",
"MP.Data",
"MP.All"
};
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS");
OnModelCreatingPartial(modelBuilder);
}
#endregion Protected Methods
}
}
@@ -11,7 +11,7 @@
<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)))
@foreach (var option in Enum.GetValues(typeof(MP.TaskMan.Objects.Enums.Task2ExeType)))
{
<option value="@option">
@option
@@ -30,7 +30,7 @@
@* <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)))
@foreach (var option in Enum.GetValues(typeof(MP.TaskMan.Objects.Enums.TaskFreqType)))
{
<option value="@option">
@option
@@ -77,7 +77,7 @@
<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)))
@foreach (var option in Enum.GetValues(typeof(MP.TaskMan.Objects.Enums.TaskFreqType)))
{
<option value="@option">
@option
@@ -1,9 +1,8 @@
using Microsoft.AspNetCore.Components;
using MP.Data.DatabaseModels;
using MP.Data.Services;
using System.Threading.Tasks;
using MP.TaskMan.Models;
using MP.TaskMan.Services;
namespace MP.Land.Components
namespace MP.TaskMan
{
public partial class TaskEdit
{
@@ -20,7 +19,7 @@ namespace MP.Land.Components
#region Protected Properties
[Inject]
protected TaskService TService { get; set; }
protected TaskService TService { get; set; } = null!;
#endregion Protected Properties
@@ -1,8 +1,6 @@
using MailKit;
using Microsoft.AspNetCore.Components;
using MongoDB.Bson;
using MP.Data.DatabaseModels;
using MP.Data.Services;
using MP.TaskMan.Models;
using MP.TaskMan.Services;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NLog;
@@ -11,7 +9,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace MP.Land.Components
namespace MP.TaskMan
{
public partial class TaskExeList
{
@@ -31,7 +29,7 @@ namespace MP.Land.Components
#region Protected Properties
[Inject]
protected NavigationManager NavManager { get; set; }
protected NavigationManager NavManager { get; set; } = null!;
/// <summary>
/// Show error mode: 0 = tutti 1 = solo errori 2 = solo ok
@@ -53,7 +51,7 @@ namespace MP.Land.Components
protected int totalCount { get; set; } = 0;
[Inject]
protected TaskService TService { get; set; }
protected TaskService TService { get; set; } = null!;
#endregion Protected Properties
+190
View File
@@ -0,0 +1,190 @@
<div class="row">
<div class="@mainCss">
<div class="card shadow">
<div class="card-header table-primary p-1">
<div class="d-flex justify-content-between">
<div class="px-2">
<b class="fs-4">TaskList</b>
</div>
<div class="px-2">
<div class="input-group">
@if (TypeSel != MP.TaskMan.Objects.Enums.Task2ExeType.ND)
{
@if (currRecord == null)
{
<button class="btn btn-success" @onclick="addNew" title="Add New"><i class="fas fa-plus"></i> Add New</button>
}
else
{
<button class="btn btn-secondary" @onclick="doCancel" title="Cancel"><i class="fas fa-undo"></i> Cancel</button>
}
}
else
{
<button class="btn btn-outline-secondary">Sel &rarr;</button>
}
<select class="form-select" @bind="@TypeSel">
@foreach (var option in Enum.GetValues(typeof(MP.TaskMan.Objects.Enums.Task2ExeType)))
{
<option value="@option">
@option
</option>
}
</select>
</div>
</div>
</div>
<TaskEdit CurrRecord="@currRecord" EC_update="forceUpdate"></TaskEdit>
</div>
<div class="card-body py-0 px-1">
@if (isLoading)
{
<ProgressDisplay DisplaySize="ProgressDisplay.ModalSize.Medium" ExpTimeMSec="@expTimeMsec" CurrVal="@currVal" NextVal="@nextVal" MaxVal="@MaxVal" Title="Task Processing" RefreshInterval="200"></ProgressDisplay>
<LoadingData Title="Elaborazione..." DisplayMode="LoadingData.SpinMode.BounceLine" DisplaySize="LoadingData.CtrlSize.Large"></LoadingData>
}
else if (ListRecords == null)
{
<LoadingData></LoadingData>
}
else if (totalCount == 0)
{
<div class="alert alert-warning text-center display-4">Nessun record trovato</div>
}
else
{
<div class="row">
<div class="col-12">
<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.TaskId)">
<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>
}
}
@record.Ordinal
@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">
<div>@record.Name</div>
<div class="small text-truncate">@record.Descript</div>
</td>
<td>
@record.TType
</td>
@if (detRecord == null)
{
<td class="small text-truncate text-break">
<div 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 &times; @record.Cad</td>
@if (detRecord == null)
{
<td class="text-end text-nowrap">
<div>@($"{record.DtLastExec:yyyy-MM-dd}")</div>
<div class="small">@($"{record.DtLastExec:ddd HH:mm:ss}")</div>
</td>
<td class="text-end text-nowrap">
<div>@($"{record.DtNextExec:yyyy-MM-dd}")</div>
<div class="small">@($"{record.DtNextExec:ddd HH:mm:ss}")</div>
</td>
<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>
<button class="btn btn-sm @btnRunCss(record.DtNextExec) me-1" @onclick="()=>doRun(record)" title="Run Now"><i class="fas fa-play"></i></button>
</td>
}
</tr>
@if (DetailTaskId != null && DetailTaskId.TaskId == record.TaskId)
{
<tr>
<td colspan="10">
<div class="d-flex justify-content-end">
<div class="p-1 small alert @alCss(record)">
<pre>@record.LastResult</pre>
</div>
</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" exportRequested="ExportCsv" fileName="@fileName" totalCount="totalCount" showLoading="isLoading" />
</div>
</div>
</div>
@if (detRecord != null && !isLoading)
{
<div class="col-6">
<TaskExeList CurrRecord="@detRecord"></TaskExeList>
</div>
}
</div>
+368
View File
@@ -0,0 +1,368 @@
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using MP.TaskMan.Models;
using MP.TaskMan.Services;
using static MP.TaskMan.Objects.Enums;
namespace MP.TaskMan
{
public partial class TaskList : ComponentBase
{
#region Public Methods
public string checkSelect(int TaskId)
{
string answ = "";
if (currRecord != null)
{
try
{
answ = (currRecord.TaskId == TaskId) ? "table-info" : "";
}
catch
{ }
}
else if (detRecord != null)
{
answ = (detRecord.TaskId == TaskId) ? "table-info" : "";
}
return answ;
}
#endregion Public Methods
#region Protected Fields
protected string fileName = "TaskList.csv";
#endregion Protected Fields
#region Protected Properties
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
protected string mainCss
{
get => detRecord == null ? "col-12" : "col-6";
}
protected int maxOrdinal { get; set; } = 999;
protected int minOrdinal { get; set; } = 0;
protected int totalCount { get; set; } = 0;
[Inject]
protected TaskService TService { get; set; } = null!;
protected Task2ExeType TypeSel
{
get => typeSel;
set
{
if (typeSel != value)
{
typeSel = value;
var pUpd = Task.Run(async () =>
{
await ReloadData();
});
pUpd.Wait();
}
}
}
#endregion Protected Properties
#region Protected Methods
protected async Task addNew()
{
currRecord = new TaskListModel()
{
Name = "Nuovo Task",
TType = TypeSel,
Descript = "Descrizione Task",
DtLastExec = DateTime.Today,
DtNextExec = DateTime.Today.AddDays(1)
};
await ReloadData();
}
/// <summary>
/// Gestione display avanzamento step
/// </summary>
/// <param name="currStep"></param>
protected async Task advStep(int currStep)
{
currVal = currStep;
nextVal = currVal + 1;
await InvokeAsync(StateHasChanged);
}
protected string alCss(TaskListModel TaskRec)
{
return TaskRec.LastIsError ? "alert-danger" : "alert-success";
}
protected string btnCss(TaskListModel TaskRec)
{
string answ = DetailTaskId != null && DetailTaskId.TaskId == TaskRec.TaskId ? "btn-" : "btn-outline-";
answ += TaskRec.LastIsError ? "danger" : "success";
return answ;
}
protected async Task doCancel()
{
currRecord = null;
detRecord = null;
await ReloadData();
}
protected async Task doClone(TaskListModel selRec)
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Confermi di voler duplicare il record selezionato?"))
return;
currRecord = new TaskListModel()
{
Args = selRec.Args,
Name = $"Copia di {selRec.Name}",
Cad = selRec.Cad,
Command = selRec.Command,
Descript = $"Copia di {selRec.Descript}",
DtNextExec = DateTime.Today.AddDays(1),
DtLastExec = DateTime.Today.AddYears(-10),
Freq = selRec.Freq,
LastDuration = 0,
LastIsError = false,
LastResult = "",
TType = selRec.TType,
Ordinal = SearchRecords.Count + 1,
};
await ReloadData();
}
protected async Task doEdit(TaskListModel selRec)
{
currRecord = selRec;
await ReloadData();
}
protected async Task doMove(TaskListModel currRec, bool goUp)
{
await TService.TaskListMove(currRec, goUp);
detRecord = null;
currRecord = null;
await ReloadData();
}
protected async Task doReset()
{
detRecord = null;
currRecord = null;
await TService.FlushCache();
await ReloadData();
}
protected async Task doRun(TaskListModel selRec)
{
// SE non è ancora scaduto chiedo conferma
if (selRec.DtNextExec > DateTime.Now)
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Confermi esecuzione forzata task non scaduto?{Environment.NewLine}[{selRec.TaskId}]: {selRec.Name} - {selRec.Descript}{Environment.NewLine}Prossima schedulazione: {selRec.DtNextExec:yyyy-MM-dd HH:mm:ss}"))
return;
}
// imposto tempo atteso esecuzione da ultimo...
isLoading = true;
MaxVal = 4;
int currStep = 0;
await advStep(currStep);
expTimeMsec = (int)(1000 * selRec.LastDuration) / 4;
detRecord = null;
await advStep(currStep++);
await Task.Delay(100);
await advStep(currStep++);
// chiama esecuzione task
var result = await TService.ExecuteTask(selRec, false);
await advStep(currStep++);
isLoading = false;
await Task.Delay(100);
await advStep(currStep++);
await ReloadData();
}
protected async Task doSelect(TaskListModel selRec)
{
detRecord = null;
currRecord = null;
DetailTaskId = null;
isLoading = true;
detRecord = selRec;
await ReloadData();
isLoading = false;
}
protected async Task forceAll()
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Confermi esecuzione forzata di tutti i task?"))
return;
isLoading = true;
detRecord = null;
await Task.Delay(100);
foreach (var taskRec in SearchRecords)
{
var result = await TService.ExecuteTask(taskRec, false);
}
isLoading = false;
await Task.Delay(100);
await ReloadData();
}
protected async Task ForceReload(int newNum)
{
numRecord = newNum;
await ReloadData();
}
protected async Task ForceReloadPage(int newNum)
{
currPage = newNum;
await ReloadData();
}
protected async Task forceUpdate(bool doForce)
{
currRecord = null;
await ReloadData();
}
protected string iconCss(TaskListModel TaskRec)
{
return TaskRec.LastIsError ? "fa-thumbs-down" : "fa-thumbs-up";
}
protected override async Task OnInitializedAsync()
{
isLoading = true;
MaxVal = 2;
CleanupDir();
await advStep(1);
numRecord = 10;
await ReloadData();
await advStep(2);
isLoading = false;
}
protected void ResetData()
{
CleanupDir();
TService.rollBackEdit(currRecord);
currRecord = null;
}
protected double righDiv(double num, double den)
{
if (den == 0)
{
den = 1;
}
double answ = num / den;
return answ;
}
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;
}
protected void ToggleDetail(TaskListModel TaskRec)
{
if (DetailTaskId == null)
{
DetailTaskId = TaskRec;
}
else
{
DetailTaskId = (DetailTaskId.TaskId == TaskRec.TaskId) ? null : TaskRec;
}
}
#endregion Protected Methods
#region Private Fields
private double currVal = 0;
private TaskListModel? DetailTaskId = null;
private List<TaskListModel> ListRecords = new List<TaskListModel>();
private int MaxVal = 10;
private double nextVal = 0;
private List<TaskListModel> SearchRecords = new List<TaskListModel>();
#endregion Private Fields
#region Private Properties
private int currPage { get; set; } = 1;
private TaskListModel? currRecord { get; set; } = null;
private TaskListModel? detRecord { get; set; } = null;
private int expTimeMsec { get; set; } = 30000;
private string fullPath
{
get => $"{Directory.GetCurrentDirectory()}\\temp\\{fileName}";
}
private bool isLoading { get; set; } = false;
private int numRecord { get; set; } = 10;
private string SearchVal { get; set; } = "";
private Task2ExeType typeSel { get; set; } = Task2ExeType.ND;
#endregion Private Properties
#region Private Methods
private string btnRunCss(DateTime dtNextExe)
{
DateTime adesso = DateTime.Now;
string answ = dtNextExe < adesso ? "btn-success" : "btn-warning";
return answ;
}
private async void CleanupDir()
{
var parentDir = Directory.GetParent(fullPath).FullName;
if (!Directory.Exists(parentDir))
{
Directory.CreateDirectory(parentDir);
}
await Task.Run(() => File.Delete(fullPath));
}
private async Task ExportCsv()
{
isLoading = true;
// salvo davvero!
await Egw.Core.Utils.SaveToCsv(SearchRecords, fullPath, ';');
isLoading = false;
}
private async Task ReloadData()
{
SearchRecords = await TService.TaskListAll(TypeSel, SearchVal);
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();
}
#endregion Private Methods
}
}
+4
View File
@@ -0,0 +1,4 @@
@using Microsoft.AspNetCore.Components.Web
@using MP.TaskMan.Models
@using EgwCoreLib.Razor
@using EgwCoreLib.Utils
Binary file not shown.

After

Width:  |  Height:  |  Size: 378 B

+6
View File
@@ -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');
}