EDMIService: Use EDMI.File functions, add DatastorePath
This commit is contained in:
parent
0e13de63fb
commit
eb527a7abb
@ -15,7 +15,7 @@ Imports DigitalData.Modules.EDMI
|
||||
|
||||
|
||||
Assert.AreEqual(oPath.GetActivePath("TestDocumentType"), $"EDMI\Active\TestDocumentType\{oYear}\{oMonth}\{oDay}")
|
||||
Assert.AreEqual(oPath.GetActivePath("TestDocumentType"), $"EDMI\Archive\TestDocumentType\{oYear}\{oMonth}\{oDay}")
|
||||
Assert.AreEqual(oPath.GetArchivePath("TestDocumentType"), $"EDMI\Archive\TestDocumentType\{oYear}\{oMonth}\{oDay}")
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
@ -14,8 +14,8 @@ Public Class Archive
|
||||
''' Sets a retention-period for a give file path by setting the file attributes LastAccessTime and ReadOnly
|
||||
''' </summary>
|
||||
''' <param name="FilePath"></param>
|
||||
''' <param name="RetentionTimeInDays"></param>
|
||||
''' <param name="[ReadOnly]"></param>
|
||||
''' <param name="RetentionTimeInDays">If greater than 0, sets this plus the current date as LastAccessTime</param>
|
||||
''' <param name="[ReadOnly]">If true, sets ReadOnly Attribute</param>
|
||||
Public Sub SetRetention(FilePath As String, RetentionTimeInDays As Integer, [ReadOnly] As Boolean)
|
||||
Try
|
||||
If RetentionTimeInDays > 0 Then
|
||||
|
||||
@ -4,25 +4,27 @@ Imports System.IO
|
||||
Public Class Path
|
||||
Private ReadOnly _LogConfig As LogConfig
|
||||
Private ReadOnly _Logger As Logger
|
||||
Private ReadOnly _BasePath As String
|
||||
|
||||
Public Const BASE_PATH_ACTIVE As String = "Active"
|
||||
Public Const BASE_PATH_ARCHIVE As String = "Archive"
|
||||
Public Const BASE_PATH_EDMI As String = "EDMI"
|
||||
Public Const PATH_ACTIVE As String = "Active"
|
||||
Public Const PATH_ARCHIVE As String = "Archive"
|
||||
Public Const PATH_EDMI As String = "EDMI"
|
||||
|
||||
Public Sub New(LogConfig As LogConfig)
|
||||
Public Sub New(LogConfig As LogConfig, DatastoreBasePath As String)
|
||||
_LogConfig = LogConfig
|
||||
_Logger = LogConfig.GetLogger()
|
||||
_BasePath = DatastoreBasePath
|
||||
End Sub
|
||||
|
||||
Public Function GetActivePath(DocumentType As String)
|
||||
Dim oPathParts As New List(Of String) From {BASE_PATH_EDMI, BASE_PATH_ACTIVE, DocumentType}
|
||||
Dim oPathParts As New List(Of String) From {_BasePath, PATH_EDMI, PATH_ACTIVE, DocumentType}
|
||||
oPathParts.AddRange(GetDatePath())
|
||||
|
||||
Return IO.Path.Combine(oPathParts.ToArray())
|
||||
End Function
|
||||
|
||||
Public Function GetArchivePath(DocumentType As String)
|
||||
Dim oPathParts As New List(Of String) From {BASE_PATH_EDMI, BASE_PATH_ARCHIVE, DocumentType}
|
||||
Dim oPathParts As New List(Of String) From {_BasePath, PATH_EDMI, PATH_ARCHIVE, DocumentType}
|
||||
oPathParts.AddRange(GetDatePath())
|
||||
|
||||
Return IO.Path.Combine(oPathParts.ToArray())
|
||||
|
||||
@ -21,12 +21,21 @@
|
||||
<trace autoflush="true" />
|
||||
</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>
|
||||
<diagnostics wmiProviderEnabled="true">
|
||||
|
||||
@ -7,6 +7,7 @@ Public Class AppConfig
|
||||
Public Shared FirebirdPassword As String
|
||||
Public Shared ContainerPath As String
|
||||
Public Shared ContainerPassword As String
|
||||
Public Shared DatastorePath As String
|
||||
|
||||
Public Shared Sub Load()
|
||||
With ConfigurationManager.AppSettings
|
||||
@ -16,6 +17,7 @@ Public Class AppConfig
|
||||
FirebirdPassword = .Item("FIREBIRD_DATABASE_PASS")
|
||||
ContainerPath = .Item("CONTAINER_PATH")
|
||||
ContainerPassword = .Item("CONTAINER_PASSWORD")
|
||||
DatastorePath = .Item("DATASTORE_PATH")
|
||||
End With
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Filesystem
|
||||
Imports DigitalData.Services.EDMIService
|
||||
Imports DigitalData.Modules
|
||||
Imports System.IO
|
||||
|
||||
<ServiceBehavior(InstanceContextMode:=InstanceContextMode.PerSession)>
|
||||
@ -12,6 +12,8 @@ Public Class EDMIService
|
||||
Public Shared LogConfig As LogConfig
|
||||
Public Shared Database As Firebird
|
||||
Public Shared AppConfig As AppConfig
|
||||
Public Shared EDMIPath As EDMI.File.Path
|
||||
Public Shared EDMIArchive As EDMI.File.Archive
|
||||
|
||||
Private ReadOnly _logger As Logger
|
||||
|
||||
@ -19,6 +21,7 @@ Public Class EDMIService
|
||||
Private _debug As Boolean = False
|
||||
Private _username As String
|
||||
|
||||
|
||||
Public Sub New()
|
||||
Dim oOperationContext As OperationContext = OperationContext.Current
|
||||
Dim oInstanceContext As InstanceContext = oOperationContext.InstanceContext
|
||||
@ -294,7 +297,8 @@ 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 oFilePath = Path.Combine(AppConfig.ContainerPath, FileInfo.Name)
|
||||
Dim oDocumentType As String = "DummyDocumentType"
|
||||
Dim oFilePath = Path.Combine(EDMIPath.GetActivePath(oDocumentType), FileInfo.Name)
|
||||
Dim oDocument = New DocumentResult2.DocumentObject() With {.FileName = FileInfo.Name}
|
||||
|
||||
Try
|
||||
@ -305,17 +309,7 @@ Public Class EDMIService
|
||||
oStream.Close()
|
||||
End Using
|
||||
|
||||
Dim oAttributes = IO.File.GetAttributes(oFilePath) Or FileAttributes.ReadOnly
|
||||
|
||||
If RetentionPeriod Then
|
||||
_logger.Info("Setting LastAccessTime")
|
||||
IO.File.SetLastAccessTime(oFilePath, Date.Now.AddYears(30))
|
||||
End If
|
||||
|
||||
If [Readonly] Then
|
||||
_logger.Info("Setting ReadOnly Attribute")
|
||||
IO.File.SetAttributes(oFilePath, oAttributes)
|
||||
End If
|
||||
EDMIArchive.SetRetention(oFilePath, RetentionPeriod, [Readonly])
|
||||
|
||||
Return New DocumentResult2(oDocument)
|
||||
Catch ex As Exception
|
||||
|
||||
@ -145,14 +145,14 @@
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\EDMI.File\EDMI.File.vbproj">
|
||||
<Project>{1477032d-7a02-4c5f-b026-a7117da4bc6b}</Project>
|
||||
<Name>EDMI.File</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Modules.Database\Database.vbproj">
|
||||
<Project>{EAF0EA75-5FA7-485D-89C7-B2D843B03A96}</Project>
|
||||
<Name>Database</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Modules.EDMIAPI\EDMI.API.vbproj">
|
||||
<Project>{5B1171DC-FFFE-4813-A20D-786AAE47B320}</Project>
|
||||
<Name>EDMI.API</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Modules.Filesystem\Filesystem.vbproj">
|
||||
<Project>{991D0231-4623-496D-8BD0-9CA906029CBC}</Project>
|
||||
<Name>Filesystem</Name>
|
||||
|
||||
@ -52,7 +52,6 @@ Interface IEDMIService
|
||||
Function ImportFile(FileInfo As FileInfo, Contents As Byte(), [ReadOnly] As Boolean, RetentionTime As Integer) As DocumentResult2
|
||||
#End Region
|
||||
|
||||
|
||||
#Region "Index"
|
||||
<OperationContract>
|
||||
Function NewFileIndex(DocObject As DocumentObject, Syskey As String, LanguageCode As String, Value As String) As IndexResult
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
Module SettingsModule
|
||||
Public Const SERVICE_NAME As String = "DDIDBSvc"
|
||||
Public Const SERVICE_DISPLAY_NAME As String = "Digital Data IDB Service"
|
||||
Public Const SERVICE_NAME As String = "DDEDMIService"
|
||||
Public Const SERVICE_DISPLAY_NAME As String = "Digital Data EDMI Service"
|
||||
End Module
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
Imports System.ServiceProcess
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules
|
||||
|
||||
Public Class WindowsService
|
||||
Inherits ServiceBase
|
||||
@ -14,6 +15,8 @@ Public Class WindowsService
|
||||
Private _db As Firebird
|
||||
Private _clientsConnected As Integer = 0
|
||||
Private _config As AppConfig
|
||||
Private _Path As EDMI.File.Path
|
||||
Private _Archive As EDMI.File.Archive
|
||||
|
||||
Public Sub New()
|
||||
ServiceName = SERVICE_NAME
|
||||
@ -27,8 +30,9 @@ Public Class WindowsService
|
||||
Try
|
||||
AppConfig.Load()
|
||||
|
||||
_logConfig = New LogConfig(LogConfig.PathType.CustomPath, "E:\EDMService")
|
||||
_logConfig.Debug = True
|
||||
_logConfig = New LogConfig(LogConfig.PathType.CustomPath, "E:\EDMService") With {
|
||||
.Debug = True
|
||||
}
|
||||
|
||||
_logger = _logConfig.GetLogger()
|
||||
|
||||
@ -45,9 +49,18 @@ Public Class WindowsService
|
||||
|
||||
_logger.Info("Database connection established.")
|
||||
|
||||
_logger.Debug("Initializing EDMI Functions")
|
||||
|
||||
_Path = New EDMI.File.Path(_logConfig, AppConfig.DatastorePath)
|
||||
_Archive = New EDMI.File.Archive(_logConfig)
|
||||
|
||||
_logger.Debug("EDMI Functions initialized.")
|
||||
|
||||
EDMIService.Database = _db
|
||||
EDMIService.LogConfig = _logConfig
|
||||
EDMIService.AppConfig = _config
|
||||
EDMIService.EDMIArchive = _Archive
|
||||
EDMIService.EDMIPath = _Path
|
||||
|
||||
_logger.Debug("Starting WCF ServiceHost...")
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user