BugFix metodi API x trasferimento task
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -12,6 +12,8 @@ namespace LiMan.APi.Controllers
|
||||
[ApiController]
|
||||
public class AppTaskController : ControllerBase
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Init generico
|
||||
/// </summary>
|
||||
@@ -22,6 +24,8 @@ namespace LiMan.APi.Controllers
|
||||
Log.Info("Avviata classe TaskController");
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#if false
|
||||
[HttpGet]
|
||||
public ActionResult<string> Get([FromHeader] string codOne = "pippo", [FromQuery] bool showAll = false)
|
||||
@@ -35,9 +39,40 @@ namespace LiMan.APi.Controllers
|
||||
await Task.Delay(1);
|
||||
string answ = $"CodOne: {codOne} | showAll: {showAll}";
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Elimina tutte le registrazioni req/run/done x device
|
||||
/// </summary>
|
||||
/// <param name="dev">dev richiedente</param>
|
||||
/// <param name="CurrRequest">Obj AuthDataDTO con chiavi (master o app)</param>
|
||||
[HttpDelete("cleanup/{dev}")]
|
||||
public async Task<Dictionary<string, string>> TaskClearAll(string dev, [FromBody] TaskResultDTO CurrRequest)
|
||||
{
|
||||
Dictionary<string, string> result = new Dictionary<string, string>();
|
||||
// verifica validità richiesta...
|
||||
if (CurrRequest.IsValid)
|
||||
{
|
||||
// FixMe ToDo !!! effettuare verifica valori chiavi/imp/device...
|
||||
|
||||
// elimina tutte le richieste x la macchina...
|
||||
var rawData = dataService.TaskListReset(CurrRequest.CodImp);
|
||||
|
||||
if (rawData != null)
|
||||
{
|
||||
result = rawData;
|
||||
}
|
||||
// salva in redis e toglie dai task da eseguire la richiesta relativa...
|
||||
|
||||
// registro infine chiamata
|
||||
await dataService.recordCall(dev, CurrRequest.CodImp, $"POST:api/apptask/clear/ | {CurrRequest.MastKey} | {CurrRequest.CodImp}");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Richiede elenco di task da eseguire x il dev richiedente
|
||||
/// </summary>
|
||||
@@ -45,8 +80,8 @@ namespace LiMan.APi.Controllers
|
||||
/// <param name="AppKey">Cod Auth applicativo</param>
|
||||
/// <param name="CodImp">CodImp del dev</param>
|
||||
[HttpGet("pend/{dev}")]
|
||||
public async Task<Dictionary<string, string>> Task2ExePending(string dev, [FromHeader] string AppKey, [FromHeader] string CodImp)
|
||||
//public async Task<ActionResult<Dictionary<string, string>>> Task2ExeRequest(string dev, [FromHeader] string AppKey, [FromHeader] string CodImp)
|
||||
public async Task<Dictionary<string, string>> TaskGetPending(string dev, [FromHeader] string AppKey, [FromHeader] string CodImp)
|
||||
//public async Task<ActionResult<Dictionary<string, string>>> TaskGetPending(string dev, [FromHeader] string AppKey, [FromHeader] string CodImp)
|
||||
{
|
||||
Dictionary<string, string> result = new Dictionary<string, string>();
|
||||
// verifica validità richiesta...
|
||||
@@ -62,39 +97,13 @@ namespace LiMan.APi.Controllers
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registra in esecuzione itask richiesti al device
|
||||
/// </summary>
|
||||
/// <param name="dev">dev richiedente</param>
|
||||
/// <param name="CurrRequest">Obj AuthDataDTO con chiavi (master o app)</param>
|
||||
[HttpPost("running/{dev}")]
|
||||
public async Task<string> Task2ExeRunning(string dev, [FromBody] TaskResultDTO CurrRequest)
|
||||
{
|
||||
string result = "NA";
|
||||
// verifica validità richiesta...
|
||||
if (CurrRequest.IsValid)
|
||||
{
|
||||
// FixMe ToDo !!! effettuare verifica valori chiavi/imp/device...
|
||||
|
||||
// recupero da REDIS le richieste pending x la macchina...
|
||||
int numDone = dataService.TaskRunning(CurrRequest.CodImp, CurrRequest.DataPayload);
|
||||
|
||||
result = $"saved {numDone}/{CurrRequest.DataPayload.Count}";
|
||||
// salva in redis e toglie dai task da eseguire la richiesta relativa...
|
||||
|
||||
// registro infine chiamata
|
||||
await dataService.recordCall(CurrRequest.CodImp, CurrRequest.CodImp, $"POST:api/apptask/running/ | {CurrRequest.MastKey} | {CurrRequest.CodImp}");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registra risultato esecuzione task richiesti al device
|
||||
/// </summary>
|
||||
/// <param name="dev">dev richiedente</param>
|
||||
/// <param name="CurrRequest">Obj AuthDataDTO con chiavi (master o app)</param>
|
||||
[HttpPost("done/{dev}")]
|
||||
public async Task<string> Task2ExeResult(string dev, [FromBody] TaskResultDTO CurrRequest)
|
||||
public async Task<string> TaskSetDone(string dev, [FromBody] TaskResultDTO CurrRequest)
|
||||
{
|
||||
string result = "NA";
|
||||
// verifica validità richiesta...
|
||||
@@ -103,7 +112,7 @@ namespace LiMan.APi.Controllers
|
||||
// FixMe ToDo !!! effettuare verifica valori chiavi/imp/device...
|
||||
|
||||
// recupero da REDIS le richieste pending x la macchina...
|
||||
int numDone = dataService.TaskDoneAdd(CurrRequest.CodImp, CurrRequest.DataPayload);
|
||||
int numDone = dataService.TaskSetDone(CurrRequest.CodImp, CurrRequest.DataPayload);
|
||||
|
||||
result = $"saved {numDone}/{CurrRequest.DataPayload.Count}";
|
||||
// salva in redis e toglie dai task da eseguire la richiesta relativa...
|
||||
@@ -115,12 +124,49 @@ namespace LiMan.APi.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Classe per logging
|
||||
/// Registra in esecuzione itask richiesti al device
|
||||
/// </summary>
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
/// <param name="dev">dev richiedente</param>
|
||||
/// <param name="CurrRequest">Obj AuthDataDTO con chiavi (master o app)</param>
|
||||
[HttpPost("running/{dev}")]
|
||||
public async Task<string> TaskSetRunning(string dev, [FromBody] TaskResultDTO CurrRequest)
|
||||
{
|
||||
string result = "NA";
|
||||
// verifica validità richiesta...
|
||||
if (CurrRequest.IsValid)
|
||||
{
|
||||
// FixMe ToDo !!! effettuare verifica valori chiavi/imp/device...
|
||||
|
||||
// recupero da REDIS le richieste pending x la macchina...
|
||||
int numDone = dataService.TaskSetRunning(CurrRequest.CodImp, CurrRequest.DataPayload);
|
||||
|
||||
result = $"saved {numDone}/{CurrRequest.DataPayload.Count}";
|
||||
// salva in redis e toglie dai task da eseguire la richiesta relativa...
|
||||
|
||||
// registro infine chiamata
|
||||
await dataService.recordCall(dev, CurrRequest.CodImp, $"POST:api/apptask/running/ | {CurrRequest.MastKey} | {CurrRequest.CodImp}");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
/// <summary>
|
||||
/// Dataservice x accesso DB
|
||||
/// </summary>
|
||||
protected ApiDataService dataService { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// Classe per logging
|
||||
/// </summary>
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1113,7 +1113,7 @@ namespace LiMan.APi.Data
|
||||
/// <param name="DataPayload"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public int TaskRunning(string CodImp, Dictionary<string, string> DataPayload)
|
||||
public int TaskSetRunning(string CodImp, Dictionary<string, string> DataPayload)
|
||||
{
|
||||
int done = 0;
|
||||
RedisKey reqKey = (RedisKey)$"{rKeyTaskReq}:{CodImp}";
|
||||
@@ -1137,7 +1137,7 @@ namespace LiMan.APi.Data
|
||||
/// <param name="DataPayload"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public int TaskDoneAdd(string CodImp, Dictionary<string, string> DataPayload)
|
||||
public int TaskSetDone(string CodImp, Dictionary<string, string> DataPayload)
|
||||
{
|
||||
int done = 0;
|
||||
RedisKey runKey = (RedisKey)$"{rKeyTaskRun}:{CodImp}";
|
||||
@@ -1171,10 +1171,25 @@ namespace LiMan.APi.Data
|
||||
/// </summary>
|
||||
/// <param name="CodImp"></param>
|
||||
/// <returns></returns>
|
||||
public bool TaskListReset(string CodImp)
|
||||
public Dictionary<string, string> TaskListReset(string CodImp)
|
||||
{
|
||||
RedisKey currKey = (RedisKey)$"{rKeyTaskReq}:{CodImp}";
|
||||
bool answ = redisHashDictDelete(currKey);
|
||||
Dictionary<string, string> answ = new Dictionary<string, string>();
|
||||
bool ok01 = redisHashDictDelete((RedisKey)$"{rKeyTaskReq}:{CodImp}");
|
||||
bool ok02 = redisHashDictDelete((RedisKey)$"{rKeyTaskRun}:{CodImp}");
|
||||
bool ok03 = redisHashDictDelete((RedisKey)$"{rKeyTaskDone}:{CodImp}");
|
||||
// leggo remaining x verificare sia ok..
|
||||
var dictReq = new Dictionary<string, string>(redisHashDictGet((RedisKey)$"{rKeyTaskReq}:{CodImp}"));
|
||||
var dictRun = new Dictionary<string, string>(redisHashDictGet((RedisKey)$"{rKeyTaskRun}:{CodImp}"));
|
||||
var dictDone = new Dictionary<string, string>(redisHashDictGet((RedisKey)$"{rKeyTaskDone}:{CodImp}"));
|
||||
answ = new Dictionary<string, string>( dictReq);
|
||||
foreach (var item in dictRun)
|
||||
{
|
||||
answ.TryAdd(item.Key, item.Value);
|
||||
}
|
||||
foreach (var item in dictDone)
|
||||
{
|
||||
answ.TryAdd(item.Key, item.Value);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
@@ -1627,7 +1642,7 @@ namespace LiMan.APi.Data
|
||||
data2ins[0] = new HashEntry("removed", $"{DateTime.Now}");
|
||||
// salvo!
|
||||
redisDb.HashSet(dictKey, data2ins);
|
||||
redisDb.KeyExpire(dictKey, DateTime.Now.AddSeconds(1));
|
||||
redisDb.KeyExpire(dictKey, DateTime.Now.AddMilliseconds(1));
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>License Manager</i>
|
||||
<h4>Versione: 2.1.2501.1716</h4>
|
||||
<h4>Versione: 2.1.2501.1717</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
2.1.2501.1716
|
||||
2.1.2501.1717
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>2.1.2501.1716</version>
|
||||
<version>2.1.2501.1717</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.UI.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>License Manager</i>
|
||||
<h4>Versione: 2.1.2501.1712</h4>
|
||||
<h4>Versione: 2.1.2501.1717</h4>
|
||||
<br />
|
||||
Note di rilascio:
|
||||
<ul>
|
||||
|
||||
@@ -1 +1 @@
|
||||
2.1.2501.1712
|
||||
2.1.2501.1717
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>2.1.2501.1712</version>
|
||||
<version>2.1.2501.1717</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.Transfer.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Version>2.1.2501.1716</Version>
|
||||
<Version>2.1.2501.1717</Version>
|
||||
<RootNamespace>LiMan.UI</RootNamespace>
|
||||
<AssemblyName>LiMan.UI</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>License Manager</i>
|
||||
<h4>Versione: 2.1.2501.1716</h4>
|
||||
<h4>Versione: 2.1.2501.1717</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
2.1.2501.1716
|
||||
2.1.2501.1717
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>2.1.2501.1716</version>
|
||||
<version>2.1.2501.1717</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.UI.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user