4 Commits

Author SHA1 Message Date
Jonathan Jenne
22a30533c2 Base: Version 1.3.4.0 2023-07-27 16:11:17 +02:00
Jonathan Jenne
de418bcca4 Base: add drawrectangle, getshorthash 2023-07-27 16:10:49 +02:00
Jonathan Jenne
7b2b37a870 Base: Add WindowsEx, ScreenEx 2023-07-27 15:47:02 +02:00
Jonathan Jenne
28538bcf41 Fix references to Firebird tables 2023-07-27 15:46:30 +02:00
10 changed files with 388 additions and 71 deletions

View File

@@ -81,8 +81,10 @@
<Compile Include="BaseUtils.vb" />
<Compile Include="DatabaseEx.vb" />
<Compile Include="ECM\ECM.vb" />
<Compile Include="WindowsEx.vb" />
<Compile Include="ModuleExtensions.vb" />
<Compile Include="FileEx.vb" />
<Compile Include="NativeMethods.vb" />
<Compile Include="ObjectEx.vb" />
<Compile Include="GraphicsEx.vb" />
<Compile Include="IDB\Attributes.vb" />
@@ -105,7 +107,6 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="PerformanceEx.vb" />
<Compile Include="ScreenEx.vb" />
<Compile Include="StringEx.vb" />
</ItemGroup>

View File

@@ -2,10 +2,20 @@
Public Class GraphicsEx
Public Shared Function GetBrightness(c As Color) As Single
Return (c.R * 0.299F + c.G * 0.587F + c.B * 0.114F) / 256.0F
''' <summary>
''' Returns the brightness of a color as a number between 0 and 1
''' </summary>
''' <param name="pColor">The color to check</param>
''' <returns>Low values for dark colors, high values for bright colors.</returns>
Public Shared Function GetBrightness(pColor As Color) As Single
Return (pColor.R * 0.299F + pColor.G * 0.587F + pColor.B * 0.114F) / 256.0F
End Function
''' <summary>
''' Returns a foreground/text color of either black or white, depending on the brightness of `pOtherColor`
''' </summary>
''' <param name="pOtherColor">The Background color whose brightness is determined</param>
''' <returns>A text color which is either white or black</returns>
Public Shared Function GetContrastedColor(pOtherColor As Color) As Color
If GetBrightness(pOtherColor) < 0.55 Then
Return Color.White
@@ -13,4 +23,21 @@ Public Class GraphicsEx
Return Color.Black
End If
End Function
Public Sub DrawRectangle(Bounds As Rectangle)
Dim oContext As IntPtr
oContext = NativeMethods.GetDC(IntPtr.Zero)
Try
Dim g As Graphics
g = Graphics.FromHdc(oContext)
Try
g.DrawRectangle(Pens.Red, Bounds)
Finally
g.Dispose()
End Try
Finally
NativeMethods.ReleaseDC(IntPtr.Zero, oContext)
End Try
End Sub
End Class

View File

@@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyCompany("")>
<Assembly: AssemblyProduct("Base")>
<Assembly: AssemblyCopyright("Copyright © 2023")>
<Assembly: AssemblyTrademark("1.3.3.0")>
<Assembly: AssemblyTrademark("1.3.4.0")>
<Assembly: ComVisible(False)>
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' indem Sie "*" wie unten gezeigt eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.3.3.0")>
<Assembly: AssemblyFileVersion("1.3.3.0")>
<Assembly: AssemblyVersion("1.3.4.0")>
<Assembly: AssemblyFileVersion("1.3.4.0")>

237
Base/NativeMethods.vb Normal file
View File

@@ -0,0 +1,237 @@
Imports System.Runtime.InteropServices
Imports System.Text
Imports DigitalData.Modules.Base.ScreenEx
Public Class NativeMethods
Public Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hwnd As Int32) As Integer
Public Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hWnd As IntPtr, ByVal WinTitle As String, ByVal MaxLength As Integer) As Integer
<DllImport("Shell32", CharSet:=CharSet.Auto, SetLastError:=True)>
Public Shared Function ShellExecuteEx(ByRef lpExecInfo As ShellExecuteInfo) As Boolean
End Function
<DllImport("user32", EntryPoint:="SetClipboardViewer")>
Public Shared Function SetClipboardViewer(ByVal hWnd As IntPtr) As IntPtr
End Function
<DllImport("user32.dll")>
Public Shared Function GetDC(ByVal hwnd As IntPtr) As IntPtr
End Function
<DllImport("user32.dll")>
Public Shared Function ReleaseDC(ByVal hwnd As IntPtr, ByVal hdc As IntPtr) As IntPtr
End Function
<DllImport("User32.dll")>
Public Shared Function ReleaseCapture() As Boolean
End Function
<DllImport("user32.dll")>
Public Shared Function GetWindowRect(ByVal hWnd As HandleRef, ByRef lpRect As RectangleAPI) As Boolean
End Function
<DllImport("user32.dll")>
Public Shared Function AttachThreadInput(ByVal idAttach As IntPtr, ByVal idAttachTo As IntPtr, fAttach As Boolean) As Boolean
End Function
<DllImport("user32.dll")>
Public Shared Function GetFocus() As IntPtr
End Function
<DllImport("user32.dll")>
Public Shared Function WindowFromPoint(ByVal p As PointAPI) As IntPtr
End Function
<DllImport("user32.dll")>
Public Shared Function GetForegroundWindow() As IntPtr
End Function
<DllImport("user32.dll")>
Public Shared Function GetWindowThreadProcessId(ByVal hwnd As IntPtr, ByRef lpdwProcessID As Integer) As Integer
End Function
<DllImport("user32.dll")>
Public Shared Function GetClassName(ByVal hwnd As Integer, ByVal lpClassName As StringBuilder, ByVal nMaxCount As Integer) As Integer
End Function
<DllImport("kernel32.dll")>
Public Shared Function OpenProcess(ByVal dwDesiredAccess As UInteger, ByVal bInheritHandle As Boolean, ByVal dwProcessId As UInteger) As IntPtr
End Function
<DllImport("kernel32.dll")>
Public Shared Function VirtualAllocEx(ByVal hProcess As IntPtr, ByVal lpAddress As IntPtr, ByVal dwSize As UIntPtr, ByVal flAllocationType As UInteger, ByVal flProtect As PageProtection) As IntPtr
End Function
<DllImport("user32.dll", SetLastError:=True)>
Public Shared Function GetWindowThreadProcessId(ByVal hWnd As IntPtr, <Out> ByRef lpdwProcessId As UInteger) As UInteger
End Function
<DllImport("kernel32.dll")>
Public Shared Function VirtualFreeEx(ByVal hProcess As IntPtr, ByVal lpAddress As IntPtr, ByVal dwSize As UIntPtr, ByVal dwFreeType As UInteger) As Boolean
End Function
<DllImport("kernel32.dll")>
Public Shared Function CloseHandle(ByVal hObject As IntPtr) As Boolean
End Function
<DllImport("kernel32.dll")>
Public Shared Function MapViewOfFile(ByVal hFileMappingObject As IntPtr, ByVal dwDesiredAccess As UInteger, ByVal dwFileOffsetHigh As UInteger, ByVal dwFileOffsetLow As UInteger, ByVal dwNumberOfBytesToMap As UIntPtr) As IntPtr
End Function
<DllImport("kernel32.dll")>
Public Shared Function UnmapViewOfFile(ByVal lpBaseAddress As IntPtr) As Boolean
End Function
<DllImport("kernel32.dll", SetLastError:=True)>
Public Shared Function CreateFileMapping(ByVal hFile As IntPtr, ByVal lpFileMappingAttributes As IntPtr, ByVal flProtect As PageProtection, ByVal dwMaximumSizeHigh As Integer, ByVal dwMaximumSizeLow As Integer, ByVal lpName As String) As IntPtr
End Function
<DllImport("user32.dll")>
Public Shared Function SendMessage(ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
End Function
<DllImport("kernel32.dll")>
Public Shared Function ReadProcessMemory(ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr,
<Out> ByVal lpBuffer As Byte(), ByVal nSize As UIntPtr, ByVal lpNumberOfBytesRead As IntPtr) As Boolean
End Function
<DllImport("Kernel32.dll", EntryPoint:="RtlMoveMemory", SetLastError:=False)>
Public Shared Sub MoveMemoryFromByte(ByVal dest As IntPtr, ByRef src As Byte, ByVal size As Integer)
End Sub
<DllImport("Kernel32.dll", EntryPoint:="RtlMoveMemory", SetLastError:=False)>
Public Shared Sub MoveMemoryToByte(ByRef dest As Byte, ByVal src As IntPtr, ByVal size As Integer)
End Sub
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)>
Public Shared Function RegisterWindowMessage(ByVal lpString As String) As Integer
End Function
<DllImport("user32.dll", ExactSpelling:=True, SetLastError:=True)>
Public Shared Function GetCursorPos(ByRef lpPoint As PointAPI) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
<DllImport("User32.dll", SetLastError:=True)>
Friend Shared Function MonitorFromWindow(ByVal hwnd As IntPtr,
ByVal dwFlags As Integer) As IntPtr
End Function
<DllImport("Shcore.dll", SetLastError:=True)>
Friend Shared Function GetDpiForMonitor(ByVal hmonitor As IntPtr,
ByVal dpiType As Monitor_DPI_Type,
ByRef dpiX As UInteger,
ByRef dpiY As UInteger) As Integer
End Function
<DllImport("gdi32.dll")>
Friend Shared Function GetDeviceCaps(ByVal hdc As IntPtr, ByVal nIndex As Integer) As Integer
End Function
Public Declare Function RegisterHotKey Lib "user32" (
ByVal Hwnd As IntPtr,
ByVal ID As Integer,
ByVal Modifiers As Integer,
ByVal Key As Integer
) As Integer
Public Declare Function UnregisterHotKey Lib "user32" (
ByVal Hwnd As IntPtr,
ByVal ID As Integer
) As Integer
Public Declare Auto Function GetWindowText Lib "user32" (
ByVal hWnd As IntPtr,
ByVal lpString As StringBuilder,
ByVal cch As Integer
) As Integer
Public Declare Function GlobalAddAtom Lib "kernel32" Alias "GlobalAddAtomA" (ByVal IDString As String) As Short
Public Declare Function GlobalDeleteAtom Lib "kernel32" (ByVal Atom As Short) As Short
Public Const STANDARD_RIGHTS_REQUIRED As Integer = &HF0000
Public Const SECTION_QUERY As Short = &H1
Public Const SECTION_MAP_WRITE As Short = &H2
Public Const SECTION_MAP_READ As Short = &H4
Public Const SECTION_MAP_EXECUTE As Short = &H8
Public Const SECTION_EXTEND_SIZE As Short = &H10
Public Const SECTION_ALL_ACCESS As Integer = STANDARD_RIGHTS_REQUIRED Or SECTION_QUERY Or SECTION_MAP_WRITE Or SECTION_MAP_READ Or SECTION_MAP_EXECUTE Or SECTION_EXTEND_SIZE
Public Const FILE_MAP_ALL_ACCESS As Integer = SECTION_ALL_ACCESS
Public Const PROCESS_VM_OPERATION As Short = &H8
Public Const PROCESS_VM_READ As Short = &H10
Public Const PROCESS_VM_WRITE As Short = &H20
Public Const PROCESS_ALL_ACCESS As Long = &H1F0FFF
Public Const MEM_COMMIT As Short = &H1000
Public Const MEM_RESERVE As Short = &H2000
Public Const MEM_DECOMMIT As Short = &H4000
Public Const MEM_RELEASE As Integer = &H8000
Public Const MEM_FREE As Integer = &H10000
Public Const MEM_PRIVATE As Integer = &H20000
Public Const MEM_MAPPED As Integer = &H40000
Public Const MEM_TOP_DOWN As Integer = &H100000
Public Const INVALID_HANDLE_VALUE As Integer = -1
Public Const SW_SHOW As Short = 5
Public Const SEE_MASK_INVOKEIDLIST = &HC
Public Const SEE_MASK_NOCLOSEPROCESS = &H40
Public Const SEE_MASK_FLAG_NO_UI = &H400
Public Const ULW_COLORKEY As Integer = &H1
Public Const ULW_ALPHA As Integer = &H2
Public Const ULW_OPAQUE As Integer = &H4
Public Const AC_SRC_OVER As Byte = &H0
Public Const AC_SRC_ALPHA As Byte = &H1
Public Const HTCAPTION As Integer = &H2
Public Const WM_NCLBUTTONDOWN As Integer = &HA1
Public Const WM_HOTKEY As Integer = &H312
Public Const WM_DRAWCLIPBOARD As Integer = &H308
Public Enum PageProtection As UInteger
NoAccess = &H1
[Readonly] = &H2
ReadWrite = &H4
WriteCopy = &H8
Execute = &H10
ExecuteRead = &H20
ExecuteReadWrite = &H40
ExecuteWriteCopy = &H80
Guard = &H100
NoCache = &H200
WriteCombine = &H400
End Enum
Public Enum ChildWindowFromPointFlags As UInteger
CWP_ALL
CWP_SKIPINVISIBLE
CWP_SKIPDISABLED
CWP_SKIPTRANSPARENT
End Enum
<StructLayout(LayoutKind.Sequential)>
Public Structure WINDOWPOS
Public hwnd As IntPtr
Public hwndInsertAfter As IntPtr
Public x As Integer
Public y As Integer
Public cx As Integer
Public cy As Integer
Public flags As Integer
End Structure
Public Structure RectangleAPI
Public Left As Integer
Public Top As Integer
Public Right As Integer
Public Bottom As Integer
Public Overrides Function ToString() As String
Return String.Format("Top: {0}, Bottom: {1}, Left: {2}, Right: {3}", Top, Bottom, Left, Right)
End Function
End Structure
Public Structure ShellExecuteInfo
Public cbSize As Integer
Public fMask As Integer
Public hwnd As IntPtr
<MarshalAs(UnmanagedType.LPTStr)> Public lpVerb As String
<MarshalAs(UnmanagedType.LPTStr)> Public lpFile As String
<MarshalAs(UnmanagedType.LPTStr)> Public lpParameters As String
<MarshalAs(UnmanagedType.LPTStr)> Public lpDirectory As String
Dim nShow As Integer
Dim hInstApp As IntPtr
Dim lpIDList As IntPtr
<MarshalAs(UnmanagedType.LPTStr)> Public lpClass As String
Public hkeyClass As IntPtr
Public dwHotKey As Integer
Public hIcon As IntPtr
Public hProcess As IntPtr
End Structure
<System.Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Sequential)>
Public Structure PointAPI
Public X As Integer
Public Y As Integer
Public Sub New(ByVal X As Integer, ByVal Y As Integer)
Me.X = X
Me.Y = Y
End Sub
End Structure
End Class

View File

@@ -1,44 +0,0 @@
Imports System.IO
Imports System.Reflection
Imports System.Runtime.InteropServices
Imports System.Security.Cryptography
Imports DigitalData.Modules.Logging
Public Class PerformanceEx
Public Sub New(pLogConfig As LogConfig, pAppDataPath As String)
Dim savedHash = String.Empty
Dim assemblyLocation = Assembly.GetEntryAssembly().Location
Dim hashPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "hash.txt")
If Not File.Exists(hashPath) Then
File.Create(hashPath)
Else
savedHash = File.ReadAllText(hashPath)
End If
Dim hash = String.Concat(SHA1.Create().ComputeHash(File.ReadAllBytes(assemblyLocation)).Select(Function(x) x.ToString("x2")))
If hash.Equals(savedHash) Then
Return
End If
Dim dotNetRuntimePath = RuntimeEnvironment.GetRuntimeDirectory()
Dim ngenPath = Path.Combine(dotNetRuntimePath, "ngen.exe")
Dim process = New Process With {
.StartInfo = New ProcessStartInfo With {
.FileName = ngenPath,
.Arguments = $"install ""{assemblyLocation}"" /nologo",
.CreateNoWindow = True,
.UseShellExecute = True,
.Verb = "runas"
}
}
Try
process.Start()
process.WaitForExit()
File.WriteAllText(hashPath, hash)
Catch
' ...
End Try
End Sub
End Class

View File

@@ -1,11 +1,30 @@
Imports System
Imports System.Drawing
Imports System.Runtime.InteropServices
Imports System.Windows.Forms
Imports DigitalData.Modules.Base.NativeMethods
Public Class ScreenEx
Public Const DEFAULT_WINDOW_HEIGHT = 480
Public Const DEFAULT_WINDOW_WIDTH = 640
Friend Const MONITORINFOF_PRIMARY As Integer = &H1
Friend Const MONITOR_DEFAULTTONEAREST As Integer = &H2
Friend Const MONITOR_DEFAULTTONULL As Integer = &H0
Friend Const MONITOR_DEFAULTTOPRIMARY As Integer = &H1
Friend Enum Monitor_DPI_Type As Integer
MDT_Effective_DPI = 0
MDT_Angular_DPI = 1
MDT_Raw_DPI = 2
MDT_Default = MDT_Effective_DPI
End Enum
Private Enum DeviceCap
VERTRES = 10
DESKTOPVERTRES = 117
End Enum
Public Shared Function GetLocationWithinScreen(pLocation As Point) As Point?
For Each screen As Screen In Screen.AllScreens
If screen.Bounds.Contains(pLocation) Then
@@ -100,4 +119,45 @@ Public Class ScreenEx
Return False
End Function
Public Function GetScreenScaling(Form As Form) As Single
Dim oHandle As IntPtr = Form.Handle
Dim oFactor1, oFactor2 As Single
oFactor1 = GetFactorFromDeviceCaps(oHandle)
oFactor2 = GetDPIFromMonitor(oHandle)
If oFactor1 > 1 Then
Return oFactor1
Else
Return oFactor2
End If
End Function
Private Function GetFactorFromDeviceCaps(Handle As IntPtr) As Single
Dim g As Graphics = Graphics.FromHwnd(Handle)
Dim desktop As IntPtr = g.GetHdc()
Dim LogicalScreenHeight As Integer = GetDeviceCaps(desktop, DeviceCap.VERTRES)
Dim PhysicalScreenHeight As Integer = GetDeviceCaps(desktop, DeviceCap.DESKTOPVERTRES)
Dim oScreenScalingFactor As Single = CSng(PhysicalScreenHeight) / CSng(LogicalScreenHeight)
Return oScreenScalingFactor
End Function
Private Function GetDPIFromMonitor(Handle As IntPtr) As Single
'Get handle to monitor that contains this window.
Dim monitorHandle As IntPtr = MonitorFromWindow(Handle, MONITOR_DEFAULTTONEAREST)
'Get DPI (If the OS is not Windows 8.1 or newer, calling GetDpiForMonitor will cause exception).
Dim dpiX As UInteger
Dim dpiY As UInteger
Dim result As Integer = GetDpiForMonitor(monitorHandle, Monitor_DPI_Type.MDT_Default, dpiX, dpiY)
If (result = 0) Then 'If S_OK (= 0)
Return dpiX / 96.0F
Else
Return -1
End If
End Function
End Class

View File

@@ -107,6 +107,10 @@ Public Class StringEx
Return GetChecksum(pStringToCheck)
End Function
Public Shared Function GetShortHash(pStringToCheck As String) As String
Return GetChecksum(pStringToCheck).Substring(0, 32)
End Function
Friend Class InvalidChars
Public Shared Filenames As String = Regex.Escape(New String(IO.Path.GetInvalidFileNameChars()))
Public Shared Paths As String = Regex.Escape(New String(IO.Path.GetInvalidPathChars()))

36
Base/WindowsEx.vb Normal file
View File

@@ -0,0 +1,36 @@
Imports System.ComponentModel
Imports System.Runtime.InteropServices
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Base.NativeMethods
Public Class WindowsEx
Private ReadOnly _LogConfig As LogConfig
Private ReadOnly _Logger As Logger
Public Sub New(LogConfig As LogConfig)
_LogConfig = LogConfig
_Logger = LogConfig.GetLogger()
End Sub
Public Function OpenFileProperties(FilePath As String) As Boolean
Try
Dim oShellExecuteInfo As New ShellExecuteInfo()
oShellExecuteInfo.cbSize = Marshal.SizeOf(oShellExecuteInfo)
oShellExecuteInfo.lpVerb = "properties"
oShellExecuteInfo.lpFile = FilePath
oShellExecuteInfo.nShow = SW_SHOW
oShellExecuteInfo.fMask = SEE_MASK_INVOKEIDLIST
If Not ShellExecuteEx(oShellExecuteInfo) Then
Dim oWin32Error = Marshal.GetLastWin32Error()
Dim oException As New Win32Exception(oWin32Error)
Throw oException
End If
Return True
Catch ex As Exception
_Logger.Error(ex)
Return False
End Try
End Function
End Class

View File

@@ -141,7 +141,7 @@ Public Class EmailFunctions
End Sub
Public Function GetEmailDataForMessageId(MessageId As String) As EmailData
Dim oSQL = $"SELECT EMAIL_FROM, EMAIL_SUBJECT, EMAIL_ATTMT1 FROM TBEMLP_HISTORY WHERE EMAIL_MSGID = '{MessageId}'"
Dim oSQL = $"SELECT EMAIL_FROM, EMAIL_SUBJECT FROM TBEMLP_HISTORY WHERE EMAIL_MSGID = '{MessageId}'"
Try
Dim oDatatable = _mssql.GetDatatable(oSQL)
Dim oRow As DataRow
@@ -159,15 +159,11 @@ Public Class EmailFunctions
Dim oFromDefault = String.Format("No Sender found for ({0})", MessageId)
Dim oFrom = oRow.ItemEx("EMAIL_FROM", oFromDefault)
Dim oAttachmentDefault = String.Format("No Attachment found for ({0})", MessageId)
Dim oAttachment = oRow.ItemEx("EMAIL_ATTMT1", oAttachmentDefault)
Dim oSubjectDefault = String.Format("No Subject found for ({0})", MessageId)
Dim oSubject = oRow.ItemEx("EMAIL_SUBJECT", oSubjectDefault)
Return New EmailData() With {
.From = oFrom,
.Attachment = oAttachment,
.Subject = oSubject
}
Catch ex As Exception

View File

@@ -309,11 +309,11 @@ Public Class ImportZUGFeRDFiles
End If
DeleteExistingPropertyValues(oMessageId, oArgs, oConnections)
DeleteExistingPropertyValues(oMessageId, oConnections)
Dim oFirstProperty = oCheckResult.ValidProperties.FirstOrDefault()
If oFirstProperty IsNot Nothing Then
InsertPropertyValue(oMessageId, oArgs, oConnections, New PropertyValues.ValidProperty() With {
InsertPropertyValue(oMessageId, oConnections, New PropertyValues.ValidProperty() With {
.MessageId = oMessageId,
.Description = "ZUGFeRDSpezifikation",
.GroupCounter = 0,
@@ -325,7 +325,7 @@ Public Class ImportZUGFeRDFiles
End If
For Each oProperty In oCheckResult.ValidProperties
InsertPropertyValue(oMessageId, oArgs, oConnections, oProperty)
InsertPropertyValue(oMessageId, oConnections, oProperty)
Next
Next
@@ -580,7 +580,7 @@ Public Class ImportZUGFeRDFiles
End Try
End Sub
Private Sub DeleteExistingPropertyValues(pMessageId As String, pArgs As WorkerArgs, pConnections As DatabaseConnections)
Private Sub DeleteExistingPropertyValues(pMessageId As String, pConnections As DatabaseConnections)
Dim oDelSQL = $"DELETE FROM TBEDMI_ITEM_VALUE where REFERENCE_GUID = '{pMessageId}'"
Dim oStep As String
@@ -592,7 +592,7 @@ Public Class ImportZUGFeRDFiles
End Try
End Sub
Private Sub InsertPropertyValue(pMessageId As String, pArgs As WorkerArgs, pConnections As DatabaseConnections, pProperty As PropertyValues.ValidProperty)
Private Sub InsertPropertyValue(pMessageId As String, pConnections As DatabaseConnections, pProperty As PropertyValues.ValidProperty)
Dim oGroupCounterValue = pProperty.GroupCounter
' If GroupCounter is -1, it means this is a default property that can only occur once.
@@ -752,21 +752,21 @@ Public Class ImportZUGFeRDFiles
Private Function Create_HistoryEntry(MessageId As String, MD5Checksum As String, Message As String, Transaction As SqlTransaction) As Boolean
Try
_logger.Info("Creating History Entry for MessageId [{0}] with comment [{1}]", MessageId, Message)
Dim oSQL = $"INSERT INTO TBEDM_ZUGFERD_HISTORY_IN (COMMENT, MD5HASH, MESSAGE_ID) VALUES ('{Message}', '{MD5Checksum}', '{MessageId}')"
Dim oSQL = $"INSERT INTO TBEMLP_HISTORY (COMMENT, MD5HASH, EMAIL_MSGID) VALUES ('{Message}', '{MD5Checksum}', '{MessageId}')"
Using oConnection = _mssql.GetConnection()
' 09.07.2021: This can't be in the transaction since the history
' Entry needs to be accessed by MoveAndRenameEmailToRejected shortly after
_mssql.ExecuteNonQueryWithConnectionObject(oSQL, Transaction.Connection, MSSQLServer.TransactionMode.NoTransaction)
_mssql.ExecuteNonQueryWithConnectionObject(oSQL, oConnection)
If Message.Contains("REJECTED") Then
oSQL = $"UPDATE TBEMLP_HISTORY SET STATUS = 'REJECTED', COMMENT = '{Message}', CUST_REJECTED = 1,CUST_REJECTED_WHEN = GETDATE() WHERE EMAIL_MSGID = '{MessageId}'"
_mssql.ExecuteNonQueryWithConnectionObject(oSQL, oConnection)
End If
_logger.Debug("History Entry created!")
End Using
_logger.Debug("History Entry created!")
If Message.Contains("REJECTED") Then
oSQL = $"UPDATE TBEMLP_HISTORY SET STATUS = 'REJECTED', COMMENT = '{Message}', CUST_REJECTED = 1,CUST_REJECTED_WHEN = GETDATE() WHERE EMAIL_MSGID = '{MessageId}'"
_mssql.ExecuteNonQuery(oSQL)
End If
Return True
Catch ex As Exception
_logger.Warn("History Entry count not be created for message id [{0}] and md5 [{1}]", MessageId, MD5Checksum)
@@ -780,12 +780,12 @@ Public Class ImportZUGFeRDFiles
Try
_logger.Info("Updating History Entry for MessageId [{0}] with comment [{1}]", MessageId, Message)
' Only look for history entry by MessageId since the MD5 Hash might not be generated yet
Dim oSQL = $"UPDATE TBEDM_ZUGFERD_HISTORY_IN SET COMMENT = '{Message}' WHERE MESSAGE_ID = '{MessageId}'"
Using oConnection = _mssql.GetConnection()
' 09.07.2021: This can't be in the transaction since the history
' Entry needs to be accessed by MoveAndRenameEmailToRejected shortly after
_mssql.ExecuteNonQueryWithConnectionObject(oSQL, Transaction.Connection, MSSQLServer.TransactionMode.NoTransaction)
Dim oSQL = $"UPDATE TBEMLP_HISTORY SET COMMENT = '{Message}' WHERE EMAIL_MSGID = '{MessageId}'"
_mssql.ExecuteNonQueryWithConnectionObject(oSQL, oConnection)
End Using
_logger.Debug("History Entry created!")