Update conf x export fixed-width AS400
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user