First bug fixes
This commit is contained in:
@@ -1,47 +0,0 @@
|
||||
Imports System.Globalization
|
||||
Imports AutoMapper
|
||||
Imports AutoMapper.Configuration
|
||||
|
||||
Public Class MapperFactory
|
||||
Private Shared MapperConfig As Object
|
||||
|
||||
'Public Shared Function GetMapper() As Mapper
|
||||
' MapperConfig = New MapperConfiguration(CreateMapperConfig())
|
||||
' MapperConfig.AssertConfigurationIsValid()
|
||||
' Return MapperConfig.CreateMapper()
|
||||
'End Function
|
||||
|
||||
'Private Shared Function CreateMapperConfig() As MapperConfigurationExpression
|
||||
' Dim oConfig As New MapperConfigurationExpression()
|
||||
|
||||
' oConfig.CreateMap(Of String, Integer)().ConvertUsing(New IntegerTypeConverter())
|
||||
' oConfig.CreateMap(Of String, Decimal)().ConvertUsing(New DecimalTypeConverter())
|
||||
' oConfig.CreateMap(Of String, DateTime)().ConvertUsing(New DateTimeTypeConverter())
|
||||
' oConfig.CreateMap(Of Schemas.Orders.Input.MESOWebService, Schemas.Orders.Output.MESOWebService)()
|
||||
' oConfig.CreateMap(Of Schemas.Orders.Input.MESOWebServiceEXIMVRG_ordersT025, Schemas.Orders.Output.MESOWebServiceEXIMVRG_ordersT025)()
|
||||
' oConfig.CreateMap(Of Schemas.Orders.Input.MESOWebServiceEXIMVRG_ordersT026, Schemas.Orders.Output.MESOWebServiceEXIMVRG_ordersT026)()
|
||||
|
||||
' Return oConfig
|
||||
'End Function
|
||||
|
||||
Private Class DateTimeTypeConverter
|
||||
Implements ITypeConverter(Of String, DateTime)
|
||||
|
||||
Public Function Convert(source As String, destination As Date, context As ResolutionContext) As Date Implements ITypeConverter(Of String, Date).Convert
|
||||
Return System.Convert.ToDateTime(source)
|
||||
End Function
|
||||
End Class
|
||||
Private Class IntegerTypeConverter
|
||||
Implements ITypeConverter(Of String, Integer)
|
||||
Public Function Convert(source As String, destination As Integer, context As ResolutionContext) As Integer Implements ITypeConverter(Of String, Integer).Convert
|
||||
Return System.Convert.ToInt32(source)
|
||||
End Function
|
||||
End Class
|
||||
Private Class DecimalTypeConverter
|
||||
Implements ITypeConverter(Of String, Decimal)
|
||||
Public Function Convert(source As String, destination As Decimal, context As ResolutionContext) As Decimal Implements ITypeConverter(Of String, Decimal).Convert
|
||||
Return System.Convert.ToDecimal(source, CultureInfo.InvariantCulture)
|
||||
End Function
|
||||
End Class
|
||||
|
||||
End Class
|
||||
@@ -44,9 +44,6 @@
|
||||
<OptionInfer>On</OptionInfer>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="AutoMapper, Version=10.0.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\AutoMapper.10.1.1\lib\net461\AutoMapper.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DevExpress.DataAccess.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
||||
<Reference Include="DigitalData.Modules.Database">
|
||||
<HintPath>..\..\DDMonorepo\Modules.Database\bin\Debug\DigitalData.Modules.Database.dll</HintPath>
|
||||
@@ -119,7 +116,6 @@
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="Mapper.vb" />
|
||||
<Compile Include="Schemas\BaseSchema.vb" />
|
||||
<Compile Include="Schemas\Orders\Helpers.vb" />
|
||||
<Compile Include="Schemas\Orders\Input.vb" />
|
||||
@@ -132,6 +128,7 @@
|
||||
<Compile Include="Winline\Configuration.vb" />
|
||||
<Compile Include="Winline\Entities\Account.vb" />
|
||||
<Compile Include="Winline\Data.vb" />
|
||||
<Compile Include="Winline\Entities\Article.vb" />
|
||||
<Compile Include="Winline\Entities\Contact.vb" />
|
||||
<Compile Include="Winline\Entities\DocumentKind.vb" />
|
||||
<Compile Include="Winline\Entities\Mandator.vb" />
|
||||
|
||||
@@ -7,7 +7,7 @@ Namespace Schemas
|
||||
Public Class SchemaLoader
|
||||
Inherits BaseClass
|
||||
|
||||
Private ns As XNamespace = "http://www.w3.org/2001/XMLSchema"
|
||||
Private ReadOnly ns As XNamespace = "http://www.w3.org/2001/XMLSchema"
|
||||
|
||||
Public SchemaList As List(Of FileInfo)
|
||||
|
||||
|
||||
@@ -12,9 +12,11 @@ Namespace Winline
|
||||
Private ReadOnly Database As MSSQLServer
|
||||
Private ReadOnly Config As Config
|
||||
|
||||
Public Articles As New List(Of Article)
|
||||
Public Accounts As New List(Of Account)
|
||||
Public Mandators As New List(Of Mandator)
|
||||
Public DocumentKinds As New List(Of DocumentKind)
|
||||
|
||||
Public Years As List(Of Integer)
|
||||
Public TemplateConfiguration As New List(Of TemplateColumn)
|
||||
|
||||
@@ -23,14 +25,18 @@ Namespace Winline
|
||||
|
||||
Public Const ALL_MESOCOMP = "mesocomp"
|
||||
|
||||
Public Const V21_ARTICLENUMBER = "c011"
|
||||
Public Const V21_ARTICLENUMBER = "c002"
|
||||
Public Const V21_ARTICLEDESCRIPTION = "c003"
|
||||
Public Const V21_MAINARTICLENUMBER = "c011"
|
||||
Public Const V21_REPLACEMENTARTICLENUMBER = "c123"
|
||||
Public Const V21_EAN = "c075"
|
||||
|
||||
Public Const V50_ACCOUNTNUMBER = "c002"
|
||||
Public Const V50_ACCOUNTNAME = "c003"
|
||||
Public Const V50_STREETNAME = "c050"
|
||||
Public Const V50_ZIPCODE = "c051"
|
||||
Public Const V50_CITYNAME = "c052"
|
||||
Public Const V50_GLN = "c260"
|
||||
|
||||
Public Const T45_KEY = "c000"
|
||||
Public Const T45_NAME = "c001"
|
||||
@@ -62,7 +68,46 @@ Namespace Winline
|
||||
Return GetWinLineYear(Config.GetYear)
|
||||
End Function
|
||||
|
||||
Public Sub LoadAccounts(pMandator As Mandator)
|
||||
Public Async Function LoadArticles(pMandator As Mandator) As Task
|
||||
Logger.Info("Loading Articles for Mandator [{0}]", pMandator)
|
||||
Dim oYear = GetWinLineYear()
|
||||
|
||||
Try
|
||||
Dim oSQL = $"
|
||||
SELECT DISTINCT
|
||||
[c002], -- Artikelnummer
|
||||
[c003], -- Bezeichnung
|
||||
[c075] -- EAN
|
||||
FROM [{pMandator.Server}].[{pMandator.Database}].[dbo].[v021]
|
||||
WHERE
|
||||
mesocomp = '{pMandator.Id}'
|
||||
AND mesoyear = {oYear}"
|
||||
|
||||
Dim oTable = Await Database.GetDatatableAsync(oSQL)
|
||||
Dim oArticles As New List(Of Article)
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
Dim oArticleId As String = Utils.NotNull(oRow.Item(V21_ARTICLENUMBER), String.Empty)
|
||||
Dim oArticleDescription As String = Utils.NotNull(oRow.Item(V21_ARTICLEDESCRIPTION), String.Empty)
|
||||
Dim oEAN As String = Utils.NotNull(oRow.Item(V21_EAN), String.Empty)
|
||||
|
||||
oArticles.Add(New Article With {
|
||||
.Id = oArticleId,
|
||||
.Name = oArticleDescription,
|
||||
.EAN = oEAN,
|
||||
.Mandator = pMandator
|
||||
})
|
||||
Next
|
||||
Articles.AddRange(oArticles)
|
||||
|
||||
Logger.Info("[{0}] Articles loaded for Mandator [{1}]", oArticles.Count, pMandator)
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Could not load Articles for Mandator [{0}]", pMandator)
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Async Function LoadAccounts(pMandator As Mandator) As Task
|
||||
Logger.Info("Loading Accounts for Mandator [{0}]", pMandator)
|
||||
Dim oYear = GetWinLineYear()
|
||||
|
||||
@@ -73,13 +118,14 @@ Namespace Winline
|
||||
[c003], -- Kundenname
|
||||
[c050], -- Straße
|
||||
[c052], -- Ort
|
||||
[c051] -- PLZ
|
||||
[c051], -- PLZ
|
||||
[c260] -- GLN
|
||||
FROM [{pMandator.Server}].[{pMandator.Database}].[dbo].[v050]
|
||||
WHERE
|
||||
c139 IS NULL
|
||||
AND mesocomp = '{pMandator.Id}'
|
||||
AND mesoyear = {oYear}"
|
||||
Dim oTable = Database.GetDatatable(oSQL)
|
||||
Dim oTable = Await Database.GetDatatableAsync(oSQL)
|
||||
Dim oAccounts As New List(Of Account)
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
@@ -88,6 +134,7 @@ Namespace Winline
|
||||
Dim oStreetName As String = Utils.NotNull(oRow.Item(V50_STREETNAME), String.Empty)
|
||||
Dim oZipCode As String = Utils.NotNull(oRow.Item(V50_ZIPCODE), String.Empty)
|
||||
Dim oCityName As String = Utils.NotNull(oRow.Item(V50_CITYNAME), String.Empty)
|
||||
Dim oGLN As String = Utils.NotNull(oRow.Item(V50_GLN), String.Empty)
|
||||
|
||||
oAccounts.Add(New Account With {
|
||||
.Id = oAccountNumber,
|
||||
@@ -95,7 +142,8 @@ Namespace Winline
|
||||
.StreetName = oStreetName,
|
||||
.ZipCode = oZipCode,
|
||||
.CityName = oCityName,
|
||||
.Mandator = pMandator.Id
|
||||
.GLN = oGLN,
|
||||
.Mandator = pMandator
|
||||
})
|
||||
Next
|
||||
Accounts.AddRange(oAccounts)
|
||||
@@ -105,12 +153,12 @@ Namespace Winline
|
||||
Logger.Warn("Could not load Accounts for Mandator [{0}]", pMandator)
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
End Function
|
||||
|
||||
Public Sub LoadMandators()
|
||||
Public Async Function LoadMandators() As Task
|
||||
Try
|
||||
Dim oSQL = "SELECT [c000], [c003], [c004] FROM [cwlsystem].[dbo].[T001SRV] (NOLOCK)"
|
||||
Dim oTable = Database.GetDatatable(oSQL)
|
||||
Dim oTable = Await Database.GetDatatableAsync(oSQL)
|
||||
|
||||
Mandators.Clear()
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
@@ -123,8 +171,8 @@ Namespace Winline
|
||||
}
|
||||
|
||||
Dim oMandatorConfig As Config.MandatorConfig = Config.Mandators.
|
||||
Where(Function(m) oMandator.Id = m.Name).
|
||||
SingleOrDefault()
|
||||
Where(Function(m) oMandator.Id = m.Name).
|
||||
SingleOrDefault()
|
||||
|
||||
If oMandatorConfig IsNot Nothing Then
|
||||
oMandator.IsWhitelisted = True
|
||||
@@ -141,7 +189,7 @@ Namespace Winline
|
||||
Logger.Warn("Could not load Mandators")
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
End Function
|
||||
|
||||
Public Sub LoadEconomicYears()
|
||||
Dim oCurrentYear = Now.Year
|
||||
@@ -149,50 +197,41 @@ Namespace Winline
|
||||
Years = oRange
|
||||
End Sub
|
||||
|
||||
Public Sub LoadDocumentKinds(pMandators As List(Of Mandator))
|
||||
Dim oDocumentKinds As New List(Of DocumentKind)
|
||||
Dim oMandatorString = String.Join(",", pMandators.Select(Function(m) $"'{m.Id}'").ToArray)
|
||||
Public Async Function LoadDocumentKinds(pMandator As Mandator) As Task
|
||||
Dim oYear As Integer = GetWinLineYear()
|
||||
DocumentKinds.Clear()
|
||||
|
||||
For Each oMandator As Mandator In pMandators
|
||||
Try
|
||||
' TODO: This is Schaum specific, maybe move to config later
|
||||
Dim oSQL = $"
|
||||
Try
|
||||
' TODO: This is Schaum specific, maybe move to config later
|
||||
Dim oSQL = $"
|
||||
SELECT
|
||||
[c030],
|
||||
[c001],
|
||||
[mesocomp]
|
||||
FROM [{oMandator.Database}].[dbo].[t357] (NOLOCK)
|
||||
FROM [{pMandator.Database}].[dbo].[t357] (NOLOCK)
|
||||
WHERE (
|
||||
[c001] LIKE 'Werk%(VK)' OR
|
||||
[c001] LIKE 'Werk%(WK)'
|
||||
)
|
||||
AND [mesocomp] = '{oMandator.Id}' AND [mesoyear] = {oYear}"
|
||||
Dim oTable As DataTable = Database.GetDatatable(oSQL)
|
||||
AND [mesocomp] = '{pMandator.Id}' AND [mesoyear] = {oYear}"
|
||||
Dim oTable As DataTable = Await Database.GetDatatableAsync(oSQL)
|
||||
Dim oKinds As New List(Of DocumentKind)
|
||||
|
||||
If oTable.Rows.Count = 0 Then
|
||||
Logger.Debug("No DocumentKinds found for Mandator [{0}]", oMandator.Id)
|
||||
Continue For
|
||||
End If
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
oKinds.Add(New DocumentKind With {
|
||||
.Id = oRow.Item(T357_KINDID),
|
||||
.Name = oRow.Item(T357_KINDNAME),
|
||||
.Mandator = pMandator
|
||||
})
|
||||
Next
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
oDocumentKinds.Add(New DocumentKind With {
|
||||
.Id = oRow.Item(T357_KINDID),
|
||||
.Name = oRow.Item(T357_KINDNAME),
|
||||
.Mandator = oRow.Item(ALL_MESOCOMP)
|
||||
})
|
||||
Next
|
||||
DocumentKinds.AddRange(oKinds)
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Could not load DocumentKinds")
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
Next
|
||||
|
||||
DocumentKinds = oDocumentKinds.ToList()
|
||||
|
||||
End Sub
|
||||
Logger.Info("[{0}] DocumentKinds loaded for [{1}]", Mandators.Count, pMandator)
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Could not load DocumentKinds")
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function TryGetAccount(pGLN As String, pMandator As Mandator) As Account
|
||||
Try
|
||||
@@ -241,7 +280,7 @@ Namespace Winline
|
||||
.StreetName = oStreetName,
|
||||
.CityName = oCityName,
|
||||
.ZipCode = oZipCode,
|
||||
.Mandator = pMandator.Id
|
||||
.Mandator = pMandator
|
||||
}
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Error while trying to get account for GLN [{0}]", pGLN)
|
||||
@@ -279,7 +318,7 @@ Namespace Winline
|
||||
End If
|
||||
|
||||
Dim oRow As DataRow = oTable.Rows.Item(0)
|
||||
Dim oArticleNumber As String = Utils.NotNull(oRow.Item(V21_ARTICLENUMBER), String.Empty)
|
||||
Dim oArticleNumber As String = Utils.NotNull(oRow.Item(V21_MAINARTICLENUMBER), String.Empty)
|
||||
Return oArticleNumber
|
||||
|
||||
Catch ex As Exception
|
||||
@@ -412,7 +451,7 @@ Namespace Winline
|
||||
End If
|
||||
|
||||
Dim oRow As DataRow = oTable.Rows.Item(0)
|
||||
Dim oArticleNumber As String = Utils.NotNull(oRow.Item(V21_ARTICLENUMBER), String.Empty)
|
||||
Dim oArticleNumber As String = Utils.NotNull(oRow.Item(V21_MAINARTICLENUMBER), String.Empty)
|
||||
|
||||
' EAN was found, now we need to check it against the Regex of the current Mandantor, if one exists
|
||||
If oMandator.Regex <> String.Empty Then
|
||||
|
||||
@@ -6,8 +6,9 @@
|
||||
Public Property StreetName As String
|
||||
Public Property CityName As String
|
||||
Public Property ZipCode As String
|
||||
Public Property GLN As String
|
||||
|
||||
Public Property Mandator As String
|
||||
Public Property Mandator As Mandator
|
||||
|
||||
Public Overrides Function GetHashCode() As Integer
|
||||
Return Id.GetHashCode()
|
||||
|
||||
21
MultiTool.Shared/Winline/Entities/Article.vb
Normal file
21
MultiTool.Shared/Winline/Entities/Article.vb
Normal file
@@ -0,0 +1,21 @@
|
||||
Namespace Winline
|
||||
Public Class Article
|
||||
Public Property Id
|
||||
Public Property Name
|
||||
Public Property EAN
|
||||
Public Property Mandator As Mandator
|
||||
|
||||
Public Overrides Function GetHashCode() As Integer
|
||||
Return Id.GetHashCode()
|
||||
End Function
|
||||
|
||||
Public Overrides Function Equals(obj As Object) As Boolean
|
||||
Return DirectCast(obj, Article).Id = Id
|
||||
End Function
|
||||
|
||||
Public Overrides Function ToString() As String
|
||||
Return $"{Name} ({Id})"
|
||||
End Function
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
@@ -1,8 +1,8 @@
|
||||
Namespace Winline
|
||||
Public Class DocumentKind
|
||||
Public Id As Integer
|
||||
Public Name As String
|
||||
Public Mandator As String
|
||||
Public Property Id As Integer
|
||||
Public Property Name As String
|
||||
Public Property Mandator As Mandator
|
||||
|
||||
Public Overrides Function GetHashCode() As Integer
|
||||
Return Id.GetHashCode()
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
Imports System.Xml
|
||||
Imports System.Net
|
||||
Imports System.Text
|
||||
Imports System.Net.Http
|
||||
Imports System.Globalization
|
||||
Imports AutoMapper
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Filesystem
|
||||
Imports MultiTool.Shared.Documents
|
||||
Imports System.Text
|
||||
|
||||
Namespace Winline
|
||||
Public Class WebService
|
||||
@@ -14,13 +11,10 @@ Namespace Winline
|
||||
|
||||
Private ReadOnly Config As Config
|
||||
Private ReadOnly Serializer As Serializer
|
||||
Private ReadOnly Mapper As AutoMapper.Mapper
|
||||
Private ReadOnly FileEx As File
|
||||
Private ReadOnly AppDataPath As String
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pConfig As Config, pAppDataPath As String)
|
||||
MyBase.New(pLogConfig, pLogConfig.GetLogger())
|
||||
FileEx = New File(pLogConfig)
|
||||
Serializer = New Serializer(pLogConfig)
|
||||
Config = pConfig
|
||||
AppDataPath = pAppDataPath
|
||||
@@ -155,11 +149,13 @@ Namespace Winline
|
||||
End Function
|
||||
|
||||
Private Function GetBytesFromDocument(pDocument As Document) As Byte()
|
||||
' TODO: should "Lief_Name" be included here?
|
||||
Dim oFilteredFields As New List(Of String) From {
|
||||
"Fakt_Name",
|
||||
"Lief_Name"
|
||||
"Fakt_Name"
|
||||
}
|
||||
|
||||
|
||||
|
||||
Using oStream As New IO.MemoryStream()
|
||||
Dim w = XmlWriter.Create(oStream)
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="AutoMapper" version="10.1.1" targetFramework="net461" />
|
||||
<package id="NLog" version="4.7.10" targetFramework="net461" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user