- reog codice x IobGeneric
This commit is contained in:
+243
-244
@@ -25,96 +25,6 @@ namespace IOB_WIN_NEXT
|
||||
{
|
||||
public class IobGeneric
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Folder in cui salvare i file importati (es excel)
|
||||
/// </summary>
|
||||
protected string fileArchiveFolder { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Folder da cui importare i file (es excel)
|
||||
/// </summary>
|
||||
protected string fileImportFolder { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Tipologia di files da importare (default excel)
|
||||
/// </summary>
|
||||
protected string fileImportType { get; set; } = "*.xslx";
|
||||
|
||||
/// <summary>
|
||||
/// Procedura di import file...
|
||||
/// </summary>
|
||||
/// <param name="fileItem"></param>
|
||||
protected virtual bool importFile(string fileItem)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// Effettua eventuale file import, archiviando file importati
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
@@ -905,6 +815,26 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// URL per chiamata generazione ODL giornalieri alla data
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// URL per forzare split ODL...
|
||||
/// </summary>
|
||||
@@ -982,44 +912,6 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// URL per recupero dati ODL alla data...
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// URL per chiamata generazione ODL giornalieri alla data
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// URL per recupero PODL correnti x macchina...
|
||||
/// </summary>
|
||||
@@ -4115,6 +4007,23 @@ namespace IOB_WIN_NEXT
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// URL per recupero dati ODL alla data...
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fornisce URL INPUT per i parametri richiesti
|
||||
/// </summary>
|
||||
@@ -4243,6 +4152,11 @@ namespace IOB_WIN_NEXT
|
||||
/// </summary>
|
||||
protected bool enablePzCountByIob = true;
|
||||
|
||||
/// <summary>
|
||||
/// dizionario (opzionale) xz decodifica file da importare
|
||||
/// </summary>
|
||||
protected Dictionary<string, int> FileDecod = new Dictionary<string, int>();
|
||||
|
||||
/// <summary>
|
||||
/// indica che è richeisto forzatamente reset contapezzi
|
||||
/// </summary>
|
||||
@@ -4425,6 +4339,21 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Folder in cui salvare i file importati (es excel)
|
||||
/// </summary>
|
||||
protected string fileArchiveFolder { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Folder da cui importare i file (es excel)
|
||||
/// </summary>
|
||||
protected string fileImportFolder { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Tipologia di files da importare (default excel)
|
||||
/// </summary>
|
||||
protected string fileImportType { get; set; } = "*.xslx";
|
||||
|
||||
/// <summary>
|
||||
/// 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Procedura di import file...
|
||||
/// </summary>
|
||||
/// <param name="fileItem"></param>
|
||||
protected virtual bool importFile(string fileItem)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera da server set di dati specifici x IOB
|
||||
/// </summary>
|
||||
@@ -5469,6 +5407,72 @@ namespace IOB_WIN_NEXT
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua eventuale file import, archiviando file importati
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processa le richieste di scrittura memoria
|
||||
/// </summary>
|
||||
@@ -5687,6 +5691,19 @@ namespace IOB_WIN_NEXT
|
||||
// FIXME TODO FARE !!!! invio PUT del file *_alarm.json
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Setup parametri decode file excel (opzionale)
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// setup parametri da file di conf
|
||||
/// </summary>
|
||||
@@ -5831,24 +5848,6 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// dizionario (opzionale) xz decodifica file da importare
|
||||
/// </summary>
|
||||
protected Dictionary<string, int> FileDecod = new Dictionary<string, int>();
|
||||
|
||||
/// <summary>
|
||||
/// Setup parametri decode file excel (opzionale)
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleanup stringa x impiego tipo ident da char dubbi
|
||||
/// </summary>
|
||||
@@ -5859,6 +5858,27 @@ namespace IOB_WIN_NEXT
|
||||
return origData.Replace(".", "").Replace(" ", "_");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua chiamata MP-IO per cheidere all'utente se vuole effettuare chiusura ODL
|
||||
/// corrente della macchina
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua chiamata MP-IO per tentare chiusura ODL corrente della macchina
|
||||
/// </summary>
|
||||
@@ -5879,25 +5899,89 @@ namespace IOB_WIN_NEXT
|
||||
return fatto;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 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...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -6852,91 +6936,6 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cerca di inviare su un altro thread i vari dati accumulati...
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiorna un valore del dizionario in INCREMENTO e lo restituisce
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user