Show Errors, Make grids usable when no mandator is selected, move completed files also when reloading

This commit is contained in:
Jonathan Jenne
2022-04-19 15:33:44 +02:00
parent 9be55f3709
commit 1bef72d65c
12 changed files with 453 additions and 294 deletions

View File

@@ -14,7 +14,6 @@ Imports MultiTool.Common.Winline
Imports MultiTool.Common.Winline.Entities
Imports MultiTool.Common.Constants
Imports MultiTool.Common.Exceptions
Imports MultiTool.Common.Documents.Document
Public Class frmImportMain
Public LogConfig As LogConfig
@@ -39,6 +38,7 @@ Public Class frmImportMain
' Runtime variables
Private CurrentGrid As GridControl = Nothing
Private CurrentDocument As Document = Nothing
Private CurrentDocumentReadOnly As Boolean = False
Public Sub New(pLogConfig As LogConfig, pConfigManager As ConfigManager(Of Config), pTemplate As Template)
InitializeComponent()
@@ -48,6 +48,12 @@ Public Class frmImportMain
CurrentTemplate = pTemplate
End Sub
Private Sub WebService_Progress(sender As Object, e As String)
SplashScreenManager.SetWaitFormDescription(e)
End Sub
#Region "Form Events"
Private Sub frmImportMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
Logger = LogConfig.GetLogger()
@@ -114,238 +120,21 @@ Public Class frmImportMain
End Try
End Sub
Private Sub Grid_Focus(sender As GridControl, e As EventArgs)
CurrentGrid = sender
End Sub
Private Sub Grid_MouseDoubleClick(sender As Object, e As MouseEventArgs)
Dim oGrid As GridControl = DirectCast(sender, GridControl)
Dim oView As GridView = DirectCast(oGrid.FocusedView, GridView)
Dim oHitInfo = oView.CalcHitInfo(e.Location)
If Not oHitInfo.InDataRow Then
Exit Sub
End If
Dim oRow As DataRow = oView.GetFocusedDataRow()
Dim oModifiedRow = EditRow(oRow, oView)
If oModifiedRow IsNot Nothing Then
ReloadRow(oModifiedRow)
End If
End Sub
Private Sub btnEditRow_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnEditRow.ItemClick
Dim oGrid As GridControl = DirectCast(CurrentGrid, GridControl)
Dim oView As GridView = DirectCast(oGrid.FocusedView, GridView)
Dim oRow As DataRow = oView.GetFocusedDataRow()
If oRow Is Nothing Then
Exit Sub
End If
Dim oModifiedRow = EditRow(oRow, oView)
If oModifiedRow IsNot Nothing Then
ReloadRow(oModifiedRow)
End If
End Sub
Private Function EditRow(pRow As DataRow, pView As GridView) As DocumentRow
Try
Dim oColumns = pView.Columns.Select(Function(c) c.FieldName).ToList()
Dim oDocumentRow = CurrentDocument.Rows.
Where(Function(r) r.Id.ToString = pRow.Item(COLUMN_GUID)).
SingleOrDefault()
Dim oTemplateTable = CurrentTemplate.Tables.
Where(Function(t) t.Name = pView.GridControl.Name).
SingleOrDefault()
Dim oForm As New frmRowEditor(
LogConfig,
oColumns,
oDocumentRow,
CurrentDocument.Mandator,
Winline,
oTemplateTable
)
If oForm.ShowDialog() = DialogResult.OK Then
Return oForm.DocumentRow
Else
Return Nothing
End If
Catch ex As Exception
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Laden_der_Detailzeilen)
Return Nothing
End Try
End Function
Private Async Function btnLoadFiles_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) As Task Handles btnLoadFiles.ItemClick
Await LoadFiles()
End Function
Private Async Function frmImportMain_KeyDown(sender As Object, e As KeyEventArgs) As Task Handles MyBase.KeyDown
If e.KeyCode = Keys.F5 Then
Await LoadFiles()
End If
End Function
Private Async Sub btnReloadFile_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnReloadFile.ItemClick
Dim oCurrentMandator As Mandator = TryCast(lookupMandator.EditValue, Mandator)
If oCurrentMandator Is Nothing Then
MsgBox(My.Resources.frmImportMainExtra.Bitte_wählen_Sie_einen_Mandanten_aus__bevor_Sie_fortfahren, MsgBoxStyle.Exclamation, Text)
Exit Sub
End If
Dim oMessage = String.Format(My.Resources.frmImportMainExtra.Wollen_Sie_wirklich_die_aktuelle_Datei_neu_laden, oCurrentMandator)
Dim oResult As DialogResult = MsgBox(oMessage, MsgBoxStyle.Question Or MsgBoxStyle.YesNo, Text)
Try
BeginLoadingUI()
If oResult = DialogResult.Yes Then
Dim oDocument As Document = GridViewFiles.GetRow(GridViewFiles.FocusedRowHandle)
Dim oNewDocument = Await DocumentLoader.LoadFile(oDocument.File, CurrentTemplate, lookupMandator.EditValue)
Dim oIndex = DocumentLoader.Files.IndexOf(oDocument)
DocumentLoader.Files.Item(oIndex) = oNewDocument
LoadDocument(oNewDocument)
End If
Catch ex As NoMandatorException
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Neuladen_des_Dokuments, My.Resources.frmImportMainExtra.Es_konnte_kein_passender_Mandant_ermittelt_werden)
Catch ex As MissingAttributeException
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Neuladen_des_Dokuments, "Ein benötigtes Attribut wurde nicht gefunden.")
Catch ex As Exception
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Neuladen_des_Dokuments)
Finally
EndLoadingUI()
End Try
End Sub
Private Sub GridViewFiles_FocusedRowChanged(sender As Object, e As Views.Base.FocusedRowChangedEventArgs) Handles GridViewFiles.FocusedRowChanged
Try
SplitContainerMain.Panel2.Enabled = True
Dim oDocument As Document = GridViewFiles.GetRow(e.FocusedRowHandle)
If oDocument Is Nothing Then
Exit Sub
End If
If oDocument.Mandator Is Nothing Then
lookupMandator.EditValue = Nothing
SplitContainerMain.Panel2.Enabled = False
For Each oGrid In Grids
oGrid.DataSource = Nothing
Next
MsgBox("Für die aktuelle Datei konnte kein Mandant zugeordnet werden! Bitte wählen Sie einen aus und laden Sie dann die Datei erneut.", MsgBoxStyle.Exclamation, Text)
Exit Sub
End If
lookupMandator.EditValue = oDocument.Mandator
LoadDocument(oDocument)
Catch ex As Exception
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Laden_des_Dokuments)
End Try
End Sub
Private Sub WebService_Progress(sender As Object, e As String)
SplashScreenManager.SetWaitFormDescription(e)
End Sub
Private Sub btnOpenInputDirectory_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnOpenInputDirectory.ItemClick
FormHelper.TryOpenDirectory(CurrentTemplate.InputDirectory, My.Resources.frmImportMainExtra.Eingangsverzeichnis)
End Sub
Private Sub btnOpenOutputDirectory_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnOpenOutputDirectory.ItemClick
FormHelper.TryOpenDirectory(CurrentTemplate.OutputDirectory, My.Resources.frmImportMainExtra.Ausgabeverzeichnis)
End Sub
Private Sub btnOpenSchemaDirectory_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnOpenSchemaDirectory.ItemClick
FormHelper.TryOpenDirectory(My.GeneralConfiguration.TemplateDirectory, My.Resources.frmImportMainExtra.Vorlagenverzeichnis)
End Sub
Private Sub btnShowXml_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnShowXml.ItemClick
Dim oForm As New frmXmlEditor With {.FileName = CurrentDocument.FullName}
oForm.Show()
End Sub
Private Sub txtCurrentFile_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles txtCurrentFile.ItemClick
If CurrentDocument IsNot Nothing Then
TryOpenFile(CurrentDocument.FullName, My.Resources.frmImportMainExtra.Aktuelle_Datei)
End If
End Sub
Private Sub btnRemoveRow_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnRemoveRow.ItemClick
If CurrentGrid Is Nothing Then
Exit Sub
End If
Dim oMessage As String = My.Resources.frmImportMainExtra.Wollen_Sie_die_ausgewählte_Zeile_wirklich_löschen_
If MsgBox(oMessage, MsgBoxStyle.Question Or MsgBoxStyle.YesNo, Text) = MsgBoxResult.Yes Then
' Get GUID of currently selected row
Dim oView As GridView = CurrentGrid.FocusedView
Dim oRow As DataRowView = oView.GetRow(oView.FocusedRowHandle)
Dim oGuid = oRow.Row.Item(COLUMN_GUID)
' Get currently selected document
Dim oDocument As Document = GridViewFiles.GetRow(GridViewFiles.FocusedRowHandle)
Dim oNewRows = oDocument.Rows.
Where(Function(r) r.Id.ToString <> oGuid).
ToList()
oDocument.Rows = oNewRows
Dim oIndex = DocumentLoader.Files.IndexOf(oDocument)
DocumentLoader.Files.Item(oIndex) = oDocument
lookupMandator.EditValue = oDocument.Mandator
LoadDocument(oDocument)
End If
End Sub
Private Sub btnOpenReport_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnOpenReport.ItemClick
Try
SplashScreenManager.ShowWaitForm()
SplashScreenManager.SetWaitFormDescription(My.Resources.frmImportMainExtra.Erstellen_der_Berichtsvorschau)
SetDocumentButtonsEnabled(False)
GridControlFiles.Enabled = False
btnLoadFiles.Enabled = False
SplitContainerGrids.Enabled = False
Dim oDocument As Document = GridViewFiles.GetRow(GridViewFiles.FocusedRowHandle)
Dim oReportGenerator = New ReportGenerator(Of OrderReport)(LogConfig, Database,
My.TemplateConfiguration,
My.GeneralConfiguration)
Dim oReport As OrderReport = oReportGenerator.GenerateReport(oDocument, CurrentTemplate)
Dim oPrintTool As New ReportPrintTool(oReport)
oPrintTool.Report.CreateDocument(False)
oPrintTool.ShowPreview()
SplitContainerGrids.Enabled = True
btnLoadFiles.Enabled = True
GridControlFiles.Enabled = True
SetDocumentButtonsEnabled(True)
SplashScreenManager.CloseWaitForm()
Catch ex As Exception
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Erstellen_der_Berichtsvorschau)
End Try
End Sub
#End Region
#Region "Grid Events"
Private Sub GridViewFiles_CustomDrawCell(sender As Object, e As Views.Base.RowCellCustomDrawEventArgs) Handles GridViewFiles.CustomDrawCell
Dim oDocument As Document = GridViewFiles.GetRow(e.RowHandle)
@@ -392,6 +181,92 @@ Public Class frmImportMain
End Sub
Private Sub Grid_Focus(sender As GridControl, e As EventArgs)
CurrentGrid = sender
End Sub
Private Sub Grid_MouseDoubleClick(sender As Object, e As MouseEventArgs)
Dim oGrid As GridControl = DirectCast(sender, GridControl)
Dim oView As GridView = DirectCast(oGrid.FocusedView, GridView)
Dim oHitInfo = oView.CalcHitInfo(e.Location)
If Not oHitInfo.InDataRow Then
Exit Sub
End If
Dim oRow As DataRow = oView.GetFocusedDataRow()
Dim oModifiedRow = EditRow(oRow, oView)
If oModifiedRow IsNot Nothing Then
ReloadRow(oModifiedRow)
End If
End Sub
Private Sub GridViewFiles_FocusedRowChanged(sender As Object, e As Views.Base.FocusedRowChangedEventArgs) Handles GridViewFiles.FocusedRowChanged
Try
SplitContainerMain.Panel2.Enabled = True
Dim oDocument As Document = GridViewFiles.GetRow(e.FocusedRowHandle)
If oDocument Is Nothing Then
Exit Sub
End If
If oDocument.Mandator Is Nothing Then
lookupMandator.EditValue = Nothing
End If
lookupMandator.EditValue = oDocument.Mandator
LoadDocument(oDocument)
Catch ex As Exception
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Laden_des_Dokuments)
End Try
End Sub
#End Region
#Region "Ribbon Events"
Private Async Sub btnCalculatePrices_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnCalculatePrices.ItemClick
Dim oCurrentMandator As Mandator = TryCast(lookupMandator.EditValue, Mandator)
If oCurrentMandator Is Nothing Then
MsgBox(My.Resources.frmImportMainExtra.Bitte_wählen_Sie_einen_Mandanten_aus__bevor_Sie_fortfahren, MsgBoxStyle.Exclamation, Text)
Exit Sub
End If
BeginLoadingUI()
SplashScreenManager.SetWaitFormDescription("Lade Preisinformationen..")
Dim oStopWatch As New Stopwatch()
Try
oStopWatch.Start()
Dim oNewDocument = Await DocumentLoader.MaybeApplyPriceFunctions(CurrentDocument, oCurrentMandator, CurrentTemplate)
oStopWatch.Stop()
DocumentLoader.ReplaceDocument(oNewDocument)
LoadDocument(oNewDocument)
Catch ex As Exception
FormHelper.ShowError(ex, "Laden der Preisinformationen")
Finally
EndLoadingUI()
Logger.Debug("Loading Priceinfo took [{0}] ms", oStopWatch.ElapsedMilliseconds)
End Try
End Sub
Private Sub btnOpenLogDirectory2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnOpenLogDirectory2.ItemClick
FormHelper.TryOpenDirectory(LogConfig.LogDirectory, My.Resources.frmImportMainExtra.Logverzeichnis)
End Sub
Private Sub btnDebugExportReport_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnDebugExportReport.ItemClick
' Get the document
Dim oDocument As Document = GridViewFiles.GetRow(GridViewFiles.FocusedRowHandle)
' Generate the report
Dim oReport = ReportGenerator.GenerateReport(oDocument, CurrentTemplate)
Dim oFilePath = ReportGenerator.GetReportFilePath(oDocument, CurrentTemplate)
' Export it to pdf
oReport.ExportToPdf(oFilePath)
End Sub
Private Async Sub btnTestTransferFile_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnTestTransferFile.ItemClick
Try
@@ -509,18 +384,147 @@ Public Class frmImportMain
End Try
End Sub
Private Sub btnDebugExportReport_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnDebugExportReport.ItemClick
' Get the document
Dim oDocument As Document = GridViewFiles.GetRow(GridViewFiles.FocusedRowHandle)
Private Sub btnEditRow_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnEditRow.ItemClick
Dim oGrid As GridControl = DirectCast(CurrentGrid, GridControl)
Dim oView As GridView = DirectCast(oGrid.FocusedView, GridView)
Dim oRow As DataRow = oView.GetFocusedDataRow()
' Generate the report
Dim oReport = ReportGenerator.GenerateReport(oDocument, CurrentTemplate)
Dim oFilePath = ReportGenerator.GetReportFilePath(oDocument, CurrentTemplate)
If oRow Is Nothing Then
Exit Sub
End If
' Export it to pdf
oReport.ExportToPdf(oFilePath)
Dim oModifiedRow = EditRow(oRow, oView)
If oModifiedRow IsNot Nothing Then
ReloadRow(oModifiedRow)
End If
End Sub
Private Async Function btnLoadFiles_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) As Task Handles btnLoadFiles.ItemClick
Await LoadFiles()
End Function
Private Async Sub btnReloadFile_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnReloadFile.ItemClick
Dim oCurrentMandator As Mandator = TryCast(lookupMandator.EditValue, Mandator)
If oCurrentMandator Is Nothing Then
MsgBox(My.Resources.frmImportMainExtra.Bitte_wählen_Sie_einen_Mandanten_aus__bevor_Sie_fortfahren, MsgBoxStyle.Exclamation, Text)
Exit Sub
End If
Dim oMessage = String.Format(My.Resources.frmImportMainExtra.Wollen_Sie_wirklich_die_aktuelle_Datei_neu_laden, oCurrentMandator)
Dim oResult As DialogResult = MsgBox(oMessage, MsgBoxStyle.Question Or MsgBoxStyle.YesNo, Text)
Try
BeginLoadingUI()
If oResult = DialogResult.Yes Then
Dim oDocument As Document = GridViewFiles.GetRow(GridViewFiles.FocusedRowHandle)
Dim oNewDocument = Await DocumentLoader.LoadFile(oDocument.File, CurrentTemplate, lookupMandator.EditValue)
Dim oIndex = DocumentLoader.Files.IndexOf(oDocument)
DocumentLoader.Files.Item(oIndex) = oNewDocument
LoadDocument(oNewDocument)
End If
Catch ex As NoMandatorException
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Neuladen_des_Dokuments, My.Resources.frmImportMainExtra.Es_konnte_kein_passender_Mandant_ermittelt_werden)
Catch ex As MissingAttributeException
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Neuladen_des_Dokuments, "Ein benötigtes Attribut wurde nicht gefunden.")
Catch ex As Exception
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Neuladen_des_Dokuments)
Finally
EndLoadingUI()
End Try
End Sub
Private Sub btnOpenInputDirectory_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnOpenInputDirectory.ItemClick
FormHelper.TryOpenDirectory(CurrentTemplate.InputDirectory, My.Resources.frmImportMainExtra.Eingangsverzeichnis)
End Sub
Private Sub btnOpenOutputDirectory_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnOpenOutputDirectory.ItemClick
FormHelper.TryOpenDirectory(CurrentTemplate.OutputDirectory, My.Resources.frmImportMainExtra.Ausgabeverzeichnis)
End Sub
Private Sub btnOpenSchemaDirectory_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnOpenSchemaDirectory.ItemClick
FormHelper.TryOpenDirectory(My.GeneralConfiguration.TemplateDirectory, My.Resources.frmImportMainExtra.Vorlagenverzeichnis)
End Sub
Private Sub btnShowXml_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnShowXml.ItemClick
Dim oForm As New frmXmlEditor With {.FileName = CurrentDocument.FullName}
oForm.Show()
End Sub
Private Sub btnRemoveRow_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnRemoveRow.ItemClick
If CurrentGrid Is Nothing Then
Exit Sub
End If
Dim oMessage As String = My.Resources.frmImportMainExtra.Wollen_Sie_die_ausgewählte_Zeile_wirklich_löschen_
If MsgBox(oMessage, MsgBoxStyle.Question Or MsgBoxStyle.YesNo, Text) = MsgBoxResult.Yes Then
' Get GUID of currently selected row
Dim oView As GridView = CurrentGrid.FocusedView
Dim oRow As DataRowView = oView.GetRow(oView.FocusedRowHandle)
Dim oGuid = oRow.Row.Item(COLUMN_GUID)
' Get currently selected document
Dim oDocument As Document = GridViewFiles.GetRow(GridViewFiles.FocusedRowHandle)
Dim oNewRows = oDocument.Rows.
Where(Function(r) r.Id.ToString <> oGuid).
ToList()
oDocument.Rows = oNewRows
Dim oIndex = DocumentLoader.Files.IndexOf(oDocument)
DocumentLoader.Files.Item(oIndex) = oDocument
lookupMandator.EditValue = oDocument.Mandator
LoadDocument(oDocument)
End If
End Sub
Private Sub btnOpenReport_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnOpenReport.ItemClick
Try
If CurrentDocumentReadOnly = True Then
FormHelper.ShowWarning("Bitte wählen Sie zunächst einen Mandanten aus, bevor Sie diese Datei exportieren!")
Exit Sub
End If
SplashScreenManager.ShowWaitForm()
SplashScreenManager.SetWaitFormDescription(My.Resources.frmImportMainExtra.Erstellen_der_Berichtsvorschau)
SetDocumentButtonsEnabled(False)
GridControlFiles.Enabled = False
btnLoadFiles.Enabled = False
SplitContainerGrids.Enabled = False
Dim oDocument As Document = GridViewFiles.GetRow(GridViewFiles.FocusedRowHandle)
Dim oReportGenerator = New ReportGenerator(Of OrderReport)(LogConfig, Database,
My.TemplateConfiguration,
My.GeneralConfiguration)
Dim oReport As OrderReport = oReportGenerator.GenerateReport(oDocument, CurrentTemplate)
Dim oPrintTool As New ReportPrintTool(oReport)
oPrintTool.Report.CreateDocument(False)
oPrintTool.ShowPreview()
SplitContainerGrids.Enabled = True
btnLoadFiles.Enabled = True
GridControlFiles.Enabled = True
SetDocumentButtonsEnabled(True)
SplashScreenManager.CloseWaitForm()
Catch ex As Exception
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Erstellen_der_Berichtsvorschau)
End Try
End Sub
#End Region
#Region "Methods"
Private Sub LoadDocument(pDocument As Document)
Try
@@ -577,6 +581,7 @@ Public Class frmImportMain
Next
txtCurrentFile.Caption = String.Format(My.Resources.frmImportMainExtra.Aktuelle_Datei___0_, pDocument.FileName)
txtErrors.Caption = String.Format("Fehler: {0}", pDocument.Errors.Count)
CurrentDocument = pDocument
@@ -588,6 +593,18 @@ Public Class frmImportMain
btnCalculatePrices.Enabled = True
End If
If CurrentDocument.Mandator Is Nothing Then
RibbonPageGroupEdit.Enabled = False
RibbonPageGroupTransfer.Enabled = False
CurrentDocumentReadOnly = True
MsgBox("Für die aktuelle Datei konnte kein Mandant zugeordnet werden! Bitte wählen Sie einen aus und laden Sie dann die Datei erneut.", MsgBoxStyle.Critical, Text)
Else
RibbonPageGroupEdit.Enabled = True
RibbonPageGroupTransfer.Enabled = True
CurrentDocumentReadOnly = False
End If
Catch ex As Exception
SetDocumentButtonsEnabled(False)
Logger.Error(ex)
@@ -610,17 +627,20 @@ Public Class frmImportMain
Try
BeginLoadingUI()
DocumentCleaner.CleanImportedDocuments(DocumentLoader.Files)
Logger.Debug("Loading [{0}] files", DocumentLoader.Files.Count)
AddHandler DocumentLoader.FileLoadComplete, Sub(_sender As Object, _e As Documents.DocumentLoader.FileLoadInfo)
Dim oMessage = String.Format("Lade Dateien ({0}/{1})", _e.FilesLoaded, _e.FilesTotal)
SplashScreenManager.SetWaitFormDescription(oMessage)
SplashScreenManager.SetWaitFormCaption(oMessage)
End Sub
AddHandler DocumentLoader.FileLoadProgress, Sub(_sender As Object, _e As Documents.DocumentLoader.FileLoadProgressInfo)
Dim oMessage = String.Format("Lade Dateien ({0}/{1}): {2}", _e.FilesLoaded, _e.FilesTotal, _e.RunningFunction)
SplashScreenManager.SetWaitFormDescription(oMessage)
SplashScreenManager.SetWaitFormDescription(_e.RunningFunction)
End Sub
SplashScreenManager.SetWaitFormDescription(String.Format("Lade Dateien ({0}/{1})", 0, DocumentLoader.Files.Count))
SplashScreenManager.SetWaitFormCaption(String.Format("Lade Dateien ({0}/{1})", 0, DocumentLoader.Files.Count))
If Await DocumentLoader.LoadFiles(CurrentTemplate, lookupMandator.EditValue) Then
GridControlFiles.DataSource = Nothing
@@ -639,7 +659,42 @@ Public Class frmImportMain
End Try
End Function
Private Function EditRow(pRow As DataRow, pView As GridView) As DocumentRow
Try
If CurrentDocumentReadOnly = True Then
FormHelper.ShowWarning("Bitte wählen Sie zunächst einen Mandanten aus, bevor Sie diese Datei bearbeiten!")
Return Nothing
End If
Dim oColumns = pView.Columns.Select(Function(c) c.FieldName).ToList()
Dim oDocumentRow = CurrentDocument.Rows.
Where(Function(r) r.Id.ToString = pRow.Item(COLUMN_GUID)).
SingleOrDefault()
Dim oTemplateTable = CurrentTemplate.Tables.
Where(Function(t) t.Name = pView.GridControl.Name).
SingleOrDefault()
Dim oForm As New frmRowEditor(
LogConfig,
oColumns,
oDocumentRow,
CurrentDocument.Mandator,
Winline,
oTemplateTable
)
If oForm.ShowDialog() = DialogResult.OK Then
Return oForm.DocumentRow
Else
Return Nothing
End If
Catch ex As Exception
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Laden_der_Detailzeilen)
Return Nothing
End Try
End Function
Private Async Function TransferFile(pDocument As Document, Optional pIsTest As Boolean = False) As Task(Of Boolean)
' Check for errors and abort
@@ -778,35 +833,16 @@ Public Class frmImportMain
btnEditRow.Enabled = pEnabled
End Sub
Private Async Sub btnCalculatePrices_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnCalculatePrices.ItemClick
Dim oCurrentMandator As Mandator = TryCast(lookupMandator.EditValue, Mandator)
If oCurrentMandator Is Nothing Then
MsgBox(My.Resources.frmImportMainExtra.Bitte_wählen_Sie_einen_Mandanten_aus__bevor_Sie_fortfahren, MsgBoxStyle.Exclamation, Text)
Exit Sub
Private Sub lookupMandator_EditValueChanged(sender As Object, e As EventArgs) Handles lookupMandator.EditValueChanged
If lookupMandator.EditValue Is Nothing Then
lookupMandator.BackColor = Color.LightCoral
Else
lookupMandator.BackColor = Nothing
End If
BeginLoadingUI()
SplashScreenManager.SetWaitFormDescription("Lade Preisinformationen..")
Dim oStopWatch As New Stopwatch()
Try
oStopWatch.Start()
Dim oNewDocument = Await DocumentLoader.MaybeApplyPriceFunctions(CurrentDocument, oCurrentMandator, CurrentTemplate)
oStopWatch.Stop()
DocumentLoader.ReplaceDocument(oNewDocument)
LoadDocument(oNewDocument)
Catch ex As Exception
FormHelper.ShowError(ex, "Laden der Preisinformationen")
Finally
EndLoadingUI()
Logger.Debug("Loading Priceinfo took [{0}] ms", oStopWatch.ElapsedMilliseconds)
End Try
End Sub
Private Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem2.ItemClick
FormHelper.TryOpenDirectory(LogConfig.LogDirectory, My.Resources.frmImportMainExtra.Logverzeichnis)
End Sub
#End Region
End Class