Merge branch 'release/UpdateBagliettoHeader'

This commit is contained in:
Samuele Locatelli
2022-10-20 10:11:50 +02:00
4 changed files with 18 additions and 6 deletions
+6 -2
View File
@@ -16,9 +16,10 @@ namespace IOB_UT_NEXT
/// <typeparam name="T"></typeparam>
/// <param name="reportData"></param>
/// <param name="path"></param>
/// <param name="writeHeader">Indica se scrivere header ad inizio CSV</param>
/// <param name="separator">Separatore da impiegare (default ";")</param>
/// <returns></returns>
public static bool SaveToCsv<T>(List<T> reportData, string path, char separator = ';')
public static bool SaveToCsv<T>(List<T> reportData, string path, bool writeHeader, char separator = ';')
{
bool answ = false;
var lines = new List<string>();
@@ -28,7 +29,10 @@ namespace IOB_UT_NEXT
var elencoValori = props.ToList();
var header = string.Join($"{separator}", props.ToList().Select(x => !string.IsNullOrEmpty(x.Description) ? x.Description : x.Name));
var fieldList = string.Join($"{separator}", props.ToList().Select(x => x.Name));
lines.Add(header);
if (writeHeader)
{
lines.Add(header);
}
var valueLines = reportData.Select(row => string.Join($"{separator}", fieldList.Split(separator).Select(a => row.GetType().GetProperty(a).GetValue(row, null))));
//var valueLines = reportData.Select(row => string.Join(";", header.Split(';').Select(a => row.GetType().GetProperty(a).GetValue(row, null))));
lines.AddRange(valueLines);
@@ -67,6 +67,7 @@ FTP_CERT=
FTP_SKIP=TRUE
FTP_LOC_DIR=temp\csv
FTP_REM_DIR=
CSV_ADD_HEADER=true
VETO_SEND_SNAPSHOT=5
+1
View File
@@ -88,6 +88,7 @@ FTP_CERT=
FTP_SKIP=TRUE
FTP_LOC_DIR=temp\csv
FTP_REM_DIR=
CSV_ADD_HEADER=true
[BRANCH]
NAME=master
+10 -4
View File
@@ -4517,7 +4517,7 @@ namespace IOB_WIN_NEXT
protected int getFluxValInt(DossierFluxLogDTO resultSet, string codFlux)
{
int answ = 0;
string rawVal = getFluxVal(resultSet, codFlux);
string rawVal = getFluxVal(resultSet, codFlux).Replace(",",".");
if (!string.IsNullOrEmpty(rawVal))
{
int.TryParse(rawVal, out answ);
@@ -4697,7 +4697,7 @@ namespace IOB_WIN_NEXT
lgInfo($"exePath: {exePath}");
lgInfo($"sacBaseDir: {sacBaseDir}");
lgInfo("----------------------");
*/
*/
string localPath = Path.Combine(basePath, locDir);
lgInfo($"basePath: {basePath} | localPath: {localPath}");
@@ -4748,6 +4748,12 @@ namespace IOB_WIN_NEXT
bool answ = false;
// salvo articoli
string locDir = getOptPar("FTP_LOC_DIR");
string sAddHeader = getOptPar("CSV_ADD_HEADER");
bool addHeader = false;
if (!string.IsNullOrEmpty(sAddHeader))
{
bool.TryParse(sAddHeader, out addHeader);
}
string basePath = Application.StartupPath;
string tempDir = Path.Combine(basePath, locDir);
if (!Directory.Exists(tempDir))
@@ -4756,14 +4762,14 @@ namespace IOB_WIN_NEXT
lgInfo($"CSV: created local dir {tempDir}");
}
string filePath = Path.Combine(tempDir, "articoli.csv");
answ = DataExport.SaveToCsv(ListaArticoli, filePath);
answ = DataExport.SaveToCsv(ListaArticoli, filePath, addHeader);
if (answ)
{
lgInfo("CSV: created ART file as articoli.csv");
// salvo PODL
string csvName = $"{DateTime.Now:dd-MM-yyyy}.csv";
filePath = Path.Combine(tempDir, $"{csvName}");
answ = DataExport.SaveToCsv(ListaJobs, filePath);
answ = DataExport.SaveToCsv(ListaJobs, filePath, addHeader);
if (answ)
{
lgInfo($"CSV: created PODL file as {csvName}");