diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/configuration.svcinfo b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/configuration.svcinfo index 4dc839d7..be0ae953 100644 --- a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/configuration.svcinfo +++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/configuration.svcinfo @@ -2,9 +2,9 @@ - + - + \ No newline at end of file diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/configuration91.svcinfo b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/configuration91.svcinfo index 12c40947..d8e67e9c 100644 --- a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/configuration91.svcinfo +++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/configuration91.svcinfo @@ -1,10 +1,10 @@ - + - + - tcpBinding + NetTcpBinding_IEDMIService @@ -121,7 +121,7 @@ - + net.tcp://localhost:9000/DigitalData/Services/Main @@ -133,7 +133,7 @@ netTcpBinding - tcpBinding + NetTcpBinding_IEDMIService EDMIServiceReference.IEDMIService @@ -196,7 +196,7 @@ False - tcpBinding + NetTcpBinding_IEDMIService diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/service.wsdl b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/service.wsdl index aaced7c1..8057e4f2 100644 --- a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/service.wsdl +++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/service.wsdl @@ -1,6 +1,6 @@  - + @@ -37,8 +37,8 @@ - - + + @@ -170,7 +170,7 @@ - + net.tcp://localhost:9000/DigitalData/Services/Main diff --git a/Modules.EDMIAPI/app.config b/Modules.EDMIAPI/app.config index 9de6fa5b..2f4d378a 100644 --- a/Modules.EDMIAPI/app.config +++ b/Modules.EDMIAPI/app.config @@ -25,7 +25,7 @@ - + @@ -34,8 +34,8 @@ + binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IEDMIService" + contract="EDMIServiceReference.IEDMIService" name="NetTcpBinding_IEDMIService"> diff --git a/Modules.Logging/LogConfig.vb b/Modules.Logging/LogConfig.vb index 11831477..b66b547c 100644 --- a/Modules.Logging/LogConfig.vb +++ b/Modules.Logging/LogConfig.vb @@ -87,11 +87,12 @@ Public Class LogConfig Private Const LOG_FORMAT_BASE As String = DATE_FORMAT_DEFAULT & "|${logger:shortName=True}|${level:uppercase=true}" Private Const LOG_FORMAT_BASE_LONG_DATE As String = DATE_FORMAT_LONG & "|${logger:shortName=True}|${level:uppercase=true}" Private Const LOG_FORMAT_CALLSITE As String = "${callsite:className=false:fileName=true:includeSourcePath=false:methodName=true}" + Private Const LOG_FORMAT_EXCEPTION As String = "${exception:format=Message,StackTrace:innerFormat=Message:maxInnerExceptionLevel=1}" Private Const LOG_FORMAT_DEFAULT As String = LOG_FORMAT_BASE & " >> ${message}" - Private Const LOG_FORMAT_EXCEPTION As String = LOG_FORMAT_BASE & " >> ${exception:format=Message}${newline}${exception:format=StackTrace}" + Private Const LOG_FORMAT_ERROR As String = LOG_FORMAT_BASE & " >> " & LOG_FORMAT_EXCEPTION Private Const LOG_FORMAT_DEBUG As String = LOG_FORMAT_BASE_LONG_DATE & " >> " & LOG_FORMAT_CALLSITE & " -> ${message}" - Private Const LOG_FORMAT_MEMORY As String = LOG_FORMAT_BASE_LONG_DATE & " >> ${message}${newline}${exception:format=Message}${newline}${exception:format=StackTrace}" + Private Const LOG_FORMAT_MEMORY As String = LOG_FORMAT_BASE_LONG_DATE & " >> " & LOG_FORMAT_EXCEPTION Private Const FILE_NAME_ACCESS_TEST = "accessTest.txt" Private Const FOLDER_NAME_LOG = "Log" @@ -404,7 +405,7 @@ Public Class LogConfig Dim errorLogWithExceptions As New FileTarget() With { .FileName = Path.Combine(basePath, FILE_NAME_FORMAT_ERROR), .Name = TARGET_ERROR_EX, - .Layout = LOG_FORMAT_EXCEPTION, + .Layout = LOG_FORMAT_ERROR, .MaxArchiveFiles = MAX_ARCHIVE_FILES_DEFAULT, .ArchiveEvery = ARCHIVE_EVERY, .KeepFileOpen = KEEP_FILES_OPEN diff --git a/Modules.Logging/My Project/AssemblyInfo.vb b/Modules.Logging/My Project/AssemblyInfo.vb index 16f7347b..d7f99248 100644 --- a/Modules.Logging/My Project/AssemblyInfo.vb +++ b/Modules.Logging/My Project/AssemblyInfo.vb @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - - + + diff --git a/Service.EDMIService/EDMIService.vb b/Service.EDMIService/EDMIService.vb index a29fb9ee..6ab1d49f 100644 --- a/Service.EDMIService/EDMIService.vb +++ b/Service.EDMIService/EDMIService.vb @@ -37,6 +37,8 @@ Public Class EDMIService Dim oDescription = ContractDescription.GetContract(GetType(IEDMIService), GetType(EDMIService)) Dim oEndpoint As New ServiceEndpoint(oDescription, oBinding, oAddress) + + Config.AddServiceEndpoint(oEndpoint) Config.Description.Behaviors.Add(New ServiceDebugBehavior With {.IncludeExceptionDetailInFaults = True}) End Sub diff --git a/Service.EDMIService/EDMIService.vbproj b/Service.EDMIService/EDMIService.vbproj index cf51d68f..eaaeb7bb 100644 --- a/Service.EDMIService/EDMIService.vbproj +++ b/Service.EDMIService/EDMIService.vbproj @@ -125,6 +125,7 @@ + diff --git a/Service.EDMIService/EDMITraceListener.vb b/Service.EDMIService/EDMITraceListener.vb new file mode 100644 index 00000000..9a72221e --- /dev/null +++ b/Service.EDMIService/EDMITraceListener.vb @@ -0,0 +1,251 @@ +Imports System.Configuration +Imports System.Globalization +Imports System.IO +Imports System.Security.Permissions +Imports System.Text.RegularExpressions + +''' +''' Adapted from: https://www.codeproject.com/Articles/30956/A-Rolling-XmlWriterTraceListener +''' + +Public Class EDMITraceListener + Inherits XmlWriterTraceListener + + Private Shared ReadOnly LogFileNumberCaptureName As String = "LogFileNumber" + Private _attributesLoaded As Boolean = False + Private _logfileSuffixExpression As Regex = New Regex("_(?<" & LogFileNumberCaptureName & ">\d*)\.", RegexOptions.Compiled) + Private _currentFileSuffixNumber As Integer = 0 + Private _maxTraceFileSize As Long = 128 * 1024 * 1024 + Private _basicTraceFileName As String = String.Empty + + Public Sub New(ByVal filename As String) + MyBase.New(filename) + Me._basicTraceFileName = filename + Me._currentFileSuffixNumber = Me.GetTraceFileNumber() + Me.StartNewTraceFile() + End Sub + + Public Sub New(ByVal filename As String, ByVal name As String) + MyBase.New(filename, name) + Me._basicTraceFileName = filename + Me.StartNewTraceFile() + End Sub + + Public ReadOnly Property CurrentTraceFileName As String + Get + Return Path.Combine(Path.GetDirectoryName(Me._basicTraceFileName), Path.GetFileNameWithoutExtension(Me._basicTraceFileName) & "_" & Me._currentFileSuffixNumber.ToString().PadLeft(4, "0"c) & Path.GetExtension(Me._basicTraceFileName)) + End Get + End Property + + Public Property MaxTraceFileSize As Long + Get + + If Not Me._attributesLoaded Then + Me.LoadAttributes() + End If + + Return Me._maxTraceFileSize + End Get + Set(ByVal value As Long) + + If Not Me._attributesLoaded Then + Me.LoadAttributes() + End If + + Me._maxTraceFileSize = value + End Set + End Property + + Protected ReadOnly Property IsRollingConditionReached As Boolean + Get + Dim streamWriter As StreamWriter = CType(Me.Writer, StreamWriter) + Dim fileStream As FileStream = CType(streamWriter.BaseStream, FileStream) + Dim traceFileName As String = fileStream.Name + Dim traceFileInfo As FileInfo = New FileInfo(traceFileName) + + If traceFileInfo.Length > Me.MaxTraceFileSize Then + Return True + Else + Return False + End If + End Get + End Property + + Public Overrides Sub Fail(ByVal message As String) + If Me.IsRollingConditionReached Then + Me.StartNewTraceFile() + End If + + MyBase.Fail(message) + End Sub + + Public Overrides Sub Fail(ByVal message As String, ByVal detailMessage As String) + If Me.IsRollingConditionReached Then + Me.StartNewTraceFile() + End If + + MyBase.Fail(message, detailMessage) + End Sub + + Public Overrides Sub TraceData(ByVal eventCache As TraceEventCache, ByVal source As String, ByVal eventType As TraceEventType, ByVal id As Integer, ByVal data As Object) + If Me.IsRollingConditionReached Then + Me.StartNewTraceFile() + End If + + MyBase.TraceData(eventCache, source, eventType, id, data) + End Sub + + Public Overrides Sub TraceData(ByVal eventCache As TraceEventCache, ByVal source As String, ByVal eventType As TraceEventType, ByVal id As Integer, ParamArray data As Object()) + If Me.IsRollingConditionReached Then + Me.StartNewTraceFile() + End If + + MyBase.TraceData(eventCache, source, eventType, id, data) + End Sub + + Public Overrides Sub TraceEvent(ByVal eventCache As TraceEventCache, ByVal source As String, ByVal eventType As TraceEventType, ByVal id As Integer) + If Me.IsRollingConditionReached Then + Me.StartNewTraceFile() + End If + + MyBase.TraceEvent(eventCache, source, eventType, id) + End Sub + + Public Overrides Sub TraceEvent(ByVal eventCache As TraceEventCache, ByVal source As String, ByVal eventType As TraceEventType, ByVal id As Integer, ByVal message As String) + If Me.IsRollingConditionReached Then + Me.StartNewTraceFile() + End If + + MyBase.TraceEvent(eventCache, source, eventType, id, message) + End Sub + + Public Overrides Sub TraceEvent(ByVal eventCache As TraceEventCache, ByVal source As String, ByVal eventType As TraceEventType, ByVal id As Integer, ByVal format As String, ParamArray args As Object()) + If Me.IsRollingConditionReached Then + Me.StartNewTraceFile() + End If + + MyBase.TraceEvent(eventCache, source, eventType, id, format, args) + End Sub + + Public Overrides Sub TraceTransfer(ByVal eventCache As TraceEventCache, ByVal source As String, ByVal id As Integer, ByVal message As String, ByVal relatedActivityId As Guid) + If Me.IsRollingConditionReached Then + Me.StartNewTraceFile() + End If + + MyBase.TraceTransfer(eventCache, source, id, message, relatedActivityId) + End Sub + + Public Overrides Sub Write(ByVal o As Object) + If Me.IsRollingConditionReached Then + Me.StartNewTraceFile() + End If + + MyBase.Write(o) + End Sub + + Public Overrides Sub Write(ByVal o As Object, ByVal category As String) + If Me.IsRollingConditionReached Then + Me.StartNewTraceFile() + End If + + MyBase.Write(o, category) + End Sub + + Public Overrides Sub Write(ByVal message As String) + If Me.IsRollingConditionReached Then + Me.StartNewTraceFile() + End If + + MyBase.Write(message) + End Sub + + Public Overrides Sub Write(ByVal message As String, ByVal category As String) + If Me.IsRollingConditionReached Then + Me.StartNewTraceFile() + End If + + MyBase.Write(message, category) + End Sub + + Public Overrides Sub WriteLine(ByVal o As Object) + If Me.IsRollingConditionReached Then + Me.StartNewTraceFile() + End If + + MyBase.WriteLine(o) + End Sub + + Public Overrides Sub WriteLine(ByVal o As Object, ByVal category As String) + If Me.IsRollingConditionReached Then + Me.StartNewTraceFile() + End If + + MyBase.WriteLine(o, category) + End Sub + + Public Overrides Sub WriteLine(ByVal message As String) + If Me.IsRollingConditionReached Then + Me.StartNewTraceFile() + End If + + MyBase.WriteLine(message) + End Sub + + Public Overrides Sub WriteLine(ByVal message As String, ByVal category As String) + If Me.IsRollingConditionReached Then + Me.StartNewTraceFile() + End If + + MyBase.WriteLine(message, category) + End Sub + + Protected Overrides Function GetSupportedAttributes() As String() + Return New String(0) {"MaxTraceFileSize"} + End Function + + Private Sub StartNewTraceFile() + Dim streamWriter As StreamWriter = CType(Me.Writer, StreamWriter) + Dim fileStream As FileStream = CType(streamWriter.BaseStream, FileStream) + fileStream.Close() + Me._currentFileSuffixNumber += 1 + Me.Writer = New StreamWriter(New FileStream(Me.CurrentTraceFileName, FileMode.Create)) + End Sub + + Private Function GetTraceFileNumber() As Integer + Dim directoryName As String = Path.GetDirectoryName(Me._basicTraceFileName) + Dim basicTraceFileNameWithoutExtension As String = Path.GetFileNameWithoutExtension(Me._basicTraceFileName) + Dim basicTraceFileNameExtension As String = Path.GetExtension(Me._basicTraceFileName) + Dim existingLogFiles As String() = Directory.GetFiles(directoryName, basicTraceFileNameWithoutExtension & "*") + Dim highestNumber As Integer = -1 + + For Each existingLogFile As String In existingLogFiles + Dim match As Match = Me._logfileSuffixExpression.Match(existingLogFile) + + If match IsNot Nothing Then + Dim tempInt As Integer + + If match.Groups.Count >= 1 AndAlso Integer.TryParse(match.Groups(LogFileNumberCaptureName).Value, tempInt) AndAlso tempInt >= highestNumber Then + highestNumber = tempInt + End If + End If + Next + + Return highestNumber + End Function + + Private Sub LoadAttributes() + If Attributes.ContainsKey("MaxTraceFileSize") AndAlso Not String.IsNullOrEmpty(Attributes("MaxTraceFileSize")) Then + Dim tempLong As Long = 0 + Dim attributeValue As String = Attributes("MaxTraceFileSize") + + If Long.TryParse(attributeValue, tempLong) Then + Me.MaxTraceFileSize = Long.Parse(Attributes("MaxTraceFileSize"), NumberFormatInfo.InvariantInfo) + Else + Throw New ConfigurationErrorsException(String.Format("Trace listener {0} has an unparseable configuration attribute ""MaxTraceFileSize"". The value ""{1}"" cannot be parsed to a long value.", Me.Name, attributeValue)) + End If + End If + + Me._attributesLoaded = True + End Sub +End Class + diff --git a/Service.EDMIService/Scheduler/JobListener.vb b/Service.EDMIService/Scheduler/JobListener.vb index 6bc7d573..93c9ecb3 100644 --- a/Service.EDMIService/Scheduler/JobListener.vb +++ b/Service.EDMIService/Scheduler/JobListener.vb @@ -6,6 +6,7 @@ Imports Quartz.Listener Public Class JobListener Inherits JobListenerSupport + Public Overrides ReadOnly Property Name As String = "JobListener" Public Property Dataset As DataSet @@ -31,7 +32,7 @@ Public Class JobListener Dim oDatatableNameTemp As String = oDatatableName & "-TEMP" If Dataset.Tables.Contains(oDatatableName) Then - _Logger.Debug("DataTable [{0}] exists, renaming and replacing", oDatatableName) + _Logger.Debug("DataTable [{0}] exists, renaming and replacing in DataSet", oDatatableName) ' Rename the new table, add TEMP suffix oDataTable.TableName = oDatatableNameTemp ' Add the new table to the dataset @@ -41,7 +42,7 @@ Public Class JobListener ' Rename the new table Dataset.Tables.Item(oDatatableNameTemp).TableName = oDatatableName Else - _Logger.Debug("DataTable [{0}] does not exist, adding", oDatatableName) + _Logger.Debug("DataTable [{0}] does not exist, adding to DataSet", oDatatableName) Dataset.Tables.Add(oDataTable) End If diff --git a/Service.EDMIService/ServiceHost.vb b/Service.EDMIService/ServiceHost.vb index 9680df2e..e24905d0 100644 --- a/Service.EDMIService/ServiceHost.vb +++ b/Service.EDMIService/ServiceHost.vb @@ -9,11 +9,15 @@ Public Class ServiceHost(Of T) MyBase.New(GetType(T), baseAddresses) End Sub + + Public Sub EnableMetadataExchange(ByVal Optional EnableHttpGet As Boolean = True) If State = CommunicationState.Opened Then Throw New InvalidOperationException("Host is already opened") End If + + Dim oMetadataBehavior As ServiceMetadataBehavior = Description.Behaviors.Find(Of ServiceMetadataBehavior)() If oMetadataBehavior Is Nothing Then