diff --git a/IOB-WIN-NEXT/IobNet/Ftp.cs b/IOB-WIN-NEXT/IobNet/Ftp.cs index e2879ada..06446fe5 100644 --- a/IOB-WIN-NEXT/IobNet/Ftp.cs +++ b/IOB-WIN-NEXT/IobNet/Ftp.cs @@ -118,6 +118,10 @@ namespace IOB_WIN_NEXT.IobNet 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) { @@ -136,6 +140,7 @@ namespace IOB_WIN_NEXT.IobNet * - step 2: creazione folder ------------------------------------------------------------------*/ // compongo remDir dai 2 parametri... + actKey = "RemoteDir"; newDir = $"{RemoteBaseDir}/{item.Value}"; currActParam.Add(actKey, newDir); currAct = new ActionConfig() @@ -169,6 +174,19 @@ namespace IOB_WIN_NEXT.IobNet { taskVal = $"DIR Already Exists: {item.Key} --> {item.Value}"; } + // ora creo il file interno... + remFile = $"{newDir}/{fNameOdl}"; + fileContent = $"NEW ODL activated | {item.Value} | {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.. saveProdData(new KeyValuePair(item.Key, item.Value)); break; @@ -191,27 +209,11 @@ namespace IOB_WIN_NEXT.IobNet else { string odlFolder = $"ODL{currIdxODL:00000000}"; + remFile = $"{RemoteBaseDir}/{odlFolder}/{fNameOdl}"; + fileContent = item.Value; // scrivo file ultima richiesta setup - string basePath = System.Windows.Forms.Application.StartupPath; - string tempDir = Path.Combine(basePath, "temp"); - string locFile = Path.Combine(tempDir, fNameOdl); - // salva col nome FISSO di ODL_CORRENTE - string remFile = $"{RemoteBaseDir}/{odlFolder}/{fNameOdl}"; - //string remFile = $"{RemoteBaseDir}/{odlFolder}/{fName}"; - // creo file locale - File.WriteAllText(locFile, item.Value); - // invio file x ODL attivo - currActParam.Add("LocalFile", locFile); - currActParam.Add("RemoteFile", remFile); - currAct = new ActionConfig() - { - Id = "01", - Description = "Upload File", - Action = ActType.UploadFile, - ParamList = currActParam - }; - // eseguo step... - taskOk = doStep(currAct); + locFile = Path.Combine(basePath, "temp", fNameOdl); + taskOk = SendOdlActFile(locFile, remFile, fileContent); if (taskOk) { taskVal = $"File uploaded: {item.Key} --> {item.Value} | locFile: {locFile} | remFile: {remFile}"; @@ -249,6 +251,32 @@ namespace IOB_WIN_NEXT.IobNet } return taskDone; } + /// + /// 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; + } /// /// Effettua processing CUSTOM x FTP: