directories per template, export tweaks

This commit is contained in:
Jonathan Jenne
2021-12-22 15:38:05 +01:00
parent 9a3761acc0
commit 79cfec3173
30 changed files with 1158 additions and 257 deletions

View File

@@ -1,10 +1,13 @@
Imports DigitalData.GUIs.Common
Imports DevExpress.XtraEditors
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.Templates
Imports MultiTool.Shared.Winline
Imports MultiTool.Shared.Winline.Entities
Public Class frmExportMain
Private ReadOnly LogConfig As LogConfig
@@ -34,13 +37,19 @@ Public Class frmExportMain
Text = String.Format(My.Resources.frmShared._0____WebService_Multitool_für_WinLine, CurrentTemplate.Name)
Logger = LogConfig.GetLogger()
FormHelper = New FormHelper(LogConfig)
FormHelper = New FormHelper(LogConfig, Me)
' Initialize Database
Dim oConnectionString = MSSQLServer.DecryptConnectionString(ConfigManager.Config.ConnectionString)
Database = New MSSQLServer(LogConfig, oConnectionString)
GridBuilder = New GridBuilder(GridViewDocuments)
Dim oViews As New List(Of GridView) From {
GridViewDocuments,
lookupMandator.Properties.View,
lookupAccount.Properties.View,
lookupDocumentKind.Properties.View
}
GridBuilder = New GridBuilder(oViews)
GridBuilder.
WithDefaults().
WithReadOnlyOptions().
@@ -48,7 +57,7 @@ Public Class frmExportMain
Winline = My.Winline
FileEx = New DigitalData.Modules.Filesystem.File(LogConfig)
WebService = New WebServiceData(LogConfig, My.GeneralConfiguration.Webservice, My.GeneralConfiguration.OutputWebserviceDirectory)
WebService = New WebServiceData(LogConfig, My.GeneralConfiguration.Webservice, My.GeneralConfiguration)
AddHandler WebService.WebServiceProgress, AddressOf WebService_Progress
Catch ex As Exception
@@ -62,35 +71,110 @@ Public Class frmExportMain
lookupMandator.Properties.DataSource = Winline.Mandators
lookupMandator.ForceInitialize()
lookupMandator.Properties.View.BestFitColumns()
lookupAccount.Properties.DataSource = Winline.Accounts
lookupAccount.ForceInitialize()
lookupAccount.Properties.View.BestFitColumns()
lookupDocumentKind.Properties.DataSource = Winline.DocumentKinds
lookupDocumentKind.ForceInitialize()
lookupDocumentKind.Properties.View.BestFitColumns()
Catch ex As Exception
FormHelper.ShowError(ex, "Initialisierung der Form")
End Try
End Sub
Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick
SearchDocuments()
End Sub
Private Sub WebService_Progress(sender As Object, e As String)
SplashScreenManager.SetWaitFormDescription(e)
End Sub
Private Sub lookupMandator_EditValueChanged(sender As Object, e As EventArgs) Handles lookupMandator.EditValueChanged
Dim oMandator As Mandator = lookupMandator.EditValue
lookupAccount.Properties.DataSource = Winline.Accounts.Where(Function(acc) acc.Mandator.Equals(oMandator))
lookupDocumentKind.Properties.DataSource = Winline.DocumentKinds.Where(Function(kind) kind.Mandator.Equals(oMandator))
End Sub
Private Sub lookup_Properties_ButtonClick(sender As Object, e As DevExpress.XtraEditors.Controls.ButtonPressedEventArgs) _
Handles lookupDocumentKind.Properties.ButtonClick, lookupAccount.Properties.ButtonClick
Dim oLookup As GridLookUpEdit = sender
If e.Button.Kind = DevExpress.XtraEditors.Controls.ButtonPredefines.Clear Then
oLookup.EditValue = Nothing
End If
End Sub
Private Sub SearchDocuments()
Try
Dim oMandator = lookupMandator.EditValue
Dim oAccount = lookupAccount.EditValue
Dim oKind = lookupDocumentKind.EditValue
Dim oDateRanges = dateDocDate.SelectedRanges
Dim oShowExported = chkShowExported.Checked
If oMandator Is Nothing Then
FormHelper.ShowWarning("Bitte einen Mandanten auswählen!")
Exit Sub
End If
'TODO: Make Document Type configurable
If oDateRanges.Count > 1 Then
FormHelper.ShowWarning("Bitte nur einen Datumsbereich auswählen!")
Exit Sub
End If
Dim oDocuments = Winline.GetDocuments(oMandator, WinlineData.DocumentType.Order)
Dim oStartDate As Date = Nothing
Dim oEndDate As Date = Nothing
If oDateRanges.Count > 0 Then
Dim oRange = oDateRanges.First()
oStartDate = oRange.StartDate
oEndDate = oRange.EndDate
End If
'TODO: Make Document Type configurable
Dim oDocuments = Winline.GetDocuments(oMandator, CurrentTemplate, WinlineData.DocumentType.Order, New WinlineData.GetDocumentArgs With {
.Account = oAccount,
.Kind = oKind,
.DateFrom = oStartDate,
.DateTo = oEndDate,
.ShowExported = oShowExported
})
GridControlDocuments.DataSource = oDocuments
Console.WriteLine()
txtResults.Caption = String.Format("{0} Ergebnisse", oDocuments.Count)
Catch ex As Exception
FormHelper.ShowError(ex, "Laden der Daten")
End Try
End Sub
Private Sub WebService_Progress(sender As Object, e As String)
Throw New NotImplementedException()
Private Async Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem2.ItemClick
Try
SplashScreenManager.ShowWaitForm()
Dim oDocument As Document = GridViewDocuments.GetRow(GridViewDocuments.FocusedRowHandle)
Dim oMandator As Mandator = lookupMandator.EditValue
Await WebService.ExportDocumentFromWinline(oDocument, CurrentTemplate, oMandator)
Catch ex As Exception
FormHelper.ShowError(ex, "Exportieren der Daten")
Finally
SplashScreenManager.CloseWaitForm()
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
End Class