Fehlerbehandlung und Fortschrittsanzeige verbessert
Die Verarbeitung von Dateien wurde robuster gestaltet: - Neue Variable `_SkippedFilesCount` zur Zählung übersprungener Dateien. - Verbesserte Fehlerbehandlung bei fehlenden oder fehlerhaften Dokumenten: - Warnungen und detaillierte Logs bei Fehlern. - Fortschritt wird auch bei übersprungenen Dateien aktualisiert. - Fortschrittsanzeige (`ProgressChanged`) angepasst: - `(Übersprungen)` bei fehlendem Dokument. - `(Dateiname leer)` bei leerem Dateinamen. - `(Fehler beim Laden)` bei Fehlern während des Ladens. - Fortschrittsbalken (`ProgressBar1` und `ProgressBar2`) aktualisiert, um übersprungene Dateien korrekt darzustellen. - Warnung am Ende des Profil-Durchlaufs, wenn Dateien übersprungen wurden.
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -313,8 +313,11 @@ Public Class frmNIHauptseite
|
|||||||
' e.Cancel = True
|
' e.Cancel = True
|
||||||
'End If
|
'End If
|
||||||
Dim _Fehler As Boolean = False
|
Dim _Fehler As Boolean = False
|
||||||
|
Dim _SkippedFilesCount As Integer = 0 ' ← Neu hinzufügen
|
||||||
For Each profil As ClassNIProfil In ClassNIProfile.Profile
|
For Each profil As ClassNIProfil In ClassNIProfile.Profile
|
||||||
_Fehler = False
|
_Fehler = False
|
||||||
|
_SkippedFilesCount = 0
|
||||||
|
|
||||||
' aktuelles Profil der Klasse mitteilen
|
' aktuelles Profil der Klasse mitteilen
|
||||||
Me.aktivesProfil = profil
|
Me.aktivesProfil = profil
|
||||||
_clsWorkfile = New clsNI_WorkFile(_MyLogger)
|
_clsWorkfile = New clsNI_WorkFile(_MyLogger)
|
||||||
@@ -501,42 +504,62 @@ Public Class frmNIHauptseite
|
|||||||
'Dim _dok As WMObject
|
'Dim _dok As WMObject
|
||||||
'_dok = Nothing
|
'_dok = Nothing
|
||||||
Try
|
Try
|
||||||
|
' Wichtig: aktivesDokument zurücksetzen
|
||||||
|
aktivesDokument = Nothing
|
||||||
aktivesDokument = _windreamNI.oWMSession.GetWMObjectByPath(ConstWMEntityDocument, oFilenameWM)
|
aktivesDokument = _windreamNI.oWMSession.GetWMObjectByPath(ConstWMEntityDocument, oFilenameWM)
|
||||||
Catch ex As Exception
|
|
||||||
_Logger.Warn($"ATTENTION: error while creating a windream-object via objectpath - ERROR [{ex.InnerException.Message}]")
|
|
||||||
_Logger.Warn($"Filename [{oFilenameWM}]")
|
|
||||||
_Logger.Error(ex)
|
|
||||||
bwProfil.ReportProgress(-4)
|
|
||||||
Exit Sub
|
|
||||||
End Try
|
|
||||||
|
|
||||||
If Not IsNothing(aktivesDokument) Then
|
If IsNothing(aktivesDokument) Then
|
||||||
|
_Logger.Warn($"ATTENTION: Could not create WMObject for path [{oFilenameWM}] - Object is Nothing. Skipping file...")
|
||||||
|
bwProfil.ReportProgress(-1) ' Fortschritt dennoch erhöhen
|
||||||
|
Continue For ' Nächste Datei
|
||||||
|
End If
|
||||||
|
|
||||||
_Logger.Debug($"..Got a windream-document-object for {aktivesDokument.aName}...")
|
_Logger.Debug($"..Got a windream-document-object for {aktivesDokument.aName}...")
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
'####### Go für das Dokument ##########
|
'####### Go für das Dokument ##########
|
||||||
' Thread für diese Datei starten
|
|
||||||
Me.startDateiDurchlauf()
|
Me.startDateiDurchlauf()
|
||||||
'######################################
|
'######################################
|
||||||
' solange der Datei-Thread noch nicht abgeschlossen wurde
|
|
||||||
|
|
||||||
While Me.bwDatei.IsBusy
|
While Me.bwDatei.IsBusy
|
||||||
|
|
||||||
End While
|
End While
|
||||||
|
|
||||||
' nächste Datei an ProgressBar2
|
' nächste Datei an ProgressBar2
|
||||||
bwProfil.ReportProgress(-1)
|
bwProfil.ReportProgress(-1)
|
||||||
oWorkCount += 1
|
oWorkCount += 1
|
||||||
|
|
||||||
' Vorgang abbrechen
|
' Vorgang abbrechen
|
||||||
If bwProfil.CancellationPending Then
|
If bwProfil.CancellationPending Then
|
||||||
_Logger.Info($"bwProfil.CancellationPending...Exit bwProfil_DoWork")
|
_Logger.Info($"bwProfil.CancellationPending...Exit bwProfil_DoWork")
|
||||||
Exit Sub
|
Exit Sub
|
||||||
ElseIf manually_cancel = True Then
|
ElseIf manually_cancel = True Then
|
||||||
_Logger.Info($"manually_cancel...Exit bwProfil_DoWork")
|
_Logger.Info($"manually_cancel...Exit bwProfil_DoWork")
|
||||||
|
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
Else
|
|
||||||
_Logger.Error("Could not create a WMDocument via path!")
|
Catch ex As Exception
|
||||||
|
' Fehler bei einzelner Datei - loggen und weitermachen
|
||||||
|
_Logger.Warn($"ATTENTION: Error processing document from path [{oFilenameWM}]")
|
||||||
|
_Logger.Warn($"Error: {ex.Message}")
|
||||||
|
|
||||||
|
If ex.InnerException IsNot Nothing Then
|
||||||
|
_Logger.Warn($"InnerException: {ex.InnerException.Message}")
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
_Logger.Error(ex)
|
||||||
|
|
||||||
|
Dim oLineNumber = GetLineNumber(ex)
|
||||||
|
If oLineNumber > 0 Then
|
||||||
|
_Logger.Warn($"#### Line Number: {oLineNumber} ####")
|
||||||
|
End If
|
||||||
|
_SkippedFilesCount += 1 ' ← Zähler erhöhen
|
||||||
|
' Fortschritt trotzdem erhöhen
|
||||||
|
bwProfil.ReportProgress(-1)
|
||||||
|
|
||||||
|
' Weiter mit nächster Datei
|
||||||
|
_Logger.Info($"Skipping file and continuing with next document...")
|
||||||
|
Continue For
|
||||||
|
End Try
|
||||||
Next
|
Next
|
||||||
Else
|
Else
|
||||||
_Logger.Error("ATTENTION: _windreamNI not intitialized properly...")
|
_Logger.Error("ATTENTION: _windreamNI not intitialized properly...")
|
||||||
@@ -587,6 +610,9 @@ Public Class frmNIHauptseite
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
End If
|
End If
|
||||||
|
If _SkippedFilesCount > 0 Then
|
||||||
|
_Logger.Warn($"#### Profile completed with {_SkippedFilesCount} skipped file(s) due to errors ####")
|
||||||
|
End If
|
||||||
_Logger.Info("####################################################End Profile DoWork####")
|
_Logger.Info("####################################################End Profile DoWork####")
|
||||||
' nächstes Profil an ProgressBar1
|
' nächstes Profil an ProgressBar1
|
||||||
bwProfil.ReportProgress(-2)
|
bwProfil.ReportProgress(-2)
|
||||||
@@ -640,7 +666,26 @@ Public Class frmNIHauptseite
|
|||||||
ElseIf e.ProgressPercentage = -2 Then
|
ElseIf e.ProgressPercentage = -2 Then
|
||||||
Me.ProgressBar1.Value += 1
|
Me.ProgressBar1.Value += 1
|
||||||
ElseIf e.ProgressPercentage = -1 Then
|
ElseIf e.ProgressPercentage = -1 Then
|
||||||
Me.lblDatei.Text = Me.aktivesDokument.aName
|
Try
|
||||||
|
If Not IsNothing(Me.aktivesDokument) Then
|
||||||
|
Dim docName As String = Me.aktivesDokument.aName
|
||||||
|
If Not String.IsNullOrEmpty(docName) Then
|
||||||
|
Me.lblDatei.Text = docName
|
||||||
|
Else
|
||||||
|
Me.lblDatei.Text = "(Dateiname leer)"
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
' Wenn aktivesDokument Nothing ist, dann war es ein Skip
|
||||||
|
Me.lblDatei.Text = "(Übersprungen)"
|
||||||
|
End If
|
||||||
|
Catch ex As Exception
|
||||||
|
' Nur bei echtem Fehler
|
||||||
|
Me.lblDatei.Text = "(Fehler beim Laden)"
|
||||||
|
_Logger.Debug($"Error in ProgressChanged: {ex.Message}")
|
||||||
|
End Try
|
||||||
|
|
||||||
|
Me.ProgressBar2.Value += 1
|
||||||
|
|
||||||
Me.ProgressBar2.Value += 1
|
Me.ProgressBar2.Value += 1
|
||||||
Else
|
Else
|
||||||
Me.ProgressBar2.Minimum = 0
|
Me.ProgressBar2.Minimum = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user