MultiTool/MultiTool.Form/frmImportMain.vb
Jonathan Jenne ee23cdd7e8 WIP
2021-11-19 13:53:38 +01:00

643 lines
27 KiB
VB.net

Imports System.IO
Imports System.Net.Http
Imports System.Xml
Imports DevExpress.Utils.Behaviors.Common
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Grid
Imports DigitalData.GUIs.Common
Imports DigitalData.Modules.Config
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Imports MultiTool.Shared
Imports MultiTool.Shared.Documents
Imports MultiTool.Shared.Schemas
Imports MultiTool.Shared.Winline
Imports MultiTool.Shared.Constants
Imports MultiTool.Shared.Exceptions
Imports DevExpress.XtraReports.UI
Imports MultiTool.Shared.Documents.DocumentRow
Public Class frmImportMain
Public LogConfig As LogConfig
Public ConfigManager As ConfigManager(Of Config)
Private Logger As Logger
Private Database As MSSQLServer
Private Winline As WinlineData
Private FileEx As DigitalData.Modules.Filesystem.File
Private WebService As WebService
Private DocumentLoader As DocumentLoader
Private FormHelper As FormHelper
Private Grids As List(Of GridControl)
Private GridLoader As GridLoader
Private GridBuilder As GridBuilder
Private ReadOnly CurrentSchema As Schema = Nothing
' Runtime variables
Private CurrentGrid As GridControl = Nothing
Private CurrentDocument As Document = Nothing
Public Sub New(pLogConfig As LogConfig, pConfigManager As ConfigManager(Of Config), pSchema As Schema)
InitializeComponent()
LogConfig = pLogConfig
ConfigManager = pConfigManager
CurrentSchema = pSchema
BehaviorManager.Attach(Of PersistenceBehavior)(Me, AddressOf LoadPersistenceSettings)
End Sub
Protected Overrides Sub OnLoad(e As EventArgs)
GridControlFiles.ForceInitialize()
MyBase.OnLoad(e)
End Sub
Private Sub LoadPersistenceSettings(pBehaviour As PersistenceBehavior)
pBehaviour.Properties.StoreChildLayouts = DevExpress.Utils.DefaultBoolean.True
pBehaviour.Properties.Storage = Storage.File
pBehaviour.Properties.Path = Application.UserAppDataPath
End Sub
Private Sub frmImportMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
Logger = LogConfig.GetLogger()
FormHelper = New FormHelper(LogConfig)
' Initialize Database
Dim oConnectionString = MSSQLServer.DecryptConnectionString(ConfigManager.Config.ConnectionString)
Database = New MSSQLServer(LogConfig, oConnectionString)
GridBuilder = New GridBuilder(GridViewFiles)
GridBuilder.WithDefaults.WithReadOnlyOptions.WithClipboardHandler()
GridViewFiles.OptionsView.ShowAutoFilterRow = False
FileEx = New DigitalData.Modules.Filesystem.File(LogConfig)
Winline = New WinlineData(LogConfig, Database, ConfigManager.Config)
WebService = New WebService(LogConfig, ConfigManager.Config, Application.UserAppDataPath)
AddHandler WebService.WebServiceProgress, AddressOf WebService_Progress
Catch ex As Exception
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Initialisieren_der_Anwendungs_Daten)
End Try
txtVersion.Caption = String.Format(My.Resources.frmImportMainExtra.Version__0_, My.Application.Info.Version.ToString)
txtCulture.Caption = String.Format(My.Resources.frmImportMainExtra.Culture___0_, My.Application.UICulture.ToString)
Text = String.Format(My.Resources.frmShared._0____WebService_Multitool_für_WinLine, CurrentSchema.Name)
End Sub
Private Async Sub frmImportMain_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
btnLoadFiles.Enabled = False
SplashScreenManager.ShowWaitForm()
' Load WinLine Data
Try
SplashScreenManager.SetWaitFormDescription("Lade Basisdaten")
Winline.Mandators.Clear()
Winline.LoadEconomicYears()
Await Winline.LoadMandators()
For Each oMandator As Mandator In Winline.Mandators
SplashScreenManager.SetWaitFormDescription(String.Format(My.Resources.frmImportMainExtra.Lade__0__Konten, oMandator.Id))
Await Winline.LoadAccounts(oMandator)
SplashScreenManager.SetWaitFormDescription(String.Format(My.Resources.frmImportMainExtra.Lade__0__Artikel, oMandator.Id))
Await Winline.LoadArticles(oMandator)
SplashScreenManager.SetWaitFormDescription(String.Format(My.Resources.frmImportMainExtra.Lade__0__Belegarten, oMandator.Id))
Await Winline.LoadDocumentKinds(oMandator)
Next
SplashScreenManager.SetWaitFormDescription(My.Resources.frmImportMainExtra.Lade_Oberfläche)
lookupMandator.Properties.DataSource = Winline.Mandators
lookupMandator.ForceInitialize()
lookupMandator.Properties.View.BestFitColumns()
DocumentLoader = New DocumentLoader(LogConfig, Winline)
GridLoader = New GridLoader(LogConfig)
SplashScreenManager.SetWaitFormDescription(My.Resources.frmImportMainExtra.Lade_Vorlagen)
'SchemaLoader.LoadFiles(ConfigManager.Config.SchemaDirectory)
'CurrentSchemaName = SchemaLoader.SchemaList.First().FullName
'CurrentSchema = SchemaLoader.GetSchemaFromFile(CurrentSchemaName)
'CurrentSchema = SchemaLoader.UpdateSchemaWithDatabaseConfiguration(CurrentSchema, SchemaLoader.TemplateConfiguration)
Grids = CreateGridsAndColumns(CurrentSchema)
For Each oGrid As GridControl In Grids
AddHandler oGrid.GotFocus, AddressOf Grid_Focus
Next
Catch ex As Exception
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Laden_der_Winline_Daten)
Finally
SplashScreenManager.CloseWaitForm()
btnLoadFiles.Enabled = True
End Try
End Sub
Private Sub Grid_Focus(sender As GridControl, e As EventArgs)
CurrentGrid = sender
End Sub
Private Function CreateGridsAndColumns(pSchema As Schemas.Schema) As List(Of GridControl)
Dim oGrids As New List(Of GridControl)
Dim oTableCounter = 0
For Each oTable In pSchema.Tables
If oTableCounter = 0 Then
Dim oGrid = GridLoader.GetGridFromElement(GridControl1, oTable)
AddHandler oGrid.DoubleClick, AddressOf Grid_MouseDoubleClick
AddHandler GridView1.CustomDrawCell, AddressOf GridView_CustomDrawCell
oGrids.Add(oGrid)
End If
If oTableCounter = 1 Then
Dim oGrid = GridLoader.GetGridFromElement(GridControl2, oTable)
AddHandler oGrid.DoubleClick, AddressOf Grid_MouseDoubleClick
AddHandler GridView2.CustomDrawCell, AddressOf GridView_CustomDrawCell
oGrids.Add(oGrid)
End If
If oTableCounter = 2 Then
Dim oGrid = GridLoader.GetGridFromElement(GridControl3, oTable)
AddHandler oGrid.DoubleClick, AddressOf Grid_MouseDoubleClick
AddHandler GridView3.CustomDrawCell, AddressOf GridView_CustomDrawCell
oGrids.Add(oGrid)
End If
If oTableCounter = 3 Then
Dim oGrid = GridLoader.GetGridFromElement(GridControl4, oTable)
AddHandler oGrid.DoubleClick, AddressOf Grid_MouseDoubleClick
AddHandler GridView4.CustomDrawCell, AddressOf GridView_CustomDrawCell
oGrids.Add(oGrid)
End If
If oTableCounter > 3 Then
MsgBox(My.Resources.frmImportMainExtra.Zur_Zeit_werden_nur_bis_zu_4_Tabellen_unterstützt_, MsgBoxStyle.Exclamation, Text)
End If
oTableCounter += 1
Next
If oTableCounter < 3 Then
SplitContainerGrids.PanelVisibility = DevExpress.XtraEditors.SplitPanelVisibility.Panel1
End If
Return oGrids
End Function
Private Sub Grid_MouseDoubleClick(sender As Object, e As MouseEventArgs)
Try
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.GetDataRow(oView.FocusedRowHandle)
Dim oColumns = oView.Columns.Select(Function(c) c.FieldName).ToList()
Dim oDocumentRow = CurrentDocument.Rows.
Where(Function(r) r.Id.ToString = oRow.Item(COLUMN_GUID)).
SingleOrDefault()
Dim oSchemaTable = CurrentSchema.Tables.
Where(Function(t) t.Name = oGrid.Name).
SingleOrDefault()
Dim oForm As New frmRowEditor(
LogConfig,
oColumns,
oDocumentRow,
CurrentDocument.Mandator,
Winline,
oSchemaTable
)
If oForm.ShowDialog() = DialogResult.OK Then
Dim oModifiedRow = oForm.DocumentRow
Dim oIndex = CurrentDocument.Rows.IndexOf(oModifiedRow)
CurrentDocument.Rows.Item(oIndex) = oModifiedRow
LoadDocument(CurrentDocument)
End If
Catch ex As Exception
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Laden_der_Detailzeilen)
End Try
End Sub
Private Sub btnLoadFiles_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnLoadFiles.ItemClick
Try
SplashScreenManager.ShowWaitForm()
SetDocumentButtonsEnabled(False)
GridControlFiles.Enabled = False
btnLoadFiles.Enabled = False
SplitContainerGrids.Enabled = False
AddHandler DocumentLoader.FileLoadComplete, Sub(_sender As Object, _e As DocumentLoader.FileLoadInfo)
Dim oMessage = String.Format("Lade Dateien ({0}/{1})", _e.FilesLoaded, _e.FilesTotal)
SplashScreenManager.SetWaitFormDescription(oMessage)
End Sub
If DocumentLoader.LoadFiles(ConfigManager.Config.InputDirectory, CurrentSchema, lookupMandator.EditValue) Then
GridControlFiles.DataSource = Nothing
GridControlFiles.DataSource = DocumentLoader.Files
txtFilesLoaded.Caption = String.Format(My.Resources.frmImportMainExtra._0__Dateien_geladen, DocumentLoader.Files.Count)
End If
Catch ex As NoMandatorException
MsgBox(My.Resources.frmImportMainExtra.Es_konnte_kein_passender_Mandant_ermittelt_werden, MsgBoxStyle.Information, Text)
Catch ex As Exception
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Laden_der_Dokumente)
Finally
SplitContainerGrids.Enabled = True
btnLoadFiles.Enabled = True
GridControlFiles.Enabled = True
SetDocumentButtonsEnabled(True)
SplashScreenManager.CloseWaitForm()
End Try
End Sub
Private 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
If oResult = DialogResult.Yes Then
Dim oDocument As Document = GridViewFiles.GetRow(GridViewFiles.FocusedRowHandle)
Dim oNewDocument = DocumentLoader.LoadFile(oDocument.File, CurrentSchema, 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)
End Try
End Sub
Private Sub GridViewFiles_FocusedRowChanged(sender As Object, e As Views.Base.FocusedRowChangedEventArgs) Handles GridViewFiles.FocusedRowChanged
Try
Dim oDocument As Document = GridViewFiles.GetRow(e.FocusedRowHandle)
If oDocument Is Nothing Then
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 LoadDocument(pDocument As Document)
Try
Dim oDatasources As New Dictionary(Of String, DataTable)
' Reset datasource so that all data will be refreshed
For Each oGrid In Grids
oGrid.DataSource = Nothing
Next
' Create initial Datatable for each Root Element
For Each oTable In CurrentSchema.Tables
Dim oDataTable As New DataTable()
' This is makes it possible to fetch the DocumentRow later
oDataTable.Columns.Add(New DataColumn(COLUMN_GUID))
For Each oColumn In oTable.Columns
oDataTable.Columns.Add(New DataColumn(oColumn.Name))
Next
oDatasources.Add(oTable.Name, oDataTable)
Next
' List of Root Elements in XML
For Each oRow In pDocument.Rows
' Grab grid for the current DocumentRow
Dim oGrid As GridControl = Grids.
Where(Function(g) g.Name = oRow.Name).
SingleOrDefault()
' Grab table for the current DocumentRow and create new row
Dim oDataTable As DataTable = oDatasources.Item(oRow.Name)
Dim oDataRow = oDataTable.NewRow()
' Assign the Guid of the DocumentRow
oDataRow.Item(COLUMN_GUID) = oRow.Id.ToString
' Set values for the current row
For Each oField In oRow.Fields
If oDataTable.Columns.Contains(oField.Key) Then
oDataRow.Item(oField.Key) = oField.Value
Else
Logger.Warn("Element [{0}] from files does not exist in Schema. Skipping.", oField.Key)
End If
Next
' Add row to the current table
oDataTable.Rows.Add(oDataRow)
oDataTable.AcceptChanges()
' Finally load data into grid
oGrid.DataSource = oDataTable
Next
txtCurrentFile.Caption = String.Format(My.Resources.frmImportMainExtra.Aktuelle_Datei___0_, pDocument.FileName)
CurrentDocument = pDocument
SetDocumentButtonsEnabled(True)
Catch ex As Exception
SetDocumentButtonsEnabled(False)
Logger.Error(ex)
Throw ex
End Try
End Sub
Private Sub SetDocumentButtonsEnabled(pEnabled As Boolean)
btnShowXml.Enabled = pEnabled
btnReloadFile.Enabled = pEnabled
btnTransferFile.Enabled = pEnabled
btnRemoveRow.Enabled = pEnabled
btnOpenReport.Enabled = pEnabled
' TODO: Implement all file transfer first
' btnTransferAllFiles.Enabled = pEnabled
End Sub
Private Async Sub btnTransferFile_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnTransferFile.ItemClick
Try
SplashScreenManager.ShowWaitForm()
SetDocumentButtonsEnabled(False)
GridControlFiles.Enabled = False
btnLoadFiles.Enabled = False
SplitContainerGrids.Enabled = False
Dim oDocument As Document = GridViewFiles.GetRow(GridViewFiles.FocusedRowHandle)
Await WebService.TransferDocumentToWinline(oDocument, lookupMandator.EditValue)
MsgBox(My.Resources.frmImportMainExtra.Datei_erfolgreich_in_die_WinLine_übertragen, MsgBoxStyle.Information, Text)
Catch ex As HttpRequestException
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Übertragung_zur_WinLine, My.Resources.frmImportMainExtra.Die_Verbindung_zum_WinLine_Server_ist_fehlgeschlagen)
Catch ex As Exception
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Übertragung_zur_WinLine)
Finally
SplitContainerGrids.Enabled = True
btnLoadFiles.Enabled = True
GridControlFiles.Enabled = True
SetDocumentButtonsEnabled(True)
SplashScreenManager.CloseWaitForm()
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
TryOpenDirectory(ConfigManager.Config.InputDirectory, My.Resources.frmImportMainExtra.Eingangsverzeichnis)
End Sub
Private Sub btnOpenOutputDirectory_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnOpenOutputDirectory.ItemClick
Dim oOutputDirectory = Path.Combine(Application.UserAppDataPath, "WebService")
TryOpenDirectory(oOutputDirectory, My.Resources.frmImportMainExtra.Ausgabeverzeichnis)
End Sub
Private Sub btnOpenSchemaDirectory_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnOpenSchemaDirectory.ItemClick
TryOpenDirectory(ConfigManager.Config.SchemaDirectory, My.Resources.frmImportMainExtra.Vorlagenverzeichnis)
End Sub
Private Sub TryOpenDirectory(pPath As String, pDisplayName As String)
If Directory.Exists(pPath) Then
Process.Start(pPath)
Else
Dim oMessage = String.Format(My.Resources.frmImportMainExtra._0__nicht_konfiguriert_oder_nicht_gefunden, pDisplayName)
MsgBox(oMessage, MsgBoxStyle.Exclamation, Text)
End If
End Sub
Private Sub TryOpenFile(pPath As String, pDisplayName As String)
If File.Exists(pPath) Then
Process.Start(pPath)
Else
Dim oMessage = String.Format(My.Resources.frmImportMainExtra._0__nicht_konfiguriert_oder_nicht_gefunden, pDisplayName)
MsgBox(oMessage, MsgBoxStyle.Exclamation, Text)
End If
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 oPrintTool As ReportPrintTool = GenerateReport(oDocument)
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
Private Function GenerateReport(pDocument As Document) As ReportPrintTool
Dim oPrintTool As ReportPrintTool = Nothing
Dim oMapperConfig As New Mapper(LogConfig)
Dim oHeadMapper = oMapperConfig.GetMapper(Of ReportHead)(New Dictionary(Of String, String) From {
{"Fakt_Kontonummer[External]", "Text1"},
{"Fakt_Kontonummer[Final]", "Text2"},
{"Auftrags-Bestellnummer", "Text3"},
{"Datum_Auftrag-Bestellung", "Text4"},
{"Bestellt_von", "Text5"}
})
Dim oPositionMapper = oMapperConfig.GetMapper(Of ReportPosition)(New Dictionary(Of String, String) From {
{"Artikelnummer", "Text1"},
{"Lieferantenartikelnummer", "Text2"},
{"Menge_bestellt", "Text4"},
{"Menge_geliefert", "Text5"},
{"Colli", "Text6"},
{"Einzelpreis[Original]", "Text7"},
{"Einzelpreis[Final]", "Text8"},
{"Umsatzsteuerprozent_Zeile", "Text9"}
})
Dim oHeadRow = pDocument.Rows.
Where(Function(r) r.Name.EndsWith("T025")).
Select(Function(r) r.Fields).
FirstOrDefault()
Dim oPositionRows = pDocument.Rows.
Where(Function(r) r.Name.EndsWith("T026")).
ToList()
Dim oReportHead = oHeadMapper.Map(Of Dictionary(Of String, FieldValue), ReportHead)(oHeadRow)
oReportHead.Title = "EDI Bestellung (orders)"
oReportHead.Subtitle = "Schaum"
oReportHead.Filename = pDocument.FileName
Dim oReportPositions As New List(Of ReportPosition)
Dim oCounter = 1
For Each oRow As DocumentRow In oPositionRows
Dim oReportPosition As ReportPosition = oPositionMapper.Map(Of Dictionary(Of String, FieldValue), ReportPosition)(oRow.Fields)
oReportPosition.Id = oCounter
oReportPositions.Add(oReportPosition)
oCounter += 1
Next
Dim oReportSource As New ReportSource With {
.Head = oReportHead,
.Positions = oReportPositions
}
Dim oReport As New OrderReport
Dim oDataSource = New DevExpress.DataAccess.ObjectBinding.ObjectDataSource With {
.DataSource = oReportSource
}
oDataSource.Fill()
oReport.DataSource = oDataSource
oPrintTool = New ReportPrintTool(oReport)
oPrintTool.Report.CreateDocument(False)
Return oPrintTool
End Function
Private Sub GridViewFiles_CustomDrawCell(sender As Object, e As Views.Base.RowCellCustomDrawEventArgs) Handles GridViewFiles.CustomDrawCell
Dim oDocument As Document = GridViewFiles.GetRow(e.RowHandle)
If oDocument.HasErrors Then
e.Appearance.Options.UseBackColor = True
e.Appearance.BackColor = Color.LightCoral
End If
End Sub
Private Sub GridView_CustomDrawCell(sender As Object, e As Views.Base.RowCellCustomDrawEventArgs)
Dim oView As GridView = sender
If e.RowHandle < 0 Or CurrentDocument Is Nothing Then
Exit Sub
End If
Dim oObject As DataRowView = oView.GetRow(e.RowHandle)
Dim oGuid = oObject.Row.Item(COLUMN_GUID)
Dim oRow As DocumentRow = CurrentDocument.Rows.
Where(Function(r) r.Id.ToString = oGuid).
SingleOrDefault()
If oRow Is Nothing Then
Exit Sub
End If
If oRow.HasErrors Then
e.Appearance.Options.UseBackColor = True
e.Appearance.BackColor = Color.LightCoral
End If
End Sub
Private Async Sub btnTestTransferFile_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnTestTransferFile.ItemClick
Try
SplashScreenManager.ShowWaitForm()
SetDocumentButtonsEnabled(False)
GridControlFiles.Enabled = False
btnLoadFiles.Enabled = False
SplitContainerGrids.Enabled = False
Dim oDocument As Document = GridViewFiles.GetRow(GridViewFiles.FocusedRowHandle)
Await WebService.TransferDocumentToWinline(oDocument, lookupMandator.EditValue, pIsTest:=True)
MsgBox(My.Resources.frmImportMainExtra.Datei_erfolgreich_in_die_WinLine_übertragen, MsgBoxStyle.Information, Text)
Catch ex As HttpRequestException
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Übertragung_zur_WinLine, My.Resources.frmImportMainExtra.Die_Verbindung_zum_WinLine_Server_ist_fehlgeschlagen)
Catch ex As Exception
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Übertragung_zur_WinLine)
Finally
SplitContainerGrids.Enabled = True
btnLoadFiles.Enabled = True
GridControlFiles.Enabled = True
SetDocumentButtonsEnabled(True)
SplashScreenManager.CloseWaitForm()
End Try
End Sub
End Class