Refactor: Add ImporterShared Project
This commit is contained in:
@@ -1,36 +1,39 @@
|
||||
Imports System.IO
|
||||
Imports System.Globalization
|
||||
Imports DevExpress.XtraGrid.Views.Grid
|
||||
Imports DevExpress.XtraGrid.Columns
|
||||
Imports DevExpress.XtraRichEdit
|
||||
Imports DevExpress.XtraEditors
|
||||
Imports DevExpress.XtraReports.UI
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Config
|
||||
Imports DigitalData.Controls.SQLConfig
|
||||
Imports DigitalData.GUIs.Common
|
||||
Imports EDIDocumentImport.DocumentInfo
|
||||
Imports EDIDocumentImport.DocumentPositions
|
||||
Imports DevExpress.XtraEditors
|
||||
Imports DevExpress.XtraReports.UI
|
||||
Imports EDIDocumentImport.WinLineInfo
|
||||
Imports ImporterShared.Documents
|
||||
Imports ImporterShared.Winline
|
||||
Imports ImporterShared.Schemas
|
||||
Imports ImporterForm.DocumentPositions
|
||||
|
||||
Public Class frmMain
|
||||
Public LogConfig As LogConfig
|
||||
Public Logger As Logger
|
||||
Public ConfigManager As ConfigManager(Of Config)
|
||||
Public ConfigManager As ConfigManager(Of ImporterShared.Config)
|
||||
Public Database As MSSQLServer
|
||||
Public DocumentLoader As DocumentLoader
|
||||
Public GridBuilder As GridBuilder
|
||||
|
||||
Public Winline As WinLineInfo
|
||||
Public WebService As WinLineWebService
|
||||
Public Winline As Data
|
||||
Public WebService As WebService
|
||||
|
||||
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
Try
|
||||
txtVersion.Caption = String.Format(txtVersion.Caption, Application.ProductVersion)
|
||||
|
||||
LogConfig = New LogConfig(LogConfig.PathType.AppData, Nothing, Nothing, "Digital Data", "EDI Document Importer")
|
||||
ConfigManager = New ConfigManager(Of Config)(LogConfig, Application.UserAppDataPath, Application.CommonAppDataPath, Application.StartupPath)
|
||||
ConfigManager = New ConfigManager(Of ImporterShared.Config)(LogConfig,
|
||||
Application.UserAppDataPath,
|
||||
Application.CommonAppDataPath,
|
||||
Application.StartupPath)
|
||||
Logger = LogConfig.GetLogger()
|
||||
|
||||
' If ConnectionString does not exist, show SQL Config Form
|
||||
@@ -49,8 +52,8 @@ Public Class frmMain
|
||||
' Initialize Database
|
||||
Dim oConnectionString = MSSQLServer.DecryptConnectionString(ConfigManager.Config.ConnectionString)
|
||||
Database = New MSSQLServer(LogConfig, oConnectionString)
|
||||
Winline = New WinLineInfo(LogConfig, Database, ConfigManager.Config)
|
||||
WebService = New WinLineWebService(LogConfig, Database, ConfigManager.Config)
|
||||
Winline = New Data(LogConfig, Database, ConfigManager.Config)
|
||||
WebService = New WebService(LogConfig, ConfigManager.Config)
|
||||
|
||||
' Load WinLine Data
|
||||
Winline.Mandators.Clear()
|
||||
@@ -72,7 +75,7 @@ Public Class frmMain
|
||||
GridBuilder.WithDefaults()
|
||||
|
||||
' Construct classes related to the xml data
|
||||
DocumentLoader = New DocumentLoader(LogConfig, ConfigManager.Config, Database, Winline)
|
||||
DocumentLoader = New DocumentLoader(LogConfig, Winline)
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
MsgBox(ex.Message, MsgBoxStyle.Critical, Text)
|
||||
@@ -81,7 +84,7 @@ Public Class frmMain
|
||||
|
||||
Private Sub btnLoadDocuments_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnLoadDocuments.ItemClick
|
||||
Try
|
||||
If DocumentLoader.LoadFiles() = True Then
|
||||
If DocumentLoader.LoadFiles(ConfigManager.Config.InputDirectory) = True Then
|
||||
|
||||
RibbonGroupData.Enabled = True
|
||||
RibbonGroupDocument.Enabled = True
|
||||
@@ -118,7 +121,12 @@ Public Class frmMain
|
||||
End Select
|
||||
|
||||
Catch ex As Xml.XmlException
|
||||
Dim oMessage As String = $"Fehler beim Verarbeiten des Dokuments {oDocument.Name}:{vbNewLine}{ex.Message}"
|
||||
Dim oMessage As String = $"Fehler beim Laden des Dokuments {oDocument.Name}:{vbNewLine}{ex.Message}"
|
||||
MsgBox(oMessage, MsgBoxStyle.Critical, Text)
|
||||
Logger.Error(ex)
|
||||
|
||||
Catch ex As Exceptions.NoMandatorException
|
||||
Dim oMessage As String = $"Fehler beim Laden des Dokuments {oDocument.Name}:{vbNewLine}{ex.Message}"
|
||||
MsgBox(oMessage, MsgBoxStyle.Critical, Text)
|
||||
Logger.Error(ex)
|
||||
|
||||
@@ -131,12 +139,13 @@ Public Class frmMain
|
||||
End Sub
|
||||
|
||||
Private Sub ShowDocument(pDocument As Document, pData As Orders.Input.MESOWebService, pDataOriginal As Orders.Input.MESOWebService)
|
||||
If pDocument.Mandator Is Nothing Then
|
||||
Throw New Exceptions.NoMandatorException("Es konnte kein Mandant gefunden werden")
|
||||
End If
|
||||
|
||||
Dim oHead = GetOrderHead(pData)
|
||||
Dim oHeadOriginal = GetOrderHead(pDataOriginal)
|
||||
|
||||
Dim oPositions = GetOrderPositions(pData)
|
||||
Dim oPositionsOriginal = GetOrderPositions(pDataOriginal)
|
||||
|
||||
' ====== Head Data ======
|
||||
|
||||
' Original, Unreplaced Data
|
||||
@@ -151,11 +160,8 @@ Public Class frmMain
|
||||
txtDocumentReference.Text = oHead.Auftragsreferenz
|
||||
dateOrderDate.EditValue = oHead.Datum_AuftragBestellung
|
||||
|
||||
|
||||
|
||||
|
||||
Dim oMandator = Winline.Mandators.
|
||||
Where(Function(m) m.Id = pDocument.Mandator.Id).
|
||||
Where(Function(m) m.Id = pDocument.Mandator).
|
||||
SingleOrDefault()
|
||||
|
||||
If oMandator Is Nothing Then
|
||||
@@ -194,9 +200,17 @@ Public Class frmMain
|
||||
' Where(Function(oAccount) oAccount.Id = oHead.Fakt_Kontonummer And oAccount.Mandator = cmbMandator.EditValue).
|
||||
' SingleOrDefault()
|
||||
|
||||
' ====== Position Data ======
|
||||
|
||||
LoadPositionViewAndColumns(GridViewPositions, DocumentType.Order)
|
||||
LoadPositionData(pData, pDataOriginal)
|
||||
GridViewPositions.BestFitColumns()
|
||||
End Sub
|
||||
|
||||
Public Sub LoadPositionData(pData As Orders.Input.MESOWebService, pDataOriginal As Orders.Input.MESOWebService)
|
||||
Dim oPositions = GetOrderPositions(pData)
|
||||
Dim oPositionsOriginal = GetOrderPositions(pDataOriginal)
|
||||
Dim oPositionList As New List(Of OrderPosition)
|
||||
|
||||
For Each oPosition In oPositions
|
||||
Dim oPositionOriginal = oPositionsOriginal.
|
||||
Where(Function(p) p.Zeilennummer = oPosition.Zeilennummer).
|
||||
@@ -215,13 +229,10 @@ Public Class frmMain
|
||||
})
|
||||
Next
|
||||
|
||||
LoadViewAndColumns(GridViewPositions, DocumentType.Order)
|
||||
GridControlPositions.DataSource = oPositionList
|
||||
GridViewPositions.BestFitColumns()
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub LoadViewAndColumns(pView As GridView, pDocumentType As DocumentType)
|
||||
Public Sub LoadPositionViewAndColumns(pView As GridView, pDocumentType As DocumentType)
|
||||
Dim oColumns As List(Of GridColumn)
|
||||
|
||||
' Create columns list depending on DocumentType
|
||||
@@ -326,7 +337,7 @@ Public Class frmMain
|
||||
Return oPositions
|
||||
End Function
|
||||
|
||||
Private Function GetFocusedDocument() As DocumentInfo.Document
|
||||
Private Function GetFocusedDocument() As Document
|
||||
Dim oRowHandles = GridViewFiles.GetSelectedRows().ToList()
|
||||
Dim oDocument As Document = GridViewFiles.GetRow(oRowHandles.First())
|
||||
Return oDocument
|
||||
|
||||
Reference in New Issue
Block a user