diff --git a/IOB-WIN-NEXT/IobGeneric.cs b/IOB-WIN-NEXT/IobGeneric.cs
index beb86200..0ffc91af 100644
--- a/IOB-WIN-NEXT/IobGeneric.cs
+++ b/IOB-WIN-NEXT/IobGeneric.cs
@@ -25,96 +25,6 @@ namespace IOB_WIN_NEXT
{
public class IobGeneric
{
-
- ///
- /// Folder in cui salvare i file importati (es excel)
- ///
- protected string fileArchiveFolder { get; set; } = "";
-
- ///
- /// Folder da cui importare i file (es excel)
- ///
- protected string fileImportFolder { get; set; } = "";
-
- ///
- /// Tipologia di files da importare (default excel)
- ///
- protected string fileImportType { get; set; } = "*.xslx";
-
- ///
- /// Procedura di import file...
- ///
- ///
- protected virtual bool importFile(string fileItem)
- {
- return false;
- }
- ///
- /// Effettua eventuale file import, archiviando file importati
- ///
- ///
- protected virtual bool processFileImport()
- {
- bool answ = false;
- if (!string.IsNullOrEmpty(fileImportFolder))
- {
- // verifico esistenza folders...
- if (Directory.Exists(fileImportFolder))
- {
- // verifico archivio
- string dirArchive = $"{fileImportFolder}/archive";
- if (!Directory.Exists(dirArchive))
- {
- Directory.CreateDirectory(dirArchive);
- }
- // cerco files
- var listFiles = Directory.GetFiles(fileImportFolder, fileImportType);
- // se li trovo --> chiamo import!
- if (listFiles != null && listFiles.Length > 0)
- {
- foreach (var fileItem in listFiles)
- {
- string errore = "";
- answ = importFile(fileItem);
- if (!answ)
- {
- errore = $"Errore in fase di importFile x {fileItem}";
- }
- else
- {
- // provo forzare send...
- answ = svuotaCodaRawTransf(true);
- if (!answ)
- {
- errore = $"Errore in fase di invio dati svuotaCodaRawTransf x {fileItem}";
- }
- else
- {
- // sposto file...
- File.Move(fileItem, $"{dirArchive}/{Path.GetFileName(fileItem)}");
- }
- }
- // log eventuali errori
- if (!answ)
- {
- string dirError = $"{fileImportFolder}/errors";
- if (!Directory.Exists(dirError))
- {
- Directory.CreateDirectory(dirError);
- }
- // sposto file...
- File.Move(fileItem, $"{dirError}/{Path.GetFileName(fileItem)}");
- // segno errore!
- string fileError = $"{fileImportFolder}/errors.log";
- File.AppendAllText(fileError, errore);
- }
- }
- }
- }
- }
- return answ;
- }
-
#region Public Fields
///
@@ -905,6 +815,26 @@ namespace IOB_WIN_NEXT
}
}
+ ///
+ /// URL per chiamata generazione ODL giornalieri alla data
+ ///
+ public string urlFixDailyOdl
+ {
+ get
+ {
+ string answ = "";
+ try
+ {
+ answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/fixDailyOdl/{cIobConf.codIOB}";
+ }
+ catch (Exception exc)
+ {
+ lgError(exc, "Errore in composizione urlFixDailyOdl");
+ }
+ return answ;
+ }
+ }
+
///
/// URL per forzare split ODL...
///
@@ -982,44 +912,6 @@ namespace IOB_WIN_NEXT
}
}
- ///
- /// URL per recupero dati ODL alla data...
- ///
- public string urlGetOdlAtDate(DateTime dtRif)
- {
- string answ = "";
- try
- {
- answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/getOdlAtDate/{cIobConf.codIOB}?dateRif={dtRif:yyyyMMdd}";
- }
- catch (Exception exc)
- {
- lgError(exc, $"Errore in composizione urlGetOdlAtDate per {dtRif}{Environment.NewLine}{exc}");
- }
- return answ;
- }
-
-
- ///
- /// URL per chiamata generazione ODL giornalieri alla data
- ///
- public string urlFixDailyOdl
- {
- get
- {
- string answ = "";
- try
- {
- answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/fixDailyOdl/{cIobConf.codIOB}";
- }
- catch (Exception exc)
- {
- lgError(exc, "Errore in composizione urlFixDailyOdl");
- }
- return answ;
- }
- }
-
///
/// URL per recupero PODL correnti x macchina...
///
@@ -4115,6 +4007,23 @@ namespace IOB_WIN_NEXT
return answ;
}
+ ///
+ /// URL per recupero dati ODL alla data...
+ ///
+ public string urlGetOdlAtDate(DateTime dtRif)
+ {
+ string answ = "";
+ try
+ {
+ answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/getOdlAtDate/{cIobConf.codIOB}?dateRif={dtRif:yyyyMMdd}";
+ }
+ catch (Exception exc)
+ {
+ lgError(exc, $"Errore in composizione urlGetOdlAtDate per {dtRif}{Environment.NewLine}{exc}");
+ }
+ return answ;
+ }
+
///
/// Fornisce URL INPUT per i parametri richiesti
///
@@ -4243,6 +4152,11 @@ namespace IOB_WIN_NEXT
///
protected bool enablePzCountByIob = true;
+ ///
+ /// dizionario (opzionale) xz decodifica file da importare
+ ///
+ protected Dictionary FileDecod = new Dictionary();
+
///
/// indica che è richeisto forzatamente reset contapezzi
///
@@ -4425,6 +4339,21 @@ namespace IOB_WIN_NEXT
}
}
+ ///
+ /// Folder in cui salvare i file importati (es excel)
+ ///
+ protected string fileArchiveFolder { get; set; } = "";
+
+ ///
+ /// Folder da cui importare i file (es excel)
+ ///
+ protected string fileImportFolder { get; set; } = "";
+
+ ///
+ /// Tipologia di files da importare (default excel)
+ ///
+ protected string fileImportType { get; set; } = "*.xslx";
+
///
/// Variabile di appoggio GLOBALE x indicare che si può forzare reset contapezzi con
/// macchina in RUN
@@ -4924,6 +4853,15 @@ namespace IOB_WIN_NEXT
return answ;
}
+ ///
+ /// Procedura di import file...
+ ///
+ ///
+ protected virtual bool importFile(string fileItem)
+ {
+ return false;
+ }
+
///
/// Recupera da server set di dati specifici x IOB
///
@@ -5469,6 +5407,72 @@ namespace IOB_WIN_NEXT
{
}
+ ///
+ /// Effettua eventuale file import, archiviando file importati
+ ///
+ ///
+ protected virtual bool processFileImport()
+ {
+ bool answ = false;
+ if (!string.IsNullOrEmpty(fileImportFolder))
+ {
+ // verifico esistenza folders...
+ if (Directory.Exists(fileImportFolder))
+ {
+ // verifico archivio
+ string dirArchive = $"{fileImportFolder}/archive";
+ if (!Directory.Exists(dirArchive))
+ {
+ Directory.CreateDirectory(dirArchive);
+ }
+ // cerco files
+ var listFiles = Directory.GetFiles(fileImportFolder, fileImportType);
+ // se li trovo --> chiamo import!
+ if (listFiles != null && listFiles.Length > 0)
+ {
+ foreach (var fileItem in listFiles)
+ {
+ string errore = "";
+ answ = importFile(fileItem);
+ if (!answ)
+ {
+ errore = $"Errore in fase di importFile x {fileItem}";
+ }
+ else
+ {
+ // provo forzare send...
+ answ = svuotaCodaRawTransf(true);
+ if (!answ)
+ {
+ errore = $"Errore in fase di invio dati svuotaCodaRawTransf x {fileItem}";
+ }
+ else
+ {
+ // sposto file...
+ File.Move(fileItem, $"{dirArchive}/{Path.GetFileName(fileItem)}");
+ }
+ }
+ // log eventuali errori
+ if (!answ)
+ {
+ string dirError = $"{fileImportFolder}/errors";
+ if (!Directory.Exists(dirError))
+ {
+ Directory.CreateDirectory(dirError);
+ }
+ // sposto file...
+ File.Move(fileItem, $"{dirError}/{Path.GetFileName(fileItem)}");
+ // segno errore!
+ string fileError = $"{fileImportFolder}/errors.log";
+ File.AppendAllText(fileError, errore);
+ }
+ }
+ }
+ }
+ }
+ return answ;
+ }
+
///
/// Processa le richieste di scrittura memoria
///
@@ -5687,6 +5691,19 @@ namespace IOB_WIN_NEXT
// FIXME TODO FARE !!!! invio PUT del file *_alarm.json
}
+ ///
+ /// Setup parametri decode file excel (opzionale)
+ ///
+ protected virtual void setupFileDecod()
+ {
+ // verifica se siano necessari configuraizoni speciali dalla excDecod:
+ // es: lettura/invio file excel
+ if (memMap.fileDecod != null && memMap.fileDecod.Count > 0)
+ {
+ FileDecod = memMap.fileDecod;
+ }
+ }
+
///
/// setup parametri da file di conf
///
@@ -5831,24 +5848,6 @@ namespace IOB_WIN_NEXT
}
}
- ///
- /// dizionario (opzionale) xz decodifica file da importare
- ///
- protected Dictionary FileDecod = new Dictionary();
-
- ///
- /// Setup parametri decode file excel (opzionale)
- ///
- protected virtual void setupFileDecod()
- {
- // verifica se siano necessari configuraizoni speciali dalla excDecod:
- // es: lettura/invio file excel
- if (memMap.fileDecod != null && memMap.fileDecod.Count > 0)
- {
- FileDecod = memMap.fileDecod;
- }
- }
-
///
/// Cleanup stringa x impiego tipo ident da char dubbi
///
@@ -5859,6 +5858,27 @@ namespace IOB_WIN_NEXT
return origData.Replace(".", "").Replace(" ", "_");
}
+ ///
+ /// Effettua chiamata MP-IO per cheidere all'utente se vuole effettuare chiusura ODL
+ /// corrente della macchina
+ ///
+ ///
+ protected bool tryAskCloseODL()
+ {
+ bool fatto = false;
+ string fullUrl = $"{urlODLAskClose}{currIdxODL}";
+ try
+ {
+ // invio chiamata URL x chiusura ODL su macchina
+ string callResp = callUrl(fullUrl, false);
+ fatto = (callResp != "KO") ? true : false;
+ }
+ catch
+ { }
+ lgInfo($"Eseguito tryAskCloseODL per {currIdxODL} | url: {fullUrl} | esito: {fatto}");
+ return fatto;
+ }
+
///
/// Effettua chiamata MP-IO per tentare chiusura ODL corrente della macchina
///
@@ -5879,25 +5899,89 @@ namespace IOB_WIN_NEXT
return fatto;
}
-
///
- /// Effettua chiamata MP-IO per cheidere all'utente se vuole effettuare chiusura ODL corrente della macchina
+ /// Cerca di inviare su un altro thread i vari dati accumulati...
///
- ///
- protected bool tryAskCloseODL()
+ protected void trySendValues()
{
- bool fatto = false;
- string fullUrl = $"{urlODLAskClose}{currIdxODL}";
+ // init obj display
+ newDisplayData currDispData = new newDisplayData();
try
{
- // invio chiamata URL x chiusura ODL su macchina
- string callResp = callUrl(fullUrl, false);
- fatto = (callResp != "KO") ? true : false;
+ // verifico se risponde il server...
+ if (checkServerAlive)
+ {
+ bool iobOk = false;
+ if (utils.CRB("sendDataByThread"))
+ {
+ Task taskCheck = Task.Run(() => iobOk = checkIobEnabled);
+ }
+ else
+ {
+ iobOk = checkIobEnabled;
+ }
+ // verifico SE posso inviare dati
+ if (iobOk)
+ {
+ currDispData.semOut = Semaforo.SV;
+ // verificare come gestire il task secondario senza interferenza (chiamate
+ // update su FORM da thread secondari danno errori)
+ if (utils.CRB("sendDataByThread"))
+ {
+ // invio con thread separato...
+ Task taskSigIN = Task.Run(() => svuotaCodaSignIN());
+ Task taskFLog = Task.Run(() => svuotaCodaFLog());
+ Task taskRawTransf = Task.Run(() => svuotaCodaRawTransf());
+ Task taskULog = Task.Run(() => svuotaCodaULog());
+ }
+ else
+ {
+ // gestione queue SignalIN (invio, display)
+ svuotaCodaSignIN();
+ currDispData.counter = contapezziIOB;
+ raiseRefresh(currDispData);
+ // provo a svuotare coda contapezzi
+ svuotaCodaContapezzi();
+ currDispData.counter = contapezziIOB;
+ raiseRefresh(currDispData);
+ // gestione queue FluxLog (invio, display)
+ svuotaCodaFLog();
+ // coda RawTransf
+ svuotaCodaRawTransf();
+ // coda UserLog
+ svuotaCodaULog();
+ // refresh
+ raiseRefresh(currDispData);
+ }
+ // se arrivo è tutto ok...
+ currSendErrors = 0;
+ }
+ else
+ {
+ // mostro VETO-SEND x invio... GIALLO
+ currDispData.semOut = Semaforo.SG;
+ if (periodicLog)
+ {
+ lgInfo("IOB - VETO SEND");
+ }
+ }
+ }
+ else
+ {
+ // mostro SERVER KO x invio... ROSSO
+ currDispData.semOut = Semaforo.SR;
+ if (periodicLog)
+ {
+ lgError("IOB - SERVER NOT READY");
+ }
+ }
}
- catch
- { }
- lgInfo($"Eseguito tryAskCloseODL per {currIdxODL} | url: {fullUrl} | esito: {fatto}");
- return fatto;
+ catch (Exception exc)
+ {
+ lgError($"Errore in fase trySendValues | currSendErrors: {currSendErrors}{Environment.NewLine}{exc}");
+ currDispData.semOut = Semaforo.SR;
+ }
+ raiseRefresh(currDispData);
}
///
@@ -6852,91 +6936,6 @@ namespace IOB_WIN_NEXT
}
}
- ///
- /// Cerca di inviare su un altro thread i vari dati accumulati...
- ///
- protected void trySendValues()
- {
- // init obj display
- newDisplayData currDispData = new newDisplayData();
- try
- {
- // verifico se risponde il server...
- if (checkServerAlive)
- {
- bool iobOk = false;
- if (utils.CRB("sendDataByThread"))
- {
- Task taskCheck = Task.Run(() => iobOk = checkIobEnabled);
- }
- else
- {
- iobOk = checkIobEnabled;
- }
- // verifico SE posso inviare dati
- if (iobOk)
- {
- currDispData.semOut = Semaforo.SV;
- // verificare come gestire il task secondario senza interferenza (chiamate
- // update su FORM da thread secondari danno errori)
- if (utils.CRB("sendDataByThread"))
- {
- // invio con thread separato...
- Task taskSigIN = Task.Run(() => svuotaCodaSignIN());
- Task taskFLog = Task.Run(() => svuotaCodaFLog());
- Task taskRawTransf = Task.Run(() => svuotaCodaRawTransf());
- Task taskULog = Task.Run(() => svuotaCodaULog());
- }
- else
- {
- // gestione queue SignalIN (invio, display)
- svuotaCodaSignIN();
- currDispData.counter = contapezziIOB;
- raiseRefresh(currDispData);
- // provo a svuotare coda contapezzi
- svuotaCodaContapezzi();
- currDispData.counter = contapezziIOB;
- raiseRefresh(currDispData);
- // gestione queue FluxLog (invio, display)
- svuotaCodaFLog();
- // coda RawTransf
- svuotaCodaRawTransf();
- // coda UserLog
- svuotaCodaULog();
- // refresh
- raiseRefresh(currDispData);
- }
- // se arrivo è tutto ok...
- currSendErrors = 0;
- }
- else
- {
- // mostro VETO-SEND x invio... GIALLO
- currDispData.semOut = Semaforo.SG;
- if (periodicLog)
- {
- lgInfo("IOB - VETO SEND");
- }
- }
- }
- else
- {
- // mostro SERVER KO x invio... ROSSO
- currDispData.semOut = Semaforo.SR;
- if (periodicLog)
- {
- lgError("IOB - SERVER NOT READY");
- }
- }
- }
- catch (Exception exc)
- {
- lgError($"Errore in fase trySendValues | currSendErrors: {currSendErrors}{Environment.NewLine}{exc}");
- currDispData.semOut = Semaforo.SR;
- }
- raiseRefresh(currDispData);
- }
-
///
/// Aggiorna un valore del dizionario in INCREMENTO e lo restituisce
///