diff --git a/IOB-WIN-FTP.sln b/IOB-WIN-FTP.sln
index ac8ac853..a62eceed 100644
--- a/IOB-WIN-FTP.sln
+++ b/IOB-WIN-FTP.sln
@@ -69,8 +69,8 @@ Global
{3ED97EEA-9EAB-480D-8E53-EDB3662DCB79}.Release|Any CPU.Build.0 = Release|Any CPU
{3ED97EEA-9EAB-480D-8E53-EDB3662DCB79}.Release|x86.ActiveCfg = Release|Any CPU
{3ED97EEA-9EAB-480D-8E53-EDB3662DCB79}.Release|x86.Build.0 = Release|Any CPU
- {3ED97EEA-9EAB-480D-8E53-EDB3662DCB79}.Remote_DEBUG|Any CPU.ActiveCfg = Release|Any CPU
- {3ED97EEA-9EAB-480D-8E53-EDB3662DCB79}.Remote_DEBUG|Any CPU.Build.0 = Release|Any CPU
+ {3ED97EEA-9EAB-480D-8E53-EDB3662DCB79}.Remote_DEBUG|Any CPU.ActiveCfg = Release_DEBUG|Any CPU
+ {3ED97EEA-9EAB-480D-8E53-EDB3662DCB79}.Remote_DEBUG|Any CPU.Build.0 = Release_DEBUG|Any CPU
{3ED97EEA-9EAB-480D-8E53-EDB3662DCB79}.Remote_DEBUG|x86.ActiveCfg = Release|Any CPU
{3ED97EEA-9EAB-480D-8E53-EDB3662DCB79}.Remote_DEBUG|x86.Build.0 = Release|Any CPU
EndGlobalSection
diff --git a/IOB-WIN-FTP/AdapterFormNext.cs b/IOB-WIN-FTP/AdapterFormNext.cs
index b32a96ea..53066a47 100644
--- a/IOB-WIN-FTP/AdapterFormNext.cs
+++ b/IOB-WIN-FTP/AdapterFormNext.cs
@@ -27,9 +27,8 @@ namespace IOB_WIN_FTP
{
switch (tipoScelto)
{
-
- case tipoAdapter.PingWatchdog:
- iobObj = new IOB_WIN_FORM.Iob.PingWatchDog(this, IOBConf);
+ case tipoAdapter.FTP:
+ iobObj = new Iob.Ftp(this, IOBConf);
btnStart.Enabled = true;
break;
diff --git a/IOB-WIN-FTP/App.config b/IOB-WIN-FTP/App.config
index 93faf2cd..fd627151 100644
--- a/IOB-WIN-FTP/App.config
+++ b/IOB-WIN-FTP/App.config
@@ -111,19 +111,19 @@
-
+
-
+
-
+
-
+
@@ -131,15 +131,15 @@
-
+
-
+
-
+
@@ -153,6 +153,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/IOB-WIN-FTP/DATA/CONF/FTP_SONATEST.ini b/IOB-WIN-FTP/DATA/CONF/FTP_SONATEST.ini
new file mode 100644
index 00000000..9aa6c689
--- /dev/null
+++ b/IOB-WIN-FTP/DATA/CONF/FTP_SONATEST.ini
@@ -0,0 +1,79 @@
+;Configurazione IOB-WIN
+[IOB]
+;Macchina TEST FTP simile a ultrasuoni Sonatest x IMI Remosa
+CNCTYPE=FTP
+PING_MS_TIMEOUT=500
+
+[MACHINE]
+VENDOR=TEST_FTP
+MODEL=TRUESCALE_FTP
+
+[CNC]
+IP=10.74.82.204
+PORT=21
+PING_IP=10.74.82.204
+GETPRGNAME=false
+
+[SERVER]
+MPIP=http://10.74.82.218
+MPURL=/MP/IO
+CMDBASE=/IOB/input/
+CMDFLOG=/IOB/flog/
+CMDALIVE=/IOB
+CMDENABLED=/IOB/enabled/
+CMDADV1=?valore=
+CMDREBO=/sendReboot.aspx?idxMacchina=
+
+[MEMORY]
+ADDR_READ=DB9999.DBB0
+ADDR_WRITE=DB9999.DBB0
+SIZE_READ=0
+SIZE_WRITE=0
+
+
+[BLINK]
+;MAX_COUNTER_BLINK = 30
+MAX_COUNTER_BLINK = 30
+BLINK_FILT=0
+
+[OPTPAR]
+; imposto breve sennò non riesce a partire...
+WAIT_REC_MSEC = 1000
+; indica gestione folder ritorno dati ODL
+ODL_FOLDER = TRUE
+; gestione contapezzi
+PZCOUNT_MODE=NONE
+DISABLE_PZCOUNT=TRUE
+ENABLE_SEND_PZC_BLOCK=FALSE
+MIN_SEND_PZC_BLOCK=0
+MAX_SEND_PZC_BLOCK=100
+;errori verifica folder FTP MAX
+MAX_ERR_CHECK=10
+; gestione DynData
+ENABLE_DYN_DATA=TRUE
+FORCE_DYN_DATA=TRUE
+DISABLE_DYN_DATA=TRUE
+DISABLE_SEND_WDST=TRUE
+
+; gestioni PING
+MAX_TRY_PING=3
+VETO_QUEUE_IN=4
+VETO_PING_SEC=4
+VETO_CHECKDIR_SEC=10
+MAX_ELAPSED_TIME_SEC=60
+
+;VETO_SEND_SNAPSHOT=3
+POWEROFF_TIMEOUT_SEC=60
+
+; conf parametri memoria READ/WRITE
+FTP_PARAM=FTP_SONATEST.json
+
+[BRANCH]
+NAME=master
+
+; Tags manuali
+[TAGS]
+Customer=SteamWare
+HostOS=WIN
+HostName=IOB-WIN-SIMULA
+HostAddr=10.74.82.76
\ No newline at end of file
diff --git a/IOB-WIN-FTP/DATA/CONF/FTP_SONATEST.json b/IOB-WIN-FTP/DATA/CONF/FTP_SONATEST.json
new file mode 100644
index 00000000..de2bdc0f
--- /dev/null
+++ b/IOB-WIN-FTP/DATA/CONF/FTP_SONATEST.json
@@ -0,0 +1,26 @@
+{
+ "ListTask": [
+ {
+ "ActionId": "FtpDownload",
+ "ServerAddr": "egw-tscale-04",
+ "ServerPort": 21,
+ "ConnUser": "testftpuser",
+ "ConnPasswd": "we4reFromB3rghem!",
+ "RawCert": "",
+ "SkipCert": true,
+ "ReExecVeto": 90,
+ "Note": "Sync periodico completo",
+ "StepsList": [
+ {
+ "Id": "01",
+ "Description": "Mirror Remote 2 Local Directory",
+ "Action": "mirrorDirR2L",
+ "ParamList": {
+ "RemoteDir": "ftpdata/syncfolder",
+ "LocalDir": "\\\\iis01\\W$\\Files"
+ }
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/IOB-WIN-FTP/DATA/CONF/IMI_SONATEST.ini b/IOB-WIN-FTP/DATA/CONF/IMI_SONATEST.ini
new file mode 100644
index 00000000..399dd54e
--- /dev/null
+++ b/IOB-WIN-FTP/DATA/CONF/IMI_SONATEST.ini
@@ -0,0 +1,79 @@
+;Configurazione IOB-WIN
+[IOB]
+;Macchina controllo ultrasuoni Sonatest x IMI Remosa
+CNCTYPE=FTP
+PING_MS_TIMEOUT=500
+
+[MACHINE]
+VENDOR=SONATEST
+MODEL=VEO
+
+[CNC]
+IP=172.28.30.208
+PORT=21
+PING_IP=172.28.30.208
+GETPRGNAME=false
+
+[SERVER]
+MPIP=http://192.168.0.110
+MPURL=/MP/IO
+CMDBASE=/IOB/input/
+CMDFLOG=/IOB/flog/
+CMDALIVE=/IOB
+CMDENABLED=/IOB/enabled/
+CMDADV1=?valore=
+CMDREBO=/sendReboot.aspx?idxMacchina=
+
+[MEMORY]
+ADDR_READ=DB9999.DBB0
+ADDR_WRITE=DB9999.DBB0
+SIZE_READ=0
+SIZE_WRITE=0
+
+
+[BLINK]
+;MAX_COUNTER_BLINK = 30
+MAX_COUNTER_BLINK = 30
+BLINK_FILT=0
+
+[OPTPAR]
+; imposto breve sennò non riesce a partire...
+WAIT_REC_MSEC = 1000
+; indica gestione folder ritorno dati ODL
+ODL_FOLDER = TRUE
+; gestione contapezzi
+PZCOUNT_MODE=NONE
+DISABLE_PZCOUNT=TRUE
+ENABLE_SEND_PZC_BLOCK=FALSE
+MIN_SEND_PZC_BLOCK=0
+MAX_SEND_PZC_BLOCK=100
+;errori verifica folder FTP MAX
+MAX_ERR_CHECK=10
+; gestione DynData
+ENABLE_DYN_DATA=TRUE
+FORCE_DYN_DATA=TRUE
+DISABLE_DYN_DATA=TRUE
+DISABLE_SEND_WDST=TRUE
+
+; gestioni PING
+MAX_TRY_PING=3
+VETO_QUEUE_IN=5
+VETO_PING_SEC=5
+VETO_CHECKDIR_SEC=10
+MAX_ELAPSED_TIME_SEC=60
+
+;VETO_SEND_SNAPSHOT=3
+POWEROFF_TIMEOUT_SEC=60
+
+; conf parametri memoria READ/WRITE
+FTP_PARAM=IMI_SONATEST.json
+
+[BRANCH]
+NAME=master
+
+; Tags manuali
+[TAGS]
+Customer=IMI-Remosa
+HostOS=WIN
+HostName=MAPO-SRV-60
+HostAddr=192.168.0.12
diff --git a/IOB-WIN-FTP/DATA/CONF/IMI_SONATEST.json b/IOB-WIN-FTP/DATA/CONF/IMI_SONATEST.json
new file mode 100644
index 00000000..c6ff3c6e
--- /dev/null
+++ b/IOB-WIN-FTP/DATA/CONF/IMI_SONATEST.json
@@ -0,0 +1,27 @@
+{
+ "ListTask": [
+ {
+ "ActionId": "FtpDownload",
+ "ServerAddr": "172.28.30.208",
+ "ServerPort": 21,
+ "ConnUser": "ftpuser",
+ "ConnPasswd": "SOnaTEst",
+ "RawCert": "",
+ "SkipCert": true,
+ "ReExecVeto": 90,
+ "Note": "Sync periodico completo",
+ "StepsList": [
+ {
+ "Id": "01",
+ "Description": "Mirror Remote 2 Local Directory",
+ "Action": "mirrorDirR2L",
+ "ParamList": {
+ "RemoteDir": "internal/MES",
+ "LocalDir": "\\\\308file\\shares\\QUAL\\Sonatest_Reports\\MES"
+ }
+ }
+
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/IOB-WIN-FTP/DATA/CONF/IOB.ini b/IOB-WIN-FTP/DATA/CONF/IOB.ini
deleted file mode 100644
index 9ac13668..00000000
--- a/IOB-WIN-FTP/DATA/CONF/IOB.ini
+++ /dev/null
@@ -1,50 +0,0 @@
-;Configurazione IOB-WIN
-[IOB]
-CNCTYPE=FANUC
-;IDXMACC=3001
-
-[CNC]
-; TEST TORNOS!
-;IP=192.168.1.80
-IP=172.16.199.10
-PORT=8193
-
-[SERVER]
-MPIP=http://10.74.82.219
-MPURL=/MP/IO
-CMDBASE=/IOB/input/
-CMDFLOG=/IOB/flog/
-CMDALIVE=/IOB
-CMDENABLED=/IOB/enabled/
-CMDADV1=?valore=
-CMDREBO=/sendReboot.aspx?idxMacchina=
-
-[MEMORY]
-BITRED=Y8.4
-BITYELLOW=Y8.5
-BITGREEN=Y8.6
-
-[BLINK]
-;MAX_COUNTER_BLINK = 30
-MAX_COUNTER_BLINK = 15
-;bit0 = 0
-;bit1 = 0
-;bit2 = 1
-;bit3 = 1
-;bit4 = 1
-;bit5 = 0
-;bit6 = 0
-;bit7 = 0
-BLINK_FILT=0
-;BLINK_FILT=28
-
-[OPTPAR]
-;PZCOUNT_MODE=STD|BIT
-PZCOUNT_MODE=BIT
-PZ_CAD_MADDR=1602
-PZ_REQ_MADDR=1603
-PZ_DONE_MADDR=1604
-PZ_GTOT_MADDR=1605
-
-[BRANCH]
-NAME=master
diff --git a/IOB-WIN-FTP/DATA/CONF/MAIN.ini b/IOB-WIN-FTP/DATA/CONF/MAIN.ini
index 43299be3..5335f1c9 100644
--- a/IOB-WIN-FTP/DATA/CONF/MAIN.ini
+++ b/IOB-WIN-FTP/DATA/CONF/MAIN.ini
@@ -17,45 +17,8 @@ CLI_INST=SteamWareSim
;--- TEST sul campo
; SIMULAZIONE verso server ufficio
;STARTLIST=SIMUL_01,SIMUL_02,SIMUL_03,SIMUL_04
-;STARTLIST=PIZ09
-;STARTLIST=VL25
-;STARTLIST=SIMUL_03
-;STARTLIST=GIACO_CEDAX_001
-;STARTLIST=GIACO_ICOEL_002
-;STARTLIST=GIACO_CENTERFRIGO
-;STARTLIST=GIACO_NWSE
-;STARTLIST=SIM_DP_01
-;STARTLIST=WPS
-;STARTLIST=FINASSI_HELPI_01
-;STARTLIST=FINASSI_OMP_01
-;STARTLIST=BAGLIETTO_CIMOLAI_01
-;STARTLIST=GIACO_SAIM_003
-;STARTLIST=PIZ09
-;STARTLIST=IMI_RIMOR_SAB_01
-;STARTLIST=IMI_RIMOR_SAB_02
-;STARTLIST=IMI_RIMOR_VER_01
-;STARTLIST=IMI_RIMOR_VER_02
-;STARTLIST=IMI_PAMA_392
-;STARTLIST=Tend_FIMAT_01
-;STARTLIST=PIZ10
-;STARTLIST=IMI_SOITAAB_Z2342_02
-;STARTLIST=IMI_GOMBA
-;STARTLIST=SIMUL_02
-;STARTLIST=SIM_DP_01
-;STARTLIST=FTP_SONATEST
-;STARTLIST=L020
-;STARTLIST=PING
-;STARTLIST=VL27
-
-;NB: mettere copy always ai file di conf x fare test...
-;STARTLIST=2014
-;STARTLIST=Tend_RAMA_10_47
-;STARTLIST=3024-PING
-;STARTLIST=2015
-;STARTLIST=3024
-;STARTLIST=SIMUL_01
-;STARTLIST=WPS
-STARTLIST=FTP-PING
+;STARTLIST=IMI_SONATEST
+STARTLIST=FTP_SONATEST
MAXCNC=10
\ No newline at end of file
diff --git a/IOB-WIN-FTP/DATA/CONF/PING.ini b/IOB-WIN-FTP/DATA/CONF/PING.ini
deleted file mode 100644
index 1a4c140e..00000000
--- a/IOB-WIN-FTP/DATA/CONF/PING.ini
+++ /dev/null
@@ -1,51 +0,0 @@
-;Configurazione IOB-WIN
-[IOB]
-CNCTYPE=PingWatchdog
-PING_MS_TIMEOUT=500
-;IOB_NAME=SIMUL_09
-IOB_NAME=SIMUL_01
-
-[MACHINE]
-VENDOR=STEAMWARE
-MODEL=WATCHDOG
-
-[CNC]
-IP=10.74.83.183
-;IP=10.74.82.253
-PORT=0000
-
-[SERVER]
-MPIP=http://10.74.82.218
-MPURL=/MP/IO
-CMDBASE=/IOB/input/
-CMDFLOG=/IOB/flog/
-CMDALIVE=/IOB
-CMDENABLED=/IOB/enabled/
-CMDADV1=?valore=
-CMDREBO=/sendReboot.aspx?idxMacchina=
-CMD_ODL_STARTED=/IOB/getCurrOdlStart/
-CMD_FORCLE_SPLIT_ODL=/IOB/forceSplitOdlFull/
-CMD_IDLE_TIME=/IOB/getIdlePeriod/
-
-[MEMORY]
-
-[BLINK]
-MAX_COUNTER_BLINK = 15
-BLINK_FILT=0
-
-[OPTPAR]
-VETO_QUEUE_IN=15
-AUTO_CHANGE_ODL=false
-POWEROFF_TIMEOUT_SEC=60
-DISABLE_PZCOUNT=TRUE
-;; gestioni PING
-;MAX_TRY_PING=3
-;VETO_QUEUE_IN=4
-;VETO_PING_SEC=4
-;VETO_CHECKDIR_SEC=10
-;MAX_ELAPSED_TIME_SEC=60
-;VETO_SEND_SNAPSHOT=3
-
-
-[BRANCH]
-NAME=master
\ No newline at end of file
diff --git a/IOB-WIN-FTP/ILLink/ILLink.Descriptors.LibraryBuild.xml b/IOB-WIN-FTP/ILLink/ILLink.Descriptors.LibraryBuild.xml
new file mode 100644
index 00000000..a42d7f0e
--- /dev/null
+++ b/IOB-WIN-FTP/ILLink/ILLink.Descriptors.LibraryBuild.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/IOB-WIN-FTP/IOB-WIN-FTP.csproj b/IOB-WIN-FTP/IOB-WIN-FTP.csproj
index 85cebd43..14cfca70 100644
--- a/IOB-WIN-FTP/IOB-WIN-FTP.csproj
+++ b/IOB-WIN-FTP/IOB-WIN-FTP.csproj
@@ -12,6 +12,8 @@
512
true
true
+
+
AnyCPU
@@ -32,9 +34,73 @@
prompt
4
+
+ true
+ bin\Remote_DEBUG\
+ DEBUG;TRACE
+ full
+ x86
+ 7.3
+ prompt
+
+
+ ..\packages\EgwProxy.Ftp.3.6.2410.816\lib\EgwProxy.Ftp.dll
+
+
+ ..\packages\FluentFTP.51.1.0\lib\net462\FluentFTP.dll
+
+
+ ..\packages\MapoSDK.6.14.2411.518\lib\MapoSDK.dll
+
+
+ ..\packages\Microsoft.Bcl.AsyncInterfaces.9.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll
+
+
+ ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.9.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll
+
+
+ ..\packages\Microsoft.Extensions.Logging.Abstractions.9.0.0\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll
+
+
+ ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll
+
+
+ ..\packages\StackExchange.Redis.2.8.24\lib\net461\StackExchange.Redis.dll
+
+
+ ..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll
+
+
+ ..\packages\System.Diagnostics.DiagnosticSource.9.0.0\lib\net462\System.Diagnostics.DiagnosticSource.dll
+
+
+ ..\packages\System.Diagnostics.PerformanceCounter.9.0.0\lib\net462\System.Diagnostics.PerformanceCounter.dll
+
+
+ ..\packages\System.IO.Pipelines.9.0.0\lib\net462\System.IO.Pipelines.dll
+
+
+ ..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll
+
+
+
+ ..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll
+
+
+ ..\packages\System.Runtime.CompilerServices.Unsafe.6.1.0\lib\net462\System.Runtime.CompilerServices.Unsafe.dll
+
+
+ ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll
+
+
+ ..\packages\System.Threading.Channels.9.0.0\lib\net462\System.Threading.Channels.dll
+
+
+ ..\packages\System.Threading.Tasks.Extensions.4.6.0\lib\net462\System.Threading.Tasks.Extensions.dll
+
@@ -52,12 +118,14 @@
Form
+
Form
+
Always
@@ -84,15 +152,17 @@
Always
-
+
Always
+
+ Always
+
+
+
Always
-
- Always
-
Always
@@ -139,6 +209,7 @@
Designer
+ true
PreserveNewest
@@ -169,4 +240,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
\ No newline at end of file
diff --git a/IOB-WIN-FTP/Iob/Ftp.cs b/IOB-WIN-FTP/Iob/Ftp.cs
new file mode 100644
index 00000000..b54c0618
--- /dev/null
+++ b/IOB-WIN-FTP/Iob/Ftp.cs
@@ -0,0 +1,1010 @@
+using EgwProxy.Ftp;
+using IOB_UT_NEXT;
+using MapoSDK;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Net.NetworkInformation;
+
+namespace IOB_WIN_FTP.Iob
+{
+ ///
+ /// Classe gestione sync via FTP
+ ///
+ public class Ftp : Iob.GenericNext
+ {
+ #region Public Constructors
+
+ ///
+ /// Estende l'init della classe base, impiegando il pacchetto EgwCoreLib.Ftp
+ /// - gestione dei task da svolgere da configurazione json specifica
+ /// - specializzazione da conf e non da codice
+ ///
+ ///
+ ///
+ public Ftp(AdapterFormNext caller, IobConfiguration IOBConf) : base(caller, IOBConf)
+ {
+ lgInfo("Init IobFtp Client");
+ // imposto
+ B_input = 0;
+ // init datetime counters
+ DateTime adesso = DateTime.Now;
+ lastPzCountSend = adesso;
+ lastWarnODL = adesso;
+ vetoCheckStatus = adesso;
+ // 2023.09.05 imposto anche primo ping e check disconnected...
+ lastPING = adesso;
+ lastDisconnCheck = adesso;
+ var VETO_PING_SEC = getOptPar("VETO_PING_SEC");
+ if (!string.IsNullOrEmpty(VETO_PING_SEC))
+ {
+ int.TryParse(VETO_PING_SEC, out vetoPingSec);
+ }
+ var VETO_CHECKDIR_SEC = getOptPar("VETO_CHECKDIR_SEC");
+ if (!string.IsNullOrEmpty(VETO_CHECKDIR_SEC))
+ {
+ int.TryParse(VETO_CHECKDIR_SEC, out vetoCheckDirSec);
+ }
+ var POWEROFF_TIMEOUT_SEC = getOptPar("POWEROFF_TIMEOUT_SEC");
+ if (!string.IsNullOrEmpty(POWEROFF_TIMEOUT_SEC))
+ {
+ int.TryParse(POWEROFF_TIMEOUT_SEC, out PoweroffTimeoutSec);
+ }
+ // fix coda ping
+ PingQueue = new DataQueue("000", "PingQueue", false);
+ // carico conf specifica steps FTP
+ string ftpConfFile = getOptPar("FTP_PARAM");
+ if (!string.IsNullOrEmpty(ftpConfFile))
+ {
+ loadFtpConfFile(ftpConfFile);
+ // mi calcolo ed imposto la ftpClientMan + Remote BaseDir...
+ string actKey = "RemoteDir";
+ if (currFtpTaskList != null && currFtpTaskList.ListTask.Count > 0)
+ {
+ // prendo i task
+ foreach (var fTask in currFtpTaskList.ListTask)
+ {
+ if (string.IsNullOrEmpty(RemoteBaseDir))
+ {
+ foreach (var fAct in fTask.StepsList)
+ {
+ // cerco nei parametri...
+ if (fAct.ParamList.ContainsKey(actKey))
+ {
+ RemoteBaseDir = fAct.ParamList[actKey];
+ break;
+ }
+ }
+ }
+ if (!ftpClientMan.IsConfigured)
+ {
+ // setup ftpClientMan!
+ ftpClientMan = new Manager(fTask.ServerAddr, fTask.ConnUser, fTask.ConnPasswd, fTask.RawCert, fTask.SkipCert);
+ }
+ }
+ }
+ }
+ forceMemMap();
+ // invio conf macchina all'inizio
+ SendMachineConf();
+ }
+
+ #endregion Public Constructors
+
+ #region Public Methods
+
+ ///
+ /// Processo i task richiesti e li elimino dalla coda
+ ///
+ ///
+ public override Dictionary executeTasks(Dictionary task2exe)
+ {
+ /*---------------------------------------------------------------------------
+ * va creata una folder x ogni ODL (una volta LANCIATO da tablet) APERTO
+ * - nella folder scriviamo un file con articolo, qta, commessa
+ * - la folder sarà usata x salvare OGNI file necessario e di rilevazione
+ * - per farlo si creeano degli ActionStep specifici e vengono poi richiamati...
+ *---------------------------------------------------------------------------*/
+
+ // Verificare il protocollo: dovrebbe togliere SOLO i task eseguiti...
+ Dictionary taskDone = new Dictionary();
+ ActionConfig currAct = new ActionConfig();
+ var currActParam = new Dictionary();
+ string actKey = "RemoteDir";
+ string newDir = "";
+ bool taskOk = false;
+ string taskVal = "";
+ string fNameOdl = "ODL_ATTIVO.txt";
+ string basePath = System.Windows.Forms.Application.StartupPath;
+ string remFile = "";
+ string fileContent = "";
+ string locFile = "";
+ // cerco task specifici: se ho startSetup --> imposto bit DBB701.DBB0.4
+ foreach (var item in task2exe)
+ {
+ taskOk = false;
+ taskVal = "";
+ // converto richiesta in enum...
+ taskType tName = taskType.nihil;
+ Enum.TryParse(item.Key, out tName);
+ // controllo sulla KEY...
+ switch (tName)
+ {
+ case taskType.setArt:
+ case taskType.setPzComm:
+ // L'articolo ed il numPz li salva nei dati di produzione... SE disponibili
+ // li indicherà nel file ODL ATTIVA...
+ upsertKey(item.Key, item.Value);
+ // salvo nei taskVal il valore acquisito...
+ taskVal = $"Saved {item.Key} = {item.Value} on ProdData";
+ break;
+
+ case taskType.setComm:
+ /*------------------------------------------------------------------
+ * La commessa è la cartella DI BASE per poter poi procedere con acquisizione dati...
+ * - step 1: check folder
+ * - step 2: creazione folder
+ * - step 3: salva file ODL_attiva
+ * - step 4: salva parametro dell'ODL corrente
+ ------------------------------------------------------------------*/
+ // compongo remDir dai 2 parametri...
+ actKey = "RemoteDir";
+ newDir = $"{RemoteBaseDir}/{item.Value}";
+ currActParam.Add(actKey, newDir);
+ currAct = new ActionConfig()
+ {
+ Id = "01",
+ Description = "Verifica esistenza directory",
+ Action = ActType.CheckDir,
+ ParamList = currActParam
+ };
+ //eseguo step...
+ bool dirOk = doStep(currAct);
+ // se la cartella mancasse
+ if (!dirOk)
+ {
+ // nuovo act x crearla!
+ currAct = new ActionConfig()
+ {
+ Id = "02",
+ Description = "Creazione directory",
+ Action = ActType.CreateDir,
+ ParamList = currActParam
+ };
+ //eseguo step...
+ dirOk = doStep(currAct);
+ if (dirOk)
+ {
+ taskVal = $"DIR Created: {item.Key} --> {item.Value}";
+ }
+ }
+ else
+ {
+ taskVal = $"DIR Already Exists: {item.Key} --> {item.Value}";
+ }
+ // ora creo il file interno...
+ remFile = $"{newDir}/{fNameOdl}";
+ // cerco se disponibili info in prodData x art/pezzi
+ string setArt = getCurrProdData("setArt", "ND");
+ string setPzComm = getCurrProdData("setPzComm", "?");
+ fileContent = $"NEW ODL activated | {item.Value} | ART: {setArt} x {setPzComm} pz | {DateTime.Now}";
+ locFile = Path.Combine(basePath, "temp", fNameOdl);
+ taskOk = SendOdlActFile(locFile, remFile, fileContent);
+ if (taskOk)
+ {
+ taskVal += $"{Environment.NewLine}File uploaded | locFile: {locFile} | remFile: {remFile}";
+ }
+ else
+ {
+ lgError($"Error in startSetup | fileUpload | locFile: {locFile} | remFile: {remFile}");
+ }
+ // salvo in currProd..
+ upsertKey(item.Key, item.Value);
+ break;
+
+ case taskType.startSetup:
+ case taskType.stopSetup:
+ //verifico odl x prima cosa...
+ pzCntReload(true);
+ // faccio pulizia preliminare della commessa corrente...
+ bool cleanDone = RemPlaceholder(RemoteBaseDir, fNameOdl);
+ if (cleanDone)
+ {
+ lgInfo($"Cleaned {fNameOdl} during startSetup | remDir: {RemoteBaseDir}");
+ }
+ // verifico di avere già un ODL corrente...
+ if (currIdxODL == 0)
+ {
+ lgTrace($"Manca ODL corrente: non procedo con impostazione start/stop setup");
+ }
+ else
+ {
+ string odlFolder = $"ODL{currIdxODL:00000000}";
+ remFile = $"{RemoteBaseDir}/{odlFolder}/{fNameOdl}";
+ fileContent = item.Value;
+ // scrivo file ultima richiesta setup
+ locFile = Path.Combine(basePath, "temp", fNameOdl);
+ taskOk = SendOdlActFile(locFile, remFile, fileContent);
+ if (taskOk)
+ {
+ taskVal = $"File uploaded: {item.Key} --> {item.Value} | locFile: {locFile} | remFile: {remFile}";
+ }
+ else
+ {
+ lgError($"Error in startSetup | fileUpload | locFile: {locFile} | remFile: {remFile}");
+ }
+ }
+
+ break;
+
+ case taskType.endProd:
+ bool okRemove = RemPlaceholder(RemoteBaseDir, fNameOdl);
+ if (okRemove)
+ {
+ taskVal = $"Cleaned CurrOdlFile: {item.Key} --> {item.Value} | remDir: {RemoteBaseDir} | fName: {fNameOdl}";
+ }
+ else
+ {
+ lgError($"Error in CurrOdlFile | remDir: {RemoteBaseDir} | fName: {fNameOdl}");
+ }
+ break;
+
+ default:
+ taskVal = $"taskReq: {tName} | key: {item.Key} | val: {item.Value} | SKIPPED | NO EXEC";
+ lgInfo($"Chiamata senza processing: taskOk: {taskOk} | taskVal: {taskVal}");
+ break;
+ }
+ // aggiungo task SE svolto!
+ if (!string.IsNullOrEmpty(taskVal))
+ {
+ taskDone.Add(item.Key, taskVal);
+ }
+ }
+ return taskDone;
+ }
+
+ ///
+ /// Effettua processing CUSTOM x FTP:
+ /// - prende ogni conf specifica
+ /// - esegue step
+ /// - registra eventuali DynData da salvare
+ ///
+ public override void processCustomTaskLF()
+ {
+ lgInfo($"Richiesto processCustomTaskLF");
+ // verifico di avere compiti da svolgere...
+ if (currFtpTaskList != null && currFtpTaskList.ListTask != null && currFtpTaskList.ListTask.Count > 0)
+ {
+ foreach (var srvFtp in currFtpTaskList.ListTask)
+ {
+ // verifico eventuale veto all'esecuzione...
+ if (ActionEnabled(srvFtp))
+ {
+ // imposto nuovo veto...
+ ActionResetVeto(srvFtp);
+ // ora setup server FTP x item...
+ ftpClientMan = new Manager(srvFtp.ServerAddr, srvFtp.ConnUser, srvFtp.ConnPasswd, srvFtp.RawCert, srvFtp.SkipCert);
+ // test server ok...
+ if (ftpClientMan.ServerOk())
+ {
+ int stepDone = 0;
+ string srvType = ftpClientMan.ServerType();
+ lgTrace($"Connesso a server {srvType} | {srvFtp.ServerAddr} | inizio processing {srvFtp.StepsList.Count} steps");
+ // ciclo tra i vari steps!
+ foreach (var step in srvFtp.StepsList)
+ {
+ bool fatto = doStep(step);
+ stepDone += fatto ? 1 : 0;
+ }
+ lgInfo($"Completata esecuzione steps FTP | {srvFtp.ActionId} | {stepDone}/{srvFtp.StepsList.Count} Done/Req");
+ }
+ else
+ {
+ // FixMe ToDo verificare se necessario...
+ //connectionOk = false;
+ //tryDisconnect();
+ lgError($"Impossibile connettersi al server {srvFtp.ServerAddr}");
+ }
+ }
+ else
+ {
+ lgTrace($"Saltata esecuzione {srvFtp.ActionId} | veto attivo");
+ }
+ }
+ }
+ lastReadPLC = DateTime.Now;
+ }
+
+ ///
+ /// Effettua lettura semafori principale Parametri da
+ /// aggiornare x display in form
+ ///
+ public override void readSemafori(ref newDisplayData currDispData)
+ {
+ DateTime adesso = DateTime.Now;
+ // procedo solo se ftp è configurato (altrimenti inutile controllare...)ù
+ if (ftpClientMan.IsConfigured)
+ {
+ // salto se fosse attivo il veto ping...
+ if (lastPING.AddSeconds(vetoPingSec) < adesso)
+ {
+ // lo stato è come ping machine, x ora puntato a IP unico (WiFi?)
+ byte[] MemBlock = new byte[2];
+ try
+ {
+ currDispData.semIn = Semaforo.SV;
+ // in primis salvo data ping comunque...
+ lastPING = adesso;
+
+ // salvo esito ping
+ bool pingOK = testPingMachine == IPStatus.Success;
+ addTest(pingOK);
+ bool ftpOk = ftpClientMan.ServerOk();
+ // se passa il check ping + folder faccio il resto...
+ if (pingStatusOk() && ftpOk)
+ {
+ // salto se fosse attivo il veto controllo folder...
+ if (lastCheckDir.AddSeconds(vetoCheckDirSec) < adesso)
+ {
+ lastCheckDir = adesso;
+ // verifico SE HO una folder da ODL in currProdData e se è disponibile...
+ string reqFolder = getCurrProdData("setComm", "");
+ if (!string.IsNullOrEmpty(reqFolder))
+ {
+ // verifico se ci sia...
+ ActionConfig currAct = new ActionConfig();
+ var currActParam = new Dictionary();
+ // compongo remDir dai 2 parametri...
+ currActParam.Add("RemoteDir", $"{RemoteBaseDir}/{reqFolder}");
+ currAct = new ActionConfig()
+ {
+ Id = "01",
+ Description = "Verifica esistenza directory",
+ Action = ActType.CheckDir,
+ ParamList = currActParam
+ };
+ //eseguo step...
+ bool dirOk = doStep(currAct);
+ if (dirOk)
+ {
+ numErroriCheck = numErroriCheck > 0 ? numErroriCheck-- : 0;
+ }
+ else
+ {
+ lgInfo($"Rilevata mancanza folder ODL: inizio ripristino tramite task setComm");
+ numErroriCheck++;
+ // altrimenti eseguo task2exe x crearla...
+ Dictionary task2ExeSetOdl = new Dictionary();
+ task2ExeSetOdl.Add($"setComm", reqFolder);
+ var res = executeTasks(task2ExeSetOdl);
+ }
+ }
+ }
+
+ // se supero soglia errori lettura --> disconnetto e resetto
+ if (numErroriCheck > maxErroriCheck)
+ {
+ lgError($"numErroriCheck: {numErroriCheck} --> disconnessione adapter con tryDisconnect");
+
+ numErroriCheck = 0;
+ connectionOk = false;
+ tryDisconnect();
+ }
+ else
+ {
+ connectionOk = true;
+ }
+
+ lastReadPLC = adesso;
+ lastWatchDog = adesso;
+ }
+ else
+ {
+ connectionOk = false;
+ }
+
+ if (connectionOk)
+ {
+ B_input = 3;
+ // aggiungo NON emergenza...
+ B_input += (1 << 7);
+ }
+ else
+ {
+ B_input = 0;
+ }
+ }
+ catch
+ {
+ currDispData.semIn = Semaforo.SR;
+ }
+ }
+ }
+ }
+
+ public override void startAdapter(bool resetQueue)
+ {
+ base.startAdapter(resetQueue);
+ // 2023.09.05 imposto anche primo ping e check disconnected...
+ DateTime adesso = DateTime.Now;
+ lastWatchDog = adesso;
+ //lastPING = adesso;
+ lastReadPLC = adesso;
+ lastDisconnCheck = adesso;
+ // faccio un primo check POST ritardo
+ tryConnect();
+ }
+
+ ///
+ /// Override connessione
+ ///
+ public override void tryConnect()
+ {
+ bool doLog = (verboseLog || periodicLog);
+ lgDebug($"FTP: tryConnect step 01 | connectionOk: {connectionOk}");
+ if (!connectionOk)
+ {
+ //// resetto coda...
+ //PingQueue = new DataQueue("000", "PingQueue", false);
+ // controllo che il ping sia stato tentato almeno pingTestSec fa...
+ if (DateTime.Now.Subtract(lastPING).TotalSeconds > vetoPingSec)
+ {
+ if (doLog)
+ {
+ lgInfo("FTP: ConnKO - tryConnect");
+ }
+ lgDebug("FTP: tryConnect step 04");
+
+ lgDebug("FTP: Reset PingQueue");
+
+ bool pingOK = testPingMachine == IPStatus.Success;
+ addTest(pingOK);
+
+ // se passa il ping faccio il resto...
+ if (pingStatusOk())
+ {
+ // in primis salvo data ping...
+ lastPING = DateTime.Now;
+ connectionOk = true;
+ queueInEnabCurr = true;
+ lgInfo("FTP - ping OK");
+ }
+ else
+ {
+ // loggo no risposta ping ...
+ lgError("FTP - ping KO");
+ }
+ }
+ }
+ }
+
+ ///
+ /// Override disconnessione
+ ///
+ public override void tryDisconnect()
+ {
+ lgInfo("Richiesta disconnessione adapter FTP!");
+ connectionOk = false;
+ queueInEnabCurr = false;
+ }
+
+ #endregion Public Methods
+
+ #region Protected Methods
+
+ ///
+ /// Imposta la memoria PLC in modo forzato (es x oggetti gestiti da FTP come setComm)
+ ///
+ protected override void forceMemMap()
+ {
+ // simulo setup mappa memoria in scrittura...
+ memMap = new plcMemMapExt();
+ // area READ
+ Dictionary ftpMemRead = new Dictionary();
+ ftpMemRead.Add("FtpSync", new dataConfTSVC()
+ {
+ description = "Last FTP sync",
+ name = "FtpSync",
+ tipoMem = plcDataType.String,
+ displOrdinal = 10
+ });
+ memMap.mMapRead = ftpMemRead;
+ // area WRITE
+ Dictionary ftpMemWrite = new Dictionary();
+ ftpMemWrite.Add("setComm", new dataConf()
+ {
+ description = "Commessa",
+ name = "setComm",
+ tipoMem = plcDataType.String,
+ displOrdinal = 1
+ });
+ ftpMemWrite.Add("setArt", new dataConf()
+ {
+ description = "Articolo",
+ name = "setArt",
+ tipoMem = plcDataType.String,
+ displOrdinal = 2
+ });
+ ftpMemWrite.Add("setPzComm", new dataConf()
+ {
+ description = "Qta Richiesta",
+ name = "setPzComm",
+ tipoMem = plcDataType.Int,
+ displOrdinal = 3
+ });
+ memMap.mMapWrite = ftpMemWrite;
+ // eseguo setup + invio info configurazione...
+ setupMemMap();
+ }
+
+ #endregion Protected Methods
+
+ #region Private Fields
+
+ private static Stopwatch sw = new Stopwatch();
+
+ ///
+ /// Ultima verifica presenza dir corrente
+ ///
+ private DateTime lastCheckDir = DateTime.Now.AddHours(-1);
+
+ ///
+ /// Dimensione coda di ping x valutazione
+ ///
+ private int maxQueuePing = 11;
+
+ ///
+ /// Coda degli esiti di ping x calcolo stato macchina
+ ///
+ private DataQueue PingQueue = new DataQueue("000", "PingQueue", false);
+
+ private int PoweroffTimeoutSec = 100;
+
+ ///
+ /// Dizionario dei divieti di esecuzione x i vari step
+ ///
+ private Dictionary StepsVeto = new Dictionary();
+
+ ///
+ /// Periodo veto controllo directory FTP corrente
+ ///
+ private int vetoCheckDirSec = 5;
+
+ ///
+ /// Veto controllo status x log...
+ ///
+ private DateTime vetoCheckStatus = DateTime.Now;
+
+ #endregion Private Fields
+
+ #region Private Properties
+
+ ///
+ /// Oggetto configurazione gestione FTP
+ ///
+ private FtpTaskList currFtpTaskList { get; set; } = new FtpTaskList();
+
+ ///
+ /// CLient connessioni FTP
+ ///
+ private Manager ftpClientMan { get; set; } = new Manager("", "", "", "", false);
+
+ ///
+ /// Directpry remota di abse
+ ///
+ private string RemoteBaseDir { get; set; } = "";
+
+ #endregion Private Properties
+
+ #region Private Methods
+
+ ///
+ /// Verifica se l'azione sia permessa o in stato veto a tempo
+ ///
+ ///
+ ///
+ private bool ActionEnabled(FtpActConf currAct)
+ {
+ bool enabled = true;
+ // se veto presente
+ if (StepsVeto.ContainsKey(currAct.ActionId))
+ {
+ // controllo scadenza
+ enabled = StepsVeto[currAct.ActionId] < DateTime.Now;
+ }
+ return enabled;
+ }
+
+ ///
+ /// Imposta veto azione corrente
+ ///
+ ///
+ ///
+ private bool ActionResetVeto(FtpActConf currAct)
+ {
+ bool fatto = false;
+ if (StepsVeto.ContainsKey(currAct.ActionId))
+ {
+ StepsVeto[currAct.ActionId] = DateTime.Now.AddSeconds(currAct.ReExecVeto);
+ }
+ else
+ {
+ StepsVeto.Add(currAct.ActionId, DateTime.Now.AddSeconds(currAct.ReExecVeto));
+ }
+ return fatto;
+ }
+
+ private void addTest(bool pingOk)
+ {
+ int score = pingOk ? 1 : 0;
+ // controllo: se era spenta e risulta ping ok --> reset coda!
+ if (B_input == 0 && pingOk)
+ {
+ B_input = 1;
+ PingQueue = new DataQueue("000", "PingQueue", false);
+ lgTrace($"PingQueue resetted on addTest");
+ }
+ PingQueue.Enqueue($"{score}");
+ while (PingQueue.Count > maxQueuePing)
+ {
+ string res = "";
+ PingQueue.TryDequeue(out res);
+ }
+ }
+
+ ///
+ /// Esegue l'azione configurata
+ ///
+ ///
+ ///
+ ///
+ private bool doStep(ActionConfig step)
+ {
+ bool fatto = false;
+ string remoteVal = "";
+ string localVal = "";
+ string sVal = "";
+ string actKey = "";
+ string actVal = "";
+ // faccio switch in base al tipo di azione da eseguire...
+ switch (step.Action)
+ {
+ case ActType.CheckDir:
+ if (step.ParamList != null && step.ParamList.Count > 0)
+ {
+ sw.Restart();
+ remoteVal = step.ParamList["RemoteDir"] ?? "";
+ //verifico dir remota
+ fatto = ftpClientMan.DirExists(remoteVal);
+ }
+ else
+ {
+ lgError("Error: missing parameters!");
+ }
+ sw.Stop();
+ if (fatto)
+ {
+ lgInfo($"Check RemDir: {remoteVal} | {sw.ElapsedMilliseconds:N1} ms");
+ }
+ break;
+
+ case ActType.CheckFile:
+ break;
+
+ case ActType.CreateDir:
+ if (step.ParamList != null && step.ParamList.Count > 0)
+ {
+ sw.Restart();
+ remoteVal = step.ParamList["RemoteDir"] ?? "";
+ //verifico dir remota
+ bool dirExist = ftpClientMan.DirExists(remoteVal);
+ if (dirExist)
+ {
+ lgTrace("Error: Folder already exists!");
+ }
+ else
+ {
+ fatto = ftpClientMan.CreateDir(remoteVal);
+ }
+ }
+ else
+ {
+ lgError("Error: missing parameters!");
+ }
+ sw.Stop();
+ if (fatto)
+ {
+ lgInfo($"Directory {remoteVal} created!| {sw.ElapsedMilliseconds:N1} ms");
+ }
+ break;
+
+ case ActType.DelDir:
+ break;
+
+ case ActType.DelFile:
+ break;
+
+ case ActType.DownloadDir:
+
+ break;
+
+ case ActType.DownloadFile:
+ break;
+
+ case ActType.GenRandomDir:
+ break;
+
+ case ActType.ListContent:
+ break;
+
+ case ActType.MirrorDirL2R:
+ break;
+
+ case ActType.MirrorDirR2L:
+ // eseguo mirroring directory
+ actKey = "FtpSync";
+ actVal = "SRC --> DEST | Size";
+ if (step.ParamList != null && step.ParamList.Count > 1)
+ {
+ sw.Restart();
+ remoteVal = step.ParamList["RemoteDir"] ?? "";
+ localVal = step.ParamList["LocalDir"] ?? "";
+ // verifico esistenza dir locale...
+ if (!Directory.Exists(localVal))
+ {
+ Directory.CreateDirectory(localVal);
+ }
+ //verifico dir remota
+ var preTest = ftpClientMan.DirExists(remoteVal);
+ if (preTest)
+ {
+ // chiamo metodo MIRROR x calcolare esattamente se ci siano stati
+ // download di sync...
+ var mirResult = ftpClientMan.MirrorRemoteDir(localVal, remoteVal, FluentFTP.FtpFolderSyncMode.Mirror);
+ // ciclo cercando eventuali info da emttere in DynData...
+ foreach (var result in mirResult)
+ {
+ // processo solo se size > 0...
+ if (result.Size > 0 && result.IsDownload && result.IsSuccess && !result.IsSkipped)
+ {
+ string objSize = MeasureUtils.SizeSuffix(result.Size, 3);
+ actVal = $"Rem2Loc | {result.Name} | {objSize} | {result.RemotePath}";
+ sVal = $"{actKey} | {actVal}";
+ accodaFLog(sVal, qEncodeFLog(actKey, actVal));
+ }
+ else
+ {
+ lgTrace($"Skipped sync | {actVal}");
+ }
+ }
+ // risultato sintetico come successi...
+ fatto = mirResult != null && mirResult.Where(x => !x.IsSuccess).Count() == 0;
+
+ if (!fatto)
+ {
+ lgError($"Error: {remoteVal} NOT mirrored!");
+ }
+ }
+ else
+ {
+ lgError($"Dir remota non trovata! RemDir: {remoteVal}");
+ }
+ }
+ else
+ {
+ lgError("Error: missing parameters!");
+ }
+ sw.Stop();
+ if (fatto)
+ {
+ lgInfo($"Mirror Rem2Loc | RemDir: {remoteVal} | {sw.ElapsedMilliseconds:N1} ms");
+ }
+
+ break;
+
+ case ActType.PingServer:
+ break;
+
+ case ActType.RemoveFileByName:
+ string fName2Del = "";
+ int numRem = 0;
+ if (step.ParamList != null && step.ParamList.Count > 1)
+ {
+ sw.Restart();
+ remoteVal = step.ParamList["RemoteDir"] ?? "";
+ fName2Del = step.ParamList["FileName2Del"] ?? "";
+ //verifico dir remota
+ fatto = ftpClientMan.DirExists(remoteVal);
+ if (fatto)
+ {
+ // recupero elenco di TUTTI i file presenti
+ List resList = ftpClientMan.GetRemoteList(remoteVal, true);
+ List list2del = new List();
+ // cerco tutti i file che indicano ODL attivo e li elimino
+ foreach (var flItem in resList)
+ {
+ if (flItem.Type == FluentFTP.FtpObjectType.File && flItem.Name.EndsWith(fName2Del))
+ {
+ list2del.Add(flItem);
+ }
+ }
+ // elimino quelli trovati
+ if (list2del.Count > 0)
+ {
+ var fList = list2del.Select(x => x.FullName).ToList();
+ numRem = ftpClientMan.DeleteFileList(fList);
+ }
+ }
+ }
+ else
+ {
+ lgError("Error: missing parameters!");
+ }
+ sw.Stop();
+ if (fatto)
+ {
+ lgInfo($"RemoveFileByName | path: {remoteVal} | name: {fName2Del} | # del: {numRem} | {sw.ElapsedMilliseconds:N1} ms");
+ }
+
+ break;
+
+ case ActType.UploadDir:
+ break;
+
+ case ActType.UploadFile:
+ if (step.ParamList != null && step.ParamList.Count > 1)
+ {
+ sw.Restart();
+ localVal = step.ParamList["LocalFile"] ?? "";
+ remoteVal = step.ParamList["RemoteFile"] ?? "";
+
+ //verifico dir remota
+ string remoteDir = remoteVal.Substring(0, remoteVal.LastIndexOf("/"));
+ bool dirExist = ftpClientMan.DirExists(remoteDir);
+ if (!dirExist)
+ {
+ fatto = ftpClientMan.CreateDir(remoteDir);
+ }
+
+ fatto = ftpClientMan.SendFile(localVal, remoteVal);
+ if (!fatto)
+ {
+ lgError($"Error: {localVal} NOT uploaded!");
+ }
+ }
+ else
+ {
+ lgError("Error: missing parameters!");
+ }
+ sw.Stop();
+ if (fatto)
+ {
+ lgInfo($"Upload File: {remoteVal} | {sw.ElapsedMilliseconds:N1} ms");
+ }
+ break;
+
+ default:
+ break;
+ }
+ return fatto;
+ }
+
+ ///
+ /// Effettuo lettura file di conf
+ ///
+ ///
+ private void loadFtpConfFile(string fileName)
+ {
+ string jsonFullPath = Path.Combine(System.Windows.Forms.Application.StartupPath, "DATA", "CONF", fileName);
+ lgInfo($"Apertura file {jsonFullPath}");
+ using (StreamReader reader = new StreamReader(jsonFullPath))
+ {
+ string jsonData = reader.ReadToEnd().Replace("\n", "").Replace("\r", "");
+ if (!string.IsNullOrEmpty(jsonData))
+ {
+ lgDebug($"File json composto da {jsonData.Length} caratteri");
+ try
+ {
+ currFtpTaskList = JsonConvert.DeserializeObject(jsonData);
+ lgDebug($"Decodifica aree FtpTaskList: trovati {currFtpTaskList.ListTask.Count} gruppi di task FTP");
+ }
+ catch (Exception exc)
+ {
+ lgError($"Eccezione in decodifica conf json FTP:{Environment.NewLine}{exc}");
+ }
+ }
+ else
+ {
+ lgError("Errore in loadFtpConfFile: file json vuoto!");
+ }
+ }
+ }
+
+ ///
+ /// Calcola status ping:
+ /// - se ha ‹ 50% coda richiesta --› true
+ /// - se ha › 50% coda richiesta --› true se è maggior parte a 1 (true)
+ ///
+ ///
+ private bool pingStatusOk()
+ {
+ bool answ = false;
+ int numVal = PingQueue.Count;
+ if (numVal > maxQueuePing / 2)
+ {
+ var listaValori = PingQueue.ToList();
+ int numOk = listaValori.Where(x => x == "1").Count();
+ int numKo = numVal - numOk;
+ answ = numOk >= numKo;
+ lgTrace($"PING ok per: {numOk} > {numKo}");
+ }
+ else
+ {
+ lgTrace($"PING check: {answ} per mancanza dati minimi test");
+ }
+ return answ;
+ }
+
+ ///
+ /// Rimuove eventuali file placeholder di ODL corrente preesistenti
+ ///
+ ///
+ ///
+ private bool RemPlaceholder(string remDir, string fNameOdl)
+ {
+ bool fatto = false;
+ try
+ {
+ Dictionary currActParam = new Dictionary();
+ currActParam.Add("RemoteDir", remDir);
+ currActParam.Add("FileName2Del", fNameOdl);
+ ActionConfig currAct = new ActionConfig()
+ {
+ Id = "01",
+ Description = "Clean Curr ODL Files",
+ Action = ActType.RemoveFileByName,
+ ParamList = currActParam
+ };
+ // eseguo step...
+ fatto = doStep(currAct);
+ }
+ catch (Exception exc)
+ {
+ lgError($"Eccezione in RemPlaceholder{Environment.NewLine}{exc}");
+ }
+ return fatto;
+ }
+
+ ///
+ /// Invia il file dell'ODL attivo
+ ///
+ ///
+ ///
+ ///
+ private bool SendOdlActFile(string locFile, string remFile, string fileContent)
+ {
+ bool taskOk = false;
+ Dictionary currActParam = new Dictionary();
+ // creo file locale
+ File.WriteAllText(locFile, fileContent);
+ // invio file x ODL attivo
+ currActParam.Add("LocalFile", locFile);
+ currActParam.Add("RemoteFile", remFile);
+ ActionConfig currAct = new ActionConfig()
+ {
+ Id = "01",
+ Description = "Upload File",
+ Action = ActType.UploadFile,
+ ParamList = currActParam
+ };
+ // eseguo step...
+ taskOk = doStep(currAct);
+ return taskOk;
+ }
+
+ #endregion Private Methods
+ }
+}
\ No newline at end of file
diff --git a/IOB-WIN-FTP/packages.config b/IOB-WIN-FTP/packages.config
index bc12d868..37e06f05 100644
--- a/IOB-WIN-FTP/packages.config
+++ b/IOB-WIN-FTP/packages.config
@@ -1,20 +1,25 @@

+
+
-
-
+
+
+
-
+
+
+
-
-
-
-
+
+
+
+
-
-
+
+
\ No newline at end of file