Add Edit Row Button, Transfer multiple files at once, F5 for Row Editor, Timeout for HTTP Client of 60 seconds
This commit is contained in:
@@ -16,6 +16,7 @@ Imports MultiTool.Shared.Winline.Entities
|
||||
Imports MultiTool.Shared.Constants
|
||||
Imports MultiTool.Shared.Exceptions
|
||||
Imports Document = MultiTool.Shared.Documents.Document
|
||||
Imports DevExpress.XtraGrid.Views.Grid.ViewInfo
|
||||
|
||||
Public Class frmImportMain
|
||||
Public LogConfig As LogConfig
|
||||
@@ -47,19 +48,6 @@ Public Class frmImportMain
|
||||
LogConfig = pLogConfig
|
||||
ConfigManager = pConfigManager
|
||||
CurrentTemplate = pTemplate
|
||||
|
||||
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
|
||||
@@ -132,70 +120,40 @@ Public Class frmImportMain
|
||||
CurrentGrid = sender
|
||||
End Sub
|
||||
|
||||
Private Function CreateGridsAndColumns(pTemplate As Templates.Template) As List(Of GridControl)
|
||||
Dim oGrids As New List(Of GridControl)
|
||||
Dim oTableCounter = 0
|
||||
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)
|
||||
|
||||
For Each oTable In pTemplate.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
|
||||
If Not oHitInfo.InDataRow Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Return oGrids
|
||||
End Function
|
||||
Dim oRow As DataRow = oView.GetFocusedDataRow()
|
||||
|
||||
Private Sub Grid_MouseDoubleClick(sender As Object, e As MouseEventArgs)
|
||||
EditRow(oRow, oView)
|
||||
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
|
||||
|
||||
EditRow(oRow, oView)
|
||||
End Sub
|
||||
|
||||
Private Sub EditRow(pRow As DataRow, pView As GridView)
|
||||
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 oColumns = pView.Columns.Select(Function(c) c.FieldName).ToList()
|
||||
Dim oDocumentRow = CurrentDocument.Rows.
|
||||
Where(Function(r) r.Id.ToString = oRow.Item(COLUMN_GUID)).
|
||||
Where(Function(r) r.Id.ToString = pRow.Item(COLUMN_GUID)).
|
||||
SingleOrDefault()
|
||||
Dim oTemplateTable = CurrentTemplate.Tables.
|
||||
Where(Function(t) t.Name = oGrid.Name).
|
||||
Where(Function(t) t.Name = pView.GridControl.Name).
|
||||
SingleOrDefault()
|
||||
|
||||
Dim oForm As New frmRowEditor(
|
||||
@@ -216,12 +174,14 @@ Public Class frmImportMain
|
||||
' Refresh Files to update Row color
|
||||
GridViewFiles.RefreshData()
|
||||
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
|
||||
LoadFiles()
|
||||
End Sub
|
||||
@@ -292,137 +252,6 @@ Public Class frmImportMain
|
||||
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 CurrentTemplate.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
|
||||
|
||||
' Get the document
|
||||
Dim oDocument As Document = GridViewFiles.GetRow(GridViewFiles.FocusedRowHandle)
|
||||
|
||||
' Check for errors and abort
|
||||
If oDocument.HasErrors = True Then
|
||||
FormHelper.ShowWarning("Diese Datei kann noch nicht übertragen werden, da sie noch Fehler oder fehlende Werte enthält.")
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
' Transfer to winline
|
||||
Dim oTransferResult = Await WebService.TransferDocumentToWinline(oDocument, CurrentTemplate, lookupMandator.EditValue)
|
||||
|
||||
If oTransferResult = True Then
|
||||
|
||||
WebService.RaiseWebServiceProgress("Bericht erzeugen")
|
||||
|
||||
' Generate the report
|
||||
Dim oReport = ReportGenerator.GenerateReport(oDocument)
|
||||
Dim oFilePath = ReportGenerator.GetReportFilePath(oDocument, CurrentTemplate)
|
||||
|
||||
WebService.RaiseWebServiceProgress("Bericht exportieren")
|
||||
|
||||
' Export it to pdf
|
||||
oReport.ExportToPdf(oFilePath)
|
||||
|
||||
WebService.RaiseWebServiceProgress("Datei archivieren")
|
||||
|
||||
' Mark Document as Imported, will be moved on Form Close
|
||||
oDocument.Imported = True
|
||||
End If
|
||||
|
||||
'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
|
||||
@@ -439,24 +268,6 @@ Public Class frmImportMain
|
||||
FormHelper.TryOpenDirectory(My.GeneralConfiguration.TemplateDirectory, 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()
|
||||
@@ -571,30 +382,121 @@ Public Class frmImportMain
|
||||
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
|
||||
BeginLoadingUI()
|
||||
|
||||
' Get the document
|
||||
Dim oDocument As Document = GridViewFiles.GetRow(GridViewFiles.FocusedRowHandle)
|
||||
Await WebService.TransferDocumentToWinline(oDocument, CurrentTemplate, lookupMandator.EditValue, pIsTest:=True)
|
||||
|
||||
MsgBox(My.Resources.frmImportMainExtra.Datei_erfolgreich_in_die_WinLine_übertragen, MsgBoxStyle.Information, Text)
|
||||
' Check for errors and abort
|
||||
If oDocument.HasErrors = True Then
|
||||
FormHelper.ShowWarning("Diese Datei kann noch nicht übertragen werden, da sie noch Fehler oder fehlende Werte enthält.")
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oResult = Await TransferFile(oDocument, pIsTest:=True)
|
||||
If oResult = True Then
|
||||
MsgBox(My.Resources.frmImportMainExtra.Datei_erfolgreich_in_die_WinLine_übertragen, MsgBoxStyle.Information, Text)
|
||||
End If
|
||||
|
||||
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 TaskCanceledException
|
||||
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()
|
||||
EndLoadingUI()
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Async Sub btnTransferFile_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnTransferFile.ItemClick
|
||||
Try
|
||||
BeginLoadingUI()
|
||||
|
||||
' Get the document
|
||||
Dim oDocument As Document = GridViewFiles.GetRow(GridViewFiles.FocusedRowHandle)
|
||||
|
||||
' Check for errors and abort
|
||||
If oDocument.HasErrors = True Then
|
||||
FormHelper.ShowWarning("Diese Datei kann noch nicht übertragen werden, da sie noch Fehler oder fehlende Werte enthält.")
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oResult = Await TransferFile(oDocument, pIsTest:=False)
|
||||
If oResult = True Then
|
||||
MsgBox(My.Resources.frmImportMainExtra.Datei_erfolgreich_in_die_WinLine_übertragen, MsgBoxStyle.Information, Text)
|
||||
End If
|
||||
|
||||
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 TaskCanceledException
|
||||
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
|
||||
EndLoadingUI()
|
||||
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Async Sub btnTransferAllFiles_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnTransferAllFiles.ItemClick
|
||||
Try
|
||||
BeginLoadingUI()
|
||||
|
||||
' Get the documents
|
||||
Dim oSelectedRows = GridViewFiles.GetSelectedRows()
|
||||
|
||||
If oSelectedRows.Length = 0 Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oDocuments As List(Of Document) = oSelectedRows.
|
||||
Select(Of Document)(Function(rowHandle) GridViewFiles.GetRow(rowHandle)).
|
||||
ToList()
|
||||
|
||||
Dim oFailedDocuments As New List(Of String)
|
||||
Dim oSuccessfulDocuments As Integer = 0
|
||||
|
||||
For Each oDocument As Document In oDocuments
|
||||
Try
|
||||
Await TransferFile(oDocument)
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
oFailedDocuments.Add(ex.Message)
|
||||
|
||||
End Try
|
||||
Next
|
||||
|
||||
oSuccessfulDocuments = oDocuments.Count - oFailedDocuments.Count
|
||||
|
||||
If oSuccessfulDocuments > 0 Then
|
||||
Dim oMessage = String.Format(My.Resources.frmImportMainExtra._0__Dateien_erfolgreich_in_die_Winline_übertragen_, oSuccessfulDocuments)
|
||||
MsgBox(oMessage, MsgBoxStyle.Information, Text)
|
||||
End If
|
||||
|
||||
If oFailedDocuments.Count > 0 Then
|
||||
Dim oErrorMessages = String.Join(vbNewLine, oFailedDocuments)
|
||||
Dim oMessage = String.Format("Für {0} Dateien ist die Übertragung in die Winline fehlgeschlagen. Folgende Fehler sind aufgetreten: {2}{1}", oFailedDocuments.Count, oErrorMessages, vbNewLine)
|
||||
MsgBox(oMessage, MsgBoxStyle.Exclamation, Text)
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Übertragung_zur_WinLine)
|
||||
|
||||
Finally
|
||||
EndLoadingUI()
|
||||
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -610,13 +512,75 @@ Public Class frmImportMain
|
||||
oReport.ExportToPdf(oFilePath)
|
||||
End Sub
|
||||
|
||||
#Region "Methods"
|
||||
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 CurrentTemplate.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 LoadFiles()
|
||||
Try
|
||||
SplashScreenManager.ShowWaitForm()
|
||||
SetDocumentButtonsEnabled(False)
|
||||
GridControlFiles.Enabled = False
|
||||
btnLoadFiles.Enabled = False
|
||||
SplitContainerGrids.Enabled = False
|
||||
BeginLoadingUI()
|
||||
|
||||
AddHandler DocumentLoader.FileLoadComplete, Sub(_sender As Object, _e As Documents.DocumentLoader.FileLoadInfo)
|
||||
Dim oMessage = String.Format("Lade Dateien ({0}/{1})", _e.FilesLoaded, _e.FilesTotal)
|
||||
@@ -636,11 +600,138 @@ Public Class frmImportMain
|
||||
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Laden_der_Dokumente)
|
||||
|
||||
Finally
|
||||
SplitContainerGrids.Enabled = True
|
||||
btnLoadFiles.Enabled = True
|
||||
GridControlFiles.Enabled = True
|
||||
SetDocumentButtonsEnabled(True)
|
||||
SplashScreenManager.CloseWaitForm()
|
||||
EndLoadingUI()
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Async Function TransferFile(pDocument As Document, Optional pIsTest As Boolean = False) As Task(Of Boolean)
|
||||
' Check for errors and abort
|
||||
If pDocument.HasErrors = True Then
|
||||
FormHelper.ShowWarning("Diese Datei kann noch nicht übertragen werden, da sie noch Fehler oder fehlende Werte enthält.")
|
||||
Return False
|
||||
End If
|
||||
|
||||
Dim oResult = Await WebService.TransferDocumentToWinline(pDocument, CurrentTemplate, lookupMandator.EditValue, pIsTest)
|
||||
|
||||
If oResult = True Then
|
||||
|
||||
' If this was only a test, we are done.
|
||||
If pIsTest = True Then
|
||||
Return True
|
||||
End If
|
||||
|
||||
WebService.RaiseWebServiceProgress("Bericht erzeugen")
|
||||
|
||||
' Generate the report
|
||||
Dim oReport = ReportGenerator.GenerateReport(pDocument)
|
||||
Dim oFilePath = ReportGenerator.GetReportFilePath(pDocument, CurrentTemplate)
|
||||
|
||||
WebService.RaiseWebServiceProgress("Bericht exportieren")
|
||||
|
||||
' Export it to pdf
|
||||
oReport.ExportToPdf(oFilePath)
|
||||
|
||||
WebService.RaiseWebServiceProgress("Datei archivieren")
|
||||
|
||||
' Mark Document as Imported, will be moved on Form Close
|
||||
pDocument.Imported = True
|
||||
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Function CreateGridsAndColumns(pTemplate As Templates.Template) As List(Of GridControl)
|
||||
Dim oGrids As New List(Of GridControl)
|
||||
Dim oTableCounter = 0
|
||||
|
||||
For Each oTable In pTemplate.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 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 BeginLoadingUI()
|
||||
SplashScreenManager.ShowWaitForm()
|
||||
SetDocumentButtonsEnabled(False)
|
||||
GridControlFiles.Enabled = False
|
||||
btnLoadFiles.Enabled = False
|
||||
SplitContainerGrids.Enabled = False
|
||||
End Sub
|
||||
|
||||
Private Sub EndLoadingUI()
|
||||
SplitContainerGrids.Enabled = True
|
||||
btnLoadFiles.Enabled = True
|
||||
GridControlFiles.Enabled = True
|
||||
SetDocumentButtonsEnabled(True)
|
||||
SplashScreenManager.CloseWaitForm()
|
||||
End Sub
|
||||
|
||||
Private Sub SetDocumentButtonsEnabled(pEnabled As Boolean)
|
||||
btnShowXml.Enabled = pEnabled
|
||||
btnReloadFile.Enabled = pEnabled
|
||||
btnTransferFile.Enabled = pEnabled
|
||||
btnRemoveRow.Enabled = pEnabled
|
||||
btnOpenReport.Enabled = pEnabled
|
||||
btnTransferAllFiles.Enabled = pEnabled
|
||||
btnEditRow.Enabled = pEnabled
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
End Class
|
||||
Reference in New Issue
Block a user