add forms, prepare webservices call
This commit is contained in:
@@ -1,25 +1,29 @@
|
||||
Public Class Winline
|
||||
Private _LogConfig As LogConfig
|
||||
Imports System.Net
|
||||
|
||||
Public Class Winline
|
||||
Private _Logger As Logger
|
||||
Private _Db As Database
|
||||
|
||||
Public ReadOnly Property NO_RUNNING_NUMBER_FOUND = "NO_RUNNING_NUMBER_FOUND"
|
||||
Public ReadOnly Property UNKNOWN_ERROR = "UNKNOWN_ERROR"
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, Database As Database)
|
||||
_LogConfig = LogConfig
|
||||
_Logger = LogConfig.GetLogger()
|
||||
_Db = Database
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Public Function GetVendors() As List(Of Vendor)
|
||||
Try
|
||||
Dim oDatatable As DataTable = _Db.GetDatatable("SELECT * FROM TBDD_ARTICLE_GENERATOR_VENDORS")
|
||||
Dim oDatatable As DataTable = _Db.GetDatatable("SELECT * FROM TBDD_ARTICLE_GENERATOR_VENDORS ORDER BY CODE")
|
||||
Dim oVendors As New List(Of Vendor)
|
||||
|
||||
For Each oRow As DataRow In oDatatable.Rows
|
||||
Dim oVendor As New Vendor() With {
|
||||
.Code = oRow.Item("CODE"),
|
||||
.Name = oRow.Item("NAME")
|
||||
.Name = oRow.Item("NAME"),
|
||||
.Guid = oRow.Item("GUID"),
|
||||
.WinlineName = oRow.Item("WINLINE_NAME"),
|
||||
.WinlineNumber = oRow.Item("WINLINE_NUMBER")
|
||||
}
|
||||
|
||||
oVendors.Add(oVendor)
|
||||
@@ -39,9 +43,10 @@
|
||||
|
||||
For Each oRow As DataRow In oDatatable.Rows
|
||||
Dim oGroup As New ProductGroup() With {
|
||||
.Guid = oRow.Item("GUID"),
|
||||
.Name = oRow.Item("NAME"),
|
||||
.Id = oRow.Item("GROUP"),
|
||||
.Vendor = oRow.Item("CODE")
|
||||
.GroupId = oRow.Item("GROUP"),
|
||||
.Code = oRow.Item("CODE")
|
||||
}
|
||||
|
||||
oGroups.Add(oGroup)
|
||||
@@ -56,14 +61,16 @@
|
||||
|
||||
Public Function GetVersionsByVendorAndGroup(VendorCode As String, GroupId As String) As List(Of ProductVersion)
|
||||
Try
|
||||
Dim oDatatable = _Db.GetDatatable($"SELECT * FROM TBDD_ARTICLE_GENERATOR_PRODUCTS WHERE VENDOR = '{VendorCode}' AND [GROUP] = {GroupId}")
|
||||
Dim oDatatable = _Db.GetDatatable($"SELECT * FROM TBDD_ARTICLE_GENERATOR_PRODUCTS WHERE CODE = '{VendorCode}' AND [GROUP] = {GroupId}")
|
||||
Dim oVersions As New List(Of ProductVersion)
|
||||
|
||||
For Each oRow As DataRow In oDatatable.Rows
|
||||
Dim oVersion As New ProductVersion() With {
|
||||
.Id = oRow.Item("VERSION"),
|
||||
.Guid = oRow.Item("GUID"),
|
||||
.VersionId = oRow.Item("VERSION"),
|
||||
.GroupId = oRow.Item("GROUP"),
|
||||
.Name = oRow.Item("NAME"),
|
||||
.Part = oRow.Item("PART")
|
||||
.Code = oRow.Item("CODE")
|
||||
}
|
||||
|
||||
oVersions.Add(oVersion)
|
||||
@@ -76,36 +83,51 @@
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetVendorIdByCode(VendorCode As String) As String
|
||||
Public Function GetNextRunningNumber(VendorCode As String, GroupId As Integer, VersionId As Integer) As String
|
||||
Try
|
||||
Return _Db.GetScalarValue($"SELECT SUBSTRING(C000,0,6) C999 FROM T309 WHERE C001 = '{VendorCode}' AND C002 = 1")
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
Dim oGroupCode As String = GroupId.ToString.PadLeft(2, "0")
|
||||
Dim oVersionCode As String = VersionId.ToString.PadLeft(2, "0")
|
||||
Dim oDbResult = _Db.GetScalarValue($"SELECT MAX(C223) FROM v021 WHERE c010 LIKE '{VendorCode}{oGroupCode}{oVersionCode}___'")
|
||||
|
||||
|
||||
|
||||
Public Function GetNextRunningNumber(VendorId As Integer, GroupId As Integer, VersionId As Integer) As Integer
|
||||
Try
|
||||
VendorId = VendorId.ToString.PadLeft(2)
|
||||
GroupId = GroupId.ToString.PadLeft(2)
|
||||
VersionId = VersionId.ToString.PadLeft(3)
|
||||
|
||||
Dim oResult = _Db.GetScalarValue($"SELECT MAX(C223) C999 FROM [CWLDATEN_MEDS].[dbo].[v021] where c078 LIKE '{VendorId}-{GroupId}-{VersionId}-_____-_____'")
|
||||
|
||||
If IsNothing(oResult) Then
|
||||
Return 1
|
||||
ElseIf IsNumeric(oResult) Then
|
||||
Return Integer.Parse(oResult) + 1
|
||||
If IsNumeric(oDbResult) Then
|
||||
Dim oNewRunningNumber = Integer.Parse(oDbResult) + 1
|
||||
Return oNewRunningNumber.ToString.PadLeft(3, "0")
|
||||
ElseIf IsNothing(oDbResult) OrElse IsDBNull(oDbResult) Then
|
||||
Throw New ApplicationException(NO_RUNNING_NUMBER_FOUND)
|
||||
Else
|
||||
Return Nothing
|
||||
Throw New ApplicationException(UNKNOWN_ERROR)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return Nothing
|
||||
Throw ex
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function SendWebserviceRequest(XmlData As String)
|
||||
Try
|
||||
Dim oWebserviceConfig = My.Application.ConfigManager.Config.WinLine_WebService
|
||||
Dim oServer As String = oWebserviceConfig.Server
|
||||
Dim oURI = $"http://{oServer}/ewlservice/import"
|
||||
|
||||
Dim oQuery As String = ""
|
||||
oQuery &= $"User={oWebserviceConfig.Username}"
|
||||
oQuery &= $"Password={oWebserviceConfig.Password}"
|
||||
oQuery &= $"Company={oWebserviceConfig.Mandator}"
|
||||
oQuery &= $"Type={oWebserviceConfig.ArticleTemplateType}"
|
||||
oQuery &= $"Vorlage={oWebserviceConfig.ArticleTemplateName}"
|
||||
oQuery &= $"Actioncode={oWebserviceConfig.ActionCode}"
|
||||
oQuery &= $"byref=0"
|
||||
oQuery &= $"Data={XmlData}"
|
||||
|
||||
oURI &= $"?{oQuery}"
|
||||
|
||||
Dim oClient As HttpWebRequest = WebRequest.Create(oURI)
|
||||
oClient.Method = "POST"
|
||||
oClient.ContentType = "application/xml"
|
||||
Catch ex As Exception
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
End Class
|
||||
|
||||
|
||||
Reference in New Issue
Block a user