Compare commits

...

19 Commits

Author SHA1 Message Date
Jonathan Jenne
6fe97d474c Version 1.3.0.0 2021-03-18 14:02:30 +01:00
Jonathan Jenne
10e90507e1 merge 2021-03-18 14:01:44 +01:00
Jonathan Jenne
a143aaf09e support custom windows for article window 2021-03-18 14:00:54 +01:00
Jonathan Jenne
83ad9db4b2 Version 1.2.0.0 2021-02-01 14:31:18 +01:00
Jonathan Jenne
9db382aead clean up 2021-02-01 14:30:42 +01:00
Jonathan Jenne
def3cdac1e Improve User Feedback for errors, fix TestArticleExists 2021-02-01 14:30:38 +01:00
Jonathan Jenne
248162732f clean up licenses 2021-02-01 14:28:12 +01:00
Jonathan Jenne
a020fbc480 Version 1.1.0.7 2021-01-21 11:15:56 +01:00
Jonathan Jenne
2c87374775 Handle NULL in Group Name 2021-01-21 11:15:29 +01:00
Jonathan Jenne
8a220ff21f Version 1.1.0.6 2020-10-13 14:23:14 +02:00
Jonathan Jenne
6155a9365a fix GetNextRunningNumber when no running exists yet 2020-10-13 14:22:31 +02:00
Jonathan Jenne
c515ca075a clean up 2020-09-25 10:23:19 +02:00
Jonathan Jenne
9d5cb0392d Version 1.1.0.5 2020-09-24 15:48:30 +02:00
Jonathan Jenne
f4ea9c8993 add logging 2020-09-24 15:48:11 +02:00
Jonathan Jenne
2d214f9e4f Version 1.1.0.4 2020-09-23 10:22:00 +02:00
Jonathan Jenne
73328b67fc add logfiles per machine 2020-09-23 10:21:13 +02:00
Jonathan Jenne
c415a9f5ec Version 1.1.0.3 2020-09-23 10:13:15 +02:00
Jonathan Jenne
e71d9d7668 add basic logging for webservices 2020-09-23 10:12:20 +02:00
Jonathan Jenne
36937abe4c change config/log path to startup directory 2020-09-23 10:12:03 +02:00
8 changed files with 109 additions and 42 deletions

View File

@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<MySubMain>true</MySubMain>
<MainForm>Form1</MainForm>
<MainForm>frmMain</MainForm>
<SingleInstance>false</SingleInstance>
<ShutdownMode>0</ShutdownMode>
<EnableVisualStyles>true</EnableVisualStyles>
<AuthenticationMode>0</AuthenticationMode>
<ApplicationType>0</ApplicationType>
<SaveMySettingsOnExit>true</SaveMySettingsOnExit>
</MyApplicationData>

View File

@@ -12,7 +12,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("Digital Data")>
<Assembly: AssemblyProduct("WinLineProductNumberGenerator")>
<Assembly: AssemblyCopyright("Copyright © 2020")>
<Assembly: AssemblyCopyright("Copyright © 2021")>
<Assembly: AssemblyTrademark("")>
<Assembly: ComVisible(False)>
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' indem Sie "*" wie unten gezeigt eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.1.0.1")>
<Assembly: AssemblyVersion("1.3.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")>

View File

@@ -22,7 +22,7 @@ Namespace My.Resources
'''<summary>
''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
'''</summary>
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0"), _
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0"), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _

View File

@@ -15,7 +15,7 @@ Option Explicit On
Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.4.0.0"), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase

View File

@@ -1,2 +1 @@
DevExpress.XtraGrid.GridControl, DevExpress.XtraGrid.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraBars.Ribbon.RibbonControl, DevExpress.XtraBars.v20.1, Version=20.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a

View File

@@ -3,15 +3,18 @@ Imports System.Net
Imports System.Xml
Public Class Winline
Private _Logger As Logger
Private _EXIM As Database
Private _Winline As Database
Private _Config As Config
Private ReadOnly _Logger As Logger
Private ReadOnly _EXIM As Database
Private ReadOnly _Winline As Database
Private ReadOnly _Config As Config
Public ReadOnly Property NO_RUNNING_NUMBER_FOUND = "NO_RUNNING_NUMBER_FOUND"
Public ReadOnly Property ARTICLE_ALREADY_EXISTS = "ARTICLE_ALREADY_EXISTS"
Public ReadOnly Property UNKNOWN_ERROR = "UNKNOWN_ERROR"
Private Const ACTIONCODE_CHECK = 0
Private Const ACTIONCODE_IMPORT = 1
Public Sub New(LogConfig As LogConfig, EximDatabase As Database, WinlineDatabase As Database, Config As Config)
_Logger = LogConfig.GetLogger()
_EXIM = EximDatabase
@@ -70,6 +73,14 @@ Public Class Winline
End Try
End Function
Private Function NotNull(Of T)(ByVal value As T, ByVal defaultValue As T) As T
If IsNothing(value) OrElse String.IsNullOrEmpty(value.ToString) OrElse IsDBNull(value) Then
Return defaultValue
Else
Return value
End If
End Function
Public Function GetGroupsByVendor(VendorCode As String) As List(Of ProductGroup)
Try
Dim oDatatable = _EXIM.GetDatatable($"SELECT * FROM TBDD_ARTICLE_GENERATOR_GROUPS WHERE CODE = '{VendorCode}'")
@@ -77,10 +88,10 @@ Public Class Winline
For Each oRow As DataRow In oDatatable.Rows
Dim oGroup As New ProductGroup() With {
.Guid = oRow.Item("GUID"),
.Name = oRow.Item("NAME"),
.GroupId = oRow.Item("GROUP"),
.Code = oRow.Item("CODE")
.Guid = NotNull(oRow.Item("GUID"), 0),
.Name = NotNull(oRow.Item("NAME"), "(Kein Name)"),
.GroupId = NotNull(oRow.Item("GROUP"), 0),
.Code = NotNull(oRow.Item("CODE"), "(Kein Code)")
}
oGroups.Add(oGroup)
@@ -100,11 +111,11 @@ Public Class Winline
For Each oRow As DataRow In oDatatable.Rows
Dim oVersion As New ProductVersion() With {
.Guid = oRow.Item("GUID"),
.VersionId = oRow.Item("VERSION"),
.GroupId = oRow.Item("GROUP_ID"),
.Name = oRow.Item("NAME"),
.Code = oRow.Item("CODE")
.Guid = NotNull(oRow.Item("GUID"), 0),
.VersionId = NotNull(oRow.Item("VERSION"), 0),
.GroupId = NotNull(oRow.Item("GROUP_ID"), 0),
.Name = NotNull(oRow.Item("NAME"), "(Kein Name)"),
.Code = NotNull(oRow.Item("CODE"), "(Kein Code)")
}
oVersions.Add(oVersion)
@@ -127,7 +138,7 @@ Public Class Winline
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)
Return 1.ToString.PadLeft(3, "0")
Else
Throw New ApplicationException(UNKNOWN_ERROR)
End If
@@ -137,7 +148,7 @@ Public Class Winline
End Try
End Function
Public Function SendWebserviceRequest(TemplateType As Integer, TemplateName As String, XmlData As String)
Public Function SendWebserviceRequest(TemplateType As Integer, TemplateName As String, XmlData As String) As Boolean
Try
Dim oWebserviceConfig = My.Application.ConfigManager.Config.WebService
Dim oServer As String = oWebserviceConfig.Server
@@ -155,6 +166,8 @@ Public Class Winline
oURI &= $"?{oQuery}"
_Logger.Info("WebService Request: {0}", oURI)
Dim oRequest As HttpWebRequest = WebRequest.Create(oURI)
Dim oResponse As HttpWebResponse = DirectCast(oRequest.GetResponse(), HttpWebResponse)
Dim oXmlResponse As String
@@ -163,18 +176,40 @@ Public Class Winline
oXmlResponse = oReader.ReadToEnd()
End Using
_Logger.Info("WebService Response: {0}", oXmlResponse)
Dim oDocument As New XmlDocument
oDocument.LoadXml(oXmlResponse)
oDocument.Save(Console.Out)
Try
oDocument.LoadXml(oXmlResponse)
oDocument.Save(Console.Out)
Catch ex As Exception
_Logger.Error(ex)
Return False
End Try
Dim oSuccess As XmlNode = oDocument.DocumentElement.SelectSingleNode("OverallSuccess")
Dim oInnerSuccess = True
If oSuccess.InnerText.ToUpper = "TRUE" Then
Return True
Dim oSuccessNodes = oDocument.DocumentElement.SelectNodes("//Success")
For Each oNode As XmlNode In oSuccessNodes
If oNode.InnerText.ToUpper <> "TRUE" Then
oInnerSuccess = False
End If
Next
_Logger.Info("Request was SUCCESSFUL!")
If oInnerSuccess = False Then
Return False
Else
Return True
End If
Else
_Logger.Info("Request FAILED!")
Return False
End If
Catch ex As Exception
_Logger.Error(ex)
Return False
@@ -183,7 +218,7 @@ Public Class Winline
Public Function TestArticleExists(ArticleNumber As String) As Boolean
Try
Dim oResult = _Winline.GetScalarValue($"SELECT c000 FROM v021 WHERE c002 = '{ArticleNumber}'")
Dim oResult = _Winline.GetScalarValue($"SELECT c002 FROM v021 WHERE c002 = '{ArticleNumber}'")
If IsNothing(oResult) Or IsDBNull(oResult) Then
Return False
@@ -195,7 +230,7 @@ Public Class Winline
End Try
End Function
Public Function CreateArticle(ArticleNumber As String, RunningNumber As String, ArticleDescription As String, Vendor As Vendor, IsSerialnumberArticle As Boolean)
Public Function CreateArticle(ArticleNumber As String, RunningNumber As String, ArticleDescription As String, Vendor As Vendor, IsSerialnumberArticle As Boolean) As Boolean
Dim oTemplateName As String = _Config.WebService.ArticleTemplateName
Dim oTemplateType As Integer = _Config.WebService.ArticleTemplateType
Dim oTaxCode As Integer = _Config.WebService.TaxCode
@@ -208,6 +243,7 @@ Public Class Winline
Dim oUseShape As String
Dim oDefaultShape As String
Dim oMultipleShapes As String
Dim oActionCode As Integer = ACTIONCODE_IMPORT
If IsSerialnumberArticle = True Then
oArticleType = 0
@@ -254,15 +290,14 @@ Public Class Winline
oXmlData &= $"</MESOWebService>"
Try
My.Application.Winline.SendWebserviceRequest(oTemplateType, oTemplateName, oXmlData)
Return True
Return My.Application.Winline.SendWebserviceRequest(oTemplateType, oTemplateName, oXmlData)
Catch ex As Exception
_Logger.Error(ex)
Return False
End Try
End Function
Public Function CreatePriceInfo(ArticleNumber As String, RunningNumber As String, VendorNumber As String)
Public Function CreatePriceInfo(ArticleNumber As String, RunningNumber As String, VendorNumber As String) As Boolean
Dim oTemplateName As String = _Config.WebService.PriceTemplateName
Dim oTemplateType As Integer = _Config.WebService.PriceTemplateType
@@ -280,25 +315,28 @@ Public Class Winline
oXmlData &= $"</MESOWebService>"
Try
My.Application.Winline.SendWebserviceRequest(oTemplateType, oTemplateName, oXmlData)
Return True
Return My.Application.Winline.SendWebserviceRequest(oTemplateType, oTemplateName, oXmlData)
Catch ex As Exception
_Logger.Error(ex)
Return False
End Try
End Function
Public Sub RunWinlineMacro(MacroName As String, ParamArray Parameters As Object())
Public Function RunWinlineMacro(MacroName As String, ParamArray Parameters As Object()) As Boolean
Try
Dim oCWLObject
Dim oParamArray As Object = New Runtime.InteropServices.VariantWrapper(Parameters)
oCWLObject = CreateObject("cwlstart.application")
oCWLObject.MacroCommands.MRunMacro(MacroName, oParamArray)
Return True
Catch ex As Exception
_Logger.Error(ex)
MsgBox($"Das WinLine-Makro [{MacroName}] konnte nicht gestartet werden. Mehr Informationen im Log.", MsgBoxStyle.Critical, "WinLine")
_Logger.Warn($"Das WinLine-Makro [{MacroName}] konnte nicht gestartet werden.")
Return False
End Try
End Sub
End Function
End Class

View File

@@ -6,6 +6,11 @@
Public Property RunningNumber As String
Private ReadOnly Config As Config = My.Application.ConfigManager.Config
Private ReadOnly Logger As Logger = My.Application.LogConfig.GetLogger
Private Const TEMPLATE_NUMBER_NORMAL_ARTICLE = 45
Private Const TEMPLATE_NUMBER_SERIAL_ARTICLE = 46
Private Const CUSTOM_WINDOW_ID = 529
Private Sub frmCreateArticle_Load(sender As Object, e As EventArgs) Handles MyBase.Load
txtRunningNumber.Text = RunningNumber
@@ -23,7 +28,12 @@
txtFinalArticleNumber.Text = String.Empty
Logger.Info("Creating Article..")
Dim oArticleResult = My.Application.Winline.CreateArticle(ArticleNumber, RunningNumber, txtArticleDescription.Text, Vendor, IsSerialNumberArticle)
Logger.Info("Creating Price Info..")
Dim oPriceResult = My.Application.Winline.CreatePriceInfo(ArticleNumber, RunningNumber, Vendor.WinlineNumber)
If oArticleResult And oPriceResult Then
@@ -51,7 +61,7 @@
Dim oArticle = StartArticleCreation(True)
If oArticle IsNot Nothing Then
My.Computer.Clipboard.SetText(oArticle)
My.Application.Winline.RunWinlineMacro(My.Application.ConfigManager.Config.CompletionMacro, oArticle)
My.Application.Winline.RunWinlineMacro(My.Application.ConfigManager.Config.CompletionMacro, oArticle, CUSTOM_WINDOW_ID, TEMPLATE_NUMBER_SERIAL_ARTICLE)
End If
End If
End Sub
@@ -60,7 +70,7 @@
Dim oArticle = StartArticleCreation(False)
If oArticle IsNot Nothing Then
My.Computer.Clipboard.SetText(oArticle)
My.Application.Winline.RunWinlineMacro(My.Application.ConfigManager.Config.CompletionMacro, oArticle)
My.Application.Winline.RunWinlineMacro(My.Application.ConfigManager.Config.CompletionMacro, oArticle, CUSTOM_WINDOW_ID, TEMPLATE_NUMBER_NORMAL_ARTICLE)
End If
End Sub
End Class

View File

@@ -4,8 +4,17 @@
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
My.Application.LogConfig = New LogConfig(LogPath:=LogConfig.PathType.AppData, CompanyName:="Digital Data", ProductName:="WinLineProductNumberGenerator")
My.Application.ConfigManager = New ConfigManager(Of Config)(My.Application.LogConfig, Application.UserAppDataPath)
My.Application.LogConfig = New LogConfig(
Suffix:=Environment.MachineName,
LogPath:=LogConfig.PathType.CustomPath,
CustomLogPath:=Application.StartupPath,
CompanyName:="Digital Data",
ProductName:="WinLineProductNumberGenerator"
)
My.Application.ConfigManager = New ConfigManager(Of Config)(
My.Application.LogConfig,
Application.StartupPath
)
_Logger = My.Application.LogConfig.GetLogger()
Catch ex As Exception
MsgBox("Fehler beim Initialisieren (Logging und Config):" & vbNewLine & ex.Message, MsgBoxStyle.Critical, Text)
@@ -44,6 +53,8 @@
Dim oVendors = My.Application.Winline.GetVendors()
listboxVendors.DataSource = oVendors
_Logger.Info("Application started from Machine {0}", Environment.MachineName)
Catch ex As Exception
MsgBox("Fehler beim Initialisieren (Datenbank):" & vbNewLine & ex.Message, MsgBoxStyle.Critical, Text)
_Logger.Error(ex)
@@ -96,9 +107,15 @@
Dim oArticleNumber = $"{oVendor.Code}{oGroup.GroupString}{oVersion.VersionString}"
Dim oRunningNumber As String
_Logger.Info("Vendor Code: [{0}]", oVendor.Code)
_Logger.Info("Group String: [{0}]", oGroup.GroupString)
_Logger.Info("Version: [{0}]", oVersion.VersionString)
Try
oRunningNumber = My.Application.Winline.GetNextRunningNumber(oVendor.Code, oGroup.GroupId, oVersion.VersionId)
_Logger.Info("New Running Number: [{0}]", oRunningNumber)
If My.Application.Winline.TestArticleExists($"{oArticleNumber}{oRunningNumber}") Then
Throw New ApplicationException(My.Application.Winline.ARTICLE_ALREADY_EXISTS)
End If
@@ -111,8 +128,12 @@
.Group = oGroup
}
_Logger.Info("Opening Article form..")
oForm.ShowDialog()
Catch ex As Exception
_Logger.Error(ex)
Dim oMessage As String = ""
Select Case ex.Message