From 55d7e025c9dc2a97e9a1549ce72f11283130560e Mon Sep 17 00:00:00 2001 From: Developer01 Date: Tue, 16 Dec 2025 17:21:18 +0100 Subject: [PATCH] Normalizing currency for windream --- app/TaskFlow/My Project/AssemblyInfo.vb | 2 +- app/TaskFlow/TaskFlow.vbproj | 13 +-- app/TaskFlow/frmValidator.vb | 126 +++++++++++++++--------- 3 files changed, 85 insertions(+), 56 deletions(-) diff --git a/app/TaskFlow/My Project/AssemblyInfo.vb b/app/TaskFlow/My Project/AssemblyInfo.vb index 8c84bad..92aaabc 100644 --- a/app/TaskFlow/My Project/AssemblyInfo.vb +++ b/app/TaskFlow/My Project/AssemblyInfo.vb @@ -32,6 +32,6 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - + diff --git a/app/TaskFlow/TaskFlow.vbproj b/app/TaskFlow/TaskFlow.vbproj index d9c5340..ba80ec5 100644 --- a/app/TaskFlow/TaskFlow.vbproj +++ b/app/TaskFlow/TaskFlow.vbproj @@ -77,12 +77,12 @@ My Project\app.manifest - - - - - - + + + + + + ..\packages\BouncyCastle.Cryptography.2.5.0\lib\net461\BouncyCastle.Cryptography.dll @@ -1036,6 +1036,7 @@ FinalIndexDataSet.xsd + MyApplicationCodeGenerator diff --git a/app/TaskFlow/frmValidator.vb b/app/TaskFlow/frmValidator.vb index 8d3e99b..e903c34 100644 --- a/app/TaskFlow/frmValidator.vb +++ b/app/TaskFlow/frmValidator.vb @@ -3585,33 +3585,53 @@ Public Class frmValidator For Each Zeile As Object In oValueFromSource MyValidationLogger.Debug($"vektorrow Value {Zeile.ToString}...") oColValuesfromSource = Split(Zeile, PMDelimiter) - 'If oColValuesfromSource.Length >= 1 Then - ' Continue For - 'End If Dim oNewRow = oDataSource.NewRow() MyValidationLogger.Debug("Creating new row..") + For index = 0 To oDTColumnsPerDevExGrid.Rows.Count - 1 Dim rawValue As String = If(index < oColValuesfromSource.Length, oColValuesfromSource(index), String.Empty) Dim targetColumn As DataColumn = oDataSource.Columns(index) + Dim colName As String = targetColumn.ColumnName + Dim colType As String = targetColumn.DataType.FullName - MyValidationLogger.Debug("Column Index {0}", index) - If oColValuesfromSource.Length > index Then - MyValidationLogger.Debug("Value: {0}", oColValuesfromSource(index)) - oNewRow.Item(index) = oColValuesfromSource(index) - Else - MyValidationLogger.Debug("Value: String.Empty") - oNewRow.Item(index) = String.Empty - End If + ' Detailliertes Debug vor der Zuweisung + MyValidationLogger.Debug("Grid row assign: RowIdx={0}, ColIdx={1}, ColName={2}, ColType={3}, RawValue=[{4}], IsEmpty={5}", + oDataSource.Rows.Count, index, colName, colType, rawValue, String.IsNullOrWhiteSpace(rawValue)) + + Try + If oColValuesfromSource.Length > index Then + oNewRow.Item(index) = oColValuesfromSource(index) + Else + If colType = "System.Double" Or colType = "System.Int32" Or colType = "System.Int64" Then + ' Numerische Spalten können nicht mit Empty befüllt werden + oNewRow.Item(index) = 0 + Else + oNewRow.Item(index) = String.Empty + End If + End If + Catch ex As Exception + ' Ausführliches Logging bei Fehlern inkl. aktuell bekannter Metadaten + MyValidationLogger.Warn("Grid row assign FAILED RowIdx = {0}, ColIdx={1}, ColName={2}, ColType={3}, RawValue=[{4}]", + oDataSource.Rows.Count, index, colName, colType, rawValue) + MyValidationLogger.Error(ex) + ' Optional: weitere Kontexthilfe – z.B. ob Spalte DBNull erlaubt + Try + MyValidationLogger.Debug("Column.AllowDBNull={0}, Column.MaxLength={1}", targetColumn.AllowDBNull, targetColumn.MaxLength) + Catch + End Try + ' Fehler weiterwerfen, damit ursprüngliches Verhalten erhalten bleibt + Throw + End Try Next - MyValidationLogger.Debug("Adding row to grid..") + MyValidationLogger.Debug("Adding row To grid..") oDataSource.Rows.Add(oNewRow) Next Else If oValueType = "System.String" Then - MyValidationLogger.Debug($"IDB Fill Grid [{oControl.Name}] with String") + MyValidationLogger.Debug($"IDB Fill Grid [{oControl.Name}] With String") MyValidationLogger.Debug($"oValueFromSource [{oValueFromSource}] - PMDelimiter[{PMDelimiter}]") oColValuesfromSource = Split(oValueFromSource.ToString, PMDelimiter) @@ -3620,7 +3640,7 @@ Public Class frmValidator End If Dim oRowData As New List(Of Object) - MyValidationLogger.Debug(String.Format("Now creating the rows for DevexpressGrid ...")) + MyValidationLogger.Debug(String.Format("Now creating the rows For DevexpressGrid ...")) Dim oMSG = "" Try For index = 1 To oColValuesfromSource.Length @@ -3633,9 +3653,9 @@ Public Class frmValidator oRowData.Add(oConvertedValue) Next Catch ex As Exception - MyValidationLogger.Warn(String.Format("Unexpected error while working on IDB Fill GridControl: {0}", oControl.Name)) + MyValidationLogger.Warn(String.Format("Unexpected Error While working On IDB Fill GridControl {0}", oControl.Name)) If Not oMSG = String.Empty Then - MyValidationLogger.Warn(String.Format("oMSG: {0}", oMSG)) + MyValidationLogger.Warn(String.Format("oMSG {0}", oMSG)) End If MyValidationLogger.Error(ex) End Try @@ -3646,14 +3666,14 @@ Public Class frmValidator ElseIf oValueType = "System.Data.DataTable" Then Dim oMyDatatable As DataTable = oValueFromSource - MyValidationLogger.Debug($"IDB Fill Grid [{oControl.Name}] with Datatable - Rows: " & oMyDatatable.Rows.Count) + MyValidationLogger.Debug($"IDB Fill Grid [{oControl.Name}] With Datatable - Rows " & oMyDatatable.Rows.Count) For Each oRow As DataRow In oMyDatatable.Rows Try MyValidationLogger.Debug($"IDB ROW Vector {oRow.Item(0).ToString}...") oColValuesfromSource = Split(oRow.Item(0).ToString, PMDelimiter) If oColValuesfromSource.Length > 8 Then - MyValidationLogger.Warn("Fill Grid with DatatableSplit Error - Max 8 columns can be configured!") + MyValidationLogger.Warn("Fill Grid With DatatableSplit Error - Max 8 columns can be configured!") End If MyValidationLogger.Debug($"oColValuesfromSource splitted - Length ({oColValuesfromSource.Length.ToString})") Dim oRowData As New List(Of Object) @@ -3661,16 +3681,16 @@ Public Class frmValidator For index = 1 To oColValuesfromSource.Length Try Dim oColumnType = oDTColumnsPerDevExGrid.Rows.Item(index - 1).Item("TYPE_COLUMN") - MyValidationLogger.Debug($"oColumnType of DGView-Column ({oColumnType.ToString})...") + MyValidationLogger.Debug($"oColumnType Of DGView-Column ({oColumnType.ToString})...") Dim oConvertedValue = ClassFormat.GetConvertedValue(oColValuesfromSource(index - 1), oColumnType) oRowData.Add(oConvertedValue) Catch ex As Exception - MyValidationLogger.Warn($"Error while converting/adding Value to oRowData: " & ex.Message) + MyValidationLogger.Warn($"Error While converting/adding Value To oRowData " & ex.Message) End Try Next oDataSource.Rows.Add(oRowData.ToArray()) Catch ex As Exception - MyValidationLogger.Warn($"Error while adding datarow [{oRow.Item(0).ToString}] to Grid: " & ex.Message) + MyValidationLogger.Warn($"Error While adding datarow [{oRow.Item(0).ToString}] To Grid " & ex.Message) End Try @@ -3679,7 +3699,7 @@ Public Class frmValidator End If Else - MyValidationLogger.Info($"DevExpressGrid: There are no columns configured/listed for control {oControlId}.") + MyValidationLogger.Info($"DevExpressGrid There are no columns configured/listed For control {oControlId}.") End If Case Else @@ -3695,7 +3715,7 @@ Public Class frmValidator Next End Select Else - MyValidationLogger.Warn($"Could not load Devexpress.Grid [{oControl.Name }] as omytype is [{oValueType}]!") + MyValidationLogger.Warn($"Could Not load Devexpress.Grid [{oControl.Name }] As omytype Is [{oValueType}]!") End If @@ -3736,10 +3756,10 @@ Public Class frmValidator End If Catch ex As Exception MyValidationLogger.Error(ex) - MyValidationLogger.Info(">> Unexpected error in FillIndexValues(GridControl: " & oMyGridControl.Name & "): " & ex.Message, True) - MyValidationLogger.Info(">> Controltype: " & oControlType) - MyValidationLogger.Info(">> Attributname: " & oIndexName) - errormessage = "Unexpected error in FillIndexValues(Combobox: " & oMyGridControl.Name & "): " & vbNewLine & ex.Message & vbNewLine & "Check Logfile" + MyValidationLogger.Info(">> Unexpected Error In FillIndexValues(GridControl " & oMyGridControl.Name & ") " & ex.Message, True) + MyValidationLogger.Info(">> Controltype " & oControlType) + MyValidationLogger.Info(">> Attributname " & oIndexName) + errormessage = "Unexpected Error In FillIndexValues(Combobox " & oMyGridControl.Name & ") " & vbNewLine & ex.Message & vbNewLine & "Check Logfile" My.Settings.Save() frmError.ShowDialog() End Try @@ -3749,15 +3769,15 @@ Public Class frmValidator MyValidationLogger.Debug("Loading checkbox...") oControlType = "CheckBox" If oSourceIndexName = "" Then - MsgBox("Attention wrong configuration:" & vbNewLine & "for control " & oControl.Name & " no INDEX configured!" & vbNewLine & "Bitte prüfen Sie den Formulardesigner!", MsgBoxStyle.Critical, ADDITIONAL_TITLE) + MsgBox("Attention wrong configuration" & vbNewLine & "For control " & oControl.Name & " no INDEX configured!" & vbNewLine & "Bitte prüfen Sie den Formulardesigner!", MsgBoxStyle.Critical, ADDITIONAL_TITLE) Exit For End If If oSourceIndexName Is Nothing = False Then Dim myCheckBox As CheckBox = oControl - If oLoadIndex = False Or {"@@DISPLAY_ONLY", "DD PM-ONLY FOR DISPLAY"}.Contains(oSourceIndexName) Then - MyValidationLogger.Debug($" oControl {oControl.Name}: Indexwert soll nicht geladen werden.") + If oLoadIndex = False Or {"@@DISPLAY_ONLY", "DD PM-ONLY For DISPLAY"}.Contains(oSourceIndexName) Then + MyValidationLogger.Debug($" oControl {oControl.Name} Indexwert soll nicht geladen werden.") Exit Select End If @@ -3771,7 +3791,7 @@ Public Class frmValidator MyValidationLogger.Debug($"..Now GetVariableValue({oSourceIndexName})...") oValueFromSource = GetVariableValuefromSource(oSourceIndexName, oIDBTyp, oIDBOverride) Catch ex As Exception - MyValidationLogger.Warn($"Could not get the windreamValue for CheckboxIndex: {oSourceIndexName} [{ex.Message}]") + MyValidationLogger.Warn($"Could Not Get the windreamValue For CheckboxIndex {oSourceIndexName} [{ex.Message}]") End Try End If @@ -3780,19 +3800,19 @@ Public Class frmValidator If oValueFromSource Is Nothing Then MyValidationLogger.Info(">> Zurückgegebener Wert des Wertes für Checkbox mit Indexname '" & oIndexName & "' ist nothing. Checking defaultvalue") MyValidationLogger.Debug(">> Zurückgegebener Wert des Wertes für Checkbox mit Indexname '" & oIndexName & "' ist nothing. Checking defaultvalue") - If oDefaultValue <> String.Empty Then - MyValidationLogger.Info($"Using Default value [{oDefaultValue}]") - MyValidationLogger.Debug($"Using Default value [{oDefaultValue}]") - myCheckBox.Checked = CBool(oDefaultValue) - Exit Select - Else - MyValidationLogger.Debug("No Default Value for Checkbox - so using false!") - myCheckBox.CheckState = CheckState.Indeterminate - End If - - - Else - MyValidationLogger.Debug("oValueFromSource: " & oValueFromSource.ToString) + If oDefaultValue <> String.Empty Then + MyValidationLogger.Info($"Using Default value [{oDefaultValue}]") + MyValidationLogger.Debug($"Using Default value [{oDefaultValue}]") + myCheckBox.Checked = CBool(oDefaultValue) + Exit Select + Else + MyValidationLogger.Debug("No Default Value for Checkbox - so using false!") + myCheckBox.CheckState = CheckState.Indeterminate + End If + + + Else + MyValidationLogger.Debug("oValueFromSource: " & oValueFromSource.ToString) If oValueFromSource.ToString = "" Then MyValidationLogger.Info(">> Versuch, default Value zu laden") If oDefaultValue <> String.Empty Then @@ -5705,12 +5725,20 @@ Public Class frmValidator Dim oValueList As New List(Of String) For Each item As Object In oRow.ItemArray - item = ObjectEx.NotNull(item, String.Empty) - ' Convert to string using InvariantCulture, so converting back from string does not screw up values - If TypeOf item IsNot String Then - item = String.Format(CultureInfo.InvariantCulture, "{0}", item) + Dim normalized As Object = ObjectEx.NotNull(item, String.Empty) + If TypeOf normalized Is IFormattable AndAlso Not TypeOf normalized Is String Then + Dim provider As IFormatProvider = + If(TypeOf normalized Is Decimal OrElse + TypeOf normalized Is Double OrElse + TypeOf normalized Is Single, + CultureInfo.CurrentCulture, + CultureInfo.InvariantCulture) + MyValidationLogger.Debug("Normalizing value [{0}]", normalized.ToString) + + normalized = DirectCast(normalized, IFormattable).ToString(Nothing, provider) End If - oValueList.Add(item) + + oValueList.Add(normalized) Next str = String.Join(PMDelimiter, oValueList.ToArray)