Merge branch 'release/IobGomba10'
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
CNCTYPE=SOAP_GOMBA
|
||||
PING_MS_TIMEOUT=500
|
||||
MinDeltaSec=5
|
||||
DIS_EXE_TASK=TRUE
|
||||
DIS_EXE_TASK=FALSE
|
||||
DIS_STATE_CH=FALSE
|
||||
|
||||
[MACHINE]
|
||||
@@ -55,10 +55,8 @@ BLINK_FILT=0
|
||||
;BLINK_FILT=28
|
||||
|
||||
[OPTPAR]
|
||||
AUTO_CHANGE_ODL=false
|
||||
CHANGE_ODL_MODE=TIME
|
||||
CHANGE_ODL_HOURS=24
|
||||
CHANGE_ODL_IDLE_MIN=5
|
||||
AUTO_CHANGE_ODL=TRUE
|
||||
CHANGE_ODL_MODE=DAILY
|
||||
PZCOUNT_MODE=GOMBA
|
||||
DISABLE_PZCOUNT=TRUE
|
||||
ENABLE_SEND_PZC_BLOCK=TRUE
|
||||
|
||||
@@ -399,6 +399,8 @@
|
||||
<Link>VersGen.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="IobFile\IobFileSoitaab.cs" />
|
||||
<Compile Include="Iob\BaseObj.cs" />
|
||||
<Compile Include="Iob\iobRefreshedEventArgs.cs" />
|
||||
<Compile Include="IobSoap\Gomba.cs" />
|
||||
<Compile Include="IobSql\SqlServLantek.cs" />
|
||||
<Compile Include="IobSql\SqlServPama.cs" />
|
||||
|
||||
@@ -0,0 +1,909 @@
|
||||
using IOB_UT_NEXT;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Threading;
|
||||
|
||||
namespace IOB_WIN_NEXT.Iob
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe di base per IOB
|
||||
/// </summary>
|
||||
public class BaseObj
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// valore booleano di check se sia stato AVVIATO l'adapter (Running)
|
||||
/// </summary>
|
||||
public bool adpRunning = false;
|
||||
|
||||
/// <summary>
|
||||
/// valore booleano di check se l'adapter STIA SALVANDO
|
||||
/// </summary>
|
||||
public bool adpSaving = false;
|
||||
|
||||
/// <summary>
|
||||
/// valore booleano (richiesta di riavvio automatico)
|
||||
/// </summary>
|
||||
public bool adpTryRestart;
|
||||
|
||||
/// <summary>
|
||||
/// Struttura allarmi mappati
|
||||
/// </summary>
|
||||
public List<BaseAlarmConf> alarmMaps = new List<BaseAlarmConf>();
|
||||
|
||||
/// <summary>
|
||||
/// Conf adapter corrente
|
||||
/// </summary>
|
||||
public IobConfiguration cIobConf;
|
||||
|
||||
/// <summary>
|
||||
/// Conteggio ATTUALE ore macchina IN LAVORO
|
||||
/// </summary>
|
||||
public double contOreMaccLav;
|
||||
|
||||
/// <summary>
|
||||
/// Conteggio ATTUALE ore macchina ON
|
||||
/// </summary>
|
||||
public double contOreMaccOn;
|
||||
|
||||
/// <summary>
|
||||
/// contatore x simulazione valori input
|
||||
/// </summary>
|
||||
public int countSim = 0;
|
||||
|
||||
/// <summary>
|
||||
/// ODL attualmente sulla macchina
|
||||
/// </summary>
|
||||
public Int32 currIdxODL = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Modo corrente (da classe ENUM)
|
||||
/// </summary>
|
||||
public CNC_MODE currMode;
|
||||
|
||||
/// <summary>
|
||||
/// ODL corrente caricato sulla macchina (stringa, da chiamata MP/IO)
|
||||
/// </summary>
|
||||
public string currODL = "";
|
||||
|
||||
/// <summary>
|
||||
/// Indica se sia richiesto campionamento memoria PERIODICO
|
||||
/// </summary>
|
||||
public bool doSampleMemory;
|
||||
|
||||
/// <summary>
|
||||
/// Indica se si debba leggere e fare DUMP delle aree di memoria (1 volta solo all'avvio x debug...)
|
||||
/// </summary>
|
||||
public bool doStartMemDump;
|
||||
|
||||
/// <summary>
|
||||
/// Data/ora ultimo avvio adapter
|
||||
/// </summary>
|
||||
public DateTime dtAvvioAdp = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// Data/ora ultimo spegnimento adapter
|
||||
/// </summary>
|
||||
public DateTime dtStopAdp = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// Indicazione VETO check status IOB x evitare loop troppo stretti...
|
||||
/// </summary>
|
||||
public DateTime dtVetoCheckIOB = DateTime.Now.AddDays(-1);
|
||||
|
||||
/// <summary>
|
||||
/// Indicazione VETO check sync ricette x evitare loop troppo stretti...
|
||||
/// </summary>
|
||||
public DateTime dtVetoCheckSyncRecipe = DateTime.Now.AddHours(-1);
|
||||
|
||||
/// <summary>
|
||||
/// Abilitazione lettura PrgName
|
||||
/// </summary>
|
||||
public bool enablePrgName = true;
|
||||
|
||||
/// <summary>
|
||||
/// Abilitazione invio pezzi "in blocco" per recupero contapezzi
|
||||
/// </summary>
|
||||
public bool enableSendPzCountBlock = false;
|
||||
|
||||
/// <summary>
|
||||
/// Determina se sia encessario convertire valori little/big endian (SIEMENS=true, OSAI=FALSE)
|
||||
/// </summary>
|
||||
public bool hasBigEndian = false;
|
||||
|
||||
/// <summary>
|
||||
/// dataOra ultima verifica CNC disconnesso...
|
||||
/// </summary>
|
||||
public DateTime lastDisconnCheck;
|
||||
|
||||
/// <summary>
|
||||
/// Data/ora ultima volta che IOB è stato dichiarato online
|
||||
/// </summary>
|
||||
public DateTime lastIobOnline = DateTime.Now.AddHours(-1);
|
||||
|
||||
/// <summary>
|
||||
/// dataOra ultimo log periodico...
|
||||
/// </summary>
|
||||
public DateTime lastPeriodicLog;
|
||||
|
||||
/// <summary>
|
||||
/// dataOra ultimo PING inviato verso il PLC...
|
||||
/// </summary>
|
||||
public DateTime lastPING = DateTime.Now.AddHours(-1);
|
||||
|
||||
/// <summary>
|
||||
/// DataOra ultima lettura da PLC
|
||||
/// </summary>
|
||||
public DateTime lastReadPLC;
|
||||
|
||||
/// <summary>
|
||||
/// ULtimo valore inviato (in caso di disconnessione lo reinvia x garantire watchdog...)
|
||||
/// </summary>
|
||||
public string lastSignInVal = "";
|
||||
|
||||
/// <summary>
|
||||
/// DateTime Ultimo valore simulazione generato
|
||||
/// </summary>
|
||||
public DateTime lastSim;
|
||||
|
||||
/// <summary>
|
||||
/// dataOra ultimo segnale inviato al SERVER...
|
||||
/// </summary>
|
||||
public DateTime lastWatchDog;
|
||||
|
||||
/// <summary>
|
||||
/// dataOra ultimo segnale inviato a macchina/PLC...
|
||||
/// </summary>
|
||||
public DateTime lastWatchDogPLC = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// Massimo numero di px da inviare in blocco
|
||||
/// </summary>
|
||||
public int maxSendPzCountBlock = 10;
|
||||
|
||||
/// <summary>
|
||||
/// Struttura memoria PLC x lettura/scrittura da JSON file
|
||||
/// </summary>
|
||||
public plcMemMapExt memMap;
|
||||
|
||||
/// <summary>
|
||||
/// Minimo numero di px da inviare in blocco
|
||||
/// </summary>
|
||||
public int minSendPzCountBlock = 5;
|
||||
|
||||
/// <summary>
|
||||
/// Variabile booleana che indica se sia necessario fare refresh del contapezzi
|
||||
/// </summary>
|
||||
public bool needRefreshPzCount = true;
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario di persistenza per i valori da salvare da/su file
|
||||
/// </summary>
|
||||
public Dictionary<string, string> persistenceLayer;
|
||||
|
||||
/// <summary>
|
||||
/// Determina se utilizzare blocchi di memoria IOT contigui (e quindi processing
|
||||
/// "monoblocco" semplificato"=
|
||||
/// </summary>
|
||||
public bool procIotMem = false;
|
||||
|
||||
/// <summary>
|
||||
/// Coda valori ALLARMI ove gestiti...
|
||||
/// </summary>
|
||||
public DataQueue QueueAlarm = new DataQueue("000", "QueueAlarm", false);
|
||||
|
||||
//public ConcurrentQueue<string> QueueAlarm = new ConcurrentQueue<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto della coda degli elementi letti di tipo FluxLog (e non ancora trasmessi)
|
||||
/// </summary>
|
||||
public DataQueue QueueFLog = new DataQueue("000", "QueueFLog", false);
|
||||
|
||||
//public ConcurrentQueue<string> QueueFLog = new ConcurrentQueue<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto della coda degli elementi letti (e non ancora trasmessi)
|
||||
/// </summary>
|
||||
public DataQueue QueueIN = new DataQueue("000", "QueueIN", false);
|
||||
|
||||
//public ConcurrentQueue<string> QueueIN = new ConcurrentQueue<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Coda valori MESSAGGI/EVENTI (da non sottocampionare come samples)...
|
||||
/// </summary>
|
||||
public DataQueue QueueMessages = new DataQueue("000", "QueueMessages", false);
|
||||
|
||||
//public ConcurrentQueue<string> QueueMessages = new ConcurrentQueue<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto della coda degli elementi di tipo RawTransf (e non ancora trasmessi)
|
||||
/// NB: sono salvati serializzati come stringhe
|
||||
/// </summary>
|
||||
public DataQueue QueueRawTransf = new DataQueue("000", "QueueRawTransf", false);
|
||||
|
||||
//public ConcurrentQueue<string> QueueRawTransf = new ConcurrentQueue<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Coda valori LOG UTENTE (da non sottocampionare come samples)...
|
||||
/// </summary>
|
||||
public DataQueue QueueULog = new DataQueue("000", "QueueULog", false);
|
||||
|
||||
//public ConcurrentQueue<string> QueueULog = new ConcurrentQueue<string>();
|
||||
|
||||
/// <summary>
|
||||
/// alias booleano false = R
|
||||
/// </summary>
|
||||
public bool R = false;
|
||||
|
||||
/// <summary>
|
||||
/// 32 byte input base (es strobe, 8 word da 32 bit di flags...)
|
||||
/// </summary>
|
||||
public byte[] RawInput = new byte[32];
|
||||
|
||||
/// <summary>
|
||||
/// 32 byte output base (es ack, 8 word da 32 bit di flags...)
|
||||
/// </summary>
|
||||
public byte[] RawOutput = new byte[32];
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto connessione REDIS
|
||||
/// </summary>
|
||||
public RedisIobCache redisMan;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto cronometro x campionamento durate chiamate
|
||||
/// </summary>
|
||||
public Stopwatch stopwatch = new Stopwatch();
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto gestione TempiCiclo e contapezzi
|
||||
/// </summary>
|
||||
public TCMan tcMan = new TCMan(0.5, 1.3, 5);
|
||||
|
||||
/// <summary>
|
||||
/// Imposta veto lettura dati (es per DB a 2 sec)
|
||||
/// </summary>
|
||||
public DateTime vetoDataRead = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// Imposta veto SYNC dati (es per DB 2 DB a 10 sec)
|
||||
/// </summary>
|
||||
public DateTime vetoDataSync = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// Imposta veto chiamata split (durante chiamata, per 60 sec)
|
||||
/// </summary>
|
||||
public DateTime vetoSplit = DateTime.Now.AddMinutes(1);
|
||||
|
||||
/// <summary>
|
||||
/// alias booleano true = W
|
||||
/// </summary>
|
||||
public bool W = true;
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Verifica se sia in modalità DEMO avanzata (campionamento da set di valori ammessi...)
|
||||
/// </summary>
|
||||
public static bool DemoInSample
|
||||
{
|
||||
get
|
||||
{
|
||||
return baseUtils.CRB("DemoInSample");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifica se sia in modalità DEMO x dati OUTPUT
|
||||
/// </summary>
|
||||
public static bool DemoOut
|
||||
{
|
||||
get
|
||||
{
|
||||
return utils.CRB("DemoOut");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicazione VETO PING a server sino alla data-ora indicata
|
||||
/// </summary>
|
||||
public static DateTime dtVetoPing
|
||||
{
|
||||
get
|
||||
{
|
||||
return utils.dtVetoPing;
|
||||
}
|
||||
set
|
||||
{
|
||||
utils.dtVetoPing = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicazione VETO accodamento valori INGRESSI/EVENTI sino alla data-ora indicata
|
||||
/// </summary>
|
||||
public static DateTime dtVetoQueueIN
|
||||
{
|
||||
get
|
||||
{
|
||||
return utils.dtVetoQueueIN;
|
||||
}
|
||||
set
|
||||
{
|
||||
utils.dtVetoQueueIN = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicazione VETO invio a server sino alla data-ora indicata
|
||||
/// </summary>
|
||||
public static DateTime dtVetoSend
|
||||
{
|
||||
get
|
||||
{
|
||||
return utils.dtVetoSend;
|
||||
}
|
||||
set
|
||||
{
|
||||
utils.dtVetoSend = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifica se sia abilitato test lettura blocchi memoria all'avvio
|
||||
/// </summary>
|
||||
public static bool EnableTest
|
||||
{
|
||||
get
|
||||
{
|
||||
return baseUtils.CRB("enableTest");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// stato Online/Offline del server MP IO (su REDIS)
|
||||
/// </summary>
|
||||
public static bool MPOnline
|
||||
{
|
||||
get
|
||||
{
|
||||
return utils.MPIO_Online;
|
||||
}
|
||||
set
|
||||
{
|
||||
utils.MPIO_Online = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Effettua chiamata URL e restituisce risultato
|
||||
/// </summary>
|
||||
/// <param name="URL"></param>
|
||||
/// <param name="doAsync">invio in modalità async (NON GARANTITO ordine...)</param>
|
||||
/// <returns></returns>
|
||||
public static string callUrl(string URL, bool doAsync)
|
||||
{
|
||||
string answ = "";
|
||||
// Chiamata ASINCRONA
|
||||
if (doAsync)
|
||||
{
|
||||
//Task<string> resp = utils.callUrlAsync(URL);
|
||||
//answ = resp.Result;
|
||||
answ = utils.callUrlAsync(URL);
|
||||
if (urlRandWait > 0)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
Thread.Sleep(rnd.Next(urlRandWait / 10, urlRandWait));
|
||||
}
|
||||
}
|
||||
// chiamata SOLO NORMALE SINCRONA...
|
||||
else
|
||||
{
|
||||
answ = utils.callUrl(URL);
|
||||
if (urlRandWait > 0)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
Thread.Sleep(rnd.Next(urlRandWait / 10, urlRandWait));
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua chiamata URL e restituisce risultato
|
||||
/// </summary>
|
||||
/// <param name="URL"></param>
|
||||
/// <param name="payload"></param>
|
||||
/// <param name="doAsync">invio in modalità async (NON GARANTITO ordine...)</param>
|
||||
/// <returns></returns>
|
||||
public static string callUrlWithPayload(string URL, string payload, bool doAsync)
|
||||
{
|
||||
string answ = "";
|
||||
// Chiamata ASINCRONA
|
||||
if (doAsync)
|
||||
{
|
||||
answ = utils.callUrlAsync(URL, payload);
|
||||
if (urlRandWait > 0)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
Thread.Sleep(rnd.Next(urlRandWait / 10, urlRandWait));
|
||||
}
|
||||
}
|
||||
// chiamata SOLO NORMALE SINCRONA...
|
||||
else
|
||||
{
|
||||
answ = utils.callUrl(URL, payload);
|
||||
if (urlRandWait > 0)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
Thread.Sleep(rnd.Next(urlRandWait / 10, urlRandWait));
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// processa dataLayer e se necessario salva/mostra
|
||||
/// </summary>
|
||||
public static void checkSavePersDataLayer()
|
||||
{
|
||||
}
|
||||
|
||||
public static string GetMACAddress()
|
||||
{
|
||||
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
|
||||
String sMacAddress = string.Empty;
|
||||
foreach (NetworkInterface adapter in nics)
|
||||
{
|
||||
if (string.IsNullOrEmpty(sMacAddress))// only return MAC Address from first card
|
||||
{
|
||||
IPInterfaceProperties properties = adapter.GetIPProperties();
|
||||
//sMacAddress = adapter.GetPhysicalAddress().ToString();
|
||||
sMacAddress = string.Join(":", (from z in adapter.GetPhysicalAddress().GetAddressBytes() select z.ToString("X2")).ToArray());
|
||||
}
|
||||
}
|
||||
return sMacAddress;
|
||||
}
|
||||
|
||||
public static void resetDebugConsole()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reset dei webclients
|
||||
/// </summary>
|
||||
public static void resetWebClients()
|
||||
{
|
||||
utils.resetWebClients();
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
/// <summary>
|
||||
/// wrapper di log
|
||||
/// </summary>
|
||||
protected static Logger lg;
|
||||
|
||||
/// <summary>
|
||||
/// Valore di attesa (random) dopo ogni invio x evitare congestione send...
|
||||
/// </summary>
|
||||
protected static int urlRandWait = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Ultimo LOG registrazione avvio (x ridurre log notturni...)
|
||||
/// </summary>
|
||||
protected DateTime lastLogStartup = DateTime.Today.AddHours(-1);
|
||||
|
||||
/// <summary>
|
||||
/// Form chiamante
|
||||
/// </summary>
|
||||
protected AdapterForm parentForm;
|
||||
|
||||
/// <summary>
|
||||
/// Veto per registrazione completa log di startup (minuti)
|
||||
/// </summary>
|
||||
protected int vetoLogStartupDuration = 60;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario condizioni di veto log x ogni tipo di messaggio (periodo differente secondo livello)
|
||||
/// </summary>
|
||||
protected Dictionary<string, DateTime> VetoLog { get; set; } = new Dictionary<string, DateTime>();
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario conteggio numero volte che si fa veto log x ogni tipo di messaggio
|
||||
/// </summary>
|
||||
protected Dictionary<string, int> VetoLogCount { get; set; } = new Dictionary<string, int>();
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Effettua logging DEBUG corretto impostanto anche la variabile IOB prima di scrivere...
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
protected void lgDebug(string message, bool sendToForm = true)
|
||||
{
|
||||
bool doVeto = checkLogVeto(20, ref message);
|
||||
// se non ho veto --> loggo
|
||||
if (!doVeto)
|
||||
{
|
||||
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.codIOB;
|
||||
lg.Debug(message);
|
||||
if (sendToForm)
|
||||
{
|
||||
sendToLogWatch("DEBUG", message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua logging DEBUG corretto impostanto anche la variabile IOB prima di scrivere...
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="args"></param>
|
||||
protected void lgDebug(string message, params object[] args)
|
||||
{
|
||||
bool doVeto = checkLogVeto(20, ref message);
|
||||
// se non ho veto --> loggo
|
||||
if (!doVeto)
|
||||
{
|
||||
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.codIOB;
|
||||
lg.Debug(message, args);
|
||||
sendToLogWatch("DEBUG", message, args);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua logging ERROR corretto impostanto anche la variabile IOB prima di scrivere...
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
protected void lgError(string message, bool sendToForm = true)
|
||||
{
|
||||
bool doVeto = checkLogVeto(2, ref message);
|
||||
// se non ho veto --> loggo
|
||||
if (!doVeto)
|
||||
{
|
||||
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.codIOB;
|
||||
lg.Error(message);
|
||||
if (sendToForm)
|
||||
{
|
||||
sendToLogWatch("ERROR", message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua logging ERROR corretto impostanto anche la variabile IOB prima di scrivere...
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="args"></param>
|
||||
protected void lgError(string message, params object[] args)
|
||||
{
|
||||
bool doVeto = checkLogVeto(2, ref message);
|
||||
// se non ho veto --> loggo
|
||||
if (!doVeto)
|
||||
{
|
||||
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.codIOB;
|
||||
lg.Error(message, args);
|
||||
sendToLogWatch("ERROR", message, args);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua logging ERROR corretto impostanto anche la variabile IOB prima di scrivere...
|
||||
/// </summary>
|
||||
/// <param name="exception"></param>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="args"></param>
|
||||
protected void lgError(Exception exception, string message, params object[] args)
|
||||
{
|
||||
bool doVeto = checkLogVeto(2, ref message);
|
||||
// se non ho veto --> loggo
|
||||
if (!doVeto)
|
||||
{
|
||||
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.codIOB;
|
||||
lg.Error(exception, message, args);
|
||||
sendToLogWatch("ERROR", message, exception, args);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua logging FATAL corretto impostanto anche la variabile IOB prima di scrivere...
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
protected void lgFatal(string message, bool sendToForm = true)
|
||||
{
|
||||
bool doVeto = checkLogVeto(1, ref message);
|
||||
// se non ho veto --> loggo
|
||||
if (!doVeto)
|
||||
{
|
||||
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.codIOB;
|
||||
lg.Fatal(message);
|
||||
if (sendToForm)
|
||||
{
|
||||
sendToLogWatch("FATAL", message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua logging FATAL corretto impostanto anche la variabile IOB prima di scrivere...
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="args"></param>
|
||||
protected void lgFatal(string message, params object[] args)
|
||||
{
|
||||
bool doVeto = checkLogVeto(1, ref message);
|
||||
// se non ho veto --> loggo
|
||||
if (!doVeto)
|
||||
{
|
||||
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.codIOB;
|
||||
lg.Fatal(message, args);
|
||||
sendToLogWatch("FATAL", message, args);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua logging FATAL corretto impostanto anche la variabile IOB prima di scrivere...
|
||||
/// </summary>
|
||||
/// <param name="exception"></param>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="args"></param>
|
||||
protected void lgFatal(Exception exception, string message, params object[] args)
|
||||
{
|
||||
bool doVeto = checkLogVeto(1, ref message);
|
||||
// se non ho veto --> loggo
|
||||
if (!doVeto)
|
||||
{
|
||||
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.codIOB;
|
||||
lg.Fatal(exception, message, args);
|
||||
sendToLogWatch("FATAL", message, exception, args);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua logging INFO corretto impostanto anche la variabile IOB prima di scrivere...
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
protected void lgInfo(string message, bool sendToForm = true)
|
||||
{
|
||||
bool doVeto = checkLogVeto(30, ref message);
|
||||
// se non ho veto --> loggo
|
||||
if (!doVeto)
|
||||
{
|
||||
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.codIOB;
|
||||
lg.Info(message);
|
||||
if (sendToForm)
|
||||
{
|
||||
sendToLogWatch("INFO", message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua logging INFO corretto impostanto anche la variabile IOB prima di scrivere...
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="args"></param>
|
||||
protected void lgInfo(string message, params object[] args)
|
||||
{
|
||||
bool doVeto = checkLogVeto(30, ref message);
|
||||
// se non ho veto --> loggo
|
||||
if (!doVeto)
|
||||
{
|
||||
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.codIOB;
|
||||
lg.Info(message, args);
|
||||
sendToLogWatch("INFO", message, args);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua logging INFO corretto impostanto anche la variabile IOB prima di scrivere...
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="sendToForm"></param>
|
||||
protected void lgInfoStartup(string message, bool sendToForm = true)
|
||||
{
|
||||
bool doVeto = checkLogVeto(30, ref message);
|
||||
// se non ho veto --> loggo
|
||||
if (!doVeto)
|
||||
{
|
||||
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.codIOB;
|
||||
DateTime adesso = DateTime.Now;
|
||||
if (adesso.Subtract(lastLogStartup).TotalMinutes > vetoLogStartupDuration)
|
||||
{
|
||||
lg.Info(message);
|
||||
// se supera di 5 minutis cadenza -_> reimposto veto...
|
||||
if (adesso.Subtract(lastLogStartup).TotalMinutes > vetoLogStartupDuration + 5)
|
||||
{
|
||||
lastLogStartup = adesso;
|
||||
}
|
||||
}
|
||||
if (sendToForm)
|
||||
{
|
||||
sendToLogWatch("INFO", message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua logging INFO corretto impostanto anche la variabile IOB prima di scrivere...
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="args"></param>
|
||||
protected void lgInfoStartup(string message, params object[] args)
|
||||
{
|
||||
bool doVeto = checkLogVeto(30, ref message);
|
||||
// se non ho veto --> loggo
|
||||
if (!doVeto)
|
||||
{
|
||||
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.codIOB;
|
||||
DateTime adesso = DateTime.Now;
|
||||
if (adesso.Subtract(lastLogStartup).TotalMinutes > vetoLogStartupDuration)
|
||||
{
|
||||
lg.Info(message, args);
|
||||
// se supera di 5 minutis cadenza -_> reimposto veto...
|
||||
if (adesso.Subtract(lastLogStartup).TotalMinutes > vetoLogStartupDuration + 5)
|
||||
{
|
||||
lastLogStartup = adesso;
|
||||
}
|
||||
}
|
||||
sendToLogWatch("INFO", message, args);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua logging INFO corretto impostanto anche la variabile IOB prima di scrivere...
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
protected void lgTrace(string message, bool sendToForm = true)
|
||||
{
|
||||
bool doVeto = checkLogVeto(60, ref message);
|
||||
// se non ho veto --> loggo
|
||||
if (!doVeto)
|
||||
{
|
||||
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.codIOB;
|
||||
lg.Trace(message);
|
||||
if (sendToForm)
|
||||
{
|
||||
sendToLogWatch("TRACE", message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua logging INFO corretto impostanto anche la variabile IOB prima di scrivere...
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="args"></param>
|
||||
protected void lgTrace(string message, params object[] args)
|
||||
{
|
||||
bool doVeto = checkLogVeto(60, ref message);
|
||||
// se non ho veto --> loggo
|
||||
if (!doVeto)
|
||||
{
|
||||
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.codIOB;
|
||||
lg.Trace(message, args);
|
||||
sendToLogWatch("TRACE", message, args);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invia messaggio a logWatcher
|
||||
/// </summary>
|
||||
/// <param name="messType"></param>
|
||||
/// <param name="message"></param>
|
||||
protected void sendToLogWatch(string messType, string message)
|
||||
{
|
||||
newDisplayData currDispData = new newDisplayData();
|
||||
currDispData.newLiveLogData = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} | {messType} | {message}";
|
||||
parentForm.updateFormDisplay(currDispData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invia messaggio a logWatcher
|
||||
/// </summary>
|
||||
/// <param name="messType"></param>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="args"></param>
|
||||
protected void sendToLogWatch(string messType, string message, params object[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
string expString = string.Format(message, args);
|
||||
newDisplayData currDispData = new newDisplayData();
|
||||
currDispData.newLiveLogData = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} | {messType} | {expString}";
|
||||
parentForm.updateFormDisplay(currDispData);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invia messaggio a logWatcher
|
||||
/// </summary>
|
||||
/// <param name="messType"></param>
|
||||
/// <param name="exception"></param>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="args"></param>
|
||||
protected void sendToLogWatch(string messType, string message, Exception exception, params object[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
string expString = string.Format(message, args);
|
||||
newDisplayData currDispData = new newDisplayData();
|
||||
currDispData.newLiveLogData = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} | {messType} | {expString}{Environment.NewLine}{exception}";
|
||||
parentForm.updateFormDisplay(currDispData);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Verifica se ci sia veto log attivo e gestisce casistiche
|
||||
/// </summary>
|
||||
/// <param name="vetoSec"></param>
|
||||
/// <param name="message"></param>
|
||||
/// <returns></returns>
|
||||
private bool checkLogVeto(int vetoSec, ref string message)
|
||||
{
|
||||
//verifico SE si debba fare log, altrimenti metto in coda...
|
||||
bool doVeto = true;
|
||||
DateTime adesso = DateTime.Now;
|
||||
if (VetoLog.ContainsKey(message))
|
||||
{
|
||||
// conteggio num veto a +1...
|
||||
if (VetoLogCount.ContainsKey(message))
|
||||
{
|
||||
VetoLogCount[message]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
VetoLogCount.Add(message, 1);
|
||||
}
|
||||
// controllo scadenza, quando superata soglia aggiorno messaggio con {n} x {messaggio}
|
||||
if (adesso.Subtract(VetoLog[message]).TotalSeconds > vetoSec)
|
||||
{
|
||||
doVeto = false;
|
||||
string newMessage = $"{VetoLogCount[message]} x {message}";
|
||||
VetoLog.Remove(message);
|
||||
VetoLogCount.Remove(message);
|
||||
message = newMessage;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// primo --> loggo
|
||||
doVeto = false;
|
||||
VetoLog.Add(message, adesso.AddSeconds(vetoSec));
|
||||
VetoLogCount.Add(message, 0);
|
||||
}
|
||||
// restituisco esito!
|
||||
return doVeto;
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
+87
-967
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,45 @@
|
||||
using IOB_UT_NEXT;
|
||||
using System;
|
||||
|
||||
namespace IOB_WIN_NEXT.Iob
|
||||
{
|
||||
/// <summary>
|
||||
/// Evento per incapsulare dati x refresh pagina
|
||||
/// </summary>
|
||||
public class iobRefreshedEventArgs : EventArgs
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
/// salvataggio obj
|
||||
/// </summary>
|
||||
/// <param name="newObject"></param>
|
||||
public iobRefreshedEventArgs(newDisplayData newObject)
|
||||
{
|
||||
_newDisplayData = newObject;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Proprietà lettura displayData aggiornato
|
||||
/// </summary>
|
||||
public newDisplayData DisplayDataObject
|
||||
{
|
||||
get { return _newDisplayData; }
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// classe obj privata
|
||||
/// </summary>
|
||||
private readonly newDisplayData _newDisplayData;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
+125
-124
@@ -1,5 +1,4 @@
|
||||
|
||||
using EgwProxy.Gomba.GombaServ;
|
||||
using EgwProxy.Gomba.GombaServ;
|
||||
using IOB_UT_NEXT;
|
||||
using MapoSDK;
|
||||
using Newtonsoft.Json;
|
||||
@@ -8,12 +7,11 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using static IOB_UT_NEXT.CustomObj;
|
||||
|
||||
namespace IOB_WIN_NEXT.IobSoap
|
||||
{
|
||||
/// <summary>
|
||||
/// Adapter specializzato per ICOEL e le chiamate tramite WS Soap al Sizer, con libreria EgwProxy.Icoel
|
||||
/// Adapter specializzato per GOMA e le chiamate tramite WS Soap alla bilancia, libreria EgwProxy.Gomba
|
||||
/// </summary>
|
||||
public class Gomba : Iob.Generic
|
||||
{
|
||||
@@ -31,84 +29,8 @@ namespace IOB_WIN_NEXT.IobSoap
|
||||
lastPING = DateTime.Now.AddHours(-1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Proxy per connessione al SOAP webservice GOMBA
|
||||
/// </summary>
|
||||
protected EgwProxy.Gomba.GombaServ.lwpServiceClient gombaConn;
|
||||
|
||||
/// <summary>
|
||||
/// Data inizio periodo dati Bilancia:
|
||||
/// - al boot impostato a -6 mesi
|
||||
/// - dopo lettura impostato a data ultimi 5 record
|
||||
/// </summary>
|
||||
private string dataFrom
|
||||
{
|
||||
get => dtStartLive.ToString("dd/MM/yyyy");
|
||||
}
|
||||
|
||||
private DateTime dtStartLive { get; set; } = DateTime.Today.AddMonths(-6);
|
||||
|
||||
/// <summary>
|
||||
/// Data fine periodo dati Bilancia: oggi + 1gg
|
||||
/// </summary>
|
||||
private string dataTo
|
||||
{
|
||||
get => DateTime.Today.AddDays(1).ToString("dd/MM/yyyy");
|
||||
}
|
||||
/// <summary>
|
||||
/// Elenco pesate attuali
|
||||
/// </summary>
|
||||
private List<EgwProxy.Gomba.GombaServ.gestWeightOut> listPesateCurr { get; set; } = new List<EgwProxy.Gomba.GombaServ.gestWeightOut>();
|
||||
|
||||
private string redKeyPesate { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Elenco lettura pesate precedenti
|
||||
/// </summary>
|
||||
private List<EgwProxy.Gomba.GombaServ.gestWeightOut> listPesatePrev { get; set; } = new List<EgwProxy.Gomba.GombaServ.gestWeightOut>();
|
||||
|
||||
/// <summary>
|
||||
/// Gestione archivio serializzato delle pesate già processate
|
||||
/// </summary>
|
||||
private List<EgwProxy.Gomba.GombaServ.gestWeightOut> listPesateArch
|
||||
{
|
||||
get
|
||||
{
|
||||
List<EgwProxy.Gomba.GombaServ.gestWeightOut> answ = new List<EgwProxy.Gomba.GombaServ.gestWeightOut>();
|
||||
string rawData = redisMan.getRSV(redKeyPesate);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
try
|
||||
{
|
||||
answ = JsonConvert.DeserializeObject<List<EgwProxy.Gomba.GombaServ.gestWeightOut>>(rawData);
|
||||
lgInfo($"Rilettura status listPesateArch: trovati {answ.Count} record");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lgError($"Errore in deserializzazione listPesateArch{Environment.NewLine}{exc}");
|
||||
answ = new List<EgwProxy.Gomba.GombaServ.gestWeightOut>();
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
set
|
||||
{
|
||||
string rawVal = JsonConvert.SerializeObject(value);
|
||||
redisMan.setRSV(redKeyPesate, rawVal);
|
||||
lgInfo($"Salvataggio status listPesateArch | {value.Count} record");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
|
||||
public enum gombaTaskType
|
||||
{
|
||||
reqIN,
|
||||
reqOUT,
|
||||
}
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -182,7 +104,6 @@ namespace IOB_WIN_NEXT.IobSoap
|
||||
{
|
||||
lgError($"Attenzione! memMap è nullo, non posso eseguire task2exe!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return taskDone;
|
||||
@@ -256,38 +177,6 @@ namespace IOB_WIN_NEXT.IobSoap
|
||||
lastReadPLC = DateTime.Now;
|
||||
return outVal;
|
||||
}
|
||||
/// <summary>
|
||||
/// Formatta record completo pesata
|
||||
/// </summary>
|
||||
/// <param name="rec">record completo pesate Gomba</param>
|
||||
/// <param name="isIN">Indica se deve formattare i dati tipo IN (true) o OUT (false)</param>
|
||||
/// <returns></returns>
|
||||
private static string formatPesata(gestWeightOut rec, bool isIN)
|
||||
{
|
||||
string currVal = "";
|
||||
if (isIN)
|
||||
{
|
||||
currVal = $"{rec.dateIn:yyyy-MM-dd HH:mm:ss} | {rec.weightIn} kg";
|
||||
}
|
||||
else
|
||||
{
|
||||
currVal = $"{rec.dateOut:yyyy-MM-dd HH:mm:ss} | {rec.weightOut} kg";
|
||||
}
|
||||
currVal += formatCode(rec.cod1);
|
||||
currVal += formatCode(rec.cod2);
|
||||
currVal += formatCode(rec.cod3);
|
||||
currVal += formatCode(rec.cod4);
|
||||
currVal += formatCode(rec.cod5);
|
||||
currVal += formatCode(rec.cod6);
|
||||
return currVal;
|
||||
}
|
||||
|
||||
private static string formatCode(string currCode)
|
||||
{
|
||||
string code = string.IsNullOrEmpty(currCode) ? "-" : currCode;
|
||||
return $" | {code}";
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Effettua lettura semafori principale <paramref name="currDispData">Parametri da
|
||||
@@ -429,11 +318,14 @@ namespace IOB_WIN_NEXT.IobSoap
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Properties
|
||||
#region Protected Fields
|
||||
|
||||
/// <summary>
|
||||
/// Proxy per connessione al SOAP webservice GOMBA
|
||||
/// </summary>
|
||||
protected EgwProxy.Gomba.GombaServ.lwpServiceClient gombaConn;
|
||||
|
||||
|
||||
#endregion Protected Properties
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
@@ -446,7 +338,7 @@ namespace IOB_WIN_NEXT.IobSoap
|
||||
foreach (var item in updatedPar)
|
||||
{
|
||||
// salvo i valori di setup x prox pesata...
|
||||
upsertKey(item.uid, item.reqValue);
|
||||
upsertKey(item.uid, item.value);
|
||||
bool fatto = false;
|
||||
// se è richiesta pesata IN/OUT --> mando chiamata
|
||||
if (item.uid == "reqIN")
|
||||
@@ -457,6 +349,11 @@ namespace IOB_WIN_NEXT.IobSoap
|
||||
{
|
||||
fatto = reqWeight(false);
|
||||
}
|
||||
else if (item.uid == "RM" || item.uid.StartsWith("Cod"))
|
||||
{
|
||||
// comunque segno fatto x altri casi
|
||||
fatto = true;
|
||||
}
|
||||
// se fatto --> aggiorno!
|
||||
if (fatto)
|
||||
{
|
||||
@@ -467,6 +364,7 @@ namespace IOB_WIN_NEXT.IobSoap
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue richiesta PESO
|
||||
/// </summary>
|
||||
@@ -481,16 +379,20 @@ namespace IOB_WIN_NEXT.IobSoap
|
||||
sw.Start();
|
||||
// preparo parametri
|
||||
string tipoRic = reqIN ? "IN" : "OUT";
|
||||
string rm = string.IsNullOrEmpty(currProdData["RM"]) ? $"{DateTime.Now:yyyyMMdd-HHmmss}" : currProdData["RM"];
|
||||
string Cod1 = string.IsNullOrEmpty(currProdData["Cod1"]) ? "" : currProdData["Cod1"];
|
||||
string Cod2 = string.IsNullOrEmpty(currProdData["Cod2"]) ? "" : currProdData["Cod2"];
|
||||
string Cod3 = string.IsNullOrEmpty(currProdData["Cod3"]) ? "" : currProdData["Cod3"];
|
||||
string Cod4 = string.IsNullOrEmpty(currProdData["Cod4"]) ? "" : currProdData["Cod4"];
|
||||
string Cod5 = string.IsNullOrEmpty(currProdData["Cod5"]) ? "" : currProdData["Cod5"];
|
||||
string Cod6 = string.IsNullOrEmpty(currProdData["Cod6"]) ? "" : currProdData["Cod6"];
|
||||
string rm = getCurrProdData("RM", $"{DateTime.Now:yyyyMMdd-HHmmss}");// string.IsNullOrEmpty(currProdData["RM"]) ? $"{DateTime.Now:yyyyMMdd-HHmmss}" : currProdData["RM"];
|
||||
string Cod1 = getCurrProdData("Cod1", ""); //string.IsNullOrEmpty(currProdData["Cod1"]) ? "" : currProdData["Cod1"];
|
||||
string Cod2 = getCurrProdData("Cod2", ""); //string.IsNullOrEmpty(currProdData["Cod2"]) ? "" : currProdData["Cod2"];
|
||||
string Cod3 = getCurrProdData("Cod3", ""); //string.IsNullOrEmpty(currProdData["Cod3"]) ? "" : currProdData["Cod3"];
|
||||
string Cod4 = getCurrProdData("Cod4", ""); //string.IsNullOrEmpty(currProdData["Cod4"]) ? "" : currProdData["Cod4"];
|
||||
string Cod5 = getCurrProdData("Cod5", ""); //string.IsNullOrEmpty(currProdData["Cod5"]) ? "" : currProdData["Cod5"];
|
||||
string Cod6 = getCurrProdData("Cod6", ""); //string.IsNullOrEmpty(currProdData["Cod6"]) ? "" : currProdData["Cod6"];
|
||||
// faccio chiamata
|
||||
var answ = gombaConn.memWeight(tipoRic, rm, Cod1, Cod2, Cod3, Cod4, Cod5, Cod6);
|
||||
fatto = answ.feedback == "C";
|
||||
if(!fatto)
|
||||
{
|
||||
lgError($"reqWeight | Errore in richiesta peso GOMBA | {answ.feedback} | {answ.notes}");
|
||||
}
|
||||
sw.Stop();
|
||||
lgInfo($"SOAP: effettuata chiamata reqWeightList in {sw.Elapsed.TotalMilliseconds}ms | {dataFrom} --> {dataTo}");
|
||||
}
|
||||
@@ -503,8 +405,107 @@ namespace IOB_WIN_NEXT.IobSoap
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Properties
|
||||
|
||||
/// <summary>
|
||||
/// Data inizio periodo dati Bilancia:
|
||||
/// - al boot impostato a -6 mesi
|
||||
/// - dopo lettura impostato a data ultimi 5 record
|
||||
/// </summary>
|
||||
private string dataFrom
|
||||
{
|
||||
get => dtStartLive.ToString("dd/MM/yyyy");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Data fine periodo dati Bilancia: oggi + 1gg
|
||||
/// </summary>
|
||||
private string dataTo
|
||||
{
|
||||
get => DateTime.Today.AddDays(1).ToString("dd/MM/yyyy");
|
||||
}
|
||||
|
||||
private DateTime dtStartLive { get; set; } = DateTime.Today.AddMonths(-6);
|
||||
|
||||
/// <summary>
|
||||
/// Gestione archivio serializzato delle pesate già processate
|
||||
/// </summary>
|
||||
private List<EgwProxy.Gomba.GombaServ.gestWeightOut> listPesateArch
|
||||
{
|
||||
get
|
||||
{
|
||||
List<EgwProxy.Gomba.GombaServ.gestWeightOut> answ = new List<EgwProxy.Gomba.GombaServ.gestWeightOut>();
|
||||
string rawData = redisMan.getRSV(redKeyPesate);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
try
|
||||
{
|
||||
answ = JsonConvert.DeserializeObject<List<EgwProxy.Gomba.GombaServ.gestWeightOut>>(rawData);
|
||||
lgInfo($"Rilettura status listPesateArch: trovati {answ.Count} record");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lgError($"Errore in deserializzazione listPesateArch{Environment.NewLine}{exc}");
|
||||
answ = new List<EgwProxy.Gomba.GombaServ.gestWeightOut>();
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
set
|
||||
{
|
||||
string rawVal = JsonConvert.SerializeObject(value);
|
||||
redisMan.setRSV(redKeyPesate, rawVal);
|
||||
lgInfo($"Salvataggio status listPesateArch | {value.Count} record");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco pesate attuali
|
||||
/// </summary>
|
||||
private List<EgwProxy.Gomba.GombaServ.gestWeightOut> listPesateCurr { get; set; } = new List<EgwProxy.Gomba.GombaServ.gestWeightOut>();
|
||||
|
||||
/// <summary>
|
||||
/// Elenco lettura pesate precedenti
|
||||
/// </summary>
|
||||
private List<EgwProxy.Gomba.GombaServ.gestWeightOut> listPesatePrev { get; set; } = new List<EgwProxy.Gomba.GombaServ.gestWeightOut>();
|
||||
|
||||
private string redKeyPesate { get; set; } = "";
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private static string formatCode(string currCode)
|
||||
{
|
||||
string code = string.IsNullOrEmpty(currCode) ? "-" : currCode;
|
||||
return $" | {code}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Formatta record completo pesata
|
||||
/// </summary>
|
||||
/// <param name="rec">record completo pesate Gomba</param>
|
||||
/// <param name="isIN">Indica se deve formattare i dati tipo IN (true) o OUT (false)</param>
|
||||
/// <returns></returns>
|
||||
private static string formatPesata(gestWeightOut rec, bool isIN)
|
||||
{
|
||||
string currVal = "";
|
||||
if (isIN)
|
||||
{
|
||||
currVal = $"{rec.dateIn:yyyy-MM-dd HH:mm:ss} | {rec.weightIn} kg";
|
||||
}
|
||||
else
|
||||
{
|
||||
currVal = $"{rec.dateOut:yyyy-MM-dd HH:mm:ss} | {rec.weightOut} kg";
|
||||
}
|
||||
currVal += formatCode(rec.cod1);
|
||||
currVal += formatCode(rec.cod2);
|
||||
currVal += formatCode(rec.cod3);
|
||||
currVal += formatCode(rec.cod4);
|
||||
currVal += formatCode(rec.cod5);
|
||||
currVal += formatCode(rec.cod6);
|
||||
return currVal;
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user