16 Commits

Author SHA1 Message Date
Jonathan Jenne
67cdc580fa Merge branch 'master' of http://git.dd:3000/AppStd/Modules 2022-12-16 09:08:42 +01:00
Jonathan Jenne
c082222c80 Messaging: Add binding class 2022-12-16 09:04:14 +01:00
Jonathan Jenne
33a95ba46d Version 2.6.1.0 2022-12-16 09:03:41 +01:00
Jonathan Jenne
a00ad5a9c0 Logging: WIP Json logging 2022-12-16 09:03:21 +01:00
Jonathan Jenne
db1d3fb197 Interfaces: Version 1.9.1.0 2022-12-16 08:37:29 +01:00
Jonathan Jenne
d5e98c5de4 Interfaces: Prepare language attribute in ADUser 2022-12-16 08:36:56 +01:00
Jonathan Jenne
e717dffa54 Filesystem: Version 1.4.1.0 2022-12-16 08:35:37 +01:00
Jonathan Jenne
eae009e82d Filesystem: Add new method GetVersionedFilenameWithFileCheck 2022-12-16 08:35:06 +01:00
Jonathan Jenne
d74e0f304a Database: Version 2.3.1.0 2022-12-16 08:34:33 +01:00
Jonathan Jenne
2816b644da Database: Log all command parameters 2022-12-16 08:34:19 +01:00
Jonathan Jenne
b927e07141 Windream: Version 1.7.1 2022-12-16 08:33:39 +01:00
Jonathan Jenne
f5107a3d21 Windream: Fix normalized paths 2022-12-16 08:33:09 +01:00
Jonathan Jenne
1ea73d9234 Windream: improve logging 2022-12-09 13:40:10 +01:00
Jonathan Jenne
d44ab2f087 Merge branch 'master' of http://git.dd:3000/AppStd/Modules 2022-12-09 13:31:08 +01:00
Jonathan Jenne
bd6d483867 Windream: Fix NewFolder 2022-12-09 13:31:01 +01:00
Jonathan Jenne
3883c0dad7 Messaging: Add general WCF code 2022-11-30 09:34:26 +01:00
19 changed files with 265 additions and 93 deletions

View File

@@ -340,7 +340,7 @@ Public Class MSSQLServer
pSqlCommandObject.CommandTimeout = pTimeout pSqlCommandObject.CommandTimeout = pTimeout
Using oAdapter As New SqlDataAdapter(pSqlCommandObject) Using oAdapter As New SqlDataAdapter(pSqlCommandObject)
Logger.Debug("GetDatatableWithConnectionObject: Running Query [{0}]", pSqlCommandObject.CommandText) Logger.Debug("GetDatatableWithConnectionObject: Running Query [{0}] and Parameters [{1}]", pSqlCommandObject.CommandText, GetParameterListAsString(pSqlCommandObject))
oAdapter.Fill(oTable) oAdapter.Fill(oTable)
End Using End Using
@@ -427,7 +427,7 @@ Public Class MSSQLServer
Dim oTransaction As SqlTransaction = MaybeGetTransaction(pSqlConnection, pTransactionMode, pTransaction) Dim oTransaction As SqlTransaction = MaybeGetTransaction(pSqlConnection, pTransactionMode, pTransaction)
Try Try
Logger.Debug("ExecuteNonQueryWithConnectionObject: Running Command [{0}]", pSqlCommandObject.CommandText) Logger.Debug("ExecuteNonQueryWithConnectionObject: Running Command [{0}] and Parameters [{1}]", pSqlCommandObject.CommandText, GetParameterListAsString(pSqlCommandObject))
pSqlCommandObject.Connection = pSqlConnection pSqlCommandObject.Connection = pSqlConnection
pSqlCommandObject.Transaction = oTransaction pSqlCommandObject.Transaction = oTransaction
@@ -517,6 +517,9 @@ Public Class MSSQLServer
Dim oResult As Object = Nothing Dim oResult As Object = Nothing
Try Try
Logger.Debug("GetScalarValueWithConnectionObject: Running Query [{0}] with Parameters [{1}]", pSqlCommandObject, GetParameterListAsString(pSqlCommandObject))
pSqlCommandObject.Connection = pSqlConnection pSqlCommandObject.Connection = pSqlConnection
pSqlCommandObject.CommandTimeout = pTimeout pSqlCommandObject.CommandTimeout = pTimeout
pSqlCommandObject.Transaction = oTransaction pSqlCommandObject.Transaction = oTransaction
@@ -601,4 +604,13 @@ Public Class MSSQLServer
Dim res = command.EndExecuteNonQuery(result) Dim res = command.EndExecuteNonQuery(result)
Logger.Info("Finished executing Async database operation: {0}", command.CommandText) Logger.Info("Finished executing Async database operation: {0}", command.CommandText)
End Sub End Sub
Private Function GetParameterListAsString(pSQLCommand As SqlCommand) As String
Dim oList = pSQLCommand.Parameters.
Cast(Of SqlParameter).
Select(Function(p) $"({p.ParameterName}={p.Value})").
ToList()
Return String.Join(",", oList)
End Function
End Class End Class

View File

@@ -99,7 +99,6 @@
<Compile Include="Dispatcher.vb" /> <Compile Include="Dispatcher.vb" />
<Compile Include="Exceptions.vb" /> <Compile Include="Exceptions.vb" />
<Compile Include="Adapters\Firebird.vb" /> <Compile Include="Adapters\Firebird.vb" />
<Compile Include="Helpers.vb" />
<Compile Include="IDatabase.vb" /> <Compile Include="IDatabase.vb" />
<Compile Include="Adapters\ODBC.vb" /> <Compile Include="Adapters\ODBC.vb" />
<Compile Include="Adapters\Oracle.vb" /> <Compile Include="Adapters\Oracle.vb" />

View File

@@ -1,10 +0,0 @@
Public Class Helpers
Public Shared Function MaybeEscapeSQLCommand(pSQLCommand As String) As String
End Function
End Class

View File

@@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyCompany("Digital Data")> <Assembly: AssemblyCompany("Digital Data")>
<Assembly: AssemblyProduct("Modules.Database")> <Assembly: AssemblyProduct("Modules.Database")>
<Assembly: AssemblyCopyright("Copyright © 2022")> <Assembly: AssemblyCopyright("Copyright © 2022")>
<Assembly: AssemblyTrademark("2.3.0.0")> <Assembly: AssemblyTrademark("2.3.1.0")>
<Assembly: ComVisible(False)> <Assembly: ComVisible(False)>
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("2.3.0.0")> <Assembly: AssemblyVersion("2.3.1.0")>
<Assembly: AssemblyFileVersion("2.3.0.0")> <Assembly: AssemblyFileVersion("2.3.1.0")>

View File

@@ -109,11 +109,21 @@ Public Class File
''' <summary> ''' <summary>
''' Adds file version string to given filename `Destination` if that file already exists. ''' Adds file version string to given filename `Destination` if that file already exists.
''' </summary> ''' </summary>
''' <param name="Destination"></param> ''' <param name="pFilePath">Filepath to check</param>
''' <returns></returns> ''' <returns>Versioned string</returns>
Public Function GetVersionedFilename(Destination As String) As String Public Function GetVersionedFilename(pFilePath As String) As String
Return GetVersionedFilenameWithFilecheck(pFilePath, Function(pPath As String) IO.File.Exists(pFilePath))
End Function
''' <summary>
''' Adds file version string to given filename `Destination` if that file already exists.
''' </summary>
''' <param name="pFilePath">Filepath to check</param>
''' <param name="pFileExistsAction">Custom action to check for file existence</param>
''' <returns>Versioned string</returns>
Public Function GetVersionedFilenameWithFilecheck(pFilePath As String, pFileExistsAction As Func(Of String, Boolean)) As String
Try Try
Dim oFileName As String = Destination Dim oFileName As String = pFilePath
Dim oFinalFileName = oFileName Dim oFinalFileName = oFileName
Dim oDestinationDir = Path.GetDirectoryName(oFileName) Dim oDestinationDir = Path.GetDirectoryName(oFileName)
@@ -131,7 +141,7 @@ Public Class File
' Shorten the filename (only filename, without extension or version) ' Shorten the filename (only filename, without extension or version)
' by cutting the length in half. This should work no matter how long the path and/or filename are. ' by cutting the length in half. This should work no matter how long the path and/or filename are.
' The initial check operates on the full path to catch all scenarios. ' The initial check operates on the full path to catch all scenarios.
If Destination.Length > MAX_FILE_PATH_LENGTH Then If pFilePath.Length > MAX_FILE_PATH_LENGTH Then
_Logger.Info("Filename is too long. Filename will be cut to prevent further errors.") _Logger.Info("Filename is too long. Filename will be cut to prevent further errors.")
_Logger.Info("Original Filename is: {0}", oFileNameWithoutExtension) _Logger.Info("Original Filename is: {0}", oFileNameWithoutExtension)
Dim oNewLength As Integer = Math.Round(oFileNameWithoutExtension.Length / 2) Dim oNewLength As Integer = Math.Round(oFileNameWithoutExtension.Length / 2)
@@ -147,15 +157,15 @@ Public Class File
_Logger.Debug("Intermediate Filename is {0}", oFinalFileName) _Logger.Debug("Intermediate Filename is {0}", oFinalFileName)
_Logger.Debug("File version: {0}", oFileVersion) _Logger.Debug("File version: {0}", oFileVersion)
oFileVersion += 1 oFileVersion += 1
Loop While (IO.File.Exists(oFinalFileName)) Loop While pFileExistsAction(oFinalFileName) = True
_Logger.Debug("Final Filename is {0}", oFinalFileName) _Logger.Debug("Final Filename is {0}", oFinalFileName)
Return oFinalFileName Return oFinalFileName
Catch ex As Exception Catch ex As Exception
_Logger.Warn("Filename {0} could not be versioned. Original filename will be returned!", Destination) _Logger.Warn("Filename {0} could not be versioned. Original filename will be returned!", pFilePath)
_Logger.Error(ex) _Logger.Error(ex)
Return Destination Return pFilePath
End Try End Try
End Function End Function
@@ -195,6 +205,8 @@ Public Class File
oStringVersion = 1 oStringVersion = 1
End If End If
_Logger.Debug("Versioned: String [{0}], Version [{1}]", pString, oStringVersion)
Return New Tuple(Of String, Integer)(pString, oStringVersion) Return New Tuple(Of String, Integer)(pString, oStringVersion)
End Function End Function

View File

@@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyCompany("Digital Data")> <Assembly: AssemblyCompany("Digital Data")>
<Assembly: AssemblyProduct("Modules.Filesystem")> <Assembly: AssemblyProduct("Modules.Filesystem")>
<Assembly: AssemblyCopyright("Copyright © 2022")> <Assembly: AssemblyCopyright("Copyright © 2022")>
<Assembly: AssemblyTrademark("1.4.0.0")> <Assembly: AssemblyTrademark("1.4.1.0")>
<Assembly: ComVisible(False)> <Assembly: ComVisible(False)>
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.4.0.0")> <Assembly: AssemblyVersion("1.4.1.0")>
<Assembly: AssemblyFileVersion("1.4.0.0")> <Assembly: AssemblyFileVersion("1.4.1.0")>

View File

@@ -193,6 +193,8 @@ Public Class ActiveDirectoryInterface
.FirebirdSyskey = oMap.FirebirdSyskey, .FirebirdSyskey = oMap.FirebirdSyskey,
.MSSQLColumn = oMap.MSSQLColumn .MSSQLColumn = oMap.MSSQLColumn
}) })
Else
_logger.Debug("Attribute [{0}] is empty.", oMap.AttributeName)
End If End If
Next Next
Else Else

View File

@@ -8,6 +8,7 @@ Public Class ADUser
Public Property GivenName As String Public Property GivenName As String
Public Property Middlename As String Public Property Middlename As String
Public Property Email As String Public Property Email As String
Public Property Language As String
Public CustomAttributes As List(Of CustomAttribute) Public CustomAttributes As List(Of CustomAttribute)

View File

@@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyCompany("Digital Data")> <Assembly: AssemblyCompany("Digital Data")>
<Assembly: AssemblyProduct("Modules.Interfaces")> <Assembly: AssemblyProduct("Modules.Interfaces")>
<Assembly: AssemblyCopyright("Copyright © 2022")> <Assembly: AssemblyCopyright("Copyright © 2022")>
<Assembly: AssemblyTrademark("1.9.0.0")> <Assembly: AssemblyTrademark("1.9.1.0")>
<Assembly: ComVisible(False)> <Assembly: ComVisible(False)>
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.9.0.0")> <Assembly: AssemblyVersion("1.9.1.0")>
<Assembly: AssemblyFileVersion("1.9.0.0")> <Assembly: AssemblyFileVersion("1.9.1.0")>

View File

@@ -81,6 +81,7 @@ Public Class LogConfig
Private Const TARGET_ERROR As String = "errorTarget" Private Const TARGET_ERROR As String = "errorTarget"
Private Const TARGET_DEBUG As String = "debugTarget" Private Const TARGET_DEBUG As String = "debugTarget"
Private Const TARGET_TRACE As String = "traceTarget" Private Const TARGET_TRACE As String = "traceTarget"
Private Const TARGET_JSON As String = "jsonTarget"
'Private Const TARGET_MEMORY As String = "memoryTarget" 'Private Const TARGET_MEMORY As String = "memoryTarget"
Private Const LOG_FORMAT_BASE As String = "${time}|${logger:shortName=True}|${level:uppercase=true}" Private Const LOG_FORMAT_BASE As String = "${time}|${logger:shortName=True}|${level:uppercase=true}"
@@ -101,8 +102,9 @@ Public Class LogConfig
Private ReadOnly _basePath As String = _failSafePath Private ReadOnly _basePath As String = _failSafePath
Private _config As LoggingConfiguration Private _config As LoggingConfiguration
Private _isDebug As Boolean = False Private _EnableDebugLogging As Boolean = False
Private _isTrace As Boolean = False Private _EnableTraceLogging As Boolean = False
Private _EnableJsonLogging As Boolean = False
#End Region #End Region
#Region "Public Properties" #Region "Public Properties"
@@ -137,21 +139,31 @@ Public Class LogConfig
''' <returns>True, if debug log will be written. False otherwise.</returns> ''' <returns>True, if debug log will be written. False otherwise.</returns>
Public Property Debug As Boolean Public Property Debug As Boolean
Get Get
Return _isDebug Return _EnableDebugLogging
End Get End Get
Set(isDebug As Boolean) Set(value As Boolean)
_isDebug = isDebug _EnableDebugLogging = value
ReloadConfig(isDebug, _isTrace) ReloadConfig()
End Set End Set
End Property End Property
Public Property Trace As Boolean Public Property Trace As Boolean
Get Get
Return _isTrace Return _EnableTraceLogging
End Get End Get
Set(isTrace As Boolean) Set(value As Boolean)
_isTrace = isTrace _EnableTraceLogging = value
ReloadConfig(_isDebug, isTrace) ReloadConfig()
End Set
End Property
Public Property EnableJsonLog As Boolean
Get
Return _EnableJsonLogging
End Get
Set(value As Boolean)
_EnableJsonLogging = value
ReloadConfig()
End Set End Set
End Property End Property
@@ -478,9 +490,7 @@ Public Class LogConfig
''' <summary> ''' <summary>
''' Reconfigures and re-adds all loggers, optionally adding the debug rule. ''' Reconfigures and re-adds all loggers, optionally adding the debug rule.
''' </summary> ''' </summary>
''' <param name="Debug">Adds the Debug rule if true.</param> Private Sub ReloadConfig()
''' <param name="Trace">Adds the Trace rule if true.</param>
Private Sub ReloadConfig(Optional Debug As Boolean = False, Optional Trace As Boolean = False)
Dim oLogger = GetLogger() Dim oLogger = GetLogger()
' Clear Logging Rules ' Clear Logging Rules
@@ -489,15 +499,22 @@ Public Class LogConfig
' Add default rules ' Add default rules
AddDefaultRules(_config) AddDefaultRules(_config)
' Add json rule, if configured
If _EnableJsonLogging = True Then
oLogger.Info("JSON Logging is now Enabled.")
_config.AddRule(LogLevel.Debug, LogLevel.Error, TARGET_JSON)
End If
' Add debug rule, if configured ' Add debug rule, if configured
If Debug = True Then If _EnableDebugLogging = True Then
_config.AddRule(LogLevel.Debug, LogLevel.Error, TARGET_DEBUG) _config.AddRule(LogLevel.Debug, LogLevel.Error, TARGET_DEBUG)
oLogger.Info("DEBUG Logging is now Enabled.") oLogger.Info("DEBUG Logging is now Enabled.")
Else Else
oLogger.Debug("DEBUG Logging is now Disabled.") oLogger.Debug("DEBUG Logging is now Disabled.")
End If End If
If Trace = True Then ' Add trace rule, if configured
If _EnableTraceLogging = True Then
_config.AddRule(LogLevel.Trace, LogLevel.Error, TARGET_TRACE) _config.AddRule(LogLevel.Trace, LogLevel.Error, TARGET_TRACE)
End If End If
@@ -506,11 +523,34 @@ Public Class LogConfig
End Sub End Sub
#Region "Log Targets" #Region "Log Targets"
Private Function GetJsonLogTarget(basePath As String) As FileTarget
Dim defaultLog As New FileTarget() With {
.FileName = Path.Combine(basePath, FILE_NAME_FORMAT_DEFAULT),
.Name = TARGET_JSON,
.Layout = LOG_FORMAT_DEFAULT,
.MaxArchiveFiles = MAX_ARCHIVE_FILES_DEFAULT,
.ArchiveEvery = ARCHIVE_EVERY,
.KeepFileOpen = KEEP_FILES_OPEN,
.Encoding = Text.Encoding.Unicode
}
Return defaultLog
End Function
Private Function GetDefaultLogTarget(basePath As String) As FileTarget Private Function GetDefaultLogTarget(basePath As String) As FileTarget
Dim oJsonLayout = New Layouts.JsonLayout
oJsonLayout.Attributes.Add(New Layouts.JsonAttribute("level", "${level}"))
oJsonLayout.Attributes.Add(New Layouts.JsonAttribute("message", "${message}"))
oJsonLayout.Attributes.Add(New Layouts.JsonAttribute("date", "${shortdate}"))
oJsonLayout.Attributes.Add(New Layouts.JsonAttribute("product", "${var:product}"))
oJsonLayout.Attributes.Add(New Layouts.JsonAttribute("suffix", "${var:suffix}"))
oJsonLayout.Attributes.Add(New Layouts.JsonAttribute("module", "${event-properties:item=ModuleName}"))
oJsonLayout.Attributes.Add(New Layouts.JsonAttribute("exception", "${exception:format=Message,StackTrace:innerFormat=Message:maxInnerExceptionLevel=3}"))
Dim defaultLog As New FileTarget() With { Dim defaultLog As New FileTarget() With {
.FileName = Path.Combine(basePath, FILE_NAME_FORMAT_DEFAULT), .FileName = Path.Combine(basePath, FILE_NAME_FORMAT_DEFAULT),
.Name = TARGET_DEFAULT, .Name = TARGET_DEFAULT,
.Layout = LOG_FORMAT_DEFAULT, .Layout = oJsonLayout,
.MaxArchiveFiles = MAX_ARCHIVE_FILES_DEFAULT, .MaxArchiveFiles = MAX_ARCHIVE_FILES_DEFAULT,
.ArchiveEvery = ARCHIVE_EVERY, .ArchiveEvery = ARCHIVE_EVERY,
.KeepFileOpen = KEEP_FILES_OPEN, .KeepFileOpen = KEEP_FILES_OPEN,
@@ -565,9 +605,9 @@ Public Class LogConfig
End Function End Function
Private Function GetTraceLogTarget(basePath As String) As FileTarget Private Function GetTraceLogTarget(basePath As String) As FileTarget
Dim debugLog As New FileTarget() With { Dim traceLog As New FileTarget() With {
.FileName = Path.Combine(basePath, FILE_NAME_FORMAT_TRACE), .FileName = Path.Combine(basePath, FILE_NAME_FORMAT_TRACE),
.Name = TARGET_DEBUG, .Name = TARGET_TRACE,
.Layout = LOG_FORMAT_DEBUG, .Layout = LOG_FORMAT_DEBUG,
.MaxArchiveFiles = MAX_ARCHIVE_FILES_DEBUG_DETAIL, .MaxArchiveFiles = MAX_ARCHIVE_FILES_DEBUG_DETAIL,
.ArchiveEvery = ARCHIVE_EVERY, .ArchiveEvery = ARCHIVE_EVERY,
@@ -578,18 +618,7 @@ Public Class LogConfig
.Encoding = Text.Encoding.Unicode .Encoding = Text.Encoding.Unicode
} }
Return debugLog Return traceLog
End Function End Function
'Private Function GetMemoryDebugTarget() As MemoryTarget
' Dim memoryLog As New MemoryTarget() With {
' .Layout = LOG_FORMAT_DEBUG,
' .Name = TARGET_MEMORY,
' .OptimizeBufferReuse = True,
' .MaxLogsCount = MAX_MEMORY_LOG_COUNT
' }
' Return memoryLog
'End Function
#End Region #End Region
End Class End Class

View File

@@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyCompany("Digital Data")> <Assembly: AssemblyCompany("Digital Data")>
<Assembly: AssemblyProduct("Modules.Logging")> <Assembly: AssemblyProduct("Modules.Logging")>
<Assembly: AssemblyCopyright("Copyright © 2022")> <Assembly: AssemblyCopyright("Copyright © 2022")>
<Assembly: AssemblyTrademark("2.6.0.0")> <Assembly: AssemblyTrademark("2.6.1.0")>
<Assembly: ComVisible(False)> <Assembly: ComVisible(False)>
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("2.6.0.0")> <Assembly: AssemblyVersion("2.6.1.0")>
<Assembly: AssemblyFileVersion("2.6.0.0")> <Assembly: AssemblyFileVersion("2.6.1.0")>

View File

@@ -96,6 +96,10 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile> </Compile>
<Compile Include="MailSender.vb" /> <Compile Include="MailSender.vb" />
<Compile Include="WCF\Binding.vb" />
<Compile Include="WCF\Channel.vb" />
<Compile Include="WCF\Constants.vb" />
<Compile Include="WCF\ServerAddress.vb" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="My Project\Resources.resx"> <EmbeddedResource Include="My Project\Resources.resx">

View File

@@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyCompany("")> <Assembly: AssemblyCompany("")>
<Assembly: AssemblyProduct("Messaging")> <Assembly: AssemblyProduct("Messaging")>
<Assembly: AssemblyCopyright("Copyright © 2022")> <Assembly: AssemblyCopyright("Copyright © 2022")>
<Assembly: AssemblyTrademark("1.8.0.0")> <Assembly: AssemblyTrademark("1.9.0.0")>
<Assembly: ComVisible(False)> <Assembly: ComVisible(False)>

31
Messaging/WCF/Binding.vb Normal file
View File

@@ -0,0 +1,31 @@
Imports System.Net
Imports System.ServiceModel
Imports System.Xml
Namespace WCF
Public Class Binding
Public Shared Function GetBinding(Optional AuthenticationMode As TcpClientCredentialType = TcpClientCredentialType.Windows) As NetTcpBinding
Return New NetTcpBinding() With {
.MaxReceivedMessageSize = Constants.ChannelSettings.MAX_RECEIVED_MESSAGE_SIZE,
.MaxBufferSize = Constants.ChannelSettings.MAX_BUFFER_SIZE,
.MaxBufferPoolSize = Constants.ChannelSettings.MAX_BUFFER_POOL_SIZE,
.TransferMode = TransferMode.Streamed,
.Security = New NetTcpSecurity() With {
.Mode = SecurityMode.Transport,
.Transport = New TcpTransportSecurity() With {
.ClientCredentialType = AuthenticationMode
}
},
.ReaderQuotas = New XmlDictionaryReaderQuotas() With {
.MaxArrayLength = Constants.ChannelSettings.MAX_ARRAY_LENGTH,
.MaxStringContentLength = Constants.ChannelSettings.MAX_STRING_CONTENT_LENGTH
}
}
End Function
Public Shared Function GetAddress(pHost As String, pPort As Integer, pName As String) As Uri
Return New Uri($"net.tcp://{pHost}:{pPort}/DigitalData/Services/{pName}")
End Function
End Class
End Namespace

52
Messaging/WCF/Channel.vb Normal file
View File

@@ -0,0 +1,52 @@
Imports System.ServiceModel
Imports System.Xml
Imports DigitalData.Modules.Base
Imports DigitalData.Modules.Logging
Namespace WCF
Public Class Channel(Of TChannel As IClientChannel)
Inherits BaseClass
Private ReadOnly ChannelFactory As ChannelFactory(Of TChannel)
Public Event Reconnect As EventHandler
Public Sub New(pLogConfig As LogConfig, pServerAddress As ServerAddress, Optional pName As String = "Main")
MyBase.New(pLogConfig)
ChannelFactory = GetChannelFactory(pServerAddress, pName)
End Sub
''' <summary>
''' Creates a channel and adds a Faulted-Handler
''' </summary>
''' <returns>A channel object</returns>
Public Function GetChannel() As TChannel
Try
Logger.Debug("Creating channel.")
Dim oChannel = ChannelFactory.CreateChannel()
AddHandler oChannel.Faulted, Sub() RaiseEvent Reconnect(Me, Nothing)
Return oChannel
Catch ex As Exception
Logger.Error(ex)
Throw ex
End Try
End Function
''' <summary>
''' Creates and returns a channel factory with the supplied name and address
''' </summary>
''' <param name="pName">The service name, will be: net.tcp://ip:port/DigitalData/Services/[name]</param>
''' <param name="pAddress">The service address, in the form of ip address and port</param>
''' <returns></returns>
Private Function GetChannelFactory(pAddress As ServerAddress, pName As String) As ChannelFactory(Of TChannel)
Dim oBinding = Binding.GetBinding()
Dim oAddress = New EndpointAddress(Binding.GetAddress(pAddress.Host, pAddress.Port, pName))
Dim oFactory = New ChannelFactory(Of TChannel)(oBinding, oAddress)
Return oFactory
End Function
End Class
End Namespace

View File

@@ -0,0 +1,20 @@
Namespace WCF
Public Class Constants
Public Const DEFAULT_SERVICE_PORT = 9000
''' <summary>
''' Infos about MaxBufferSize and MaxBufferPoolSize
''' https://social.msdn.microsoft.com/Forums/vstudio/en-US/d6e234d3-942f-4e9d-8470-32618d3f3212/maxbufferpoolsize-vs-maxbuffersize?forum=wcf
''' </summary>
Public Class ChannelSettings
Public Const MAX_RECEIVED_MESSAGE_SIZE = 2147483647 ' 1GB
Public Const MAX_BUFFER_SIZE = 104857600 ' 100MB
Public Const MAX_BUFFER_POOL_SIZE = 1048576 ' 1MB
Public Const MAX_CONNECTIONS = 500
Public Const MAX_ARRAY_LENGTH = 2147483647
Public Const MAX_STRING_CONTENT_LENGTH = 2147483647
End Class
End Class
End Namespace

View File

@@ -0,0 +1,7 @@
Namespace WCF
Public Structure ServerAddress
Public Host As String
Public Port As Integer
End Structure
End Namespace

View File

@@ -12,8 +12,8 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyDescription("")> <Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("")> <Assembly: AssemblyCompany("")>
<Assembly: AssemblyProduct("Modules.Windream")> <Assembly: AssemblyProduct("Modules.Windream")>
<Assembly: AssemblyCopyright("Copyright © 2021")> <Assembly: AssemblyCopyright("Copyright © 2022")>
<Assembly: AssemblyTrademark("1.7.0.0")> <Assembly: AssemblyTrademark("1.7.1.0")>
<Assembly: ComVisible(False)> <Assembly: ComVisible(False)>
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.7.0.0")> <Assembly: AssemblyVersion("1.7.1.0")>
<Assembly: AssemblyFileVersion("1.7.0.0")> <Assembly: AssemblyFileVersion("1.7.1.0")>

View File

@@ -638,6 +638,7 @@ Public Class Windream
Return False Return False
End Try End Try
End Function End Function
''' <summary> ''' <summary>
''' Archives windream object immediately ''' Archives windream object immediately
''' </summary> ''' </summary>
@@ -654,7 +655,7 @@ Public Class Windream
End Try End Try
End Function End Function
Public Function NewFolder(Path As String, pExtension As String) As Boolean Public Function NewFolder(Path As String) As Boolean
If Not TestSessionLoggedIn() Then If Not TestSessionLoggedIn() Then
Return False Return False
End If End If
@@ -665,13 +666,11 @@ Public Class Windream
Dim oFolderObject As WMObject Dim oFolderObject As WMObject
Dim oCurrentPath As String = String.Empty Dim oCurrentPath As String = String.Empty
For Each oFolder In oFolders For Each oFolder In oFolders
If oFolder.ToString.EndsWith(pExtension) Then If oFolder = String.Empty Then
Exit For
ElseIf oFolder = String.Empty Then
Continue For Continue For
End If End If
oCurrentPath = Combine(oCurrentPath, oFolder) oCurrentPath = Combine(oCurrentPath, oFolder)
If TestFolderExists(oCurrentPath) = False Then If TestFolderExists(oCurrentPath) = False Then
@@ -707,13 +706,13 @@ Public Class Windream
Public Function NewFileStream(ByVal FilenameSource As String, ByVal FilenameTarget As String, ByVal WMObjecttypeName As String) As Boolean Public Function NewFileStream(ByVal FilenameSource As String, ByVal FilenameTarget As String, ByVal WMObjecttypeName As String) As Boolean
NewDocumentID = 0 NewDocumentID = 0
Dim oExtension As String = Path.GetExtension(FilenameSource)
If Not TestSessionLoggedIn() Then If Not TestSessionLoggedIn() Then
Return False Return False
End If End If
Dim oTargetDrive As String = Path.GetDirectoryName(FilenameTarget) Dim oTargetDrive As String = Path.GetDirectoryName(FilenameTarget)
FilenameTarget = GetNormalizedPath(FilenameTarget, True) FilenameTarget = GetNormalizedPath(FilenameTarget, True)
_logger.Debug($"Preparing to stream file from {FilenameSource} to {FilenameTarget}") _logger.Debug($"Preparing to stream file from {FilenameSource} to {FilenameTarget}")
@@ -722,7 +721,7 @@ Public Class Windream
Dim oFileIO As WMFileIO Dim oFileIO As WMFileIO
Dim oWMStream As WMStream Dim oWMStream As WMStream
NewFolder(FilenameTarget, oExtension) NewFolder(oTargetDrive)
'Indexierungsdialog der Session unterdrücken 'Indexierungsdialog der Session unterdrücken
Session.SwitchEvents(Constants.COM_EVENT_SESSION_NEED_INDEX, False) Session.SwitchEvents(Constants.COM_EVENT_SESSION_NEED_INDEX, False)
@@ -778,7 +777,6 @@ Public Class Windream
oWMStream.Close() oWMStream.Close()
_logger.Debug("Saving new object") _logger.Debug("Saving new object")
oWMObject.aObjectType = GetObjectByName(WMObjecttypeName, WMEntityObjectType) oWMObject.aObjectType = GetObjectByName(WMObjecttypeName, WMEntityObjectType)
oWMObject.Save() oWMObject.Save()
@@ -818,24 +816,20 @@ Public Class Windream
End Try End Try
End Function End Function
Public Function GetNormalizedPath(Path As String, pCleanPath As Boolean) As String Public Function GetNormalizedPath(pPath As String, pCleanPath As Boolean) As String
_logger.Debug("Normalizing Path: [{0}]", Path) _logger.Debug("Normalizing Path: [{0}]", pPath)
Dim oNormalizedPath As String = Path Dim oNormalizedPath As String = pPath
If pCleanPath = True Then
oNormalizedPath = Language.Utils.RemoveInvalidCharacters(Path)
_logger.Debug("path after RemoveInvalidCharacters: [{0}]", oNormalizedPath)
End If
Try
' Convert any forward slashes / and double slashes \\ into backslashes \
' See: https://stackoverflow.com/questions/3144492/how-do-i-get-nets-path-combine-to-convert-forward-slashes-to-backslashes
If IsPathRooted(oNormalizedPath) Then
oNormalizedPath = GetFullPath(oNormalizedPath)
End If
If pCleanPath = True Then
oNormalizedPath = Utils.RemoveInvalidCharacters(pPath)
_logger.Debug("Path after RemoveInvalidCharacters: [{0}]", oNormalizedPath)
End If
Try
' Remove Driveletter, eg. W:\ ' Remove Driveletter, eg. W:\
If oNormalizedPath.StartsWith($"{ClientDriveLetter}:\") Then If oNormalizedPath.StartsWith($"{ClientDriveLetter}:\") Then
oNormalizedPath = oNormalizedPath.Substring(ClientDriveLetter.Length + 2) oNormalizedPath = oNormalizedPath.Substring(ClientDriveLetter.Length + 2)
_logger.Debug($"path after replaced ClientDriveLetter: [{oNormalizedPath}]") _logger.Debug($"Path after replaced ClientDriveLetter: [{oNormalizedPath}]")
End If End If
' Remove Windream Base Path, eg. \\windream\objects\ ' Remove Windream Base Path, eg. \\windream\objects\
@@ -846,22 +840,41 @@ Public Class Windream
' Handle misconfigured drive-letter ' Handle misconfigured drive-letter
If oNormalizedPath.Contains(":") Then If oNormalizedPath.Contains(":") Then
_logger.Warn($"oNormalizedPath still contains a drive name!!") _logger.Warn($"NormalizedPath [{oNormalizedPath}] still contains a drive name!!")
_logger.Warn($"Check Your config ClientDriveLetter [{ClientDriveLetter}] // ClientBasePath [{ClientBasePath}]") _logger.Warn($"Check Your config ClientDriveLetter [{ClientDriveLetter}] // ClientBasePath [{ClientBasePath}]")
oNormalizedPath = oNormalizedPath.Substring(3) oNormalizedPath = oNormalizedPath.Substring(3)
End If End If
' Convert any forward slashes / and double slashes \\ into backslashes \
' See: https://stackoverflow.com/questions/3144492/how-do-i-get-nets-path-combine-to-convert-forward-slashes-to-backslashes
If IsPathRooted(oNormalizedPath) Then
' This breaks because it converts the path "\SomeFolder" into "C:\SomeFolder" LOL
'oNormalizedPath = GetFullPath(oNormalizedPath)
' Lets just be pragmatic here
oNormalizedPath = oNormalizedPath.Replace("\\", "\")
oNormalizedPath = oNormalizedPath.Replace("/", "\")
_logger.Debug("Path after converting slashes: [{0}]", oNormalizedPath)
End If
If oNormalizedPath.StartsWith("\") = False Then If oNormalizedPath.StartsWith("\") = False Then
oNormalizedPath = $"\{oNormalizedPath}" oNormalizedPath = $"\{oNormalizedPath}"
End If End If
_logger.Debug($"oNormalizedPath: [{oNormalizedPath}]")
_logger.Debug($"NormalizedPath: [{oNormalizedPath}]")
Return oNormalizedPath Return oNormalizedPath
Catch ex As Exception Catch ex As Exception
_logger.Warn($"Unexpected error in GetNormalizedPath - oNormalizedPath [{oNormalizedPath}] - Error: [{ex.Message}]") _logger.Warn($"Unexpected error in GetNormalizedPath - NormalizedPath [{oNormalizedPath}] - Error: [{ex.Message}]")
Return "" Return ""
End Try End Try
End Function End Function
Public Function GetAbsolutePath(pPath As String) As String
Dim oNormalizedPath = GetNormalizedPath(pPath, False)
Return $"\\windream\objects{oNormalizedPath}"
End Function
''' <summary> ''' <summary>
''' Returns the result of a search file ''' Returns the result of a search file
''' </summary> ''' </summary>