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

@ -63,6 +63,10 @@
ArticleNotFound
End Enum
Public Enum DocumentError
MandatorNotFound
End Enum
Public Enum XmlFunction
None = 0
GLN = 1

View File

@ -1,4 +1,5 @@
Imports System.IO
Imports MultiTool.Common.Constants
Imports MultiTool.Common.Templates
Imports MultiTool.Common.Winline.Entities
@ -27,6 +28,18 @@ Namespace Documents
End Get
End Property
Public ReadOnly Property Errors As List(Of String)
Get
Dim oRowErrors = Rows.SelectMany(Function(row) row.Errors).ToList()
Dim oDocumentErrors As List(Of String) = GetDocumentErrors().
Select(Function(err) err.ToString()).
ToList()
Return oDocumentErrors.
Concat(oRowErrors).
ToList()
End Get
End Property
Public ReadOnly Property MandatorId As String
Get
Return Mandator?.Id
@ -69,6 +82,17 @@ Namespace Documents
Public Overrides Function Equals(obj As Object) As Boolean
Return FullName = DirectCast(obj, Document).FullName
End Function
Private Function GetDocumentErrors() As List(Of DocumentError)
Dim oErrors As New List(Of DocumentError)
If Mandator Is Nothing Then
oErrors.Add(DocumentError.MandatorNotFound)
End If
Return oErrors
End Function
End Class
End Namespace

View File

@ -22,11 +22,23 @@ Namespace Documents
Where(Function(doc) doc.Imported = True).
ToList()
If oImportedDocuments.Count = 0 Then
Logger.Debug("No exported files found. Skipping.")
Return True
End If
Logger.Debug("Cleaning [{0}] exported files, moving to [{1}]", oImportedDocuments.Count, oOutputDirectory)
Dim oRemovedDocuments As New List(Of Document)
For Each oDocument As Document In oImportedDocuments
Try
Dim oFileinfo = New FileInfo(oDocument.FullName)
Dim oDestination = Path.Combine(oOutputDirectory, oFileinfo.Name)
File.Move(oFileinfo.FullName, oDestination)
oRemovedDocuments.Add(oDocument)
Logger.Debug("File [{0}] successfully moved.", oFileinfo.Name)
Catch ex As Exception
Logger.Warn("File [{0}] could not be moved to output directory!", oDocument.FullName)
Logger.Error(ex)
@ -34,6 +46,12 @@ Namespace Documents
End Try
Next
Logger.Debug("Moved [{0}] files successfully.", oRemovedDocuments.Count)
pDocuments = pDocuments.
Except(oRemovedDocuments).
ToList()
Return oResult
End Function
End Class

View File

@ -314,6 +314,10 @@ Namespace Documents
Dim oFunctionName = oColumn.Config.FunctionName
Dim oFunctionParams = oColumn.Config.FunctionParams
Logger.Debug("Running Function: [{0}]", oFunctionName)
Logger.Debug("With Parameters: [{0}]", oFunctionParams)
Dim oParamsDict = ParseFunctionParamsAsDict(oFunctionParams)
If oFunctionName = Constants.FUNCTION_PRICE Then
@ -468,13 +472,26 @@ Namespace Documents
Dim oPriceItem As DocumentRow.FieldValue = pRow.Fields.GetOrDefault(pPriceField)
' These fields are fetched from the current row
Dim oArticleNumberField As String = oFieldMap.GetOrDefault("Article", Nothing)
Const PARAMETER_ARTICLE = "Article"
Dim oArticleNumberField As String = oFieldMap.GetOrDefault(PARAMETER_ARTICLE, Nothing)
If oArticleNumberField Is Nothing Then
Logger.Warn("Parameter '{0}' not found for Function PRICE", PARAMETER_ARTICLE)
End If
If pRow.Fields.ContainsKey(oArticleNumberField) = False Then
Logger.Warn("Value '{0}' for Parameter '{1}' not found for Function PRICE", oArticleNumberField, PARAMETER_ARTICLE)
End If
Dim oArticleNumber As String = pRow.Fields.Item(oArticleNumberField).Final
Dim oQuantityField As String = oFieldMap.GetOrDefault("Quantity", Nothing)
Const PARAMETER_QUANTITY = "Quantity"
Dim oQuantityField As String = oFieldMap.GetOrDefault(PARAMETER_QUANTITY, Nothing)
If oQuantityField Is Nothing Then
Logger.Warn("Parameter '{0}' not found for Function PRICE", PARAMETER_QUANTITY)
End If
Dim oQuantity As Integer = 1
If Integer.TryParse(pRow.Fields.Item(oQuantityField).Final, oQuantity) = False Then
Logger.Warn("Value for parameter Quantity could not be parsed. Setting to 1.")
Logger.Warn("Value for parameter '{0}' could not be parsed. Setting to 1.", PARAMETER_QUANTITY)
End If
' These fields a fetched from the head row, ie. the first row

View File

@ -39,7 +39,7 @@ Namespace Documents
Get
Return Fields.
Where(Function(f) f.Value.HasError).
Select(Function(f) f.Key).ToList()
Select(Function(f) $"{f.Key} has Error: {f.Value.Error}").ToList()
End Get
End Property
@ -56,7 +56,7 @@ Namespace Documents
Private _External As String = ""
Private _Original As String = ""
Public Property DataType As Constants.ColumnType = Constants.ColumnType.String
Public Property DataType As ColumnType = ColumnType.String
Public Property [Error] As FieldError = FieldError.None
Public Sub New()
@ -117,7 +117,7 @@ Namespace Documents
Return Final
End Function
Private Function FormatValue(pValue As String, pType As Constants.ColumnType) As String
Private Function FormatValue(pValue As String, pType As ColumnType) As String
Select Case pType
Case ColumnType.Decimal
Return FormatDecimalValue(pValue)
@ -131,11 +131,11 @@ Namespace Documents
''' This function will capture values like below and format them according to winline format values
'''
''' 1000
''' 1.000.000
''' 1.000.000,00
''' 1.000
''' 1.000,00
''' </summary>
''' <param name="pValue">A string value that represents a number</param>
''' <returns>A string value which contains at dot (.) as the decimal divider</returns>
''' <returns>A string value which contains at dot (.) as the decimal divider, ex. 1000.00</returns>
Private Function FormatDecimalValue(pValue As String) As String
If Not pValue.Contains(","c) Then
Return pValue

View File

@ -338,6 +338,7 @@
<ItemGroup>
<Content Include="CREATE_DATABASE.sql" />
<Content Include="MultiTool.ico" />
<None Include="Resources\highimportance.svg" />
<None Include="Resources\refreshpivottable.svg" />
<None Include="Resources\update.svg" />
<None Include="Resources\actions_reload1.svg" />

View File

@ -360,6 +360,16 @@ Namespace My.Resources
End Get
End Property
'''<summary>
''' Sucht eine lokalisierte Ressource vom Typ DevExpress.Utils.Svg.SvgImage.
'''</summary>
Friend ReadOnly Property highimportance() As DevExpress.Utils.Svg.SvgImage
Get
Dim obj As Object = ResourceManager.GetObject("highimportance", resourceCulture)
Return CType(obj,DevExpress.Utils.Svg.SvgImage)
End Get
End Property
'''<summary>
''' Sucht eine lokalisierte Ressource vom Typ DevExpress.Utils.Svg.SvgImage.
'''</summary>

View File

@ -142,6 +142,9 @@
<data name="tilelabels" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\tilelabels.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="refreshpivottable" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\refreshpivottable.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="squarified1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\squarified1.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
@ -196,9 +199,6 @@
<data name="open3" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\open3.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="bo_sale" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\bo_sale.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="actions_checkcircled" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\actions_checkcircled.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
@ -220,6 +220,9 @@
<data name="actions_send1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\actions_send1.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="actions_send4" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\actions_send4.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="actions_send2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\actions_send2.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
@ -235,6 +238,9 @@
<data name="open23" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\open23.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="insertpagecount" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\insertpagecount.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="actions_reload1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\actions_reload1.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
@ -268,9 +274,6 @@
<data name="paymentrefund" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\paymentrefund.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="squarified" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\squarified.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="support" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\support.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
@ -286,8 +289,8 @@
<data name="preview" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\preview.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="insertpagecount" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\insertpagecount.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
<data name="bo_sale" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\bo_sale.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="exporttopdf" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\exporttopdf.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
@ -313,8 +316,8 @@
<data name="actions_addcircled" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\actions_addcircled.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="actions_send4" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\actions_send4.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
<data name="squarified" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\squarified.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="logical2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\logical2.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
@ -331,7 +334,7 @@
<data name="actions_checkcircled2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\actions_checkcircled2.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="refreshpivottable" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\refreshpivottable.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
<data name="highimportance" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\highimportance.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
</root>

View File

@ -0,0 +1,19 @@
<?xml version='1.0' encoding='UTF-8'?>
<svg x="0px" y="0px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" id="Layer_1" style="enable-background:new 0 0 32 32">
<style type="text/css">
.Yellow{fill:#FFB115;}
.Red{fill:#D11C1C;}
.Blue{fill:#1177D7;}
.Green{fill:#039C23;}
.Black{fill:#727272;}
.White{fill:#FFFFFF;}
.st0{opacity:0.5;}
.st1{display:none;}
.st2{display:inline;fill:#039C23;}
.st3{display:inline;fill:#D11C1C;}
.st4{display:inline;fill:#727272;}
</style>
<g id="HighImportance">
<path d="M16,2C8.3,2,2,8.3,2,16s6.3,14,14,14s14-6.3,14-14S23.7,2,16,2z M16,24c-1.1,0-2-0.9-2-2s0.9-2,2-2s2,0.9,2,2 S17.1,24,16,24z M18,18h-4V8h4V18z" class="Red" />
</g>
</svg>

View File

@ -56,7 +56,8 @@ Partial Class frmImportMain
Me.btnDebugExportReport = New DevExpress.XtraBars.BarButtonItem()
Me.btnEditRow = New DevExpress.XtraBars.BarButtonItem()
Me.btnCalculatePrices = New DevExpress.XtraBars.BarButtonItem()
Me.BarButtonItem2 = New DevExpress.XtraBars.BarButtonItem()
Me.btnOpenLogDirectory2 = New DevExpress.XtraBars.BarButtonItem()
Me.txtErrors = New DevExpress.XtraBars.BarStaticItem()
Me.RibbonPage1 = New DevExpress.XtraBars.Ribbon.RibbonPage()
Me.RibbonPageGroupLoad = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
Me.RibbonPageGroupReport = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
@ -222,9 +223,9 @@ Partial Class frmImportMain
'RibbonControl
'
Me.RibbonControl.ExpandCollapseItem.Id = 0
Me.RibbonControl.Items.AddRange(New DevExpress.XtraBars.BarItem() {Me.RibbonControl.ExpandCollapseItem, Me.RibbonControl.SearchEditItem, Me.txtFilesLoaded, Me.btnLoadFiles, Me.btnTransferFile, Me.btnOpenInputDirectory, Me.btnOpenOutputDirectory, Me.btnOpenSchemaDirectory, Me.btnReloadFile, Me.btnTransferAllFiles, Me.btnOpenReport, Me.btnShowXml, Me.btnOpenLogDirectory, Me.btnOpenConfigDirectory, Me.txtCurrentFile, Me.btnConfig, Me.btnRemoveRow, Me.btnTestTransferFile, Me.BarButtonItem1, Me.btnDebugExportReport, Me.btnEditRow, Me.btnCalculatePrices, Me.BarButtonItem2})
Me.RibbonControl.Items.AddRange(New DevExpress.XtraBars.BarItem() {Me.RibbonControl.ExpandCollapseItem, Me.RibbonControl.SearchEditItem, Me.txtFilesLoaded, Me.btnLoadFiles, Me.btnTransferFile, Me.btnOpenInputDirectory, Me.btnOpenOutputDirectory, Me.btnOpenSchemaDirectory, Me.btnReloadFile, Me.btnTransferAllFiles, Me.btnOpenReport, Me.btnShowXml, Me.btnOpenLogDirectory, Me.btnOpenConfigDirectory, Me.txtCurrentFile, Me.btnConfig, Me.btnRemoveRow, Me.btnTestTransferFile, Me.BarButtonItem1, Me.btnDebugExportReport, Me.btnEditRow, Me.btnCalculatePrices, Me.btnOpenLogDirectory2, Me.txtErrors})
resources.ApplyResources(Me.RibbonControl, "RibbonControl")
Me.RibbonControl.MaxItemId = 38
Me.RibbonControl.MaxItemId = 39
Me.RibbonControl.Name = "RibbonControl"
Me.RibbonControl.Pages.AddRange(New DevExpress.XtraBars.Ribbon.RibbonPage() {Me.RibbonPage1, Me.RibbonPage2})
Me.RibbonControl.RepositoryItems.AddRange(New DevExpress.XtraEditors.Repository.RepositoryItem() {Me.RepositoryItemComboBox1, Me.RepositoryItemProgressBar1})
@ -383,12 +384,21 @@ Partial Class frmImportMain
Me.btnCalculatePrices.ImageOptions.SvgImage = Global.MultiTool.Form.My.Resources.Resources.bo_sale
Me.btnCalculatePrices.Name = "btnCalculatePrices"
'
'BarButtonItem2
'btnOpenLogDirectory2
'
resources.ApplyResources(Me.BarButtonItem2, "BarButtonItem2")
Me.BarButtonItem2.Id = 37
Me.BarButtonItem2.ImageOptions.SvgImage = Global.MultiTool.Form.My.Resources.Resources.logical2
Me.BarButtonItem2.Name = "BarButtonItem2"
resources.ApplyResources(Me.btnOpenLogDirectory2, "btnOpenLogDirectory2")
Me.btnOpenLogDirectory2.Id = 37
Me.btnOpenLogDirectory2.ImageOptions.SvgImage = Global.MultiTool.Form.My.Resources.Resources.logical2
Me.btnOpenLogDirectory2.Name = "btnOpenLogDirectory2"
'
'txtErrors
'
resources.ApplyResources(Me.txtErrors, "txtErrors")
Me.txtErrors.Id = 38
Me.txtErrors.ImageOptions.SvgImage = Global.MultiTool.Form.My.Resources.Resources.highimportance
Me.txtErrors.Name = "txtErrors"
Me.txtErrors.PaintStyle = DevExpress.XtraBars.BarItemPaintStyle.CaptionGlyph
Me.txtErrors.Tag = "Fehler: {0}"
'
'RibbonPage1
'
@ -438,7 +448,7 @@ Partial Class frmImportMain
Me.RibbonPageGroup5.ItemLinks.Add(Me.btnOpenInputDirectory)
Me.RibbonPageGroup5.ItemLinks.Add(Me.btnOpenOutputDirectory)
Me.RibbonPageGroup5.ItemLinks.Add(Me.btnOpenSchemaDirectory)
Me.RibbonPageGroup5.ItemLinks.Add(Me.BarButtonItem2)
Me.RibbonPageGroup5.ItemLinks.Add(Me.btnOpenLogDirectory2)
Me.RibbonPageGroup5.Name = "RibbonPageGroup5"
resources.ApplyResources(Me.RibbonPageGroup5, "RibbonPageGroup5")
'
@ -465,6 +475,7 @@ Partial Class frmImportMain
'
Me.RibbonStatusBar.ItemLinks.Add(Me.txtFilesLoaded)
Me.RibbonStatusBar.ItemLinks.Add(Me.txtCurrentFile)
Me.RibbonStatusBar.ItemLinks.Add(Me.txtErrors)
resources.ApplyResources(Me.RibbonStatusBar, "RibbonStatusBar")
Me.RibbonStatusBar.Name = "RibbonStatusBar"
Me.RibbonStatusBar.Ribbon = Me.RibbonControl
@ -488,7 +499,10 @@ Partial Class frmImportMain
resources.ApplyResources(Me.lookupMandator, "lookupMandator")
Me.lookupMandator.MenuManager = Me.RibbonControl
Me.lookupMandator.Name = "lookupMandator"
Me.lookupMandator.Properties.Appearance.BackColor = System.Drawing.Color.White
Me.lookupMandator.Properties.Appearance.Options.UseBackColor = True
Me.lookupMandator.Properties.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() {New DevExpress.XtraEditors.Controls.EditorButton(CType(resources.GetObject("lookupMandator.Properties.Buttons"), DevExpress.XtraEditors.Controls.ButtonPredefines))})
Me.lookupMandator.Properties.NullText = resources.GetString("lookupMandator.Properties.NullText")
Me.lookupMandator.Properties.PopupView = Me.GridLookUpEdit1View
'
'GridLookUpEdit1View
@ -744,5 +758,6 @@ Partial Class frmImportMain
Friend WithEvents GridBand2 As DevExpress.XtraGrid.Views.BandedGrid.GridBand
Friend WithEvents btnEditRow As DevExpress.XtraBars.BarButtonItem
Friend WithEvents btnCalculatePrices As DevExpress.XtraBars.BarButtonItem
Friend WithEvents BarButtonItem2 As DevExpress.XtraBars.BarButtonItem
Friend WithEvents btnOpenLogDirectory2 As DevExpress.XtraBars.BarButtonItem
Friend WithEvents txtErrors As DevExpress.XtraBars.BarStaticItem
End Class

View File

@ -250,9 +250,12 @@
<data name="btnCalculatePrices.Caption" xml:space="preserve">
<value>Preiskalkulation ausführen</value>
</data>
<data name="BarButtonItem2.Caption" xml:space="preserve">
<data name="btnOpenLogDirectory2.Caption" xml:space="preserve">
<value>Logverzeichnis öffnen</value>
</data>
<data name="txtErrors.Caption" xml:space="preserve">
<value>Fehler: 0</value>
</data>
<data name="RibbonControl.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 0</value>
</data>
@ -376,6 +379,9 @@
<data name="lookupMandator.Properties.Buttons" type="DevExpress.XtraEditors.Controls.ButtonPredefines, DevExpress.Utils.v21.2">
<value>Combo</value>
</data>
<data name="lookupMandator.Properties.NullText" xml:space="preserve">
<value>[Mandant auswählen]</value>
</data>
<data name="colId.Caption" xml:space="preserve">
<value>Id</value>
</data>
@ -780,7 +786,7 @@
</value>
</data>
<data name="$this.Text" xml:space="preserve">
<value>{0} - WebService Multitool für WinLine</value>
<value>{0} - Import - WebService Multitool für WinLine</value>
</data>
<data name="&gt;&gt;GridViewFiles.Name" xml:space="preserve">
<value>GridViewFiles</value>
@ -944,12 +950,18 @@
<data name="&gt;&gt;btnCalculatePrices.Type" xml:space="preserve">
<value>DevExpress.XtraBars.BarButtonItem, DevExpress.XtraBars.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="&gt;&gt;BarButtonItem2.Name" xml:space="preserve">
<value>BarButtonItem2</value>
<data name="&gt;&gt;btnOpenLogDirectory2.Name" xml:space="preserve">
<value>btnOpenLogDirectory2</value>
</data>
<data name="&gt;&gt;BarButtonItem2.Type" xml:space="preserve">
<data name="&gt;&gt;btnOpenLogDirectory2.Type" xml:space="preserve">
<value>DevExpress.XtraBars.BarButtonItem, DevExpress.XtraBars.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="&gt;&gt;txtErrors.Name" xml:space="preserve">
<value>txtErrors</value>
</data>
<data name="&gt;&gt;txtErrors.Type" xml:space="preserve">
<value>DevExpress.XtraBars.BarStaticItem, DevExpress.XtraBars.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="&gt;&gt;RibbonPage1.Name" xml:space="preserve">
<value>RibbonPage1</value>
</data>

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