From 9b17e116abe268b7000f47d03e445d5e817fbe8c Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 21 Feb 2025 19:13:54 +0100 Subject: [PATCH 1/2] Porting nuova versione conf + nuova gestione obj x calcolo URL: NON finito, ma compila... --- IOB-UT-NEXT/Config/Base/CmdUriDto.cs | 15 +- IOB-UT-NEXT/Config/Base/IobDto.cs | 8 + IOB-UT-NEXT/Config/Base/ServerMapoDto.cs | 30 ++ IOB-UT-NEXT/Config/IobConfTree.cs | 119 ++++--- IOB-UT-NEXT/Config/Special/SpecializedDto.cs | 4 +- IOB-UT-NEXT/baseUtils.cs | 13 + IOB-WIN-FORM/AdapterForm.cs | 17 +- IOB-WIN-FORM/Iob/BaseObj.cs | 100 +----- IOB-WIN-FORM/Iob/Generic.cs | 338 +++++++------------ IOB-WIN-FORM/Properties/AssemblyInfo.cs | 2 +- IOB-WIN-SHELLY/Properties/AssemblyInfo.cs | 2 +- 11 files changed, 265 insertions(+), 383 deletions(-) diff --git a/IOB-UT-NEXT/Config/Base/CmdUriDto.cs b/IOB-UT-NEXT/Config/Base/CmdUriDto.cs index a593d7f7..2184ca6b 100644 --- a/IOB-UT-NEXT/Config/Base/CmdUriDto.cs +++ b/IOB-UT-NEXT/Config/Base/CmdUriDto.cs @@ -45,8 +45,8 @@ namespace IOB_UT_NEXT.Config.Base /// public string GetCommand(string key) { - // default ad implicito... - string answ = $"{BaseUri}/{key}/"; + // default ad implicito con IOB... + string answ = $"{BaseUri}/IOB/{key}/"; if (CurrSetup.ContainsKey(key)) { answ = CurrSetup[key]; @@ -57,17 +57,24 @@ namespace IOB_UT_NEXT.Config.Base public Dictionary StdCommands() { CurrSetup = new Dictionary(); - CurrSetup.Add("Alive", "IOB"); + CurrSetup.Add("alive", "IOB"); CurrSetup.Add("Base", "IOB/input/"); CurrSetup.Add("BaseJson", "IOB/evListJson/"); CurrSetup.Add("RawTransfJson", "IOB/rawTransfJson/"); CurrSetup.Add("Enabled", "IOB/enabled/"); CurrSetup.Add("Flog", "IOB/flog/"); CurrSetup.Add("FlogJson", "IOB/flogJson/"); - CurrSetup.Add("ForcleSplitOdl", "IOB/forceSplitOdlFull/"); + //CurrSetup.Add("fixDailyDossier", "IOB/fixDailyDossier/"); + //CurrSetup.Add("fixDailyOdl", "IOB/fixDailyOdl/"); + //CurrSetup.Add("fixDailyOdlConfPzCount", "IOB/fixDailyOdlConfPzCount/"); + //CurrSetup.Add("forceCreatePOdl", "IOB/forceCreatePOdl/"); + //CurrSetup.Add("forceSplitOdlFull", "IOB/forceSplitOdlFull/"); + //CurrSetup.Add("getPOdlAct", "IOB/getPOdlAct/"); CurrSetup.Add("IdleTime", "IOB/getIdlePeriod/"); CurrSetup.Add("OdlStarted", "IOB/getCurrOdlStart/"); CurrSetup.Add("Reboot", "IOB/sendReboot.aspx?idxMacchina="); + //CurrSetup.Add("savePzCountInc", "IOB/savePzCountInc/"); + //CurrSetup.Add("savePzCountIncAtDate", "IOB/savePzCountIncAtDate/"); // riordino CurrSetup = CurrSetup.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value); return CurrSetup; diff --git a/IOB-UT-NEXT/Config/Base/IobDto.cs b/IOB-UT-NEXT/Config/Base/IobDto.cs index e8ea27dc..6d6659ef 100644 --- a/IOB-UT-NEXT/Config/Base/IobDto.cs +++ b/IOB-UT-NEXT/Config/Base/IobDto.cs @@ -17,6 +17,14 @@ namespace IOB_UT_NEXT.Config.Base /// public string ConfFileName { get; set; } = ""; + /// + /// Filename senza desinenza del tipo di file + /// + public string FilenameIOB + { + get => baseUtils.StringBeforeLastChar(ConfFileName, '.'); + } + /// /// Tipo Adapter specifico (implementazione) /// diff --git a/IOB-UT-NEXT/Config/Base/ServerMapoDto.cs b/IOB-UT-NEXT/Config/Base/ServerMapoDto.cs index 90641b06..5cbab5f6 100644 --- a/IOB-UT-NEXT/Config/Base/ServerMapoDto.cs +++ b/IOB-UT-NEXT/Config/Base/ServerMapoDto.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using YamlDotNet.Core.Tokens; namespace IOB_UT_NEXT.Config.Base { @@ -23,6 +24,35 @@ namespace IOB_UT_NEXT.Config.Base /// public string BaseAppUrl { get; set; } = "/MP/IO/"; + /// + /// Restituisce la API del comando richiesto dalla BaseUrl + /// + /// Comando richiesto da comporre + /// + public string ApiUrl(string CmdReq) + { + // default ad implicito con IOB... + string answ = $"{BaseAppUrl}/IOB/{CmdReq}"; + if (Commands.ContainsKey(CmdReq)) + { + answ = $"{BaseAppUrl}{Commands[CmdReq]}"; + } + return answ; +#if false + string answ = BaseAppUrl; + if (Commands.ContainsKey(CmdReq)) + { + answ = $"{BaseAppUrl}{Commands[CmdReq]}"; + } + // altrimenti prendo cmd base IOB e compongo... + else + { + answ = $"{BaseAppUrl}/IOB/{CmdReq}"; + } + return answ; +#endif + } + /// /// Dizionario comandi configurati /// diff --git a/IOB-UT-NEXT/Config/IobConfTree.cs b/IOB-UT-NEXT/Config/IobConfTree.cs index 465686cb..ae4f2ea6 100644 --- a/IOB-UT-NEXT/Config/IobConfTree.cs +++ b/IOB-UT-NEXT/Config/IobConfTree.cs @@ -69,7 +69,7 @@ namespace IOB_UT_NEXT.Config if (newConfObj != null) { // ora copio in oggetto corrente... - IobConf = newConfObj.IobConf; + GenConf = newConfObj.GenConf; DeviceConf = newConfObj.DeviceConf; ProcInputConf = newConfObj.ProcInputConf; OptParConf = newConfObj.OptParConf; @@ -78,7 +78,7 @@ namespace IOB_UT_NEXT.Config TCDataConf = newConfObj.TCDataConf; ActionConf = newConfObj.ActionConf; // sovrascrivo filename - IobConf.ConfFileName = fileName; + GenConf.ConfFileName = fileName; } } } @@ -100,7 +100,7 @@ namespace IOB_UT_NEXT.Config string codIob = Path.GetFileNameWithoutExtension(iniFilePath); // Dati generali (vendor, modello...) - newConfObj.IobConf = new IobDto() + newConfObj.GenConf = new IobDto() { CodIOB = fIni.ReadString("IOB", "IOB_NAME", codIob), ConfFileName = Path.GetFileName(iniFilePath), @@ -114,11 +114,11 @@ namespace IOB_UT_NEXT.Config // tipo adapter// verifico tipo adapter try { - newConfObj.IobConf.IobType = (tipoAdapter)Enum.Parse(typeof(tipoAdapter), fIni.ReadString("IOB", "CNCTYPE", "ND")); + newConfObj.GenConf.IobType = (tipoAdapter)Enum.Parse(typeof(tipoAdapter), fIni.ReadString("IOB", "CNCTYPE", "ND")); } catch (Exception exc) { - newConfObj.IobConf.IobType = tipoAdapter.ND; + newConfObj.GenConf.IobType = tipoAdapter.ND; string rawVal = fIni.ReadString("IOB", "CNCTYPE", "DEMO"); newConfObj.lgError($"Eccezione in conversione tipo adapter: richiesto {rawVal} | tipo non codificato...{Environment.NewLine}{exc}"); } @@ -312,63 +312,10 @@ namespace IOB_UT_NEXT.Config return newConfObj; } - #region Logging - /// - /// oggetto logging + /// Info generali delative all'IOB impiegato /// - protected Logger Log;// = LogManager.GetCurrentClassLogger(); - - /// - /// Effettua logging DEBUG corretto impostanto anche la variabile IOB prima di scrivere... - /// - /// - protected void lgDebug(string txt2log) - { - Log.Factory.Configuration.Variables["codIOB"] = IobConf.CodIOB; - Log.Debug(txt2log); - } - - /// - /// Effettua logging ERROR corretto impostanto anche la variabile IOB prima di scrivere... - /// - /// - protected void lgError(string txt2log) - { - if (!string.IsNullOrEmpty(txt2log)) - { - Log.Factory.Configuration.Variables["codIOB"] = IobConf.CodIOB; - Log.Error(txt2log); - } - } - - /// - /// Effettua logging INFO corretto impostanto anche la variabile IOB prima di scrivere... - /// - /// - protected void lgInfo(string txt2log) - { - Log.Factory.Configuration.Variables["codIOB"] = IobConf.CodIOB; - Log.Info(txt2log); - } - - /// - /// Effettua logging TRACE corretto impostanto anche la variabile IOB prima di scrivere... - /// - /// - protected void lgTrace(string txt2log) - { - Log.Factory.Configuration.Variables["codIOB"] = IobConf.CodIOB; - Log.Trace(txt2log); - } - - #endregion - - - /// - /// Info specifiche del programma IOB - /// - public IobDto IobConf { get; set; } = new IobDto(); + public IobDto GenConf { get; set; } = new IobDto(); /// /// Info relative al device interconnesso @@ -485,5 +432,57 @@ namespace IOB_UT_NEXT.Config } #endregion + + #region Logging + + /// + /// oggetto logging + /// + protected Logger Log;// = LogManager.GetCurrentClassLogger(); + + /// + /// Effettua logging DEBUG corretto impostanto anche la variabile IOB prima di scrivere... + /// + /// + protected void lgDebug(string txt2log) + { + Log.Factory.Configuration.Variables["codIOB"] = GenConf.CodIOB; + Log.Debug(txt2log); + } + + /// + /// Effettua logging ERROR corretto impostanto anche la variabile IOB prima di scrivere... + /// + /// + protected void lgError(string txt2log) + { + if (!string.IsNullOrEmpty(txt2log)) + { + Log.Factory.Configuration.Variables["codIOB"] = GenConf.CodIOB; + Log.Error(txt2log); + } + } + + /// + /// Effettua logging INFO corretto impostanto anche la variabile IOB prima di scrivere... + /// + /// + protected void lgInfo(string txt2log) + { + Log.Factory.Configuration.Variables["codIOB"] = GenConf.CodIOB; + Log.Info(txt2log); + } + + /// + /// Effettua logging TRACE corretto impostanto anche la variabile IOB prima di scrivere... + /// + /// + protected void lgTrace(string txt2log) + { + Log.Factory.Configuration.Variables["codIOB"] = GenConf.CodIOB; + Log.Trace(txt2log); + } + + #endregion } } \ No newline at end of file diff --git a/IOB-UT-NEXT/Config/Special/SpecializedDto.cs b/IOB-UT-NEXT/Config/Special/SpecializedDto.cs index 87e4f1d1..955a2993 100644 --- a/IOB-UT-NEXT/Config/Special/SpecializedDto.cs +++ b/IOB-UT-NEXT/Config/Special/SpecializedDto.cs @@ -18,7 +18,7 @@ namespace IOB_UT_NEXT.Config.Special public plcMemMapExt MemMap { get; set; } /// - /// Configurazione specifica OPC-UA + /// Configurazione specifica MTC /// public MtcParamConf MtcConf { get; set; } @@ -28,7 +28,7 @@ namespace IOB_UT_NEXT.Config.Special public OpcUaParamConf OpcUaConf { get; set; } /// - /// Configurazione specifica OPC-UA + /// Configurazione specifica REST /// public RestParamConf RestConf { get; set; } diff --git a/IOB-UT-NEXT/baseUtils.cs b/IOB-UT-NEXT/baseUtils.cs index b5e1bdce..b85b4d71 100644 --- a/IOB-UT-NEXT/baseUtils.cs +++ b/IOB-UT-NEXT/baseUtils.cs @@ -782,6 +782,19 @@ namespace IOB_UT_NEXT } } + /// + /// Restitusice la stringa prima dell'ultima occorrenza del char richiesto + /// + /// string originale + /// char separatore da cercare + /// + public static string StringBeforeLastChar(string origString, char sepChar) + { + int index = origString.LastIndexOf(sepChar); + string answ = (index == -1) ? origString : origString.Substring(0, index); + return answ; + } + #endregion Public Methods #region Protected Properties diff --git a/IOB-WIN-FORM/AdapterForm.cs b/IOB-WIN-FORM/AdapterForm.cs index 4771bb95..68cfd333 100644 --- a/IOB-WIN-FORM/AdapterForm.cs +++ b/IOB-WIN-FORM/AdapterForm.cs @@ -1738,7 +1738,10 @@ namespace IOB_WIN_FORM // preparazione file conf con nuovo formato e salvataggio... IOBConfFull = IobConfTree.LoadFromINI(iniConfFile); - IOBConfFull.IobConf.ConfFileName = IOBConfFull.IobConf.ConfFileName.Replace("ini", "yaml"); + if (IOBConfFull.GenConf.ConfFileName.EndsWith("ini")) + { + IOBConfFull.GenConf.ConfFileName = IOBConfFull.GenConf.ConfFileName.Replace("ini", "yaml"); + } // salvo anche yaml... IOBConfFull.SaveYaml(fullPath.Replace("iob", "yaml")); @@ -1948,15 +1951,15 @@ namespace IOB_WIN_FORM counterIob = $"pz IOB {iobObj.contapezziIOB}"; counterMac = $"pz PLC {iobObj.contapezziPLC}"; Dictionary setPar = new Dictionary(); - setPar.Add("IP", iobObj.cIobConf.cncIpAddr); - setPar.Add("PORT", iobObj.cIobConf.cncPort); - string note = $"{iobObj.cIobConf.codIOB} | DT ultimo avvio: {iobObj.dtAvvioAdp}"; + setPar.Add("IP", iobObj.IOBConfFull.DeviceConf.ConnectConf.IpAddr); + setPar.Add("PORT", iobObj.IOBConfFull.DeviceConf.ConnectConf.Port); + string note = $"{iobObj.IOBConfFull.GenConf.CodIOB} | DT ultimo avvio: {iobObj.dtAvvioAdp}"; // verifico IOB status IobWinStatus currIobStatus = new IobWinStatus() { - //CodIob = iobObj.cIobConf.codIOB, - CodIob = iobObj.cIobConf.filenameIOB, - IobType = iobObj.cIobConf.tipoIob.ToString(), + //CodIob = iobObj.cIobConf.filenameIOB, + CodIob = iobObj.IOBConfFull.GenConf.FilenameIOB, + IobType = $"{iobObj.IOBConfFull.GenConf.IobType}",//iobObj.cIobConf.tipoIob.ToString(), queueAlLen = alQueueLen, queueEvLen = evQueueLen, queueFlLen = flQueueLen, diff --git a/IOB-WIN-FORM/Iob/BaseObj.cs b/IOB-WIN-FORM/Iob/BaseObj.cs index f44734c0..c4b17408 100644 --- a/IOB-WIN-FORM/Iob/BaseObj.cs +++ b/IOB-WIN-FORM/Iob/BaseObj.cs @@ -37,7 +37,7 @@ namespace IOB_WIN_FORM.Iob // se non ho veto --> loggo if (!doVeto) { - lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB; + lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB; lg.Error(message, args); sendToLogWatch("ERROR", message, args); } @@ -80,7 +80,7 @@ namespace IOB_WIN_FORM.Iob // se non ho veto --> loggo if (!doVeto) { - lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB; + lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB; lg.Debug(message); if (sendToForm) { @@ -100,7 +100,7 @@ namespace IOB_WIN_FORM.Iob // se non ho veto --> loggo if (!doVeto) { - lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB; + lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB; lg.Debug(message, args); sendToLogWatch("DEBUG", message, args); } @@ -112,20 +112,11 @@ namespace IOB_WIN_FORM.Iob /// protected void lgError(string message, bool sendToForm = true) { -#if false - try - { - } - catch - { - readErrorCurr++; - } -#endif bool doVeto = checkLogVeto(2, ref message); // se non ho veto --> loggo if (!doVeto) { - lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB; + lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB; lg.Error(message); if (sendToForm) { @@ -142,20 +133,11 @@ namespace IOB_WIN_FORM.Iob /// protected void lgError(Exception exception, string message, params object[] args) { -#if false - try - { - } - catch - { - readErrorCurr++; - } -#endif bool doVeto = checkLogVeto(2, ref message); // se non ho veto --> loggo if (!doVeto) { - lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB; + lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB; lg.Error(exception, message, args); sendToLogWatch("ERROR", message, exception, args); } @@ -167,20 +149,11 @@ namespace IOB_WIN_FORM.Iob /// protected void lgFatal(string message, bool sendToForm = true) { -#if false - try - { - } - catch - { - readErrorCurr++; - } -#endif bool doVeto = checkLogVeto(1, ref message); // se non ho veto --> loggo if (!doVeto) { - lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB; + lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB; lg.Fatal(message); if (sendToForm) { @@ -196,20 +169,11 @@ namespace IOB_WIN_FORM.Iob /// protected void lgFatal(string message, params object[] args) { -#if false - try - { - } - catch - { - readErrorCurr++; - } -#endif bool doVeto = checkLogVeto(1, ref message); // se non ho veto --> loggo if (!doVeto) { - lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB; + lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB; lg.Fatal(message, args); sendToLogWatch("FATAL", message, args); } @@ -223,20 +187,11 @@ namespace IOB_WIN_FORM.Iob /// protected void lgFatal(Exception exception, string message, params object[] args) { -#if false - try - { - } - catch - { - readErrorCurr++; - } -#endif bool doVeto = checkLogVeto(1, ref message); // se non ho veto --> loggo if (!doVeto) { - lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB; + lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB; lg.Fatal(exception, message, args); sendToLogWatch("FATAL", message, exception, args); } @@ -252,22 +207,13 @@ namespace IOB_WIN_FORM.Iob // se non ho veto --> loggo if (!doVeto) { - lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB; + lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB; lg.Info(message); if (sendToForm) { sendToLogWatch("INFO", message); } } -#if false - try - { - } - catch - { - readErrorCurr++; - } -#endif } /// @@ -277,20 +223,11 @@ namespace IOB_WIN_FORM.Iob /// protected void lgInfo(string message, params object[] args) { -#if false - try - { - } - catch - { - readErrorCurr++; - } -#endif bool doVeto = checkLogVeto(30, ref message); // se non ho veto --> loggo if (!doVeto) { - lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB; + lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB; lg.Info(message, args); sendToLogWatch("INFO", message, args); } @@ -303,20 +240,11 @@ namespace IOB_WIN_FORM.Iob /// protected void lgInfoStartup(string message, bool sendToForm = true) { -#if false - try - { - } - catch - { - readErrorCurr++; - } -#endif bool doVeto = checkLogVeto(30, ref message); // se non ho veto --> loggo if (!doVeto) { - lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB; + lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB; DateTime adesso = DateTime.Now; if (adesso.Subtract(lastLogStartup).TotalMinutes > vetoLogStartupDuration) { @@ -345,7 +273,7 @@ namespace IOB_WIN_FORM.Iob // se non ho veto --> loggo if (!doVeto) { - lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB; + lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB; DateTime adesso = DateTime.Now; if (adesso.Subtract(lastLogStartup).TotalMinutes > vetoLogStartupDuration) { @@ -370,7 +298,7 @@ namespace IOB_WIN_FORM.Iob // se non ho veto --> loggo if (!doVeto) { - lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB; + lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB; lg.Trace(message); if (sendToForm) { @@ -390,7 +318,7 @@ namespace IOB_WIN_FORM.Iob // se non ho veto --> loggo if (!doVeto) { - lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB; + lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB; lg.Trace(message, args); sendToLogWatch("TRACE", message, args); } diff --git a/IOB-WIN-FORM/Iob/Generic.cs b/IOB-WIN-FORM/Iob/Generic.cs index 0f9e1839..e4d94330 100644 --- a/IOB-WIN-FORM/Iob/Generic.cs +++ b/IOB-WIN-FORM/Iob/Generic.cs @@ -59,8 +59,8 @@ namespace IOB_WIN_FORM.Iob cIobConf = IOBConf; IOBConfFull = IobConfNew; - // imposto le code! - QueueIN = new DataQueue(cIobConf.codIOB, "QueueIN", cIobConf.EnableRedisQueue); + // imposto le code! + QueueIN = new DataQueue(IOBConfFull.GenConf.CodIOB, "QueueIN", cIobConf.EnableRedisQueue); lastConnectTry = DateTime.Now; @@ -213,7 +213,7 @@ namespace IOB_WIN_FORM.Iob } else { - lgError($"SERVER NOT RESPONDING (PING at {cIobConf.serverData.MPIP})"); + lgError($"SERVER NOT RESPONDING (PING at {IOBConfFull.MapoMesConf.IpAddr})"); MPOnline = false; // imposto veto a 10 volte reinvio dati standard... dtVetoPing = DateTime.Now.AddMilliseconds(baseUtils.nextPauseSendMSec * 10); @@ -497,24 +497,35 @@ namespace IOB_WIN_FORM.Iob /// public int RawDataInputStart { get; set; } = 0; + /// + /// URL di base del server MES da contattare + /// + private string urlMesServer + { + get => $@"{IOBConfFull.MapoMesConf.Transport}://{IOBConfFull.MapoMesConf.IpAddr}"; + } + + /// + /// URL del comando letto da conf in aggiunta al server MES da contattare + /// + private string urlCommand(string cmqReq) + { + return $@"{urlMesServer}{IOBConfFull.MapoMesConf.ApiUrl(cmqReq)}"; + } + /// + /// URL come urlCommand + aggiunta codice IOB da cui viene inviato + /// + private string urlCommandIob(string cmqReq) + { + return $@"{urlMesServer}{IOBConfFull.MapoMesConf.ApiUrl(cmqReq)}{IOBConfFull.GenConf.CodIOB}"; + } + /// /// URL per INVIO IN BLOCCO di un INCREMENTO x contapezzi (quelli della macchina: PLC/CNC)... /// public string urlAddPzCount { - get - { - string answ = ""; - try - { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/savePzCountInc/{cIobConf.codIOB}?qty="; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlAddPzCount"); - } - return answ; - } + get => $@"{urlCommandIob("savePzCountInc")}?qty="; } /// @@ -523,19 +534,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlAddPzCountAtDate { - get - { - string answ = ""; - try - { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/savePzCountIncAtDate/{cIobConf.codIOB}?qty="; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlAddPzCount"); - } - return answ; - } + get => $@"{urlCommandIob("savePzCountIncAtDate")}?qty="; } /// @@ -545,7 +544,7 @@ namespace IOB_WIN_FORM.Iob { get { - return $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}"; + return $@"{urlCommand("alive")}"; } } @@ -554,19 +553,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlCreatePOdl { - get - { - string answ = ""; - try - { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/forceCreatePOdl/{cIobConf.codIOB}?"; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlStartPODL"); - } - return answ; - } + get => $@"{urlCommandIob("forceCreatePOdl")}?"; } /// @@ -574,19 +561,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlFixDailyDossier { - get - { - string answ = ""; - try - { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/fixDailyDossier/{cIobConf.codIOB}"; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlFixDailyDossier"); - } - return answ; - } + get => $@"{urlCommandIob("fixDailyDossier")}"; } /// @@ -594,19 +569,7 @@ namespace IOB_WIN_FORM.Iob /// 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; - } + get => $@"{urlCommandIob("fixDailyOdl")}"; } /// @@ -614,19 +577,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlFixDailyOdlConfPzCount { - get - { - string answ = ""; - try - { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/fixDailyOdlConfPzCount/{cIobConf.codIOB}"; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlFixDailyOdlConfPzCount"); - } - return answ; - } + get => $@"{urlCommandIob("fixDailyOdlConfPzCount")}"; } /// @@ -634,16 +585,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlForceSplit { - get - { - string answ = $"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMD_FORCLE_SPLIT_ODL}{cIobConf.codIOB}?doConfirm=true&qtyFromLast=true&roundStep=500"; - // se richiesto inviare Key Richiesta --> accodo! - if (sendKeyRichiesta) - { - answ += $"&keyRichiesta={nextKeyRich}"; - } - return answ; - } + get => $"{urlCommandIob("forceSplitOdlFull")}?doConfirm=true&qtyFromLast=true&roundStep=500"; } /// @@ -651,19 +593,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlGetActPODL { - get - { - string answ = ""; - try - { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/getPOdlAct/{cIobConf.codIOB}"; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlGetActPODL"); - } - return answ; - } + get => $@"{urlCommandIob("getPOdlAct")}"; } /// @@ -671,19 +601,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlGetCurrArt { - get - { - string answ = ""; - try - { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/getLastArtByMacc/{cIobConf.codIOB}"; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlGetCurrArt"); - } - return answ; - } + get => $@"{urlCommandIob("getLastArtByMacc")}"; } /// @@ -691,19 +609,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlGetCurrDOSS { - get - { - string answ = ""; - try - { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/getLastDossByMacc/{cIobConf.codIOB}"; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlGetCurrDOSS"); - } - return answ; - } + get => $@"{urlCommandIob("getLastDossByMacc")}"; } /// @@ -711,19 +617,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlGetCurrODL { - get - { - string answ = ""; - try - { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/getCurrODL/{cIobConf.codIOB}"; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlGetCurrODL"); - } - return answ; - } + get => $@"{urlCommandIob("getCurrODL")}"; } /// @@ -736,7 +630,7 @@ namespace IOB_WIN_FORM.Iob string answ = ""; try { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/getCurrOdlRow/{cIobConf.codIOB}"; + answ = $@"{urlCommand("alive")}/getCurrOdlRow/{IOBConfFull.GenConf.CodIOB}"; } catch (Exception exc) { @@ -757,7 +651,7 @@ namespace IOB_WIN_FORM.Iob string answ = ""; try { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/getCurrPODL/{cIobConf.codIOB}"; + answ = $@"{urlCommand("alive")}/getCurrPODL/{IOBConfFull.GenConf.CodIOB}"; } catch (Exception exc) { @@ -777,7 +671,7 @@ namespace IOB_WIN_FORM.Iob string answ = ""; try { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/getListValByTable/PODL"; + answ = $@"{urlCommand("alive")}/getListValByTable/PODL"; } catch (Exception exc) { @@ -797,7 +691,7 @@ namespace IOB_WIN_FORM.Iob string answ = ""; try { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/getPOdlNext/{cIobConf.codIOB}"; + answ = $@"{urlCommand("alive")}/getPOdlNext/{IOBConfFull.GenConf.CodIOB}"; } catch (Exception exc) { @@ -817,7 +711,7 @@ namespace IOB_WIN_FORM.Iob string answ = ""; try { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/getArtNum/{cIobConf.codIOB}"; + answ = $@"{urlCommand("alive")}/getArtNum/{IOBConfFull.GenConf.CodIOB}"; } catch (Exception exc) { @@ -837,7 +731,7 @@ namespace IOB_WIN_FORM.Iob string answ = ""; try { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/getXdlNum/{cIobConf.codIOB}"; + answ = $@"{urlCommand("alive")}/getXdlNum/{IOBConfFull.GenConf.CodIOB}"; } catch (Exception exc) { @@ -857,7 +751,7 @@ namespace IOB_WIN_FORM.Iob string answ = ""; try { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/getCurrOdlQtaReq/{cIobConf.codIOB}"; + answ = $@"{urlCommand("alive")}/getCurrOdlQtaReq/{IOBConfFull.GenConf.CodIOB}"; } catch (Exception exc) { @@ -877,7 +771,7 @@ namespace IOB_WIN_FORM.Iob string answ = ""; try { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/getObjItems2Write/{cIobConf.codIOB}"; + answ = $@"{urlCommand("alive")}/getObjItems2Write/{IOBConfFull.GenConf.CodIOB}"; } catch (Exception exc) { @@ -897,7 +791,7 @@ namespace IOB_WIN_FORM.Iob string answ = ""; try { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/getCounter/{cIobConf.codIOB}"; + answ = $@"{urlCommand("alive")}/getCounter/{IOBConfFull.GenConf.CodIOB}"; } catch (Exception exc) { @@ -917,7 +811,7 @@ namespace IOB_WIN_FORM.Iob string answ = ""; try { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/getCounterTCRec/{cIobConf.codIOB}"; + answ = $@"{urlCommand("alive")}/getCounterTCRec/{IOBConfFull.GenConf.CodIOB}"; } catch (Exception exc) { @@ -937,7 +831,7 @@ namespace IOB_WIN_FORM.Iob string answ = ""; try { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/getTask2Exe/{cIobConf.codIOB}"; + answ = $@"{urlCommand("alive")}/getTask2Exe/{IOBConfFull.GenConf.CodIOB}"; } catch (Exception exc) { @@ -954,7 +848,7 @@ namespace IOB_WIN_FORM.Iob { get { - return $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMD_IDLE_TIME}{cIobConf.codIOB}"; + return $@"{urlMesServer}{IOBConfFull.MapoMesConf.BaseAppUrl}{cIobConf.serverData.CMD_IDLE_TIME}{IOBConfFull.GenConf.CodIOB}"; } } @@ -965,7 +859,7 @@ namespace IOB_WIN_FORM.Iob { get { - return $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMD_ODL_STARTED}{cIobConf.codIOB}"; + return $@"{urlMesServer}{IOBConfFull.MapoMesConf.BaseAppUrl}{cIobConf.serverData.CMD_ODL_STARTED}{IOBConfFull.GenConf.CodIOB}"; } } @@ -976,7 +870,7 @@ namespace IOB_WIN_FORM.Iob { get { - return $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDENABLED}{cIobConf.codIOB}"; + return $@"{urlMesServer}{IOBConfFull.MapoMesConf.BaseAppUrl}{cIobConf.serverData.CMDENABLED}{IOBConfFull.GenConf.CodIOB}"; } } @@ -990,7 +884,7 @@ namespace IOB_WIN_FORM.Iob string answ = ""; try { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/askCloseODL/{cIobConf.codIOB}?idxOdl="; + answ = $@"{urlCommand("alive")}/askCloseODL/{IOBConfFull.GenConf.CodIOB}?idxOdl="; } catch (Exception exc) { @@ -1010,7 +904,7 @@ namespace IOB_WIN_FORM.Iob string answ = ""; try { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/closeODL/{cIobConf.codIOB}?idxOdl="; + answ = $@"{urlCommand("alive")}/closeODL/{IOBConfFull.GenConf.CodIOB}?idxOdl="; } catch (Exception exc) { @@ -1030,7 +924,7 @@ namespace IOB_WIN_FORM.Iob string answ = ""; try { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/forceStartPOdl/{cIobConf.codIOB}?idxPODL="; + answ = $@"{urlCommand("alive")}/forceStartPOdl/{IOBConfFull.GenConf.CodIOB}?idxPODL="; } catch (Exception exc) { @@ -1050,7 +944,7 @@ namespace IOB_WIN_FORM.Iob string answ = ""; try { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/closePODL/{cIobConf.codIOB}?idxPOdl="; + answ = $@"{urlCommand("alive")}/closePODL/{IOBConfFull.GenConf.CodIOB}?idxPOdl="; } catch (Exception exc) { @@ -1070,11 +964,11 @@ namespace IOB_WIN_FORM.Iob string answ = ""; try { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDREBO}{cIobConf.codIOB}&mac={GetMACAddress()}"; + answ = $@"{urlMesServer}{IOBConfFull.MapoMesConf.BaseAppUrl}{cIobConf.serverData.CMDREBO}{IOBConfFull.GenConf.CodIOB}&mac={GetMACAddress()}"; } catch { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDREBO}{cIobConf.codIOB}"; + answ = $@"{urlMesServer}{IOBConfFull.MapoMesConf.BaseAppUrl}{cIobConf.serverData.CMDREBO}{IOBConfFull.GenConf.CodIOB}"; } return answ; } @@ -1090,7 +984,7 @@ namespace IOB_WIN_FORM.Iob string answ = ""; try { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/remTask2Exe/{cIobConf.codIOB}?taskName="; + answ = $@"{urlCommand("alive")}/remTask2Exe/{IOBConfFull.GenConf.CodIOB}?taskName="; } catch (Exception exc) { @@ -1111,7 +1005,7 @@ namespace IOB_WIN_FORM.Iob try { string machineName = Environment.MachineName; - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/setObjItems/{cIobConf.codIOB}"; + answ = $@"{urlCommand("alive")}/setObjItems/{IOBConfFull.GenConf.CodIOB}"; } catch (Exception exc) { @@ -1131,7 +1025,7 @@ namespace IOB_WIN_FORM.Iob string answ = ""; try { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/saveMachineIobConf/{cIobConf.codIOB}"; + answ = $@"{urlCommand("alive")}/saveMachineIobConf/{IOBConfFull.GenConf.CodIOB}"; } catch (Exception exc) { @@ -1152,7 +1046,7 @@ namespace IOB_WIN_FORM.Iob try { string machineName = Environment.MachineName; - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/saveConf/{cIobConf.codIOB}"; + answ = $@"{urlCommand("alive")}/saveConf/{IOBConfFull.GenConf.CodIOB}"; } catch (Exception exc) { @@ -1172,7 +1066,7 @@ namespace IOB_WIN_FORM.Iob string answ = ""; try { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/sendAlarmBankUpdate/{cIobConf.codIOB}"; + answ = $@"{urlCommand("alive")}/sendAlarmBankUpdate/{IOBConfFull.GenConf.CodIOB}"; } catch (Exception exc) { @@ -1192,7 +1086,7 @@ namespace IOB_WIN_FORM.Iob string answ = ""; try { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/setRedisHashDict/{cIobConf.codIOB}"; + answ = $@"{urlCommand("alive")}/setRedisHashDict/{IOBConfFull.GenConf.CodIOB}"; } catch (Exception exc) { @@ -1213,7 +1107,7 @@ namespace IOB_WIN_FORM.Iob try { string machineName = Environment.MachineName; - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/setM2IOB/{cIobConf.codIOB}?IOB_name={machineName}"; + answ = $@"{urlCommand("alive")}/setM2IOB/{IOBConfFull.GenConf.CodIOB}?IOB_name={machineName}"; } catch (Exception exc) { @@ -1233,7 +1127,7 @@ namespace IOB_WIN_FORM.Iob string answ = ""; try { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/addOptPar/{cIobConf.codIOB}?"; + answ = $@"{urlCommand("alive")}/addOptPar/{IOBConfFull.GenConf.CodIOB}?"; } catch (Exception exc) { @@ -1253,7 +1147,7 @@ namespace IOB_WIN_FORM.Iob string answ = ""; try { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/setCounter/{cIobConf.codIOB}?counter="; + answ = $@"{urlCommand("alive")}/setCounter/{IOBConfFull.GenConf.CodIOB}?counter="; } catch (Exception exc) { @@ -1273,7 +1167,7 @@ namespace IOB_WIN_FORM.Iob string answ = ""; try { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/setCounter/MAC_{cIobConf.codIOB}?counter="; + answ = $@"{urlCommand("alive")}/setCounter/MAC_{IOBConfFull.GenConf.CodIOB}?counter="; } catch (Exception exc) { @@ -1293,7 +1187,7 @@ namespace IOB_WIN_FORM.Iob string answ = ""; try { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/takeFlogSnapshot/{cIobConf.codIOB}"; + answ = $@"{urlCommand("alive")}/takeFlogSnapshot/{IOBConfFull.GenConf.CodIOB}"; } catch (Exception exc) { @@ -1314,7 +1208,7 @@ namespace IOB_WIN_FORM.Iob try { string machineName = Environment.MachineName; - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/upsertObjItems/{cIobConf.codIOB}"; + answ = $@"{urlCommand("alive")}/upsertObjItems/{IOBConfFull.GenConf.CodIOB}"; } catch (Exception exc) { @@ -2651,15 +2545,15 @@ namespace IOB_WIN_FORM.Iob foreach (TimeRec item in TimingData.results) { // loggo SOLO se del mio IOB corrente... - if (item.classCall == cIobConf.codIOB) + if (item.classCall == IOBConfFull.GenConf.CodIOB) { - lgInfo("{4}|Chiamate {0}: effettuate {1}, tempo medio {2:N2} msec | impegno canale {3:P3}", item.codCall, item.numCall, item.avgMsec, item.totMsec.TotalSeconds / DateTime.Now.Subtract(dtAvvioAdp).TotalSeconds, cIobConf.codIOB); + lgInfo("{4}|Chiamate {0}: effettuate {1}, tempo medio {2:N2} msec | impegno canale {3:P3}", item.codCall, item.numCall, item.avgMsec, item.totMsec.TotalSeconds / DateTime.Now.Subtract(dtAvvioAdp).TotalSeconds, IOBConfFull.GenConf.CodIOB); globNumCall += item.numCall; globAvgMsec += item.totMsec; } } // riporto conteggio medio al secondo... - lgInfo("{4}|Chiamate GLOBALI: {0}, periodo: {1:N2} minuti.cent, tempo medio {2:N2} msec | impegno canale {3:P3}", globNumCall, DateTime.Now.Subtract(dtAvvioAdp).TotalMinutes, globAvgMsec.TotalMilliseconds / globNumCall, globAvgMsec.TotalSeconds / DateTime.Now.Subtract(dtAvvioAdp).TotalSeconds, cIobConf.codIOB); + lgInfo("{4}|Chiamate GLOBALI: {0}, periodo: {1:N2} minuti.cent, tempo medio {2:N2} msec | impegno canale {3:P3}", globNumCall, DateTime.Now.Subtract(dtAvvioAdp).TotalMinutes, globAvgMsec.TotalMilliseconds / globNumCall, globAvgMsec.TotalSeconds / DateTime.Now.Subtract(dtAvvioAdp).TotalSeconds, IOBConfFull.GenConf.CodIOB); lgInfo("{0}--------------- STOP TIMING DATA ---------------{0}", Environment.NewLine); // mostro in form statistiche globali! parentForm.updateComStats(string.Format("Periodo: {0:N2}min | {1} x {2:N2}ms | canale {3:P3}", DateTime.Now.Subtract(dtAvvioAdp).TotalMinutes, globNumCall, globAvgMsec.TotalMilliseconds / globNumCall, globAvgMsec.TotalSeconds / DateTime.Now.Subtract(dtAvvioAdp).TotalSeconds)); @@ -3313,21 +3207,21 @@ namespace IOB_WIN_FORM.Iob if (checkServerAlive) { // leggo PRIMA ODL .... - calcUrl = string.IsNullOrEmpty(forceMach) ? urlGetCurrODL : urlGetCurrODL.Replace(cIobConf.codIOB, forceMach); + calcUrl = string.IsNullOrEmpty(forceMach) ? urlGetCurrODL : urlGetCurrODL.Replace(IOBConfFull.GenConf.CodIOB, forceMach); lastIdxODL = utils.callUrl(calcUrl); lgTrace($"Lettura ODL dall'url {calcUrl} --> {lastIdxODL}"); // se ho valori in coda da trasmettere uso dati REDIS if (forceCountRec) { // uso dati da TCiclo registrati... - calcUrl = string.IsNullOrEmpty(forceMach) ? urlGetPzCountRec : urlGetPzCountRec.Replace(cIobConf.codIOB, forceMach); + calcUrl = string.IsNullOrEmpty(forceMach) ? urlGetPzCountRec : urlGetPzCountRec.Replace(IOBConfFull.GenConf.CodIOB, forceMach); currServerCount = utils.callUrl(calcUrl); lgInfo($"Lettura contapezzi da TCiclo registrati dall'url {calcUrl} --> num pz: {currServerCount}"); } else { // uso il contapezzi dichiarato dall'IOB stesso - calcUrl = string.IsNullOrEmpty(forceMach) ? urlGetPzCount : urlGetPzCount.Replace(cIobConf.codIOB, forceMach); + calcUrl = string.IsNullOrEmpty(forceMach) ? urlGetPzCount : urlGetPzCount.Replace(IOBConfFull.GenConf.CodIOB, forceMach); currServerCount = utils.callUrl(calcUrl); lgInfo($"Lettura contapezzi dall'url {calcUrl} --> {currServerCount}"); } @@ -4046,7 +3940,7 @@ namespace IOB_WIN_FORM.Iob // invio sendDataBlock(urlType.FLog, listaValori); // svuoto! - QueueFLog = new DataQueue(cIobConf.codIOB, "QueueFLog", cIobConf.EnableRedisQueue); + QueueFLog = new DataQueue(IOBConfFull.GenConf.CodIOB, "QueueFLog", cIobConf.EnableRedisQueue); //QueueFLog = new ConcurrentQueue(); } } @@ -4086,7 +3980,7 @@ namespace IOB_WIN_FORM.Iob // invio sendDataBlock(urlType.ULog, listaValori); // svuoto! - QueueULog = new DataQueue(cIobConf.codIOB, "QueueULog", cIobConf.EnableRedisQueue); + QueueULog = new DataQueue(IOBConfFull.GenConf.CodIOB, "QueueULog", cIobConf.EnableRedisQueue); //QueueULog = new ConcurrentQueue(); } } @@ -4150,7 +4044,7 @@ namespace IOB_WIN_FORM.Iob // invio sendDataBlock(urlType.SignIN, listaValori); // svuoto! - QueueIN = new DataQueue(cIobConf.codIOB, "QueueIN", cIobConf.EnableRedisQueue); + QueueIN = new DataQueue(IOBConfFull.GenConf.CodIOB, "QueueIN", cIobConf.EnableRedisQueue); //QueueIN = new ConcurrentQueue(); } } @@ -4289,7 +4183,7 @@ namespace IOB_WIN_FORM.Iob break; } // URL base x input - string answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{tipoComando}{cIobConf.codIOB}"; + string answ = $@"{urlMesServer}{IOBConfFull.MapoMesConf.BaseAppUrl}{tipoComando}{IOBConfFull.GenConf.CodIOB}"; return answ; } @@ -4301,11 +4195,11 @@ namespace IOB_WIN_FORM.Iob public string urlFLog(string queueVal) { // URL base x input - string answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDFLOG}"; + string answ = $@"{urlMesServer}{IOBConfFull.MapoMesConf.BaseAppUrl}{cIobConf.serverData.CMDFLOG}"; // decodifica valore! string[] valori = qDecodeIN(queueVal); // aggiungo macchina e valore... - answ += string.Format(@"{0}?flux={1}&&valore={2}", cIobConf.codIOB, valori[1], valori[2]); + answ += string.Format(@"{0}?flux={1}&&valore={2}", IOBConfFull.GenConf.CodIOB, valori[1], valori[2]); // aggiondo dataOra evento e corrente + contatore... answ += string.Format(@"&&dtEve={0}&&dtCurr={1:yyyyMMddHHmmssfff}&&cnt={2}", valori[0], DateTime.Now, valori[3]); return answ; @@ -4319,7 +4213,7 @@ namespace IOB_WIN_FORM.Iob string answ = ""; try { - answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/getOdlAtDate/{cIobConf.codIOB}?dateRif={dtRif:yyyyMMdd}"; + answ = $@"{urlCommand("alive")}/getOdlAtDate/{IOBConfFull.GenConf.CodIOB}?dateRif={dtRif:yyyyMMdd}"; } catch (Exception exc) { @@ -4336,11 +4230,11 @@ namespace IOB_WIN_FORM.Iob public string urlInput(string queueVal) { // URL base x input - string answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDBASE}"; + string answ = $@"{urlMesServer}{IOBConfFull.MapoMesConf.BaseAppUrl}{cIobConf.serverData.CMDBASE}"; // decodifica valore! string[] valori = qDecodeIN(queueVal); // aggiungo macchina e valore... - answ += string.Format(@"{0}?valore={1}", cIobConf.codIOB, valori[1]); + answ += string.Format(@"{0}?valore={1}", IOBConfFull.GenConf.CodIOB, valori[1]); // aggiondo dataOra evento e corrente + contatore... answ += string.Format(@"&&dtEve={0}&&dtCurr={1:yyyyMMddHHmmssfff}&&cnt={2}", valori[0], DateTime.Now, valori[2]); return answ; @@ -4354,11 +4248,11 @@ namespace IOB_WIN_FORM.Iob public string urlULog(string queueVal) { // URL base x input - string answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDULOG}"; + string answ = $@"{urlMesServer}{IOBConfFull.MapoMesConf.BaseAppUrl}{cIobConf.serverData.CMDULOG}"; // decodifica valore! string[] valori = qDecodeIN(queueVal); // aggiungo macchina e valore... - answ += string.Format(@"{0}?flux={1}&&valore={2}", cIobConf.codIOB, valori[1], valori[2]); + answ += string.Format(@"{0}?flux={1}&&valore={2}", IOBConfFull.GenConf.CodIOB, valori[1], valori[2]); // aggiondo dataOra evento e corrente + contatore... answ += string.Format(@"&&dtEve={0}&&dtCurr={1:yyyyMMddHHmmssfff}&&cnt={2}", valori[0], DateTime.Now, valori[3]); return answ; @@ -4786,7 +4680,7 @@ namespace IOB_WIN_FORM.Iob get { List answ = new List(); - string redKeyFLog = redisMan.redHash($"IOB:CurrData:{cIobConf.codIOB}:LogFile:FluxLog"); + string redKeyFLog = redisMan.redHash($"IOB:CurrData:{IOBConfFull.GenConf.CodIOB}:LogFile:FluxLog"); var rawData = redisMan.getRSV(redKeyFLog); if (!string.IsNullOrEmpty(rawData)) { @@ -4796,7 +4690,7 @@ namespace IOB_WIN_FORM.Iob } set { - string redKeyFLog = redisMan.redHash($"IOB:CurrData:{cIobConf.codIOB}:LogFile:FluxLog"); + string redKeyFLog = redisMan.redHash($"IOB:CurrData:{IOBConfFull.GenConf.CodIOB}:LogFile:FluxLog"); string fluxLogRaw = JsonConvert.SerializeObject(value); redisMan.setRSV(redKeyFLog, fluxLogRaw); } @@ -4939,7 +4833,7 @@ namespace IOB_WIN_FORM.Iob get { Dictionary answ = new Dictionary(); - string redKey = redisMan.redHash($"IOB:Status:{cIobConf.codIOB}:POdlSent"); + string redKey = redisMan.redHash($"IOB:Status:{IOBConfFull.GenConf.CodIOB}:POdlSent"); string rawData = redisMan.getRSV(redKey); if (!string.IsNullOrEmpty(rawData)) { @@ -4958,7 +4852,7 @@ namespace IOB_WIN_FORM.Iob set { string rawVal = JsonConvert.SerializeObject(value); - string redKey = redisMan.redHash($"IOB:Status:{cIobConf.codIOB}:POdlSent"); + string redKey = redisMan.redHash($"IOB:Status:{IOBConfFull.GenConf.CodIOB}:POdlSent"); redisMan.setRSV(redKey, rawVal); lgDebug($"Salvataggio status POdlSentFileArch | {value.Count} record"); } @@ -5011,22 +4905,22 @@ namespace IOB_WIN_FORM.Iob protected string redKeyLogfileAct { - get => redisMan.redHash($"IOB:CurrData:{cIobConf.codIOB}:LogFile:Act"); + get => redisMan.redHash($"IOB:CurrData:{IOBConfFull.GenConf.CodIOB}:LogFile:Act"); } protected string redKeyLogfileLast { - get => redisMan.redHash($"IOB:CurrData:{cIobConf.codIOB}:LogFile:Last"); + get => redisMan.redHash($"IOB:CurrData:{IOBConfFull.GenConf.CodIOB}:LogFile:Last"); } protected string redKeyProdLastArt { - get => redisMan.redHash($"IOB:CurrData:{cIobConf.codIOB}:prodDecod:lastArtDesc"); + get => redisMan.redHash($"IOB:CurrData:{IOBConfFull.GenConf.CodIOB}:prodDecod:lastArtDesc"); } protected string redKeyProdRunState { - get => redisMan.redHash($"IOB:CurrData:{cIobConf.codIOB}:prodDecod:isRunningState"); + get => redisMan.redHash($"IOB:CurrData:{IOBConfFull.GenConf.CodIOB}:prodDecod:isRunningState"); } protected Random rndGen { get; set; } = new Random(); @@ -5685,7 +5579,7 @@ namespace IOB_WIN_FORM.Iob // se inviato --> salvo stato da current... item.updStatusVal(i, (uint)(item.alarmsMask[i] & currStatus)); // salvo in redis... - string alarmHash = redisMan.redHash($"IOB:ALARM_STATUS:{cIobConf.codIOB}:{item.memAddr}"); + string alarmHash = redisMan.redHash($"IOB:ALARM_STATUS:{IOBConfFull.GenConf.CodIOB}:{item.memAddr}"); string rawAlarms = JsonConvert.SerializeObject(item.alarmsState); redisMan.setRSV(alarmHash, rawAlarms); } @@ -6618,7 +6512,7 @@ namespace IOB_WIN_FORM.Iob redHashWeek.Add(cWeek, rawWeek); } // salvo in redis... - string fullKey = redisMan.redHash($"IOB:Status:{cIobConf.codIOB}:WeekStats"); + string fullKey = redisMan.redHash($"IOB:Status:{IOBConfFull.GenConf.CodIOB}:WeekStats"); var okHashDict = redisMan.redSaveHashDict(fullKey, redHashWeek); // invio ANCHE in MP-IO l'update delle info... @@ -6647,7 +6541,7 @@ namespace IOB_WIN_FORM.Iob // 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 = redisMan.redHash($"IOB:Status:{cIobConf.codIOB}:WeekStats"); + string fullKey = redisMan.redHash($"IOB:Status:{IOBConfFull.GenConf.CodIOB}:WeekStats"); Dictionary currStats = redisMan.redGetHashDict(fullKey); if (currStats != null && currStats.Count > 0) { @@ -6678,7 +6572,7 @@ namespace IOB_WIN_FORM.Iob string recLocalArchPath = Path.Combine(pathList["path-locBase"], pathList["path-00-Arch"]); string recRemArchPath = pathList["path-06-remRec"]; // leggo da redis (se disponibile) elenco hast file/MD5.... - string fullKey = redisMan.redHash($"IOB:Remote:{cIobConf.codIOB}:FileCheck"); + string fullKey = redisMan.redHash($"IOB:Remote:{IOBConfFull.GenConf.CodIOB}:FileCheck"); Dictionary dictRecMd5 = redisMan.redGetHashDict(fullKey); // leggo la directory remota... var remoteList = Directory.GetFiles(recRemArchPath); @@ -7111,7 +7005,7 @@ namespace IOB_WIN_FORM.Iob { bool hasPzCount = (enablePzCountByApp || enablePzCountByIob) && !disablePzCountByIob; // creo obj dati necessari... - currDict.Add("IobName", cIobConf.codIOB); + currDict.Add("IobName", IOBConfFull.GenConf.CodIOB); currDict.Add("IobType", $"{cIobConf.tipoIob}"); currDict.Add("MachIp", cIobConf.cncIpAddr); currDict.Add("MachPort", cIobConf.cncPort); @@ -7226,7 +7120,7 @@ namespace IOB_WIN_FORM.Iob { item.setupData(); // se ho in redis una tab di allarmi precedenti la carico... - string alarmHash = redisMan.redHash($"IOB:ALARM_STATUS:{cIobConf.codIOB}:{item.memAddr}"); + string alarmHash = redisMan.redHash($"IOB:ALARM_STATUS:{IOBConfFull.GenConf.CodIOB}:{item.memAddr}"); string rawVal = redisMan.getRSV(alarmHash); if (!string.IsNullOrEmpty(rawVal)) { @@ -7659,7 +7553,7 @@ namespace IOB_WIN_FORM.Iob lastUrl = $"{urlAddPzCount}{numIncr}"; if (!string.IsNullOrEmpty(forceMachName)) { - lastUrl = lastUrl.Replace(cIobConf.codIOB, forceMachName); + lastUrl = lastUrl.Replace(IOBConfFull.GenConf.CodIOB, forceMachName); } string resp = utils.callUrlNow(lastUrl); if (!string.IsNullOrEmpty(resp)) @@ -7675,7 +7569,7 @@ namespace IOB_WIN_FORM.Iob string fullUrl = $"{urlSetPzCount}{contapezziIOB}"; if (!string.IsNullOrEmpty(forceMachName)) { - fullUrl = fullUrl.Replace(cIobConf.codIOB, forceMachName); + fullUrl = fullUrl.Replace(IOBConfFull.GenConf.CodIOB, forceMachName); } string retVal = utils.callUrl(fullUrl); // verifica se tutto OK @@ -8025,7 +7919,7 @@ namespace IOB_WIN_FORM.Iob /// private string rKeyCurrProdData { - get => redisMan.redHash($"IOB:Status:{cIobConf.codIOB}:CurrProdData"); + get => redisMan.redHash($"IOB:Status:{IOBConfFull.GenConf.CodIOB}:CurrProdData"); } /// @@ -8053,7 +7947,7 @@ namespace IOB_WIN_FORM.Iob address = IPAddress.Loopback; int maxRetry = maxPingRetry + 1; int numRetry = 1; - string ipAddr = cIobConf.serverData.MPIP.Replace($"{cIobConf.serverData.TRANSP}://", ""); + string ipAddr = IOBConfFull.MapoMesConf.IpAddr.Replace($"{IOBConfFull.MapoMesConf.Transport}://", ""); // fix se fosse ip + porta... if (ipAddr.IndexOf(":") >= 0) { @@ -8199,7 +8093,7 @@ namespace IOB_WIN_FORM.Iob private void checkShrinkDir() { // comprimo x prima cosa la folder dell'IOB corrente - string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logs", cIobConf.codIOB); + string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logs", IOBConfFull.GenConf.CodIOB); try { baseUtils.shrinkDir(path); @@ -8814,7 +8708,7 @@ namespace IOB_WIN_FORM.Iob /// private void RecipeRemoveWeekStatus(string keyReq) { - string fullKey = redisMan.redHash($"IOB:Status:{cIobConf.codIOB}:WeekStats"); + string fullKey = redisMan.redHash($"IOB:Status:{IOBConfFull.GenConf.CodIOB}:WeekStats"); var okHashDict = redisMan.redRemoveHashField(fullKey, keyReq); // rileggo status hash Dictionary currDict = redisMan.redGetHashDict(fullKey); @@ -8853,17 +8747,17 @@ namespace IOB_WIN_FORM.Iob // svuoto code se richiesto if (resetQueue) { - QueueAlarm = new DataQueue(cIobConf.codIOB, "QueueAlarm", cIobConf.EnableRedisQueue); + QueueAlarm = new DataQueue(IOBConfFull.GenConf.CodIOB, "QueueAlarm", cIobConf.EnableRedisQueue); //QueueAlarm = new ConcurrentQueue(); - QueueIN = new DataQueue(cIobConf.codIOB, "QueueIN", cIobConf.EnableRedisQueue); + QueueIN = new DataQueue(IOBConfFull.GenConf.CodIOB, "QueueIN", cIobConf.EnableRedisQueue); //QueueIN = new ConcurrentQueue(); - QueueFLog = new DataQueue(cIobConf.codIOB, "QueueFLog", cIobConf.EnableRedisQueue); + QueueFLog = new DataQueue(IOBConfFull.GenConf.CodIOB, "QueueFLog", cIobConf.EnableRedisQueue); //QueueFLog = new ConcurrentQueue(); - QueueMessages = new DataQueue(cIobConf.codIOB, "QueueMessages", cIobConf.EnableRedisQueue); + QueueMessages = new DataQueue(IOBConfFull.GenConf.CodIOB, "QueueMessages", cIobConf.EnableRedisQueue); //QueueMessages = new ConcurrentQueue(); - QueueRawTransf = new DataQueue(cIobConf.codIOB, "QueueRawTransf", cIobConf.EnableRedisQueue); + QueueRawTransf = new DataQueue(IOBConfFull.GenConf.CodIOB, "QueueRawTransf", cIobConf.EnableRedisQueue); //QueueRawTransf = new ConcurrentQueue(); - QueueULog = new DataQueue(cIobConf.codIOB, "QueueULog", cIobConf.EnableRedisQueue); + QueueULog = new DataQueue(IOBConfFull.GenConf.CodIOB, "QueueULog", cIobConf.EnableRedisQueue); //QueueULog = new ConcurrentQueue(); } // imposto contatori blink a zero... @@ -9006,7 +8900,7 @@ namespace IOB_WIN_FORM.Iob // invio sendDataBlock(urlType.FLog, listaValori); // svuoto! - QueueFLog = new DataQueue(cIobConf.codIOB, "QueueFLog", cIobConf.EnableRedisQueue); + QueueFLog = new DataQueue(IOBConfFull.GenConf.CodIOB, "QueueFLog", cIobConf.EnableRedisQueue); //QueueFLog = new ConcurrentQueue(); lastWatchDog = DateTime.Now; } @@ -9078,7 +8972,7 @@ namespace IOB_WIN_FORM.Iob if (fatto) { // svuoto se ha okReport! - QueueRawTransf = new DataQueue(cIobConf.codIOB, "QueueRawTransf", cIobConf.EnableRedisQueue); + QueueRawTransf = new DataQueue(IOBConfFull.GenConf.CodIOB, "QueueRawTransf", cIobConf.EnableRedisQueue); //QueueRawTransf = new ConcurrentQueue(); } } @@ -9140,7 +9034,7 @@ namespace IOB_WIN_FORM.Iob // invio sendDataBlock(urlType.ULog, listaValori); // svuoto! - QueueULog = new DataQueue(cIobConf.codIOB, "QueueULog", cIobConf.EnableRedisQueue); + QueueULog = new DataQueue(IOBConfFull.GenConf.CodIOB, "QueueULog", cIobConf.EnableRedisQueue); } } else diff --git a/IOB-WIN-FORM/Properties/AssemblyInfo.cs b/IOB-WIN-FORM/Properties/AssemblyInfo.cs index f6072281..be621cda 100644 --- a/IOB-WIN-FORM/Properties/AssemblyInfo.cs +++ b/IOB-WIN-FORM/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// GenConf Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("IOB-WIN-FORM")] diff --git a/IOB-WIN-SHELLY/Properties/AssemblyInfo.cs b/IOB-WIN-SHELLY/Properties/AssemblyInfo.cs index 3811e376..0bd2a674 100644 --- a/IOB-WIN-SHELLY/Properties/AssemblyInfo.cs +++ b/IOB-WIN-SHELLY/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// GenConf Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("IOB-WIN-SHELLY")] From 2a5fe80e39e4c4ac1ae35327bb6034efa4592a89 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 24 Feb 2025 16:48:42 +0100 Subject: [PATCH 2/2] Update conf di base, test su Shelly x nuova gestione URL --- IOB-UT-NEXT/Config/Base/CmdUriDto.cs | 10 +- IOB-UT-NEXT/Config/Base/ServerMapoDto.cs | 2 +- IOB-WIN-FORM/Iob/Generic.cs | 436 +++++------------------ IOB-WIN-SHELLY/DATA/CONF/SHELLY_01.json | 2 +- 4 files changed, 102 insertions(+), 348 deletions(-) diff --git a/IOB-UT-NEXT/Config/Base/CmdUriDto.cs b/IOB-UT-NEXT/Config/Base/CmdUriDto.cs index 2184ca6b..86b18166 100644 --- a/IOB-UT-NEXT/Config/Base/CmdUriDto.cs +++ b/IOB-UT-NEXT/Config/Base/CmdUriDto.cs @@ -58,11 +58,11 @@ namespace IOB_UT_NEXT.Config.Base { CurrSetup = new Dictionary(); CurrSetup.Add("alive", "IOB"); - CurrSetup.Add("Base", "IOB/input/"); + //CurrSetup.Add("Base", "IOB/input/"); CurrSetup.Add("BaseJson", "IOB/evListJson/"); CurrSetup.Add("RawTransfJson", "IOB/rawTransfJson/"); - CurrSetup.Add("Enabled", "IOB/enabled/"); - CurrSetup.Add("Flog", "IOB/flog/"); + //CurrSetup.Add("Enabled", "IOB/enabled/"); + //CurrSetup.Add("Flog", "IOB/flog/"); CurrSetup.Add("FlogJson", "IOB/flogJson/"); //CurrSetup.Add("fixDailyDossier", "IOB/fixDailyDossier/"); //CurrSetup.Add("fixDailyOdl", "IOB/fixDailyOdl/"); @@ -70,8 +70,8 @@ namespace IOB_UT_NEXT.Config.Base //CurrSetup.Add("forceCreatePOdl", "IOB/forceCreatePOdl/"); //CurrSetup.Add("forceSplitOdlFull", "IOB/forceSplitOdlFull/"); //CurrSetup.Add("getPOdlAct", "IOB/getPOdlAct/"); - CurrSetup.Add("IdleTime", "IOB/getIdlePeriod/"); - CurrSetup.Add("OdlStarted", "IOB/getCurrOdlStart/"); + //CurrSetup.Add("IdleTime", "IOB/getIdlePeriod/"); + //CurrSetup.Add("OdlStarted", "IOB/getCurrOdlStart/"); CurrSetup.Add("Reboot", "IOB/sendReboot.aspx?idxMacchina="); //CurrSetup.Add("savePzCountInc", "IOB/savePzCountInc/"); //CurrSetup.Add("savePzCountIncAtDate", "IOB/savePzCountIncAtDate/"); diff --git a/IOB-UT-NEXT/Config/Base/ServerMapoDto.cs b/IOB-UT-NEXT/Config/Base/ServerMapoDto.cs index 5cbab5f6..76877061 100644 --- a/IOB-UT-NEXT/Config/Base/ServerMapoDto.cs +++ b/IOB-UT-NEXT/Config/Base/ServerMapoDto.cs @@ -32,7 +32,7 @@ namespace IOB_UT_NEXT.Config.Base public string ApiUrl(string CmdReq) { // default ad implicito con IOB... - string answ = $"{BaseAppUrl}/IOB/{CmdReq}"; + string answ = $"{BaseAppUrl}IOB/{CmdReq}/"; if (Commands.ContainsKey(CmdReq)) { answ = $"{BaseAppUrl}{Commands[CmdReq]}"; diff --git a/IOB-WIN-FORM/Iob/Generic.cs b/IOB-WIN-FORM/Iob/Generic.cs index e4d94330..13125968 100644 --- a/IOB-WIN-FORM/Iob/Generic.cs +++ b/IOB-WIN-FORM/Iob/Generic.cs @@ -1,6 +1,7 @@ using IOB_UT_NEXT; using IOB_UT_NEXT.Config; using MapoSDK; +using MathNet.Numerics; using MathNet.Numerics.Statistics; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -625,19 +626,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlGetCurrOdlRow { - get - { - string answ = ""; - try - { - answ = $@"{urlCommand("alive")}/getCurrOdlRow/{IOBConfFull.GenConf.CodIOB}"; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlGetCurrOdlRow"); - } - return answ; - } + get => $@"{urlCommandIob("getCurrOdlRow")}"; } /// @@ -646,19 +635,7 @@ namespace IOB_WIN_FORM.Iob [Obsolete("Metodo obsoleto (dubbia interpretazione): sostituire con urlGetNextPODL se si vogliono PROSSIMI POdl attivabili (significato originale) o con urlGetActPODL x il POdl attualmente in produzione (per casi come Rama OPC-UA Siemens)")] public string urlGetCurrPODL { - get - { - string answ = ""; - try - { - answ = $@"{urlCommand("alive")}/getCurrPODL/{IOBConfFull.GenConf.CodIOB}"; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlGetCurrPODL"); - } - return answ; - } + get => $@"{urlCommandIob("getCurrPODL")}"; } /// @@ -666,19 +643,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlGetListValFasiPodl { - get - { - string answ = ""; - try - { - answ = $@"{urlCommand("alive")}/getListValByTable/PODL"; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlGetListValFasiPodl"); - } - return answ; - } + get => $@"{urlCommand("getListValByTable")}PODL"; } /// @@ -686,19 +651,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlGetNextPODL { - get - { - string answ = ""; - try - { - answ = $@"{urlCommand("alive")}/getPOdlNext/{IOBConfFull.GenConf.CodIOB}"; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlGetNextPODL"); - } - return answ; - } + get => $@"{urlCommandIob("getPOdlNext")}"; } /// @@ -706,19 +659,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlGetNumArt { - get - { - string answ = ""; - try - { - answ = $@"{urlCommand("alive")}/getArtNum/{IOBConfFull.GenConf.CodIOB}"; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlGetNumArt"); - } - return answ; - } + get => $@"{urlCommandIob("getArtNum")}"; } /// @@ -726,19 +667,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlGetNumComm { - get - { - string answ = ""; - try - { - answ = $@"{urlCommand("alive")}/getXdlNum/{IOBConfFull.GenConf.CodIOB}"; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlGetNumComm"); - } - return answ; - } + get => $@"{urlCommandIob("getXdlNum")}"; } /// @@ -746,19 +675,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlGetNumPzCurrODL { - get - { - string answ = ""; - try - { - answ = $@"{urlCommand("alive")}/getCurrOdlQtaReq/{IOBConfFull.GenConf.CodIOB}"; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlGetNumPzCurrODL"); - } - return answ; - } + get => $@"{urlCommandIob("getCurrOdlQtaReq")}"; } /// @@ -766,19 +683,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlGetParams2Write { - get - { - string answ = ""; - try - { - answ = $@"{urlCommand("alive")}/getObjItems2Write/{IOBConfFull.GenConf.CodIOB}"; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlGetParams2Write"); - } - return answ; - } + get => $@"{urlCommandIob("getObjItems2Write")}"; } /// @@ -786,19 +691,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlGetPzCount { - get - { - string answ = ""; - try - { - answ = $@"{urlCommand("alive")}/getCounter/{IOBConfFull.GenConf.CodIOB}"; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlGetPzCount"); - } - return answ; - } + get => $@"{urlCommandIob("getCounter")}"; } /// @@ -806,19 +699,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlGetPzCountRec { - get - { - string answ = ""; - try - { - answ = $@"{urlCommand("alive")}/getCounterTCRec/{IOBConfFull.GenConf.CodIOB}"; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlGetPzCountRec"); - } - return answ; - } + get => $@"{urlCommandIob("getCounterTCRec")}"; } /// @@ -826,19 +707,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlGetTask2Exe { - get - { - string answ = ""; - try - { - answ = $@"{urlCommand("alive")}/getTask2Exe/{IOBConfFull.GenConf.CodIOB}"; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlGetTask2Exe"); - } - return answ; - } + get => $@"{urlCommandIob("getTask2Exe")}"; } /// @@ -846,10 +715,13 @@ namespace IOB_WIN_FORM.Iob /// public string urlIdleTime { + get => $@"{urlCommandIob("getIdlePeriod")}"; +#if false get { return $@"{urlMesServer}{IOBConfFull.MapoMesConf.BaseAppUrl}{cIobConf.serverData.CMD_IDLE_TIME}{IOBConfFull.GenConf.CodIOB}"; - } + } +#endif } /// @@ -857,10 +729,13 @@ namespace IOB_WIN_FORM.Iob /// public string urlInizioOdlIob { + get => $@"{urlCommandIob("getCurrOdlStart")}"; +#if false get { return $@"{urlMesServer}{IOBConfFull.MapoMesConf.BaseAppUrl}{cIobConf.serverData.CMD_ODL_STARTED}{IOBConfFull.GenConf.CodIOB}"; - } + } +#endif } /// @@ -868,10 +743,13 @@ namespace IOB_WIN_FORM.Iob /// public string urlIobEnabled { + get => $@"{urlCommandIob("enabled")}"; +#if false get { return $@"{urlMesServer}{IOBConfFull.MapoMesConf.BaseAppUrl}{cIobConf.serverData.CMDENABLED}{IOBConfFull.GenConf.CodIOB}"; - } + } +#endif } /// @@ -879,19 +757,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlODLAskClose { - get - { - string answ = ""; - try - { - answ = $@"{urlCommand("alive")}/askCloseODL/{IOBConfFull.GenConf.CodIOB}?idxOdl="; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlODLClose"); - } - return answ; - } + get => $@"{urlCommandIob("askCloseODL")}?idxOdl="; } /// @@ -899,19 +765,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlODLClose { - get - { - string answ = ""; - try - { - answ = $@"{urlCommand("alive")}/closeODL/{IOBConfFull.GenConf.CodIOB}?idxOdl="; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlODLClose"); - } - return answ; - } + get => $@"{urlCommandIob("closeODL")}/?idxOdl="; } /// @@ -919,19 +773,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlOdlStartFromPOdl { - get - { - string answ = ""; - try - { - answ = $@"{urlCommand("alive")}/forceStartPOdl/{IOBConfFull.GenConf.CodIOB}?idxPODL="; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlStartPODL"); - } - return answ; - } + get=> $@"{urlCommandIob("forceStartPOdl")}?idxPODL="; } /// @@ -939,19 +781,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlPODLClose { - get - { - string answ = ""; - try - { - answ = $@"{urlCommand("alive")}/closePODL/{IOBConfFull.GenConf.CodIOB}?idxPOdl="; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlPODLClose"); - } - return answ; - } + get=> $@"{urlCommandIob("closePODL")}?idxPOdl="; } /// @@ -959,6 +789,8 @@ namespace IOB_WIN_FORM.Iob /// public string urlReboot { + get => $@"{urlCommandIob("sendReboot")}?mac={GetMACAddress()}"; +#if false get { string answ = ""; @@ -971,7 +803,8 @@ namespace IOB_WIN_FORM.Iob answ = $@"{urlMesServer}{IOBConfFull.MapoMesConf.BaseAppUrl}{cIobConf.serverData.CMDREBO}{IOBConfFull.GenConf.CodIOB}"; } return answ; - } + } +#endif } /// @@ -979,19 +812,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlRemTask2Exe { - get - { - string answ = ""; - try - { - answ = $@"{urlCommand("alive")}/remTask2Exe/{IOBConfFull.GenConf.CodIOB}?taskName="; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlRemTask2Exe"); - } - return answ; - } + get=> $@"{urlCommandIob("remTask2Exe")}?taskName="; } /// @@ -999,20 +820,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlSaveAllParams { - get - { - string answ = ""; - try - { - string machineName = Environment.MachineName; - answ = $@"{urlCommand("alive")}/setObjItems/{IOBConfFull.GenConf.CodIOB}"; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlSaveMemConf"); - } - return answ; - } + get=> $@"{urlCommandIob("setObjItems")}"; } /// @@ -1020,19 +828,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlSaveMachIobConf { - get - { - string answ = ""; - try - { - answ = $@"{urlCommand("alive")}/saveMachineIobConf/{IOBConfFull.GenConf.CodIOB}"; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlSetHashDict"); - } - return answ; - } + get=> $@"{urlCommandIob("saveMachineIobConf")}"; } /// @@ -1040,20 +836,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlSaveMemMap { - get - { - string answ = ""; - try - { - string machineName = Environment.MachineName; - answ = $@"{urlCommand("alive")}/saveConf/{IOBConfFull.GenConf.CodIOB}"; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlSaveMemConf"); - } - return answ; - } + get => $@"{urlCommandIob("saveConf")}"; } /// @@ -1061,19 +844,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlSendAlarm { - get - { - string answ = ""; - try - { - answ = $@"{urlCommand("alive")}/sendAlarmBankUpdate/{IOBConfFull.GenConf.CodIOB}"; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlAddPzCount"); - } - return answ; - } + get => $@"{urlCommandIob("sendAlarmBankUpdate")}"; } /// @@ -1081,19 +852,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlSetHashDict { - get - { - string answ = ""; - try - { - answ = $@"{urlCommand("alive")}/setRedisHashDict/{IOBConfFull.GenConf.CodIOB}"; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlSetHashDict"); - } - return answ; - } + get => $@"{urlCommandIob("setRedisHashDict")}"; } /// @@ -1101,6 +860,8 @@ namespace IOB_WIN_FORM.Iob /// public string urlSetM2IOB { + get => $@"{urlCommandIob("setM2IOB")}?IOB_name={Environment.MachineName}"; +#if false get { string answ = ""; @@ -1114,7 +875,8 @@ namespace IOB_WIN_FORM.Iob lgError(exc, "Errore in composizione urlSetM2IOB"); } return answ; - } + } +#endif } /// @@ -1122,19 +884,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlSetOptVal { - get - { - string answ = ""; - try - { - answ = $@"{urlCommand("alive")}/addOptPar/{IOBConfFull.GenConf.CodIOB}?"; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlSetOptVal"); - } - return answ; - } + get => $@"{urlCommandIob("addOptPar")}"; } /// @@ -1142,19 +892,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlSetPzCount { - get - { - string answ = ""; - try - { - answ = $@"{urlCommand("alive")}/setCounter/{IOBConfFull.GenConf.CodIOB}?counter="; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlSetPzCount"); - } - return answ; - } + get => $@"{urlCommandIob("setCounter")}?counter="; } /// @@ -1162,6 +900,8 @@ namespace IOB_WIN_FORM.Iob /// public string urlSetPzCountMAC { + get => $@"{urlCommand("setCounter")}MAC_{IOBConfFull.GenConf.CodIOB}?counter="; +#if false get { string answ = ""; @@ -1174,7 +914,8 @@ namespace IOB_WIN_FORM.Iob lgError(exc, "Errore in composizione urlSetPzCountMAC"); } return answ; - } + } +#endif } /// @@ -1182,19 +923,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlTakeSnapshot { - get - { - string answ = ""; - try - { - answ = $@"{urlCommand("alive")}/takeFlogSnapshot/{IOBConfFull.GenConf.CodIOB}"; - } - catch (Exception exc) - { - lgError(exc, "Errore in composizione urlTakeSnapshot"); - } - return answ; - } + get => $@"{urlCommandIob("takeFlogSnapshot")}"; } /// @@ -1202,12 +931,13 @@ namespace IOB_WIN_FORM.Iob /// public string urlUpdateWriteParams { + get => $@"{urlCommandIob("upsertObjItems")}"; +#if false get { string answ = ""; try { - string machineName = Environment.MachineName; answ = $@"{urlCommand("alive")}/upsertObjItems/{IOBConfFull.GenConf.CodIOB}"; } catch (Exception exc) @@ -1215,7 +945,8 @@ namespace IOB_WIN_FORM.Iob lgError(exc, "Errore in composizione urlUpdateWriteParams"); } return answ; - } + } +#endif } /// @@ -4183,7 +3914,10 @@ namespace IOB_WIN_FORM.Iob break; } // URL base x input - string answ = $@"{urlMesServer}{IOBConfFull.MapoMesConf.BaseAppUrl}{tipoComando}{IOBConfFull.GenConf.CodIOB}"; + string answ = $@"{urlCommandIob(tipoComando)}"; +#if false + string answ = $@"{urlMesServer}{IOBConfFull.MapoMesConf.BaseAppUrl}{tipoComando}{IOBConfFull.GenConf.CodIOB}"; +#endif return answ; } @@ -4195,13 +3929,23 @@ namespace IOB_WIN_FORM.Iob public string urlFLog(string queueVal) { // URL base x input + string answ = $@"{urlCommandIob("flog")}"; +#if false string answ = $@"{urlMesServer}{IOBConfFull.MapoMesConf.BaseAppUrl}{cIobConf.serverData.CMDFLOG}"; - // decodifica valore! +#endif + // decodifica valore! string[] valori = qDecodeIN(queueVal); + // aggiungo flux e valore... + answ += $@"?flux={valori[1]}&&valore={valori[2]}"; +#if false // aggiungo macchina e valore... - answ += string.Format(@"{0}?flux={1}&&valore={2}", IOBConfFull.GenConf.CodIOB, valori[1], valori[2]); + answ += string.Format(@"{0}?flux={1}&&valore={2}", IOBConfFull.GenConf.CodIOB, valori[1], valori[2]); +#endif // aggiondo dataOra evento e corrente + contatore... - answ += string.Format(@"&&dtEve={0}&&dtCurr={1:yyyyMMddHHmmssfff}&&cnt={2}", valori[0], DateTime.Now, valori[3]); + answ += $@"&&dtEve={valori[0]}&&dtCurr={DateTime.Now:yyyyMMddHHmmssfff}&&cnt={valori[3]}"; +#if false + answ += string.Format(@"&&dtEve={0}&&dtCurr={1:yyyyMMddHHmmssfff}&&cnt={2}", valori[0], DateTime.Now, valori[3]); +#endif return answ; } @@ -4210,15 +3954,7 @@ namespace IOB_WIN_FORM.Iob /// public string urlGetOdlAtDate(DateTime dtRif) { - string answ = ""; - try - { - answ = $@"{urlCommand("alive")}/getOdlAtDate/{IOBConfFull.GenConf.CodIOB}?dateRif={dtRif:yyyyMMdd}"; - } - catch (Exception exc) - { - lgError(exc, $"Errore in composizione urlGetOdlAtDate per {dtRif}{Environment.NewLine}{exc}"); - } + string answ = $@"{urlCommandIob("getOdlAtDate")}?dateRif={dtRif:yyyyMMdd}"; return answ; } @@ -4230,13 +3966,22 @@ namespace IOB_WIN_FORM.Iob public string urlInput(string queueVal) { // URL base x input - string answ = $@"{urlMesServer}{IOBConfFull.MapoMesConf.BaseAppUrl}{cIobConf.serverData.CMDBASE}"; +#if false + string answ = $@"{urlMesServer}{IOBConfFull.MapoMesConf.BaseAppUrl}{cIobConf.serverData.CMDBASE}"; +#endif + string answ = $@"{urlCommandIob("input")}"; // decodifica valore! string[] valori = qDecodeIN(queueVal); // aggiungo macchina e valore... - answ += string.Format(@"{0}?valore={1}", IOBConfFull.GenConf.CodIOB, valori[1]); + answ += $@"?valore={valori[1]}"; +#if false + answ += string.Format(@"{0}?valore={1}", IOBConfFull.GenConf.CodIOB, valori[1]); +#endif // aggiondo dataOra evento e corrente + contatore... - answ += string.Format(@"&&dtEve={0}&&dtCurr={1:yyyyMMddHHmmssfff}&&cnt={2}", valori[0], DateTime.Now, valori[2]); + answ += $@"&&dtEve={valori[0]}&&dtCurr={DateTime.Now:yyyyMMddHHmmssfff}&&cnt={valori[2]}"; +#if false + answ += string.Format(@"&&dtEve={0}&&dtCurr={1:yyyyMMddHHmmssfff}&&cnt={2}", valori[0], DateTime.Now, valori[2]); +#endif return answ; } @@ -4248,13 +3993,22 @@ namespace IOB_WIN_FORM.Iob public string urlULog(string queueVal) { // URL base x input - string answ = $@"{urlMesServer}{IOBConfFull.MapoMesConf.BaseAppUrl}{cIobConf.serverData.CMDULOG}"; +#if false + string answ = $@"{urlMesServer}{IOBConfFull.MapoMesConf.BaseAppUrl}{cIobConf.serverData.CMDULOG}"; +#endif + string answ = $@"{urlCommandIob("ulog")}"; // decodifica valore! string[] valori = qDecodeIN(queueVal); // aggiungo macchina e valore... - answ += string.Format(@"{0}?flux={1}&&valore={2}", IOBConfFull.GenConf.CodIOB, valori[1], valori[2]); + answ += $@"?flux={valori[1]}&&valore={valori[2]}"; +#if false + answ += string.Format(@"{0}?flux={1}&&valore={2}", IOBConfFull.GenConf.CodIOB, valori[1], valori[2]); +#endif // aggiondo dataOra evento e corrente + contatore... - answ += string.Format(@"&&dtEve={0}&&dtCurr={1:yyyyMMddHHmmssfff}&&cnt={2}", valori[0], DateTime.Now, valori[3]); + answ += $@"&&dtEve={valori[0]}&&dtCurr={DateTime.Now:yyyyMMddHHmmssfff}&&cnt={valori[3]}"; +#if false + answ += string.Format(@"&&dtEve={0}&&dtCurr={1:yyyyMMddHHmmssfff}&&cnt={2}", valori[0], DateTime.Now, valori[3]); +#endif return answ; } diff --git a/IOB-WIN-SHELLY/DATA/CONF/SHELLY_01.json b/IOB-WIN-SHELLY/DATA/CONF/SHELLY_01.json index d60bfa47..f8d7c7e7 100644 --- a/IOB-WIN-SHELLY/DATA/CONF/SHELLY_01.json +++ b/IOB-WIN-SHELLY/DATA/CONF/SHELLY_01.json @@ -30,7 +30,7 @@ "optKVP": { "shelly_tout": 5, "fluxLogReduce": true, - "fluxLogRedDeadBand": 2.5, + "fluxLogRedDeadBand": 3.5, "fluxLogResendPeriod": 60 } } \ No newline at end of file