create directory on import, version filename

This commit is contained in:
Jonathan Jenne 2020-04-08 11:38:34 +02:00
parent a7e48a939c
commit 425d51c65c
8 changed files with 86 additions and 47 deletions

View File

@ -112,6 +112,8 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DDZUGFeRDService", "Service
EndProject EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DDEDMLicenseService", "Services.LicenseService\DDEDMLicenseService.vbproj", "{CBE9322E-67A1-4CC5-B25F-4A1B4C9FC55C}" Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DDEDMLicenseService", "Services.LicenseService\DDEDMLicenseService.vbproj", "{CBE9322E-67A1-4CC5-B25F-4A1B4C9FC55C}"
EndProject EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "GUIs.Test.EDMIBenchmark", "GUIs.Test.EDMIBenchmark\GUIs.Test.EDMIBenchmark.vbproj", "{5FDEC007-7AE0-4829-B1AE-6165E29375DA}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU 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}.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.ActiveCfg = Release|Any CPU
{CBE9322E-67A1-4CC5-B25F-4A1B4C9FC55C}.Release|Any CPU.Build.0 = 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 EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -338,6 +344,7 @@ Global
{1FB2854F-C050-427D-9FAC-1D8F232E8025} = {7AF3F9C2-C939-4A08-95C1-0453207E298A} {1FB2854F-C050-427D-9FAC-1D8F232E8025} = {7AF3F9C2-C939-4A08-95C1-0453207E298A}
{7DEEC36E-EA5F-4711-AD1E-FD8894F4AD77} = {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} {CBE9322E-67A1-4CC5-B25F-4A1B4C9FC55C} = {7AF3F9C2-C939-4A08-95C1-0453207E298A}
{5FDEC007-7AE0-4829-B1AE-6165E29375DA} = {CC368D6A-6AC4-4EB9-A092-14700FABEF7A}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C1BE4090-A0FD-48AF-86CB-39099D14B286} SolutionGuid = {C1BE4090-A0FD-48AF-86CB-39099D14B286}

View File

@ -4,20 +4,21 @@ Imports System.Xml
Public Class Channel Public Class Channel
Public Shared Function GetBinding(Optional AuthenticationMode As TcpClientCredentialType = TcpClientCredentialType.Windows) As NetTcpBinding Public Shared Function GetBinding(Optional AuthenticationMode As TcpClientCredentialType = TcpClientCredentialType.Windows) As NetTcpBinding
Return New NetTcpBinding() With { Return New NetTcpBinding() With {
.MaxReceivedMessageSize = Constants.MAX_RECEIVED_MESSAGE_SIZE, .MaxReceivedMessageSize = Constants.MAX_RECEIVED_MESSAGE_SIZE,
.MaxBufferSize = Constants.MAX_BUFFER_SIZE, .MaxBufferSize = Constants.MAX_BUFFER_SIZE,
.MaxBufferPoolSize = Constants.MAX_BUFFER_POOL_SIZE, .MaxBufferPoolSize = Constants.MAX_BUFFER_POOL_SIZE,
.MaxConnections = Constants.MAX_CONNECTIONS, .MaxConnections = Constants.MAX_CONNECTIONS,
.Security = New NetTcpSecurity() With { .TransferMode = TransferMode.Buffered,
.Mode = SecurityMode.Transport, .Security = New NetTcpSecurity() With {
.Transport = New TcpTransportSecurity() With { .Mode = SecurityMode.Transport,
.ClientCredentialType = AuthenticationMode .Transport = New TcpTransportSecurity() With {
} .ClientCredentialType = AuthenticationMode
},
.ReaderQuotas = New XmlDictionaryReaderQuotas() With {
.MaxArrayLength = Constants.MAX_ARRAY_LENGTH,
.MaxStringContentLength = Constants.MAX_STRING_CONTENT_LENGTH
} }
},
.ReaderQuotas = New XmlDictionaryReaderQuotas() With {
.MaxArrayLength = Constants.MAX_ARRAY_LENGTH,
.MaxStringContentLength = Constants.MAX_STRING_CONTENT_LENGTH
} }
}
End Function End Function
End Class End Class

View File

@ -1,8 +1,12 @@
Public Class Constants Public Class Constants
Public Const MAX_RECEIVED_MESSAGE_SIZE = 2147483647 ' Infos about MaxBufferSize and MaxBufferPoolSize
Public Const MAX_BUFFER_SIZE = 2147483647 ' https://social.msdn.microsoft.com/Forums/vstudio/en-US/d6e234d3-942f-4e9d-8470-32618d3f3212/maxbufferpoolsize-vs-maxbuffersize?forum=wcf
Public Const MAX_BUFFER_POOL_SIZE = 2147483647
Public Const MAX_CONNECTIONS = 10000 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_ARRAY_LENGTH = 2147483647
Public Const MAX_STRING_CONTENT_LENGTH = 2147483647 Public Const MAX_STRING_CONTENT_LENGTH = 2147483647
End Class End Class

View File

@ -1,5 +1,22 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<appSettings>
<!-- FIREBIRD SETTINGS -->
<add key="FIREBIRD_DATASOURCE" value=""/>
<add key="FIREBIRD_DATABASE_NAME" value=""/>
<add key="FIREBIRD_DATABASE_USER" value=""/>
<add key="FIREBIRD_DATABASE_PASS" value=""/>
<!-- END FIREBIRD SETTINGS -->
<!-- DATASTORE SETTINGS -->
<add key="DATASTORE_PATH" value=""/>
<!-- END DATASTORE SETTINGS -->
<!-- CONTAINER SETTINGS -->
<add key="CONTAINER_PATH" value=""/>
<add key="CONTAINER_PASSWORD" value=""/>
<!-- END CONTAINER SETTINGS -->
</appSettings>
<system.diagnostics> <system.diagnostics>
<sources> <sources>
<source name="System.ServiceModel" switchValue="Information,ActivityTracing" propagateActivity="true"> <source name="System.ServiceModel" switchValue="Information,ActivityTracing" propagateActivity="true">
@ -18,23 +35,6 @@
</sharedListeners> </sharedListeners>
<trace autoflush="true"/> <trace autoflush="true"/>
</system.diagnostics> </system.diagnostics>
<appSettings>
<!-- FIREBIRD SETTINGS -->
<add key="FIREBIRD_DATASOURCE" value=""/>
<add key="FIREBIRD_DATABASE_NAME" value=""/>
<add key="FIREBIRD_DATABASE_USER" value=""/>
<add key="FIREBIRD_DATABASE_PASS" value=""/>
<!-- END FIREBIRD SETTINGS -->
<!-- DATASTORE SETTINGS -->
<add key="DATASTORE_PATH" value=""/>
<!-- END DATASTORE SETTINGS -->
<!-- CONTAINER SETTINGS -->
<add key="CONTAINER_PATH" value=""/>
<add key="CONTAINER_PASSWORD" value=""/>
<!-- END CONTAINER SETTINGS -->
</appSettings>
<system.serviceModel> <system.serviceModel>
<diagnostics wmiProviderEnabled="true"> <diagnostics wmiProviderEnabled="true">
<messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtTransportLevel="true"/> <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtTransportLevel="true"/>
@ -42,21 +42,27 @@
</diagnostics> </diagnostics>
<bindings> <bindings>
<netTcpBinding> <netTcpBinding>
<binding name="tcpBinding" sendTimeout="00:10:00" transferMode="Buffered" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> <binding name="tcpBinding"
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/> sendTimeout="00:10:00"
transferMode="Buffered"
maxBufferSize="10000000"
maxBufferPoolSize="40000000"
maxReceivedMessageSize="1000000000">
<readerQuotas
maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"/>
<security mode="None"> <security mode="None">
<transport clientCredentialType="None"/> <transport clientCredentialType="Windows"/>
</security> </security>
</binding> </binding>
</netTcpBinding> </netTcpBinding>
</bindings> </bindings>
<services> <services>
<service behaviorConfiguration="DefaultServiceBehavior" name="DigitalData.Services.EDMIService.EDMIService"> <service behaviorConfiguration="DefaultServiceBehavior" name="DigitalData.Services.EDMIService.EDMIService">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="tcpBinding" name="tcpBinding" contract="DigitalData.Services.EDMIService.IEDMIService"> <endpoint address="" binding="netTcpBinding" bindingConfiguration="tcpBinding" name="tcpBinding" contract="DigitalData.Services.EDMIService.IEDMIService" />
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" name="MexTcpBinding" contract="IMetadataExchange"/> <endpoint address="mex" binding="mexTcpBinding" name="MexTcpBinding" contract="IMetadataExchange"/>
<host> <host>
<baseAddresses> <baseAddresses>

View File

@ -4,6 +4,8 @@ Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Filesystem Imports DigitalData.Modules.Filesystem
Imports DigitalData.Modules Imports DigitalData.Modules
Imports System.IO Imports System.IO
Imports System.ServiceModel.Description
Imports System.ServiceModel.Channels
<ServiceBehavior(InstanceContextMode:=InstanceContextMode.PerSession)> <ServiceBehavior(InstanceContextMode:=InstanceContextMode.PerSession)>
Public Class EDMIService Public Class EDMIService
@ -12,6 +14,7 @@ Public Class EDMIService
Public Shared LogConfig As LogConfig Public Shared LogConfig As LogConfig
Public Shared Database As Firebird Public Shared Database As Firebird
Public Shared AppConfig As AppConfig Public Shared AppConfig As AppConfig
Public Shared Filesystem As Filesystem.File
Public Shared EDMIPath As EDMI.File.Path Public Shared EDMIPath As EDMI.File.Path
Public Shared EDMIArchive As EDMI.File.Archive Public Shared EDMIArchive As EDMI.File.Archive
@ -298,18 +301,28 @@ Public Class EDMIService
#Region "Document" #Region "Document"
Public Function ImportFile(FileInfo As FileInfo, Contents() As Byte, [Readonly] As Boolean, RetentionPeriod As Integer) As DocumentResult2 Implements IEDMIService.ImportFile 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 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} Dim oDocument = New DocumentResult2.DocumentObject() With {.FileName = FileInfo.Name}
Try Try
_logger.Info("Saving file [{0}] to path [{1}]", FileInfo.Name, oFilePath) Directory.CreateDirectory(oDirectoryPath)
Using oStream = New FileStream(oFilePath, FileMode.CreateNew) 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.Write(Contents, 0, Contents.Length)
oStream.Flush(True) oStream.Flush(True)
oStream.Close() oStream.Close()
End Using End Using
EDMIArchive.SetRetention(oFilePath, RetentionPeriod, [Readonly]) EDMIArchive.SetRetention(oVersionedFileName, RetentionPeriod, [Readonly])
Return New DocumentResult2(oDocument) Return New DocumentResult2(oDocument)
Catch ex As Exception Catch ex As Exception

View File

@ -170,6 +170,10 @@
<Project>{EAF0EA75-5FA7-485D-89C7-B2D843B03A96}</Project> <Project>{EAF0EA75-5FA7-485D-89C7-B2D843B03A96}</Project>
<Name>Database</Name> <Name>Database</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\Modules.EDMIAPI\EDMI.API.vbproj">
<Project>{25017513-0d97-49d3-98d7-ba76d9b251b0}</Project>
<Name>EDMI.API</Name>
</ProjectReference>
<ProjectReference Include="..\Modules.Filesystem\Filesystem.vbproj"> <ProjectReference Include="..\Modules.Filesystem\Filesystem.vbproj">
<Project>{991D0231-4623-496D-8BD0-9CA906029CBC}</Project> <Project>{991D0231-4623-496D-8BD0-9CA906029CBC}</Project>
<Name>Filesystem</Name> <Name>Filesystem</Name>

View File

@ -2,7 +2,7 @@
Imports System.ServiceModel Imports System.ServiceModel
Imports DigitalData.Modules.Filesystem Imports DigitalData.Modules.Filesystem
<ServiceContract([Namespace]:="http://DigitalData.Services.EDMIService")> <ServiceContract(Name:="IEDMIService", [Namespace]:="http://DigitalData.Services.EDMIService")>
Interface IEDMIService Interface IEDMIService
#Region "Heartbeat" #Region "Heartbeat"

View File

@ -3,6 +3,7 @@ Imports System.ServiceProcess
Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Database Imports DigitalData.Modules.Database
Imports DigitalData.Modules Imports DigitalData.Modules
Imports System.ServiceModel.Description
Public Class WindowsService Public Class WindowsService
Inherits ServiceBase Inherits ServiceBase
@ -17,6 +18,7 @@ Public Class WindowsService
Private _config As AppConfig Private _config As AppConfig
Private _Path As EDMI.File.Path Private _Path As EDMI.File.Path
Private _Archive As EDMI.File.Archive Private _Archive As EDMI.File.Archive
Private _filesystem As Filesystem.File
Public Sub New() Public Sub New()
ServiceName = SERVICE_NAME ServiceName = SERVICE_NAME
@ -53,6 +55,7 @@ Public Class WindowsService
_Path = New EDMI.File.Path(_logConfig, AppConfig.DatastorePath) _Path = New EDMI.File.Path(_logConfig, AppConfig.DatastorePath)
_Archive = New EDMI.File.Archive(_logConfig) _Archive = New EDMI.File.Archive(_logConfig)
_filesystem = New Filesystem.File(_logConfig)
_logger.Debug("EDMI Functions initialized.") _logger.Debug("EDMI Functions initialized.")
@ -61,6 +64,7 @@ Public Class WindowsService
EDMIService.AppConfig = _config EDMIService.AppConfig = _config
EDMIService.EDMIArchive = _Archive EDMIService.EDMIArchive = _Archive
EDMIService.EDMIPath = _Path EDMIService.EDMIPath = _Path
EDMIService.Filesystem = _filesystem
_logger.Debug("Starting WCF ServiceHost...") _logger.Debug("Starting WCF ServiceHost...")