Update ftp (da completare con check manager configurato)

This commit is contained in:
Samuele Locatelli
2024-10-08 09:27:32 +02:00
parent 668687ca1e
commit 6a54f949dd
+62 -10
View File
@@ -32,6 +32,8 @@ namespace IOB_WIN_NEXT.IobNet
public Ftp(AdapterForm caller, IobConfiguration IOBConf) : base(caller, IOBConf)
{
lgInfo("Init IobFtp Client");
// imposto
B_input = 0;
// init datetime counters
DateTime adesso = DateTime.Now;
lastPzCountSend = adesso;
@@ -57,7 +59,7 @@ namespace IOB_WIN_NEXT.IobNet
if (!string.IsNullOrEmpty(ftpConfFile))
{
loadFtpConfFile(ftpConfFile);
// mi calcolo ed imposto la remoteBaseDir...
// mi calcolo ed imposto la ftpClient + Remote BaseDir...
string actKey = "RemoteDir";
if (currFtpTaskList != null && currFtpTaskList.ListTask.Count > 0)
{
@@ -76,10 +78,17 @@ namespace IOB_WIN_NEXT.IobNet
}
}
}
if (ftpClient == null)
{
// setup ftpClient!
ftpClient = new Manager(fTask.ServerAddr, fTask.ConnUser, fTask.ConnPasswd, fTask.RawCert, fTask.SkipCert);
}
}
}
}
}
/// <summary>
/// Directpry remota di abse
/// </summary>
@@ -211,8 +220,8 @@ namespace IOB_WIN_NEXT.IobNet
#endif
break;
default:
taskVal = $"taskReq: {tName} | key: {item.Key} | val: {item.Value} | SKIPPED | NO EXEC";
lgInfo($"Chiamata senza processing: taskOk: {taskOk} | taskVal: {taskVal}");
//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!
@@ -312,13 +321,14 @@ namespace IOB_WIN_NEXT.IobNet
if (connectionOk)
{
B_input = 1;
//B_input = 1;
B_input = 3;
}
else
{
B_input = 0;
}
// aggiungo NON emergenza...
B_input += (1 << 7);
@@ -510,16 +520,61 @@ namespace IOB_WIN_NEXT.IobNet
private bool doStep(ActionConfig step)
{
bool fatto = false;
string remoteDir = "";
string localDir = "";
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();
remoteDir = step.ParamList["RemoteDir"] ?? "";
//verifico dir remota
fatto = ftpClient.DirExists(remoteDir);
}
else
{
lgError("Error: missing parameters!");
}
sw.Stop();
if (fatto)
{
lgInfo($"Check RemDir: {remoteDir} | {sw.ElapsedMilliseconds:N1} ms");
}
break;
case ActType.CheckFile:
break;
case ActType.CreateDir:
if (step.ParamList != null && step.ParamList.Count > 0)
{
sw.Restart();
remoteDir = step.ParamList["RemoteDir"] ?? "";
//verifico dir remota
bool dirExist = ftpClient.DirExists(remoteDir);
if (dirExist)
{
lgTrace("Error: Folder already exists!");
}
else
{
fatto = ftpClient.CreateDir(remoteDir);
}
}
else
{
lgError("Error: missing parameters!");
}
sw.Stop();
if (fatto)
{
lgInfo($"Directory {remoteDir} created!| {sw.ElapsedMilliseconds:N1} ms");
}
break;
case ActType.DelDir:
@@ -546,11 +601,8 @@ namespace IOB_WIN_NEXT.IobNet
case ActType.MirrorDirR2L:
// eseguo mirroring directory
string remoteDir = "";
string localDir = "";
string sVal = "";
string actKey = "FtpSync";
string actVal = "SRC --> DEST | Size";
actKey = "FtpSync";
actVal = "SRC --> DEST | Size";
if (step.ParamList != null && step.ParamList.Count > 1)
{
sw.Restart();