Fix chiamate callUrls: sempre da utils x evitare inutili incapsulamenti
This commit is contained in:
@@ -371,6 +371,7 @@ namespace IOB_UT_NEXT.Iob
|
||||
|
||||
#region Public Methods
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Effettua chiamata URL e restituisce risultato
|
||||
/// </summary>
|
||||
@@ -403,7 +404,7 @@ namespace IOB_UT_NEXT.Iob
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua chiamata URL e restituisce risultato
|
||||
@@ -431,6 +432,7 @@ namespace IOB_UT_NEXT.Iob
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// processa dataLayer e se necessario salva/mostra
|
||||
@@ -455,22 +457,12 @@ namespace IOB_UT_NEXT.Iob
|
||||
return sMacAddress;
|
||||
}
|
||||
|
||||
public static void resetDebugConsole()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reset dei webclients
|
||||
/// </summary>
|
||||
public static void resetWebClients()
|
||||
{
|
||||
utils.resetWebClients();
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Valore di attesa (random) dopo ogni invio x evitare congestione send...
|
||||
/// </summary>
|
||||
|
||||
@@ -600,12 +600,6 @@ namespace IOB_UT_NEXT
|
||||
if (num >= 100) num /= 100;
|
||||
if (num >= 10) num /= 10;
|
||||
|
||||
#if false
|
||||
// formulazione alternativa con ciclo...
|
||||
while (num >= 10)
|
||||
num /= 10;
|
||||
#endif
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
@@ -812,15 +806,6 @@ namespace IOB_UT_NEXT
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void resetWebClients()
|
||||
{
|
||||
#if false
|
||||
// resetto i webclients...
|
||||
client = new WebClientWT();
|
||||
clientPayload = new WebClientWT();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua reverse della stringa
|
||||
/// </summary>
|
||||
|
||||
@@ -1466,7 +1466,7 @@ namespace IOB_WIN_FORM
|
||||
// salvo nuovo valore invio
|
||||
iobObj.LastSendSet(sendKey, DateTime.Now);
|
||||
// segnalo reboot (programma - url file)...
|
||||
await Iob.Generic.callUrl(iobObj.urlReboot, true);
|
||||
await utils.callUrlAsync(iobObj.urlReboot);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
+59
-235
@@ -60,7 +60,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
|
||||
// init oggetto redis...
|
||||
redisMan = new RedisIobCache(IobConfNew.MapoMes.IpAddr, IobConfNew.General.FilenameIOB, $"{IobConfNew.General.IobType}", IobConfNew.General.MinDeltaSec);
|
||||
|
||||
|
||||
// init code
|
||||
SetupQueue();
|
||||
|
||||
@@ -1316,19 +1316,6 @@ namespace IOB_WIN_FORM.Iob
|
||||
case taskType.processOtherInfo:
|
||||
bool okProc = ProcessOtherInfo(iKey, item.Value);
|
||||
taskVal = okProc ? $"OK ProcessOtherInfoAsync | {iKey} | {item.Value}" : $"ERROR ProcessOtherInfoAsync | {iKey} | {item.Value}";
|
||||
#if false
|
||||
try
|
||||
{
|
||||
Task.Run(async () => okProc = await ProcessOtherInfoAsync(iKey, item.Value))
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
taskVal = okProc ? $"OK ProcessOtherInfoAsync | {iKey} | {item.Value}" : $"ERROR ProcessOtherInfoAsync | {iKey} | {item.Value}";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
lgError("ProcessOtherInfoAsync | Crash nel ponte Sync/Async: " + ex.Message);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -1439,7 +1426,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
if (!isMulti)
|
||||
{
|
||||
// invio chiamata URL x reset ODL su macchina
|
||||
rawSplit = await callUrl(urlForceSplit, false);
|
||||
rawSplit = await utils.callUrlAsync(urlForceSplit);
|
||||
fatto = (rawSplit != "KO") ? true : false;
|
||||
}
|
||||
// se multi gestisco il bit delle tavole...
|
||||
@@ -1450,7 +1437,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
// invio chiamata URL x reset ODL su macchina, ATTENZIONE scriviamo
|
||||
// | al posto di "#" che in URL sarebbe filtrato...
|
||||
fullUrl = $"{urlForceSplit}&multi={item}";
|
||||
rawSplit = await callUrl(fullUrl, false);
|
||||
rawSplit = await utils.callUrlAsync(fullUrl);
|
||||
lgDebug($"Esecuzione forceSplit | URL: {fullUrl} | esito: {rawSplit}");
|
||||
}
|
||||
fatto = (rawSplit == "OK") ? true : false;
|
||||
@@ -1874,32 +1861,6 @@ namespace IOB_WIN_FORM.Iob
|
||||
|
||||
case urlType.RawTransf:
|
||||
BaseRawTransf currRTData = new BaseRawTransf();
|
||||
#if false
|
||||
rawTransfJsonPayload fullRTObj = new rawTransfJsonPayload();
|
||||
fullRTObj.rawTransfData = new List<BaseRawTransf>();
|
||||
// inizio processando ogni valore
|
||||
foreach (var item in elencoValori)
|
||||
{
|
||||
try
|
||||
{
|
||||
currRTData = JsonConvert.DeserializeObject<BaseRawTransf>(item);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lgError($"Eccezione in deserializzazione BaseRawTransf:{Environment.NewLine}{exc}");
|
||||
}
|
||||
fullRTObj.rawTransfData.Add(currRTData);
|
||||
}
|
||||
// conversione finale
|
||||
try
|
||||
{
|
||||
answ = JsonConvert.SerializeObject(fullRTObj);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lgError($"RawTransf Errore in costruzione jsonPayload:{Environment.NewLine}{exc}");
|
||||
}
|
||||
#endif
|
||||
|
||||
// provo una serializzazione "brutale", ovvero aggiungo alla stringa il
|
||||
// valore di testa...
|
||||
@@ -1971,9 +1932,9 @@ namespace IOB_WIN_FORM.Iob
|
||||
/// <returns></returns>
|
||||
public DateTime LastSendGet(string keyReq)
|
||||
{
|
||||
DateTime lastSend = DateTime.Now.AddDays(-1);
|
||||
string lastSendKey = GetStatusField("LastSend");
|
||||
string rawVal = redisMan.redGetHashField(lastSendKey, keyReq);
|
||||
DateTime lastSend = DateTime.Now.AddDays(-1);
|
||||
string lastSendKey = GetStatusField("LastSend");
|
||||
string rawVal = redisMan.redGetHashField(lastSendKey, keyReq);
|
||||
if (!string.IsNullOrEmpty(rawVal))
|
||||
{
|
||||
lastSend = DataSerializer.Deserialize<DateTime>(rawVal);
|
||||
@@ -1995,7 +1956,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
/// <param name="dtRif"></param>
|
||||
public bool LastSendSet(string keyReq, DateTime dtRif)
|
||||
{
|
||||
string lastSendKey = GetStatusField("LastSend");
|
||||
string lastSendKey = GetStatusField("LastSend");
|
||||
string rawVal = DataSerializer.Serialize(dtRif);
|
||||
KeyValuePair<string, string>[] hashFields = new KeyValuePair<string, string>[1];
|
||||
hashFields[0] = new KeyValuePair<string, string>(keyReq, rawVal);
|
||||
@@ -2212,7 +2173,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
foreach (var item in IOBConfFull.Device.MultiIobList)
|
||||
{
|
||||
fullUrl = $@"{urlCommand("fixDailyOdlConfPzCount")}{item}";
|
||||
autoOdlRes = await callUrl(fullUrl, false);
|
||||
autoOdlRes = await utils.callUrlAsync(fullUrl);
|
||||
}
|
||||
}
|
||||
fatto = autoOdlRes == "OK";
|
||||
@@ -2236,7 +2197,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
rawDataInizio = "";
|
||||
if (!isMulti)
|
||||
{
|
||||
rawDataInizio = await callUrl(urlInizioOdlIob, false);
|
||||
rawDataInizio = await utils.callUrlAsync(urlInizioOdlIob);
|
||||
DateTime.TryParse(rawDataInizio, out inizioOdl);
|
||||
}
|
||||
else
|
||||
@@ -2246,7 +2207,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
foreach (var item in IOBConfFull.Device.MultiIobList)
|
||||
{
|
||||
fullUrl = $"{urlInizioOdlIob}|{item}";
|
||||
rawDataInizio = await callUrl(fullUrl, false);
|
||||
rawDataInizio = await utils.callUrlAsync(fullUrl);
|
||||
DateTime.TryParse(rawDataInizio, out tmpData);
|
||||
inizioOdl = (tmpData < inizioOdl) ? tmpData : inizioOdl;
|
||||
}
|
||||
@@ -2260,7 +2221,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
{
|
||||
// controllo SE sono fermo (spento o in manuale) per il
|
||||
// periodo minimo richiesto...
|
||||
rawIdle = await callUrl(urlIdleTime, false);
|
||||
rawIdle = await utils.callUrlAsync(urlIdleTime);
|
||||
int.TryParse(rawIdle, out idlePeriod);
|
||||
}
|
||||
else
|
||||
@@ -2270,7 +2231,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
foreach (var item in IOBConfFull.Device.MultiIobList)
|
||||
{
|
||||
fullUrl = $"{urlIdleTime}|{item}";
|
||||
rawIdle = await callUrl(fullUrl, false);
|
||||
rawIdle = await utils.callUrlAsync(fullUrl);
|
||||
int.TryParse(rawIdle, out tmpIdle);
|
||||
idlePeriod = tmpIdle > idlePeriod ? tmpIdle : idlePeriod;
|
||||
}
|
||||
@@ -2285,7 +2246,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
// fare, se sfora (RANDOM) > +(50...110)% --> cambia!
|
||||
if (!callChangeODL && IOBConfFull.Odl.ChangeOdlMode == "SIMUL")
|
||||
{
|
||||
var rawCount = await callUrl(urlGetNumPzCurrODL, false);
|
||||
var rawCount = await utils.callUrlAsync(urlGetNumPzCurrODL);
|
||||
if (int.TryParse(rawCount, out var numPzReqOdl))
|
||||
{
|
||||
int limitQty = (numPzReqOdl * rndGen.Next(150, 210)) / 100;
|
||||
@@ -2751,72 +2712,6 @@ namespace IOB_WIN_FORM.Iob
|
||||
return taskDone;
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Processa esecuzione task ricevuti
|
||||
/// </summary>
|
||||
/// <param name="task2exe"></param>
|
||||
/// <param name="codTav"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Dictionary<string, string>> ProcessTask(Dictionary<string, string> task2exe, string codTav)
|
||||
{
|
||||
Dictionary<string, string> taskDone = new Dictionary<string, string>();
|
||||
Dictionary<string, string> task2Add = new Dictionary<string, string>();
|
||||
// eseguo realmente solo se NON disabilitata questa gestione (caso doppio PLC/HMI)...
|
||||
if (!IOBConfFull.Device.DisabExeTask)
|
||||
{
|
||||
if (task2exe != null)
|
||||
{
|
||||
string logMsg = $"Task2Exe S01: {task2exe.Count} task ricevuti";
|
||||
if (!string.IsNullOrEmpty(codTav))
|
||||
{
|
||||
logMsg += $" | codTav: {codTav}";
|
||||
}
|
||||
lgInfo(logMsg);
|
||||
int idTask = 0;
|
||||
foreach (var item in task2exe)
|
||||
{
|
||||
idTask++;
|
||||
lgInfo($"[{idTask:00}] - {item.Key} --> {item.Value}");
|
||||
// verifico SE il task abbia un duplo writeLink e nel caso lo aggiungo...
|
||||
var linkVal = getOptWriteLink(item.Key);
|
||||
if (!string.IsNullOrEmpty(linkVal))
|
||||
{
|
||||
// aggiungo a task2add SE manca...
|
||||
if (!task2Add.ContainsKey(linkVal))
|
||||
{
|
||||
task2Add.Add(linkVal, item.Value);
|
||||
}
|
||||
lgInfo($"Aggiunta task linked: {linkVal} -> {item.Value}");
|
||||
}
|
||||
}
|
||||
// se ho task Link da aggiungere li aggiungo!
|
||||
if (task2Add.Count > 0)
|
||||
{
|
||||
foreach (var item in task2Add)
|
||||
{
|
||||
task2exe.Add(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
// chiamo procedura esecutiva (diversa x ogni IOB)
|
||||
taskDone = executeTasks(task2exe, codTav);
|
||||
lgInfo($"Task2Exe S02: eseguiti {taskDone.Count} task");
|
||||
// loggo tutti i task done...
|
||||
foreach (var item in taskDone)
|
||||
{
|
||||
sendToTaskWatch(item.Key, item.Value, codTav);
|
||||
}
|
||||
// ora chiamo la cancellazione dei task eseguiti...
|
||||
foreach (var item in taskDone)
|
||||
{
|
||||
await remTask2exe(item.Key, item.Value, codTav);
|
||||
}
|
||||
}
|
||||
}
|
||||
return taskDone;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Classe fittizia in caso di processing task in MsVHF
|
||||
/// </summary>
|
||||
@@ -3363,16 +3258,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
if (await CheckServerAliveAsync())
|
||||
{
|
||||
// chiamo URL!
|
||||
string answ = await callUrlWithPayloadAsync(lastUrl, payload, doAsync);
|
||||
|
||||
// valutare invio REST alternativo...
|
||||
#if false
|
||||
// invio alternativo nuovo
|
||||
if (string.IsNullOrEmpty(answ))
|
||||
{
|
||||
answ = utils.ExecCallPostPlain(lastUrl, payload);
|
||||
}
|
||||
#endif
|
||||
string answ = await utils.callUrlAsync(lastUrl, payload);
|
||||
|
||||
// loggo!
|
||||
lgInfo($"[SEND payload] TipoURL: {tipoUrl} | {listQueueVal.Count} records --> {answ}");
|
||||
@@ -3460,7 +3346,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
if (await CheckServerAliveAsync())
|
||||
{
|
||||
// chiamo URL!
|
||||
string answ = await callUrl(lastUrl, false);
|
||||
string answ = await utils.callUrlAsync(lastUrl);
|
||||
// loggo!
|
||||
lgDebug(string.Format("[SEND] {0} -> {1}", queueVal, answ));
|
||||
// se oltre 1 min NON era online --> check pezzi!
|
||||
@@ -3687,7 +3573,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
parentForm.displayTaskAndLog("[STOP] Stopping adapter - last periodic data read...", true);
|
||||
|
||||
// salvo statistiche
|
||||
string callKey = GetCallStatsKey();
|
||||
string callKey = GetCallStatsKey();
|
||||
await CallMetricsCollector.SaveToRedisAsync(redisMan.currDb, callKey, false);
|
||||
|
||||
// chiudo la connessione all'adapter...
|
||||
@@ -3981,11 +3867,10 @@ namespace IOB_WIN_FORM.Iob
|
||||
// Se non è il primo tentativo, resetta i client e aspetta
|
||||
if (i > 0)
|
||||
{
|
||||
if (i == 4) resetWebClients(); // Reset specifico a metà tentativi
|
||||
await Task.Delay(rand.Next(150, 500));
|
||||
}
|
||||
|
||||
string resp = await callUrl(urlAlive, false);
|
||||
string resp = await utils.callUrlAsync(urlAlive);
|
||||
if (resp == "OK") return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -3996,35 +3881,6 @@ namespace IOB_WIN_FORM.Iob
|
||||
return false;
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Processing di una risposta raw di task2exe
|
||||
/// </summary>
|
||||
/// <param name="resp">Risposta come string RAW</param>
|
||||
/// <param name="codTav">Cod Tav (opzionale)</param>
|
||||
private async Task ProcessResp(string resp, string codTav)
|
||||
{
|
||||
Dictionary<string, string> task2exe = new Dictionary<string, string>();
|
||||
Dictionary<string, string> taskDone = new Dictionary<string, string>();
|
||||
if (!string.IsNullOrEmpty(resp) && resp.Length > 2)
|
||||
{
|
||||
try
|
||||
{
|
||||
task2exe = JsonConvert.DeserializeObject<Dictionary<string, string>>(resp);
|
||||
// se ho da fare chiamo esecuzione..
|
||||
if (task2exe.Count > 0)
|
||||
{
|
||||
taskDone = await ProcessTask(task2exe, codTav);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lgError($"Eccezione in ServerGetRequestsAsync.ProcessResp:{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Update stato server
|
||||
/// </summary>
|
||||
@@ -4663,8 +4519,8 @@ namespace IOB_WIN_FORM.Iob
|
||||
get
|
||||
{
|
||||
Dictionary<int, PODLModel> answ = new Dictionary<int, PODLModel>();
|
||||
string redKey = GetPOdlSentKey();
|
||||
string rawData = redisMan.getRSV(redKey);
|
||||
string redKey = GetPOdlSentKey();
|
||||
string rawData = redisMan.getRSV(redKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
try
|
||||
@@ -4682,8 +4538,8 @@ namespace IOB_WIN_FORM.Iob
|
||||
set
|
||||
{
|
||||
string rawVal = JsonConvert.SerializeObject(value);
|
||||
string redKey = GetPOdlSentKey();
|
||||
redisMan.setRSV(redKey, rawVal);
|
||||
string redKey = GetPOdlSentKey();
|
||||
redisMan.setRSV(redKey, rawVal);
|
||||
lgDebug($"Salvataggio status POdlSentFileArch | {value.Count} record");
|
||||
}
|
||||
}
|
||||
@@ -4753,10 +4609,10 @@ namespace IOB_WIN_FORM.Iob
|
||||
/// <summary>
|
||||
/// Redis key del dizionari valori DataItemMem persistiti
|
||||
/// </summary>
|
||||
protected string rKeyFluxMem
|
||||
{
|
||||
get => GetFluxMemKey();
|
||||
}
|
||||
protected string rKeyFluxMem
|
||||
{
|
||||
get => GetFluxMemKey();
|
||||
}
|
||||
|
||||
protected Random rndGen { get; set; } = new Random();
|
||||
|
||||
@@ -6075,33 +5931,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
/// </summary>
|
||||
protected virtual bool iobWriteLocalUSTD()
|
||||
{
|
||||
bool answ = false;
|
||||
#if false
|
||||
// conf ftp
|
||||
var ftpConf = IOBConfFull.Special.FtpConf;
|
||||
// salvo articoli
|
||||
string locDir = ftpConf.DirLocal;
|
||||
bool addHeader = ftpConf.CsvAddHeader;
|
||||
string basePath = Application.StartupPath;
|
||||
string tempDir = Path.Combine(basePath, locDir);
|
||||
lgInfo($"iobWriteLocalCSV | locDir: {locDir} | addHeader: {addHeader} | tempDir: {tempDir}");
|
||||
baseUtils.checkDir(tempDir);
|
||||
string filePath = Path.Combine(tempDir, "articoli.csv");
|
||||
answ = DataExport.SaveToCsv(ListaArticoli, filePath, addHeader);
|
||||
if (answ)
|
||||
{
|
||||
lgInfo($"CSV: saved ART file as articoli.csv at {filePath}");
|
||||
// salvo PODL
|
||||
string csvName = $"{DateTime.Now:dd-MM-yyyy}.csv";
|
||||
filePath = Path.Combine(tempDir, $"{csvName}");
|
||||
answ = DataExport.SaveToCsv(ListaJobs, filePath, addHeader);
|
||||
if (answ)
|
||||
{
|
||||
lgInfo($"CSV: saved PODL file {csvName} at {filePath}");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return answ;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -6352,7 +6182,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
// PONTE SYNC/ASYNC: Ora sw.Stop() aspetterà la fine reale dell'operazione
|
||||
Task.Run(async () =>
|
||||
{
|
||||
var rawListPODL = await callUrl(urlGetNextPODL, false);
|
||||
var rawListPODL = await utils.callUrlAsync(urlGetNextPODL);
|
||||
if (!string.IsNullOrEmpty(rawListPODL))
|
||||
{
|
||||
reqPOdlList = JsonConvert.DeserializeObject<List<PODLModel>>(rawListPODL) ?? new List<PODLModel>();
|
||||
@@ -6889,15 +6719,14 @@ namespace IOB_WIN_FORM.Iob
|
||||
string rawWeek = JsonConvert.SerializeObject(cPerInfo);
|
||||
redHashWeek.Add(cWeek, rawWeek);
|
||||
}
|
||||
// salvo in redis...
|
||||
string fullKey = GetWeekStatsKey();
|
||||
var okHashDict = redisMan.redSaveHashDict(fullKey, redHashWeek);
|
||||
// salvo in redis...
|
||||
string fullKey = GetWeekStatsKey();
|
||||
var okHashDict = redisMan.redSaveHashDict(fullKey, redHashWeek);
|
||||
|
||||
// invio ANCHE in MP-IO l'update delle info...
|
||||
string remUrl = urlSetHashDict;
|
||||
string dictPayload = JsonConvert.SerializeObject(redHashWeek);
|
||||
//await callUrlWithPayloadAsync(remUrl, dictPayload, false);
|
||||
await callUrlWithPayloadAsync(remUrl, dictPayload, true);
|
||||
await utils.callUrlAsync(remUrl, dictPayload);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6919,9 +6748,9 @@ namespace IOB_WIN_FORM.Iob
|
||||
week = cal.GetWeekOfYear(adesso, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
|
||||
// verifico se ci sia la settimana indicata in elenco...
|
||||
string currWeek = $"{adesso:yyyy}-{week:00}";
|
||||
// recupero elenco delle settimane da processare da redis/WeekStats
|
||||
string fullKey = GetWeekStatsKey();
|
||||
Dictionary<string, string> currStats = redisMan.redGetHashDict(fullKey);
|
||||
// recupero elenco delle settimane da processare da redis/WeekStats
|
||||
string fullKey = GetWeekStatsKey();
|
||||
Dictionary<string, string> currStats = redisMan.redGetHashDict(fullKey);
|
||||
if (currStats != null && currStats.Count > 0)
|
||||
{
|
||||
// definisco il DICT delle settimane da processare (= settimane passate, NON la corrente...)
|
||||
@@ -7157,7 +6986,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
// PONTE SYNC/ASYNC: Ora sw.Stop() aspetterà la fine reale dell'operazione
|
||||
Task.Run(async () =>
|
||||
{
|
||||
var rawListPODL = await callUrl(urlGetNextPODL, false);
|
||||
var rawListPODL = await utils.callUrlAsync(urlGetNextPODL);
|
||||
if (!string.IsNullOrEmpty(rawListPODL))
|
||||
{
|
||||
try
|
||||
@@ -7350,7 +7179,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
{
|
||||
bool answ = false;
|
||||
DateTime dtCurr = DateTime.Now;
|
||||
string resp = await callUrl($"{urlODLClose}{idxOdl}&dtEve={dtRif}&dtCurr={dtCurr}", false);
|
||||
string resp = await utils.callUrlAsync($"{urlODLClose}{idxOdl}&dtEve={dtRif}&dtCurr={dtCurr}");
|
||||
answ = resp == "OK";
|
||||
return answ;
|
||||
}
|
||||
@@ -7371,7 +7200,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
Task.Run(async () =>
|
||||
{
|
||||
// invio chiamata URL x chiusura ODL su macchina
|
||||
string callResp = await callUrl(fullUrl, false);
|
||||
string callResp = await utils.callUrlAsync(fullUrl);
|
||||
answ = callResp == "OK";
|
||||
})
|
||||
.GetAwaiter()
|
||||
@@ -7522,7 +7351,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
// invio e salvo...
|
||||
string remUrl = urlSaveMachIobConf;
|
||||
string dictPayload = JsonConvert.SerializeObject(currDict);
|
||||
await callUrlWithPayloadAsync(remUrl, dictPayload, true);
|
||||
await utils.callUrlAsync(remUrl, dictPayload);
|
||||
lgTrace("Invio MachineConf effettuato");
|
||||
}
|
||||
}
|
||||
@@ -7549,9 +7378,6 @@ namespace IOB_WIN_FORM.Iob
|
||||
string url2call = $"{urlSetOptVal}pName={paramName}&pValue={paramValue}";
|
||||
lgInfo("chiamata URL " + url2call);
|
||||
await utils.callUrlAsync(url2call);
|
||||
#if false
|
||||
utils.callUrlNow(url2call);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7584,7 +7410,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
Task.Run(async () =>
|
||||
{
|
||||
// invio chiamata URL x chiusura ODL su macchina
|
||||
string callResp = await callUrl(fullUrl, false);
|
||||
string callResp = await utils.callUrlAsync(fullUrl);
|
||||
answ = callResp == "OK";
|
||||
})
|
||||
.GetAwaiter()
|
||||
@@ -7614,7 +7440,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
Task.Run(async () =>
|
||||
{
|
||||
// invio chiamata URL x chiusura ODL su macchina
|
||||
string callResp = await callUrl(fullUrl, false);
|
||||
string callResp = await utils.callUrlAsync(fullUrl);
|
||||
answ = callResp == "OK";
|
||||
})
|
||||
.GetAwaiter()
|
||||
@@ -8167,7 +7993,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
try
|
||||
{
|
||||
// invio chiamata URL x chiusura ODL su macchina
|
||||
string callResp = await callUrl(fullUrl, false);
|
||||
string callResp = await utils.callUrlAsync(fullUrl);
|
||||
fatto = (callResp != "KO") ? true : false;
|
||||
}
|
||||
catch
|
||||
@@ -8211,7 +8037,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
try
|
||||
{
|
||||
// invio chiamata URL x chiusura ODL su macchina
|
||||
string callResp = await callUrl(fullUrl, false);
|
||||
string callResp = await utils.callUrlAsync(fullUrl);
|
||||
fatto = (callResp != "KO") ? true : false;
|
||||
}
|
||||
catch
|
||||
@@ -8257,7 +8083,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
try
|
||||
{
|
||||
// invio chiamata URL x chiusura ODL su macchina
|
||||
string callResp = await callUrl(fullUrl, false);
|
||||
string callResp = await utils.callUrlAsync(fullUrl);
|
||||
fatto = (callResp != "KO") ? true : false;
|
||||
}
|
||||
catch
|
||||
@@ -8281,7 +8107,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
Task.Run(async () =>
|
||||
{
|
||||
// invio chiamata URL x chiusura ODL su macchina
|
||||
string callResp = await callUrl(fullUrl, false);
|
||||
string callResp = await utils.callUrlAsync(fullUrl);
|
||||
fatto = (callResp != "KO") ? true : false;
|
||||
})
|
||||
.GetAwaiter()
|
||||
@@ -8313,7 +8139,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
Task.Run(async () =>
|
||||
{
|
||||
// invio chiamata URL x chiusura ODL su macchina
|
||||
string callResp = await callUrl(fullUrl, false);
|
||||
string callResp = await utils.callUrlAsync(fullUrl);
|
||||
fatto = (callResp != "KO") ? true : false;
|
||||
})
|
||||
.GetAwaiter()
|
||||
@@ -8342,7 +8168,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
// PONTE SYNC/ASYNC: Ora sw.Stop() aspetterà la fine reale dell'operazione
|
||||
Task.Run(async () =>
|
||||
{
|
||||
string resp = await callUrl(urlEncoded, false);
|
||||
string resp = await utils.callUrlAsync(urlEncoded);
|
||||
int.TryParse(resp, out answ);
|
||||
})
|
||||
.GetAwaiter()
|
||||
@@ -8608,7 +8434,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
try
|
||||
{
|
||||
// invio chiamata URL x avvio PODL su macchina
|
||||
string rawSplit = await callUrl(fullUrl, false);
|
||||
string rawSplit = await utils.callUrlAsync(fullUrl);
|
||||
fatto = (rawSplit != "KO") ? true : false;
|
||||
}
|
||||
catch
|
||||
@@ -8633,7 +8459,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
try
|
||||
{
|
||||
// invio chiamata URL x avvio PODL su macchina
|
||||
string rawSplit = await callUrl(fullUrl, false);
|
||||
string rawSplit = await utils.callUrlAsync(fullUrl);
|
||||
fatto = (rawSplit != "KO") ? true : false;
|
||||
}
|
||||
catch
|
||||
@@ -8934,7 +8760,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
private async Task<DateTime> currOdlStart()
|
||||
{
|
||||
DateTime inizioOdl = DateTime.Now;
|
||||
string rawDataInizio = await callUrl(urlInizioOdlIob, false);
|
||||
string rawDataInizio = await utils.callUrlAsync(urlInizioOdlIob);
|
||||
DateTime.TryParse(rawDataInizio, out inizioOdl);
|
||||
return inizioOdl;
|
||||
}
|
||||
@@ -9060,7 +8886,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
|
||||
private async Task<bool> ExecuteIobCheckWithRetry(int maxRetries)
|
||||
{
|
||||
var rand = new Random();
|
||||
@@ -9070,14 +8896,11 @@ namespace IOB_WIN_FORM.Iob
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
// Al terzo tentativo fallito resetto i client
|
||||
if (i == 3) resetWebClients();
|
||||
|
||||
int delay = i == 3 ? rand.Next(250, 1000) : rand.Next(250, 500);
|
||||
await Task.Delay(delay);
|
||||
}
|
||||
|
||||
string callResp = await callUrl(urlIobEnabled, i < 3); // true per i primi tentativi
|
||||
string callResp = await utils.callUrlAsync(urlIobEnabled);
|
||||
if (callResp == "OK") return true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
@@ -9650,12 +9473,12 @@ namespace IOB_WIN_FORM.Iob
|
||||
// prova ad avviare/chiudere PODL relativo (eventualmente duplicandolo)
|
||||
dtEve = $"{dtStartPOdl:yyyyMMddHHmmssfff}";
|
||||
dtCurr = $"{DateTime.Now:yyyyMMddHHmmssfff}";
|
||||
await callUrl($"{urlOdlStartFromPOdl}{idxPOdl}&dtEve={dtEve}&dtCurr={dtCurr}", false);
|
||||
await utils.callUrlAsync($"{urlOdlStartFromPOdl}{idxPOdl}&dtEve={dtEve}&dtCurr={dtCurr}");
|
||||
|
||||
// ora chiamo chiusura...
|
||||
dtEve = $"{dtEndPOdl:yyyyMMddHHmmssfff}";
|
||||
dtCurr = $"{DateTime.Now:yyyyMMddHHmmssfff}";
|
||||
await callUrl($"{urlPODLClose}{idxPOdl}&dtEve={dtEve}&dtCurr={dtCurr}", false);
|
||||
await utils.callUrlAsync($"{urlPODLClose}{idxPOdl}&dtEve={dtEve}&dtCurr={dtCurr}");
|
||||
})
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
@@ -9676,14 +9499,15 @@ namespace IOB_WIN_FORM.Iob
|
||||
/// <param name="keyReq"></param>
|
||||
private async Task RecipeRemoveWeekStatus(string keyReq)
|
||||
{
|
||||
string fullKey = GetWeekStatsKey();
|
||||
var okHashDict = redisMan.redRemoveHashField(fullKey, keyReq);
|
||||
// rileggo status hash
|
||||
Dictionary<string, string> currDict = redisMan.redGetHashDict(fullKey);
|
||||
string fullKey = GetWeekStatsKey();
|
||||
var okHashDict = redisMan.redRemoveHashField(fullKey, keyReq);
|
||||
// rileggo status hash
|
||||
Dictionary<string, string> currDict = redisMan.redGetHashDict(fullKey);
|
||||
// invio ANCHE in MP-IO l'update delle info...
|
||||
string remUrl = urlSetHashDict;
|
||||
string dictPayload = JsonConvert.SerializeObject(currDict);
|
||||
await callUrlWithPayloadAsync(remUrl, dictPayload, true);
|
||||
await utils.callUrlAsync(remUrl, dictPayload);
|
||||
//await callUrlWithPayloadAsync(remUrl, dictPayload, true);
|
||||
//await callUrlWithPayloadAsync(remUrl, dictPayload, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -1603,10 +1603,10 @@ namespace IOB_WIN_FORM.Iob
|
||||
// PONTE SYNC/ASYNC: Ora sw.Stop() aspetterà la fine reale dell'operazione
|
||||
Task.Run(async () =>
|
||||
{
|
||||
var rawListArt = await callUrl(urlGetCurrArt, false);
|
||||
var rawListDOSS = await callUrl(urlGetCurrDOSS, false);
|
||||
var rawListPODL = await callUrl(urlGetNextPODL, false);
|
||||
var rawLVFasi = await callUrl(urlGetListValFasiPodl, false);
|
||||
var rawListArt = await utils.callUrlAsync(urlGetCurrArt);
|
||||
var rawListDOSS = await utils.callUrlAsync(urlGetCurrDOSS);
|
||||
var rawListPODL = await utils.callUrlAsync(urlGetNextPODL);
|
||||
var rawLVFasi = await utils.callUrlAsync(urlGetListValFasiPodl);
|
||||
|
||||
if (!string.IsNullOrEmpty(rawListArt))
|
||||
{
|
||||
@@ -1754,9 +1754,9 @@ namespace IOB_WIN_FORM.Iob
|
||||
// PONTE SYNC/ASYNC: Ora sw.Stop() aspetterà la fine reale dell'operazione
|
||||
Task.Run(async () =>
|
||||
{
|
||||
var rawListArt = await callUrl(urlGetCurrArt, false);
|
||||
var rawListDOSS = await callUrl(urlGetCurrDOSS, false);
|
||||
var rawListPODL = await callUrl(urlGetNextPODL, false);
|
||||
var rawListArt = await utils.callUrlAsync(urlGetCurrArt);
|
||||
var rawListDOSS = await utils.callUrlAsync(urlGetCurrDOSS);
|
||||
var rawListPODL = await utils.callUrlAsync(urlGetNextPODL);
|
||||
if (!string.IsNullOrEmpty(rawListArt))
|
||||
{
|
||||
try
|
||||
|
||||
+15
-7
@@ -12,17 +12,25 @@ Extract infrastructure and helper components from `Generic.cs` to improve modula
|
||||
- [ ] Implement a singleton/service-based `CommunicationService` using `HttpClient`.
|
||||
- [ ] **Italian Commenting Requirement**: All new/modified code comments must be in Italian.
|
||||
|
||||
### 2. Redis Service Extraction
|
||||
- [ ] Encapsulate all `redisMan` calls into a `RedisService`.
|
||||
- [ ] Define a clean interface for key/value and hash operations.
|
||||
### 2. Redis Service Extraction (COMPLETED)
|
||||
- [x] Encapsulate all `redisMan` calls into a `RedisService`.
|
||||
- [x] Define a clean interface for key/value and hash operations.
|
||||
- [x] **Refactored**: Moved semantic key construction from `RedisService` to `BaseObj` to eliminate redundant service layer.
|
||||
|
||||
### 3. Data Serializer Extraction
|
||||
- [ ] Move all `JsonConvert` and custom string formatting (e.g., `qEncodeFLog`, `qEncodeIN`) to a `DataSerializer` service.
|
||||
- [ ] Centralize `CultureInfo.InvariantCulture` usage.
|
||||
|
||||
### 4. BaseObj Simplification (NEW)
|
||||
- [ ] Analyze `BaseObj` responsibilities (State, Config, Messaging, Diagnostics).
|
||||
- [ ] Identify candidates for extraction into specialized services (e.g., `QueueManager`, `ConfigService`, `DiagnosticService`).
|
||||
- [ ] Implement extraction of identified components.
|
||||
|
||||
## Progress Log
|
||||
- [x] Created WIP document.
|
||||
- [x] Analyzed `Generic.cs` for Phase 1 candidates (found ~200 occurrences of key patterns).
|
||||
- [ ] Started Extraction of `CommunicationService`.
|
||||
- [ ] Started Extraction of `RedisService`.
|
||||
- [ ] Started Extraction of `DataSerializer`.
|
||||
- [x] Analyzed `Generic.cs` for Phase 1 candidates.
|
||||
- [x] Completed Redis Semantic Refactoring:
|
||||
- Moved key construction logic from `RedisService` to `BaseObj`.
|
||||
- Refactored `Generic.cs` to use `BaseObj` semantic methods.
|
||||
- Eliminated redundant `RedisService.cs`.
|
||||
- [ ] Started Analysis of `BaseObj` to identify extraction candidates.
|
||||
|
||||
Reference in New Issue
Block a user