Update conf x export fixed-width AS400

This commit is contained in:
Samuele Locatelli
2023-07-26 19:06:50 +02:00
parent d5f041756b
commit 458d378c12
4 changed files with 20 additions and 2 deletions
+9 -1
View File
@@ -51,7 +51,7 @@ namespace IOB_UT_NEXT
/// <param name="path">Percorso file di output</param>
/// <param name="widthList">Vettore delle larghezze richieste</param>
/// <returns></returns>
public static bool SaveFixedWidth<T>(List<T> reportData, string path, Dictionary<string, int> widthList, Dictionary<string, char> fieldLPad)
public static bool SaveFixedWidth<T>(List<T> reportData, string path, Dictionary<string, int> widthList, Dictionary<string, char> fieldLPad, Dictionary<string, int> numDecReq)
{
bool answ = false;
var lines = new List<string>();
@@ -66,6 +66,14 @@ namespace IOB_UT_NEXT
foreach (var item in widthList)
{
string currValue = dataRow.GetType().GetProperty(item.Key).GetValue(dataRow, null).ToString();
// se ha un num decimali specifico richiesto esegue...
if (numDecReq.ContainsKey(item.Key))
{
string nDec = $"N{numDecReq[item.Key]}";
decimal rawVal = 0;
decimal.TryParse(currValue, out rawVal);
currValue = rawVal.ToString(nDec);
}
if (currValue.Length > item.Value)
{
currValue = currValue.Substring(0, item.Value);
+4
View File
@@ -180,6 +180,10 @@ namespace IOB_UT_NEXT.DataModel
/// </summary>
public Dictionary<string, int> fieldLength { get; set; } = new Dictionary<string, int>();
/// <summary>
/// Numero decimali campo
/// </summary>
public Dictionary<string, int> fieldNDec { get; set; } = new Dictionary<string, int>();
/// <summary>
/// Padding left (OVE necessari)
/// </summary>
public Dictionary<string, char> fieldLPad { get; set; } = new Dictionary<string, char>();
@@ -21,5 +21,11 @@
"UM": 2,
"WeightKgProc": 8,
"DtRif": 10
},
"fieldNDec": {
"WeightKgProc": "2"
},
"fieldLPad": {
"WeightKgProc": "0"
}
}
+1 -1
View File
@@ -8007,7 +8007,7 @@ namespace IOB_WIN_NEXT.Iob
switch (expMode)
{
case "fixwidth":
fatto = DataExport.SaveFixedWidth(ListConsSum, $"{reportPath}.txt", currConf.fieldLength, currConf.fieldLPad);
fatto = DataExport.SaveFixedWidth(ListConsSum, $"{reportPath}.txt", currConf.fieldLength, currConf.fieldLPad, currConf.fieldNDec);
break;
case "csv":
default: