- creazione file commessa al momento dell'upload della folder...
This commit is contained in:
Samuele Locatelli
2024-10-16 16:51:21 +02:00
parent f7d482c571
commit e453a6ddc6
+48 -20
View File
@@ -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<string, string>(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;
}
/// <summary>
/// Invia il file dell'ODL attivo
/// </summary>
/// <param name="locFile"></param>
/// <param name="remFile"></param>
/// <param name="fileContent"></param>
private bool SendOdlActFile(string locFile, string remFile, string fileContent)
{
bool taskOk = false;
Dictionary<string, string> currActParam = new Dictionary<string, string>();
// 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;
}
/// <summary>
/// Effettua processing CUSTOM x FTP: