From 425d51c65c0d71ba8c71f2c5c1f8937b6a023e37 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Wed, 8 Apr 2020 11:38:34 +0200 Subject: [PATCH] create directory on import, version filename --- DDMonorepo.sln | 7 ++++ Modules.EDMIAPI/Channel.vb | 27 +++++++------ Modules.EDMIAPI/Constants.vb | 12 ++++-- Service.EDMIService/App.config | 56 ++++++++++++++------------ Service.EDMIService/EDMIService.vb | 21 ++++++++-- Service.EDMIService/EDMIService.vbproj | 4 ++ Service.EDMIService/IEDMIService.vb | 2 +- Service.EDMIService/WindowsService.vb | 4 ++ 8 files changed, 86 insertions(+), 47 deletions(-) diff --git a/DDMonorepo.sln b/DDMonorepo.sln index 5a638e3c..14fb2b72 100644 --- a/DDMonorepo.sln +++ b/DDMonorepo.sln @@ -112,6 +112,8 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DDZUGFeRDService", "Service EndProject Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DDEDMLicenseService", "Services.LicenseService\DDEDMLicenseService.vbproj", "{CBE9322E-67A1-4CC5-B25F-4A1B4C9FC55C}" EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "GUIs.Test.EDMIBenchmark", "GUIs.Test.EDMIBenchmark\GUIs.Test.EDMIBenchmark.vbproj", "{5FDEC007-7AE0-4829-B1AE-6165E29375DA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -290,6 +292,10 @@ Global {CBE9322E-67A1-4CC5-B25F-4A1B4C9FC55C}.Debug|Any CPU.Build.0 = Debug|Any CPU {CBE9322E-67A1-4CC5-B25F-4A1B4C9FC55C}.Release|Any CPU.ActiveCfg = Release|Any CPU {CBE9322E-67A1-4CC5-B25F-4A1B4C9FC55C}.Release|Any CPU.Build.0 = Release|Any CPU + {5FDEC007-7AE0-4829-B1AE-6165E29375DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5FDEC007-7AE0-4829-B1AE-6165E29375DA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5FDEC007-7AE0-4829-B1AE-6165E29375DA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5FDEC007-7AE0-4829-B1AE-6165E29375DA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -338,6 +344,7 @@ Global {1FB2854F-C050-427D-9FAC-1D8F232E8025} = {7AF3F9C2-C939-4A08-95C1-0453207E298A} {7DEEC36E-EA5F-4711-AD1E-FD8894F4AD77} = {7AF3F9C2-C939-4A08-95C1-0453207E298A} {CBE9322E-67A1-4CC5-B25F-4A1B4C9FC55C} = {7AF3F9C2-C939-4A08-95C1-0453207E298A} + {5FDEC007-7AE0-4829-B1AE-6165E29375DA} = {CC368D6A-6AC4-4EB9-A092-14700FABEF7A} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C1BE4090-A0FD-48AF-86CB-39099D14B286} diff --git a/Modules.EDMIAPI/Channel.vb b/Modules.EDMIAPI/Channel.vb index b08d4700..21022dcd 100644 --- a/Modules.EDMIAPI/Channel.vb +++ b/Modules.EDMIAPI/Channel.vb @@ -4,20 +4,21 @@ Imports System.Xml Public Class Channel Public Shared Function GetBinding(Optional AuthenticationMode As TcpClientCredentialType = TcpClientCredentialType.Windows) As NetTcpBinding Return New NetTcpBinding() With { - .MaxReceivedMessageSize = Constants.MAX_RECEIVED_MESSAGE_SIZE, - .MaxBufferSize = Constants.MAX_BUFFER_SIZE, - .MaxBufferPoolSize = Constants.MAX_BUFFER_POOL_SIZE, - .MaxConnections = Constants.MAX_CONNECTIONS, - .Security = New NetTcpSecurity() With { - .Mode = SecurityMode.Transport, - .Transport = New TcpTransportSecurity() With { - .ClientCredentialType = AuthenticationMode - } - }, - .ReaderQuotas = New XmlDictionaryReaderQuotas() With { - .MaxArrayLength = Constants.MAX_ARRAY_LENGTH, - .MaxStringContentLength = Constants.MAX_STRING_CONTENT_LENGTH + .MaxReceivedMessageSize = Constants.MAX_RECEIVED_MESSAGE_SIZE, + .MaxBufferSize = Constants.MAX_BUFFER_SIZE, + .MaxBufferPoolSize = Constants.MAX_BUFFER_POOL_SIZE, + .MaxConnections = Constants.MAX_CONNECTIONS, + .TransferMode = TransferMode.Buffered, + .Security = New NetTcpSecurity() With { + .Mode = SecurityMode.Transport, + .Transport = New TcpTransportSecurity() With { + .ClientCredentialType = AuthenticationMode } + }, + .ReaderQuotas = New XmlDictionaryReaderQuotas() With { + .MaxArrayLength = Constants.MAX_ARRAY_LENGTH, + .MaxStringContentLength = Constants.MAX_STRING_CONTENT_LENGTH } + } End Function End Class diff --git a/Modules.EDMIAPI/Constants.vb b/Modules.EDMIAPI/Constants.vb index 06c03b3a..74d153b2 100644 --- a/Modules.EDMIAPI/Constants.vb +++ b/Modules.EDMIAPI/Constants.vb @@ -1,8 +1,12 @@ Public Class Constants - Public Const MAX_RECEIVED_MESSAGE_SIZE = 2147483647 - Public Const MAX_BUFFER_SIZE = 2147483647 - Public Const MAX_BUFFER_POOL_SIZE = 2147483647 - Public Const MAX_CONNECTIONS = 10000 + ' Infos about MaxBufferSize and MaxBufferPoolSize + ' https://social.msdn.microsoft.com/Forums/vstudio/en-US/d6e234d3-942f-4e9d-8470-32618d3f3212/maxbufferpoolsize-vs-maxbuffersize?forum=wcf + + Public Const MAX_RECEIVED_MESSAGE_SIZE = 2147483647 ' 1GB + Public Const MAX_BUFFER_SIZE = 2147483647 ' 10MB + Public Const MAX_BUFFER_POOL_SIZE = 2147483647 ' 40MB + + Public Const MAX_CONNECTIONS = 500 Public Const MAX_ARRAY_LENGTH = 2147483647 Public Const MAX_STRING_CONTENT_LENGTH = 2147483647 End Class diff --git a/Service.EDMIService/App.config b/Service.EDMIService/App.config index c9a15314..c72e7240 100644 --- a/Service.EDMIService/App.config +++ b/Service.EDMIService/App.config @@ -1,5 +1,22 @@ + + + + + + + + + + + + + + + + + @@ -18,23 +35,6 @@ - - - - - - - - - - - - - - - - - @@ -42,21 +42,27 @@ - - + + - + - - - - - + diff --git a/Service.EDMIService/EDMIService.vb b/Service.EDMIService/EDMIService.vb index 53dc1f43..1a21cad8 100644 --- a/Service.EDMIService/EDMIService.vb +++ b/Service.EDMIService/EDMIService.vb @@ -4,6 +4,8 @@ Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Filesystem Imports DigitalData.Modules Imports System.IO +Imports System.ServiceModel.Description +Imports System.ServiceModel.Channels Public Class EDMIService @@ -12,6 +14,7 @@ Public Class EDMIService Public Shared LogConfig As LogConfig Public Shared Database As Firebird Public Shared AppConfig As AppConfig + Public Shared Filesystem As Filesystem.File Public Shared EDMIPath As EDMI.File.Path Public Shared EDMIArchive As EDMI.File.Archive @@ -298,18 +301,28 @@ Public Class EDMIService #Region "Document" Public Function ImportFile(FileInfo As FileInfo, Contents() As Byte, [Readonly] As Boolean, RetentionPeriod As Integer) As DocumentResult2 Implements IEDMIService.ImportFile Dim oDocumentType As String = "DummyDocumentType" - Dim oFilePath = Path.Combine(EDMIPath.GetActivePath(oDocumentType), FileInfo.Name) + Dim oDirectoryPath = EDMIPath.GetActivePath(oDocumentType) + Dim oFilePath = Path.Combine(oDirectoryPath, FileInfo.Name) Dim oDocument = New DocumentResult2.DocumentObject() With {.FileName = FileInfo.Name} Try - _logger.Info("Saving file [{0}] to path [{1}]", FileInfo.Name, oFilePath) - Using oStream = New FileStream(oFilePath, FileMode.CreateNew) + Directory.CreateDirectory(oDirectoryPath) + Catch ex As Exception + _logger.Error(ex) + Return New DocumentResult2(ex.Message) + End Try + + Try + Dim oVersionedFileName As String = Filesystem.GetVersionedFilename(oFilePath) + + _logger.Info("Saving file [{0}] to path [{1}]", FileInfo.Name, oVersionedFileName) + Using oStream = New FileStream(oVersionedFileName, FileMode.CreateNew) oStream.Write(Contents, 0, Contents.Length) oStream.Flush(True) oStream.Close() End Using - EDMIArchive.SetRetention(oFilePath, RetentionPeriod, [Readonly]) + EDMIArchive.SetRetention(oVersionedFileName, RetentionPeriod, [Readonly]) Return New DocumentResult2(oDocument) Catch ex As Exception diff --git a/Service.EDMIService/EDMIService.vbproj b/Service.EDMIService/EDMIService.vbproj index 65fd134b..db351beb 100644 --- a/Service.EDMIService/EDMIService.vbproj +++ b/Service.EDMIService/EDMIService.vbproj @@ -170,6 +170,10 @@ {EAF0EA75-5FA7-485D-89C7-B2D843B03A96} Database + + {25017513-0d97-49d3-98d7-ba76d9b251b0} + EDMI.API + {991D0231-4623-496D-8BD0-9CA906029CBC} Filesystem diff --git a/Service.EDMIService/IEDMIService.vb b/Service.EDMIService/IEDMIService.vb index d7b15caa..0acc56b9 100644 --- a/Service.EDMIService/IEDMIService.vb +++ b/Service.EDMIService/IEDMIService.vb @@ -2,7 +2,7 @@ Imports System.ServiceModel Imports DigitalData.Modules.Filesystem - + Interface IEDMIService #Region "Heartbeat" diff --git a/Service.EDMIService/WindowsService.vb b/Service.EDMIService/WindowsService.vb index 8e616f5c..60ef89a2 100644 --- a/Service.EDMIService/WindowsService.vb +++ b/Service.EDMIService/WindowsService.vb @@ -3,6 +3,7 @@ Imports System.ServiceProcess Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Database Imports DigitalData.Modules +Imports System.ServiceModel.Description Public Class WindowsService Inherits ServiceBase @@ -17,6 +18,7 @@ Public Class WindowsService Private _config As AppConfig Private _Path As EDMI.File.Path Private _Archive As EDMI.File.Archive + Private _filesystem As Filesystem.File Public Sub New() ServiceName = SERVICE_NAME @@ -53,6 +55,7 @@ Public Class WindowsService _Path = New EDMI.File.Path(_logConfig, AppConfig.DatastorePath) _Archive = New EDMI.File.Archive(_logConfig) + _filesystem = New Filesystem.File(_logConfig) _logger.Debug("EDMI Functions initialized.") @@ -61,6 +64,7 @@ Public Class WindowsService EDMIService.AppConfig = _config EDMIService.EDMIArchive = _Archive EDMIService.EDMIPath = _Path + EDMIService.Filesystem = _filesystem _logger.Debug("Starting WCF ServiceHost...")