Modules/EDMI.File/Path.vb
2020-04-14 10:34:30 +02:00

52 lines
1.8 KiB
VB.net

Imports DigitalData.Modules.Logging
Imports System.IO
Public Class Path
Private ReadOnly _LogConfig As LogConfig
Private ReadOnly _Logger As Logger
Private ReadOnly _BasePath As String
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, DatastoreBasePath As String)
_LogConfig = LogConfig
_Logger = LogConfig.GetLogger()
_BasePath = DatastoreBasePath
End Sub
Public Function GetActivePath(DocumentType As String, Optional FileName As String = "")
Dim oPathParts As New List(Of String) From {_BasePath, PATH_EDMI, PATH_ACTIVE}
oPathParts.AddRange(GetRelativePath(DocumentType, FileName))
Return IO.Path.Combine(oPathParts.ToArray())
End Function
Public Function GetArchivePath(DocumentType As String, Optional FileName As String = "")
Dim oPathParts As New List(Of String) From {_BasePath, PATH_EDMI, PATH_ARCHIVE}
oPathParts.AddRange(GetRelativePath(DocumentType, FileName))
Return IO.Path.Combine(oPathParts.ToArray())
End Function
Public Function GetRelativePath(DocumentType As String, Optional FileName As String = "")
Dim oPathParts As New List(Of String) From {DocumentType}
oPathParts.AddRange(GetDatePath())
oPathParts.Add(FileName)
Return IO.Path.Combine(oPathParts.ToArray())
End Function
Private Function GetDatePath() As List(Of String)
Dim oDate = DateTime.Now
Dim oResultList As New List(Of String) From {
oDate.Year,
oDate.Month.ToString.PadLeft(2, "0"),
oDate.Day.ToString.PadLeft(2, "0")
}
Return oResultList
End Function
End Class