WIP: cleanup, work on doc result form
This commit is contained in:
@@ -1,70 +0,0 @@
|
||||
Imports System.IO
|
||||
Imports System.IO.Compression
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class Compression
|
||||
Private ReadOnly _logger As Logger
|
||||
|
||||
Public Sub New(LogConfig As LogConfig)
|
||||
_logger = LogConfig.GetLogger()
|
||||
End Sub
|
||||
|
||||
Public Async Function CompressAsync(data As Byte()) As Task(Of Byte())
|
||||
Return Await Task.Run(Function() As Byte()
|
||||
Return Compress(data)
|
||||
End Function)
|
||||
End Function
|
||||
|
||||
Public Function Compress(data As Byte()) As Byte()
|
||||
Try
|
||||
' ByteArray in Stream umwandeln
|
||||
Using originalStream As New MemoryStream(data)
|
||||
' Ziel Stream erstellen
|
||||
Using compressedStream As New MemoryStream()
|
||||
' Gzip-Stream erstellen, der alle Daten komprimiert und zu compressedStream durchleitet
|
||||
'
|
||||
' > MemoryStream > GzipStream > MemoryStream
|
||||
' originalStream --> compressionStream --> compressedFileStream
|
||||
'
|
||||
Using compressionStream As New GZipStream(compressedStream, CompressionMode.Compress)
|
||||
originalStream.CopyTo(compressionStream)
|
||||
compressionStream.Close()
|
||||
Return compressedStream.ToArray()
|
||||
End Using
|
||||
End Using
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Throw ex
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Async Function DecompressAsync(data As Byte()) As Task(Of Byte())
|
||||
Return Await Task.Run(Function() As Byte()
|
||||
Return Decompress(data)
|
||||
End Function)
|
||||
End Function
|
||||
|
||||
Public Function Decompress(data As Byte()) As Byte()
|
||||
Try
|
||||
' ByteArray in Stream umwandeln
|
||||
Using compressedStream As New MemoryStream(data)
|
||||
' Ziel Stream erstellen
|
||||
Using decompressedStream As New MemoryStream()
|
||||
' Gzip-Stream erstellen, der alle Daten komprimiert und zu compressedStream durchleitet
|
||||
'
|
||||
' > MemoryStream > GzipStream > MemoryStream
|
||||
' compressedStream --> decompressionStream --> decompressedStream
|
||||
'
|
||||
Using decompressionStream As New GZipStream(compressedStream, CompressionMode.Decompress)
|
||||
decompressionStream.CopyTo(decompressedStream)
|
||||
Return decompressedStream.ToArray()
|
||||
End Using
|
||||
End Using
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Throw ex
|
||||
End Try
|
||||
End Function
|
||||
End Class
|
||||
@@ -1,18 +0,0 @@
|
||||
Imports System.Runtime.Serialization
|
||||
|
||||
<Serializable>
|
||||
Public Class DocumentObject
|
||||
|
||||
<DataMember(Name:="FileName")>
|
||||
Public ReadOnly FileName As String
|
||||
<DataMember(Name:="ContainerId")>
|
||||
Public ReadOnly ContainerId As String
|
||||
<DataMember(Name:="DocumentId")>
|
||||
Public ReadOnly DocumentId As Int64
|
||||
|
||||
Public Sub New(ContainerId As String, DocumentId As Int64, FileName As String)
|
||||
Me.ContainerId = ContainerId
|
||||
Me.DocumentId = DocumentId
|
||||
Me.FileName = FileName
|
||||
End Sub
|
||||
End Class
|
||||
@@ -1,148 +0,0 @@
|
||||
Imports System.IO
|
||||
Imports System.Security.Cryptography
|
||||
Imports System.Text.Encoding
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
''' <summary>
|
||||
''' https://stackoverflow.com/questions/10168240/encrypting-decrypting-a-string-in-c-sharp
|
||||
''' </summary>
|
||||
Public Class Encryption
|
||||
' This constant is used to determine the keysize of the encryption algorithm in bits.
|
||||
' We divide this by 8 within the code below to get the equivalent number of bytes.
|
||||
Private Const KEY_SIZE As Integer = 256
|
||||
' This constant determines the number of iterations for the password bytes generation function.
|
||||
Private Const DERIVATION_ITERATIONS As Integer = 1000
|
||||
Private Const BLOCK_SIZE As Integer = 256
|
||||
|
||||
Private _paddingMode As PaddingMode = PaddingMode.Zeros
|
||||
Private _cipherMode As CipherMode = CipherMode.CBC
|
||||
|
||||
Private ReadOnly _password As String
|
||||
Private _logger As Logger
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, Password As String)
|
||||
_logger = LogConfig.GetLogger()
|
||||
|
||||
If IsNothing(Password) Then
|
||||
Throw New ArgumentNullException("Password")
|
||||
End If
|
||||
|
||||
_password = Password
|
||||
End Sub
|
||||
|
||||
Public Async Function EncryptAsync(PlainTextBytes As Byte()) As Task(Of Byte())
|
||||
Return Await Task.Run(Function() As Byte()
|
||||
Return Encrypt(PlainTextBytes)
|
||||
End Function)
|
||||
End Function
|
||||
|
||||
Public Function Encrypt(PlainText As String) As String
|
||||
Try
|
||||
Dim oBytes As Byte() = UTF8.GetBytes(PlainText)
|
||||
Dim oEncrypted As Byte() = Encrypt(oBytes)
|
||||
Return UTF8.GetString(oEncrypted)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Throw ex
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function Encrypt(PlainTextBytes As Byte()) As Byte()
|
||||
Try
|
||||
' Salt and IV is randomly generated each time, but is preprended to encrypted cipher text
|
||||
' so that the same Salt and IV values can be used when decrypting.
|
||||
Dim oSaltStringBytes = Generate256BitsOfRandomEntropy()
|
||||
Dim oIvStringBytes = Generate256BitsOfRandomEntropy()
|
||||
Using oPassword = New Rfc2898DeriveBytes(_password, oSaltStringBytes, DERIVATION_ITERATIONS)
|
||||
Dim oKeyBytes = oPassword.GetBytes(KEY_SIZE / 8)
|
||||
Using oSymmetricKey = New RijndaelManaged()
|
||||
oSymmetricKey.BlockSize = BLOCK_SIZE
|
||||
oSymmetricKey.Mode = _cipherMode
|
||||
oSymmetricKey.Padding = _paddingMode
|
||||
|
||||
Using oEncryptor = oSymmetricKey.CreateEncryptor(oKeyBytes, oIvStringBytes)
|
||||
Using oMemoryStream = New MemoryStream()
|
||||
Using oCryptoStream = New CryptoStream(oMemoryStream, oEncryptor, CryptoStreamMode.Write)
|
||||
oCryptoStream.Write(PlainTextBytes, 0, PlainTextBytes.Length)
|
||||
oCryptoStream.FlushFinalBlock()
|
||||
' Create the final bytes as a concatenation of the random salt bytes, the random iv bytes and the cipher bytes.
|
||||
Dim oCipherTextBytes = oSaltStringBytes
|
||||
oCipherTextBytes = oCipherTextBytes.Concat(oIvStringBytes).ToArray()
|
||||
oCipherTextBytes = oCipherTextBytes.Concat(oMemoryStream.ToArray()).ToArray()
|
||||
oMemoryStream.Close()
|
||||
oCryptoStream.Close()
|
||||
Return oCipherTextBytes
|
||||
End Using
|
||||
End Using
|
||||
End Using
|
||||
End Using
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Throw ex
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Async Function DecryptAsync(CipherTextBytesWithSaltAndIv As Byte()) As Task(Of Byte())
|
||||
Return Await Task.Run(Function() As Byte()
|
||||
Return Decrypt(CipherTextBytesWithSaltAndIv)
|
||||
End Function)
|
||||
End Function
|
||||
|
||||
Public Function Decrypt(CipherTextPlainWithSaltAndIv As String) As String
|
||||
Try
|
||||
Dim oBytes As Byte() = UTF8.GetBytes(CipherTextPlainWithSaltAndIv)
|
||||
Dim oDecrypted As Byte() = Decrypt(oBytes)
|
||||
Return UTF8.GetString(oDecrypted)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Throw ex
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function Decrypt(CipherTextBytesWithSaltAndIv As Byte()) As Byte()
|
||||
Try
|
||||
' Get the complete stream of bytes that represent:
|
||||
' [32 bytes of Salt] + [32 bytes of IV] + [n bytes of CipherText]
|
||||
' Get the saltbytes by extracting the first 32 bytes from the supplied cipherText bytes.
|
||||
Dim oSaltStringBytes = CipherTextBytesWithSaltAndIv.Take(KEY_SIZE / 8).ToArray()
|
||||
' Get the IV bytes by extracting the next 32 bytes from the supplied cipherText bytes.
|
||||
Dim oIvStringBytes = CipherTextBytesWithSaltAndIv.Skip(KEY_SIZE / 8).Take(KEY_SIZE / 8).ToArray()
|
||||
' Get the actual cipher text bytes by removing the first 64 bytes from the cipherText string.
|
||||
Dim oCipherTextBytes = CipherTextBytesWithSaltAndIv.Skip((KEY_SIZE / 8) * 2).Take(CipherTextBytesWithSaltAndIv.Length - ((KEY_SIZE / 8) * 2)).ToArray()
|
||||
|
||||
Using oPassword = New Rfc2898DeriveBytes(_password, oSaltStringBytes, DERIVATION_ITERATIONS)
|
||||
Dim oKeyBytes = oPassword.GetBytes(KEY_SIZE / 8)
|
||||
Using oSymmetricKey = New RijndaelManaged()
|
||||
oSymmetricKey.BlockSize = BLOCK_SIZE
|
||||
oSymmetricKey.Mode = _cipherMode
|
||||
oSymmetricKey.Padding = _paddingMode
|
||||
Using oDecryptor = oSymmetricKey.CreateDecryptor(oKeyBytes, oIvStringBytes)
|
||||
Using oMemoryStream = New MemoryStream(oCipherTextBytes)
|
||||
Using oCryptoStream = New CryptoStream(oMemoryStream, oDecryptor, CryptoStreamMode.Read)
|
||||
Dim oPlainTextBytes = New Byte(oCipherTextBytes.Length - 1) {}
|
||||
Dim oDecryptedByteCount = oCryptoStream.Read(oPlainTextBytes, 0, oPlainTextBytes.Length)
|
||||
oMemoryStream.Close()
|
||||
oCryptoStream.Close()
|
||||
Return oPlainTextBytes
|
||||
End Using
|
||||
End Using
|
||||
End Using
|
||||
End Using
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Throw ex
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Shared Function Generate256BitsOfRandomEntropy() As Byte()
|
||||
Dim oRandomBytes = New Byte(31) {}
|
||||
' 32 Bytes will give us 256 bits.
|
||||
Using oRNGCsp = New RNGCryptoServiceProvider()
|
||||
' Fill the array with cryptographically secure random bytes.
|
||||
oRNGCsp.GetBytes(oRandomBytes)
|
||||
End Using
|
||||
Return oRandomBytes
|
||||
End Function
|
||||
End Class
|
||||
@@ -1,66 +0,0 @@
|
||||
Imports System.Security.Cryptography
|
||||
|
||||
Public Class EncryptionLegacy
|
||||
Private TripleDes As New TripleDESCryptoServiceProvider
|
||||
Sub New(ByVal key As String)
|
||||
' Initialize the crypto provider.
|
||||
TripleDes.Key = TruncateHash(key, TripleDes.KeySize \ 8)
|
||||
TripleDes.IV = TruncateHash("", TripleDes.BlockSize \ 8)
|
||||
End Sub
|
||||
|
||||
Private Function TruncateHash(ByVal key As String, ByVal length As Integer) As Byte()
|
||||
Dim sha1 As New SHA1CryptoServiceProvider
|
||||
|
||||
' Hash the key.
|
||||
Dim keyBytes() As Byte =
|
||||
System.Text.Encoding.Unicode.GetBytes(key)
|
||||
Dim hash() As Byte = sha1.ComputeHash(keyBytes)
|
||||
|
||||
' Truncate or pad the hash.
|
||||
ReDim Preserve hash(length - 1)
|
||||
Return hash
|
||||
End Function
|
||||
|
||||
Public Function EncryptData(ByVal plaintext As String) As String
|
||||
|
||||
' Convert the plaintext string to a byte array.
|
||||
Dim plaintextBytes() As Byte =
|
||||
System.Text.Encoding.Unicode.GetBytes("!Didalog35452Heuchelheim=" & plaintext)
|
||||
|
||||
' Create the stream.
|
||||
Dim ms As New System.IO.MemoryStream
|
||||
' Create the encoder to write to the stream.
|
||||
Dim encStream As New CryptoStream(ms,
|
||||
TripleDes.CreateEncryptor(),
|
||||
System.Security.Cryptography.CryptoStreamMode.Write)
|
||||
|
||||
' Use the crypto stream to write the byte array to the stream.
|
||||
encStream.Write(plaintextBytes, 0, plaintextBytes.Length)
|
||||
encStream.FlushFinalBlock()
|
||||
|
||||
' Convert the encrypted stream to a printable string.
|
||||
Return Convert.ToBase64String(ms.ToArray)
|
||||
End Function
|
||||
|
||||
'Entschlüsselt die Zeichenfolge
|
||||
Public Function DecryptData(ByVal encryptedtext As String) As String
|
||||
' Convert the encrypted text string to a byte array.
|
||||
Dim encryptedBytes() As Byte = Convert.FromBase64String(encryptedtext)
|
||||
|
||||
' Create the stream.
|
||||
Dim ms As New System.IO.MemoryStream
|
||||
' Create the decoder to write to the stream.
|
||||
Dim decStream As New CryptoStream(ms,
|
||||
TripleDes.CreateDecryptor(),
|
||||
System.Security.Cryptography.CryptoStreamMode.Write)
|
||||
|
||||
' Use the crypto stream to write the byte array to the stream.
|
||||
decStream.Write(encryptedBytes, 0, encryptedBytes.Length)
|
||||
decStream.FlushFinalBlock()
|
||||
Dim result = System.Text.Encoding.Unicode.GetString(ms.ToArray)
|
||||
result = result.Replace("!Didalog35452Heuchelheim=", "")
|
||||
' Convert the plaintext stream to a string.
|
||||
Return result
|
||||
End Function
|
||||
End Class
|
||||
|
||||
@@ -1,232 +0,0 @@
|
||||
Imports System.IO
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
''' <module>File</module>
|
||||
''' <version>0.0.0.1</version>
|
||||
''' <date>11.10.2018</date>
|
||||
''' <summary>
|
||||
''' Module that provides variouse File operations
|
||||
''' </summary>
|
||||
''' <dependencies>
|
||||
''' NLog, >= 4.5.8
|
||||
''' </dependencies>
|
||||
''' <params>
|
||||
''' LogConfig, DigitalData.Module.Logging.LogConfig
|
||||
''' A LogConfig object
|
||||
''' </params>
|
||||
''' <props>
|
||||
''' </props>
|
||||
''' <example>
|
||||
''' </example>
|
||||
''' <remarks>
|
||||
''' </remarks>
|
||||
Public Class File
|
||||
Private ReadOnly _logger As Logger
|
||||
Private ReadOnly _logConfig As LogConfig
|
||||
|
||||
Private Const FILE_NAME_ACCESS_TEST = "accessTest.txt"
|
||||
|
||||
Public Sub New(LogConfig As LogConfig)
|
||||
_logConfig = LogConfig
|
||||
_logger = LogConfig.GetLogger()
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Adds fileversions to given filename `Destination` if that file already exists.
|
||||
''' </summary>
|
||||
''' <param name="Destination"></param>
|
||||
''' <returns></returns>
|
||||
Public Function GetVersionedFilename(Destination As String) As String
|
||||
Try
|
||||
Dim oFileName As String = Destination
|
||||
Dim oFinalFileName = oFileName
|
||||
|
||||
Dim oDestinationDir = Path.GetDirectoryName(oFileName)
|
||||
Dim oExtension = Path.GetExtension(oFileName)
|
||||
|
||||
Dim oVersionSeparator As Char = "~"c
|
||||
Dim oFileVersion As Integer = Nothing
|
||||
|
||||
' Split Filename without extension at version separator to:
|
||||
' - Check if file is already versioned
|
||||
' - Get the file version of an already versioned file
|
||||
'
|
||||
' Example:
|
||||
' test1.pdf --> test1 --> ['test1'] --> no fileversion
|
||||
' test1~2.pdf --> test1~2 --> ['test1', '2'] --> version 2
|
||||
' test1~12345~2.pdf --> test1~12345~2 --> ['test1', '12345', '2'] --> still version 2
|
||||
Dim oFileNameWithoutExtension = Path.GetFileNameWithoutExtension(oFileName)
|
||||
Dim oSplitFilename = oFileNameWithoutExtension.Split(oVersionSeparator).ToList()
|
||||
|
||||
' if file is already versioned, extract file version
|
||||
' else just use the filename and set version to 1
|
||||
If oSplitFilename.Count > 1 Then
|
||||
Dim oVersion As Integer = 1
|
||||
Try
|
||||
oVersion = Integer.Parse(oSplitFilename.Last())
|
||||
Catch ex As Exception
|
||||
' oFilenameWithoutExtension does NOT change
|
||||
oFileNameWithoutExtension = oFileNameWithoutExtension
|
||||
Finally
|
||||
oFileVersion = oVersion
|
||||
End Try
|
||||
Else
|
||||
oFileVersion = 1
|
||||
oFileNameWithoutExtension = String.Join(String.Empty, oSplitFilename.Take(oSplitFilename.Count - 1))
|
||||
End If
|
||||
|
||||
' while file exists, increment version
|
||||
Do
|
||||
oFinalFileName = Path.Combine(oDestinationDir, GetFilenameWithVersion(oFileNameWithoutExtension, oVersionSeparator, oFileVersion, oExtension))
|
||||
_logger.Debug("Intermediate Filename is {0}", oFinalFileName)
|
||||
_logger.Debug("File version: {0}", oFileVersion)
|
||||
oFileVersion += 1
|
||||
Loop While (IO.File.Exists(oFinalFileName))
|
||||
|
||||
_logger.Debug("Final Filename is {0}", oFinalFileName)
|
||||
|
||||
Return oFinalFileName
|
||||
Catch ex As Exception
|
||||
_logger.Warn("Filename {0} could not be versioned. Original filename will be returned!", Destination)
|
||||
_logger.Error(ex)
|
||||
Return Destination
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function GetFilenameWithVersion(FileNameWithoutExtension As String, VersionSeparator As Char, FileVersion As Integer, Extension As String) As String
|
||||
If FileVersion <= 1 Then
|
||||
Return $"{FileNameWithoutExtension}{Extension}"
|
||||
Else
|
||||
Return $"{FileNameWithoutExtension}{VersionSeparator}{FileVersion}{Extension}"
|
||||
End If
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Removes files in a directory filtered by filename, extension and last write date
|
||||
''' </summary>
|
||||
''' <param name="Path">The directory in which files will be deleted</param>
|
||||
''' <param name="FileKeepTime">Only delete files which are older than x days. Must be between 0 and 1000 days.</param>
|
||||
''' <param name="FileBaseName">A filename filter which will be checked</param>
|
||||
''' <param name="FileExtension">A file extension which will be checked</param>
|
||||
''' <param name="ContinueOnError">Should the function continue with deleting when a file could not be deleted?</param>
|
||||
''' <returns>True if all files were deleted or if no files were deleted, otherwise false</returns>
|
||||
Public Function RemoveFiles(Path As String, FileKeepTime As Integer, FileBaseName As String, Optional FileExtension As String = "log", Optional ContinueOnError As Boolean = True) As Boolean
|
||||
If Not TestPathIsDirectory(Path) Then
|
||||
Throw New ArgumentException($"Path {Path} is not a directory!")
|
||||
End If
|
||||
|
||||
If Not Directory.Exists(Path) Then
|
||||
Throw New DirectoryNotFoundException($"Path {Path} does not exist!")
|
||||
End If
|
||||
|
||||
If FileKeepTime < 0 Or FileKeepTime > 1000 Then
|
||||
Throw New ArgumentOutOfRangeException("FileKeepTime must be an integer between 0 and 1000!")
|
||||
End If
|
||||
|
||||
Dim oUnableToDeleteCounter = 0
|
||||
Dim oDirectory As New DirectoryInfo(Path)
|
||||
Dim oDateLimit As DateTime = DateTime.Now.AddDays(FileKeepTime)
|
||||
Dim oFiles As List(Of FileInfo) = oDirectory.
|
||||
EnumerateFiles($"*{FileBaseName}*").
|
||||
Where(Function(oFileInfo As FileInfo)
|
||||
Return oFileInfo.Extension = FileExtension And oFileInfo.LastWriteTime < oDateLimit
|
||||
End Function)
|
||||
|
||||
If oFiles.Count = 0 Then
|
||||
_logger.Debug("No files found that match the criterias.")
|
||||
Return True
|
||||
End If
|
||||
|
||||
_logger.Debug("Deleting old files (Found {0}).", oFiles.Count)
|
||||
|
||||
For Each oFile As FileInfo In oFiles
|
||||
Try
|
||||
oFile.Delete()
|
||||
Catch ex As Exception
|
||||
If ContinueOnError = False Then
|
||||
_logger.Warn("Deleting files was aborted at file {0}.", oFile.FullName)
|
||||
Return False
|
||||
End If
|
||||
oUnableToDeleteCounter = oUnableToDeleteCounter + 1
|
||||
_logger.Warn("File {0} could not be deleted!")
|
||||
End Try
|
||||
Next
|
||||
|
||||
If oUnableToDeleteCounter > 0 Then
|
||||
_logger.Debug("Old files partially removed. {0} files could not be removed.", oUnableToDeleteCounter)
|
||||
Else
|
||||
_logger.Debug("Old files removed.")
|
||||
End If
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Public Sub MoveTo(FilePath As String, Directory As String)
|
||||
Dim oFileInfo As New FileInfo(FilePath)
|
||||
IO.File.Move(FilePath, Path.Combine(Directory, oFileInfo.Name))
|
||||
End Sub
|
||||
|
||||
Public Sub MoveTo(FilePath As String, NewFileName As String, Directory As String)
|
||||
Dim oFileInfo As New FileInfo(FilePath)
|
||||
IO.File.Move(FilePath, Path.Combine(Directory, NewFileName))
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Tries to create a directory and returns its path.
|
||||
''' Returns a temp path if `DirectoryPath` can not be created or written to.
|
||||
''' </summary>
|
||||
''' <param name="DirectoryPath">The directory to create</param>
|
||||
''' <param name="TestWriteAccess">Should a write access test be performed?</param>
|
||||
''' <returns>The used path</returns>
|
||||
Public Function CreateDirectory(DirectoryPath As String, Optional TestWriteAccess As Boolean = True) As String
|
||||
Dim oFinalPath As String
|
||||
If Directory.Exists(DirectoryPath) Then
|
||||
_logger.Debug("Directory {0} already exists. Skipping.", DirectoryPath)
|
||||
oFinalPath = DirectoryPath
|
||||
Else
|
||||
Try
|
||||
Directory.CreateDirectory(DirectoryPath)
|
||||
oFinalPath = DirectoryPath
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
_logger.Warn("Directory {0} could not be created. Temp path will be used instead.", DirectoryPath)
|
||||
oFinalPath = Path.GetTempPath()
|
||||
End Try
|
||||
End If
|
||||
|
||||
If TestWriteAccess AndAlso Not TestPathIsWritable(DirectoryPath) Then
|
||||
_logger.Warn("Directory {0} is not writable. Temp path will be used instead.", DirectoryPath)
|
||||
oFinalPath = Path.GetTempPath()
|
||||
Else
|
||||
oFinalPath = DirectoryPath
|
||||
End If
|
||||
|
||||
_logger.Debug("Using path {0}", oFinalPath)
|
||||
|
||||
Return oFinalPath
|
||||
End Function
|
||||
|
||||
Public Function TestPathIsWritable(DirectoryPath As String) As Boolean
|
||||
Try
|
||||
Dim fileAccessPath = Path.Combine(DirectoryPath, FILE_NAME_ACCESS_TEST)
|
||||
Using fs As FileStream = IO.File.Create(fileAccessPath)
|
||||
fs.WriteByte(0)
|
||||
End Using
|
||||
|
||||
IO.File.Delete(fileAccessPath)
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function TestPathIsDirectory(Path As String) As Boolean
|
||||
If Not Directory.Exists(Path) Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
Dim oIsDirectory As Boolean = (System.IO.File.GetAttributes(Path) And FileAttributes.Directory) = FileAttributes.Directory
|
||||
Return oIsDirectory
|
||||
End Function
|
||||
|
||||
End Class
|
||||
@@ -1,192 +0,0 @@
|
||||
Imports System.IO
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports ProtoBuf
|
||||
|
||||
''' <module>FileContainer</module>
|
||||
''' <version>0.0.0.2</version>
|
||||
''' <date>21.11.2018</date>
|
||||
''' <summary>
|
||||
''' File Container for securely saving files
|
||||
''' </summary>
|
||||
''' <dependencies>
|
||||
''' NLog, >= 4.5.8
|
||||
''' </dependencies>
|
||||
''' <params>
|
||||
''' LogConfig, DigitalData.Module.Logging.LogConfig
|
||||
''' A LogConfig object
|
||||
''' Password, String
|
||||
''' The Password to Encrypt
|
||||
''' Path, String
|
||||
''' The Path to save/load the container
|
||||
''' </params>
|
||||
''' <example>
|
||||
''' dim oContainer = Container.Create(logConfig, "pass", "E:\some.container")
|
||||
''' dim oContainer = Container.Load(logConfig, "pass", "E:\some.container")
|
||||
'''
|
||||
''' dim oContainer = new Container(logConfig, "pass", "E:\some.container")
|
||||
''' oContainer.Save()
|
||||
'''
|
||||
''' dim oContainer = new Container(logConfig, "pass", "E:\some.container")
|
||||
''' oContainer.Contents = oSomeData
|
||||
''' oContainer.Save()
|
||||
'''
|
||||
''' dim oContainer = new Container(logConfig, "pass", "E:\some.container")
|
||||
''' oContainer.Load()
|
||||
''' dim oContents = oContainer.Contents
|
||||
'''
|
||||
''' dim oContainer = new Container(logConfig, "pass", "E:\some.container")
|
||||
''' oContainer.Load()
|
||||
''' oContainer.Contents = oSomeOtherData
|
||||
''' oContainer.Save()
|
||||
''' oContainer.SaveAs("E:\some2.container")
|
||||
''' </example>
|
||||
Public Class FileContainer
|
||||
Private _crypto As Encryption
|
||||
Private _compression As Compression
|
||||
Private _inner As FileContainerInner
|
||||
Private _logger As Logger
|
||||
Private _logConfig As LogConfig
|
||||
Private _path As String
|
||||
|
||||
Public Property Contents As Byte()
|
||||
Get
|
||||
Return _inner.Contents
|
||||
End Get
|
||||
Set(value As Byte())
|
||||
_inner.Contents = value
|
||||
End Set
|
||||
End Property
|
||||
Public ReadOnly Property ContainerId As String
|
||||
Get
|
||||
Return _inner.FileId
|
||||
End Get
|
||||
End Property
|
||||
Public ReadOnly Property CreatedAt As String
|
||||
Get
|
||||
Return _inner.CreatedAt
|
||||
End Get
|
||||
End Property
|
||||
Public ReadOnly Property UpdatedAt As String
|
||||
Get
|
||||
Return _inner.UpdatedAt
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Shared Function Create(LogConfig As LogConfig, Password As String) As FileContainer
|
||||
Dim oContainer = New FileContainer(LogConfig, Password)
|
||||
Return oContainer
|
||||
End Function
|
||||
|
||||
Public Shared Function Load(LogConfig As LogConfig, Password As String, Path As String) As FileContainer
|
||||
Dim oContainer = New FileContainer(LogConfig, Password, Path)
|
||||
oContainer.Load()
|
||||
Return oContainer
|
||||
End Function
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, Password As String)
|
||||
_logger = LogConfig.GetLogger()
|
||||
_crypto = New Encryption(LogConfig, Password)
|
||||
_compression = New Compression(LogConfig)
|
||||
_inner = New FileContainerInner()
|
||||
End Sub
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, Password As String, Path As String)
|
||||
MyClass.New(LogConfig, Password)
|
||||
_path = Path
|
||||
End Sub
|
||||
|
||||
Public Sub SetFile(Contents As Byte(), FileName As String)
|
||||
_inner.Contents = Contents
|
||||
_inner.UpdatedAt = Date.Now
|
||||
_inner.FileName = FileName
|
||||
End Sub
|
||||
|
||||
Public Function GetFile() As FileContainerInner
|
||||
Return _inner
|
||||
End Function
|
||||
|
||||
Public Sub Save()
|
||||
If IsNothing(_path) Then
|
||||
Throw New ArgumentException("Path not set")
|
||||
End If
|
||||
|
||||
SaveAs(_path)
|
||||
End Sub
|
||||
|
||||
Public Sub SaveAs(Path As String)
|
||||
Try
|
||||
WriteBytesToFile(TransformToBytes(_inner), Path)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Throw ex
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Public Sub Load()
|
||||
If IsNothing(_path) Then
|
||||
Throw New ArgumentException("Path not set")
|
||||
End If
|
||||
|
||||
LoadFrom(_path)
|
||||
End Sub
|
||||
|
||||
Public Sub LoadFrom(Path As String)
|
||||
Try
|
||||
_inner = TransformToObject(ReadBytesFromFile(_path))
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Throw ex
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Function TransformToBytes([Object] As FileContainerInner) As Byte()
|
||||
Dim oBytes = Serialize([Object])
|
||||
Dim oCompressed = _compression.Compress(oBytes)
|
||||
Dim oEncrypted = _crypto.Encrypt(oCompressed)
|
||||
Return oEncrypted
|
||||
End Function
|
||||
|
||||
Private Function TransformToObject(Bytes As Byte()) As FileContainerInner
|
||||
Dim oDecrypted = _crypto.Decrypt(Bytes)
|
||||
Dim oDecompressed = _compression.Decompress(oDecrypted)
|
||||
Dim oObject = Deserialize(oDecompressed)
|
||||
Return oObject
|
||||
End Function
|
||||
|
||||
Private Function Serialize(InnerData As FileContainerInner) As Byte()
|
||||
Dim oBinaryData As Byte()
|
||||
|
||||
Using oStream As New MemoryStream
|
||||
Serializer.Serialize(oStream, InnerData)
|
||||
oBinaryData = oStream.ToArray()
|
||||
End Using
|
||||
|
||||
Return oBinaryData
|
||||
End Function
|
||||
|
||||
Private Function Deserialize(InnerData As Byte()) As FileContainerInner
|
||||
Dim oObject As FileContainerInner
|
||||
|
||||
Using oStream As New MemoryStream(InnerData)
|
||||
oObject = Serializer.Deserialize(Of FileContainerInner)(oStream)
|
||||
End Using
|
||||
|
||||
Return oObject
|
||||
End Function
|
||||
|
||||
Private Sub WriteBytesToFile(Data As Byte(), FilePath As String)
|
||||
Using oSourceStream As New FileStream(FilePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None)
|
||||
oSourceStream.Write(Data, 0, Data.Length)
|
||||
oSourceStream.Flush()
|
||||
End Using
|
||||
End Sub
|
||||
|
||||
Private Function ReadBytesFromFile(FilePath As String) As Byte()
|
||||
Using oFileStream = New FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.Read, 4096)
|
||||
Dim oBuffer As Byte() = New Byte(oFileStream.Length - 1) {}
|
||||
oFileStream.Read(oBuffer, 0, oFileStream.Length)
|
||||
oFileStream.Close()
|
||||
Return oBuffer
|
||||
End Using
|
||||
End Function
|
||||
End Class
|
||||
@@ -1,23 +0,0 @@
|
||||
Imports ProtoBuf
|
||||
|
||||
<Serializable>
|
||||
<ProtoContract>
|
||||
Public Class FileContainerInner
|
||||
<ProtoMember(1)>
|
||||
Public FileId As String
|
||||
<ProtoMember(2)>
|
||||
Public Contents As Byte()
|
||||
<ProtoMember(3)>
|
||||
Public CreatedAt As DateTime
|
||||
<ProtoMember(4)>
|
||||
Public UpdatedAt As DateTime
|
||||
<ProtoMember(5)>
|
||||
Public FileName As String
|
||||
|
||||
Public Sub New()
|
||||
FileId = Guid.NewGuid().ToString
|
||||
CreatedAt = Date.Now
|
||||
UpdatedAt = Date.Now
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
@@ -1,132 +0,0 @@
|
||||
Imports System.IO
|
||||
Imports DigitalData.Modules.Filesystem
|
||||
Imports DigitalData.Modules.Filesystem.FileWatcherFilters
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
|
||||
Public Class FileWatcher
|
||||
' Internals
|
||||
Private ReadOnly _Logger As Logger
|
||||
Private ReadOnly _Watchers As List(Of FileSystemWatcher)
|
||||
Private ReadOnly _Files As Dictionary(Of String, FileWatcherProperties)
|
||||
Private ReadOnly _Filters As List(Of BaseFileFilter)
|
||||
|
||||
' Options
|
||||
Private _Path As String
|
||||
|
||||
' Public Events
|
||||
Public Event FileSaved(ByVal FullName As String, ByVal IsSpecial As Boolean)
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, Path As String, Optional Filters As List(Of BaseFileFilter) = Nothing)
|
||||
_Logger = LogConfig.GetLogger()
|
||||
_Files = New Dictionary(Of String, FileWatcherProperties)
|
||||
_Watchers = New List(Of FileSystemWatcher)
|
||||
_Filters = IIf(IsNothing(Filters), GetDefaultFilters(), Filters)
|
||||
_Path = Path
|
||||
|
||||
For Each oFilePath In Directory.EnumerateFiles(_Path)
|
||||
Try
|
||||
If IO.File.Exists(oFilePath) Then
|
||||
_Files.Add(oFilePath, New FileWatcherProperties With {
|
||||
.CreatedAt = DateTime.Now,
|
||||
.ChangedAt = Nothing
|
||||
})
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("File {0} cannot be watched!")
|
||||
End Try
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Public Sub Add(Filter As String)
|
||||
_Watchers.Add(CreateWatcher(Filter))
|
||||
End Sub
|
||||
|
||||
Public Sub Start()
|
||||
For Each oWatcher In _Watchers
|
||||
oWatcher.EnableRaisingEvents = True
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Public Sub [Stop]()
|
||||
For Each oWatcher In _Watchers
|
||||
If Not IsNothing(oWatcher) Then
|
||||
oWatcher.EnableRaisingEvents = False
|
||||
oWatcher.Dispose()
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Private Function GetDefaultFilters()
|
||||
Return New List(Of BaseFileFilter) From {
|
||||
New TempFileFilter,
|
||||
New OfficeFileFilter
|
||||
}
|
||||
End Function
|
||||
|
||||
Private Function CreateWatcher(Filter As String)
|
||||
Dim oWatcher = New FileSystemWatcher() With {
|
||||
.Path = _Path,
|
||||
.Filter = Filter,
|
||||
.NotifyFilter = NotifyFilters.LastAccess _
|
||||
Or NotifyFilters.LastWrite _
|
||||
Or NotifyFilters.FileName _
|
||||
Or NotifyFilters.Size _
|
||||
Or NotifyFilters.FileName _
|
||||
Or NotifyFilters.Attributes
|
||||
}
|
||||
|
||||
AddHandler oWatcher.Created, AddressOf HandleFileCreated
|
||||
AddHandler oWatcher.Changed, AddressOf HandleFileChanged
|
||||
AddHandler oWatcher.Deleted, AddressOf HandleFileDeleted
|
||||
AddHandler oWatcher.Renamed, AddressOf HandleFileRenamed
|
||||
|
||||
Return oWatcher
|
||||
End Function
|
||||
|
||||
Private Sub HandleFileCreated(sender As Object, e As FileSystemEventArgs)
|
||||
_Files.Add(e.FullPath, New FileWatcherProperties())
|
||||
_Logger.Debug("[Created] " & e.FullPath)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' This may fire twice for a single save operation,
|
||||
''' see: https://blogs.msdn.microsoft.com/oldnewthing/20140507-00/?p=1053/
|
||||
''' </summary>
|
||||
Private Sub HandleFileChanged(sender As Object, e As FileSystemEventArgs)
|
||||
_Files.Item(e.FullPath).ChangedAt = DateTime.Now
|
||||
_Logger.Debug("[Changed] " & e.FullPath)
|
||||
|
||||
Dim oShouldRaiseSave As Boolean = Not _Filters.Any(Function(oFilter)
|
||||
Return oFilter.ShouldFilter(e)
|
||||
End Function)
|
||||
|
||||
If oShouldRaiseSave Then
|
||||
RaiseEvent FileSaved(e.FullPath, False)
|
||||
End If
|
||||
End Sub
|
||||
Private Sub HandleFileDeleted(sender As Object, e As FileSystemEventArgs)
|
||||
_Files.Remove(e.FullPath)
|
||||
_Logger.Debug("[Removed] " & e.FullPath)
|
||||
End Sub
|
||||
|
||||
Private Sub HandleFileRenamed(sender As Object, e As RenamedEventArgs)
|
||||
Dim oProperties = _Files.Item(e.OldFullPath)
|
||||
_Files.Remove(e.OldFullPath)
|
||||
_Files.Add(e.FullPath, oProperties)
|
||||
' Soll eine umbenannte datei als NEU gelten?
|
||||
|
||||
Dim oShouldRaiseSave = _Filters.Any(Function(oFilter)
|
||||
Return oFilter.ShouldRaiseSave(e)
|
||||
End Function)
|
||||
|
||||
If oShouldRaiseSave Then
|
||||
RaiseEvent FileSaved(e.OldFullPath, True)
|
||||
End If
|
||||
|
||||
_Logger.Debug("[Renamed] {0} --> {1}", e.OldFullPath, e.FullPath)
|
||||
End Sub
|
||||
|
||||
|
||||
End Class
|
||||
@@ -1,61 +0,0 @@
|
||||
Imports System.IO
|
||||
|
||||
''' <summary>
|
||||
''' Built-in filters for FileWatcher that are useful for correctly detecting changes on Office documents (currently Office 2016)
|
||||
''' </summary>
|
||||
Public Class FileWatcherFilters
|
||||
''' <summary>
|
||||
''' Base Filter that all filters must inherit from
|
||||
''' Provides two functions that may be overridden and some useful file extension lists
|
||||
''' </summary>
|
||||
Public MustInherit Class BaseFileFilter
|
||||
Public TempFiles As New List(Of String) From {".tmp", ""}
|
||||
|
||||
Public Overridable Function ShouldFilter(e As FileSystemEventArgs) As Boolean
|
||||
Return False
|
||||
End Function
|
||||
Public Overridable Function ShouldRaiseSave(e As RenamedEventArgs) As Boolean
|
||||
Return False
|
||||
End Function
|
||||
End Class
|
||||
|
||||
''' <summary>
|
||||
''' Simple Filter that filters changes made on temporary files
|
||||
''' </summary>
|
||||
Public Class TempFileFilter
|
||||
Inherits BaseFileFilter
|
||||
|
||||
Public Overrides Function ShouldFilter(e As FileSystemEventArgs) As Boolean
|
||||
Dim oFileInfo As New FileInfo(e.FullPath)
|
||||
Return TempFiles.Contains(oFileInfo.Extension)
|
||||
End Function
|
||||
End Class
|
||||
|
||||
''' <summary>
|
||||
''' Filter to detect changes on Office files
|
||||
''' </summary>
|
||||
Public Class OfficeFileFilter
|
||||
Inherits BaseFileFilter
|
||||
|
||||
Public OfficeFiles As New List(Of String) From {".docx", ".pptx", ".xlsx"}
|
||||
|
||||
Public Overrides Function ShouldFilter(e As FileSystemEventArgs) As Boolean
|
||||
Dim oFileInfo As New FileInfo(e.FullPath)
|
||||
Return OfficeFiles.Contains(oFileInfo.Extension) And oFileInfo.Name.StartsWith("~")
|
||||
End Function
|
||||
|
||||
Public Overrides Function ShouldRaiseSave(e As RenamedEventArgs) As Boolean
|
||||
Dim oIsTransform = OfficeFiles.Any(Function(Extension As String)
|
||||
Return e.OldName.EndsWith(Extension)
|
||||
End Function)
|
||||
|
||||
' Check if it is renamed to a temp file
|
||||
Dim oIsTempFile = TempFiles.Any(Function(Extension)
|
||||
Return e.Name.EndsWith(Extension)
|
||||
End Function)
|
||||
|
||||
|
||||
Return oIsTransform And oIsTempFile
|
||||
End Function
|
||||
End Class
|
||||
End Class
|
||||
@@ -1,10 +0,0 @@
|
||||
Public Class FileWatcherProperties
|
||||
Public Property CreatedAt As DateTime
|
||||
Public Property ChangedAt As DateTime
|
||||
Public ReadOnly Property HasChanged As Boolean
|
||||
Public Sub New()
|
||||
CreatedAt = DateTime.Now
|
||||
ChangedAt = Nothing
|
||||
HasChanged = False
|
||||
End Sub
|
||||
End Class
|
||||
@@ -1,133 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{991D0231-4623-496D-8BD0-9CA906029CBC}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>DigitalData.Modules.Filesystem</RootNamespace>
|
||||
<AssemblyName>DigitalData.Modules.Filesystem</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<MyType>Windows</MyType>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<DefineDebug>true</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DocumentationFile>DigitalData.Modules.Filesystem.xml</DocumentationFile>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<DefineDebug>false</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DocumentationFile>DigitalData.Modules.Filesystem.xml</DocumentationFile>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionExplicit>On</OptionExplicit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionCompare>Binary</OptionCompare>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionStrict>Off</OptionStrict>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionInfer>On</OptionInfer>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.4.6.7\lib\net45\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="protobuf-net, Version=2.4.0.0, Culture=neutral, PublicKeyToken=257b51d87d2e4d67, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\protobuf-net.2.4.0\lib\net40\protobuf-net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Import Include="Microsoft.VisualBasic" />
|
||||
<Import Include="System" />
|
||||
<Import Include="System.Collections" />
|
||||
<Import Include="System.Collections.Generic" />
|
||||
<Import Include="System.Data" />
|
||||
<Import Include="System.Diagnostics" />
|
||||
<Import Include="System.Linq" />
|
||||
<Import Include="System.Xml.Linq" />
|
||||
<Import Include="System.Threading.Tasks" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Compression.vb" />
|
||||
<Compile Include="DocumentObject.vb" />
|
||||
<Compile Include="EncryptionLegacy.vb" />
|
||||
<Compile Include="FileContainer.vb" />
|
||||
<Compile Include="Encryption.vb" />
|
||||
<Compile Include="File.vb">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Compile>
|
||||
<Compile Include="FileContainerInner.vb" />
|
||||
<Compile Include="FileWatcher.vb" />
|
||||
<Compile Include="FileWatcherFilters.vb" />
|
||||
<Compile Include="FileWatcherProperties.vb" />
|
||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||
<Compile Include="My Project\Application.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Application.myapp</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="My Project\Resources.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="My Project\Settings.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="My Project\Resources.resx">
|
||||
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
|
||||
<CustomToolNamespace>My.Resources</CustomToolNamespace>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="My Project\Application.myapp">
|
||||
<Generator>MyApplicationCodeGenerator</Generator>
|
||||
<LastGenOutput>Application.Designer.vb</LastGenOutput>
|
||||
</None>
|
||||
<None Include="My Project\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<CustomToolNamespace>My</CustomToolNamespace>
|
||||
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Modules.Logging\Logging.vbproj">
|
||||
<Project>{903b2d7d-3b80-4be9-8713-7447b704e1b0}</Project>
|
||||
<Name>Logging</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
||||
</Project>
|
||||
13
Filesystem/My Project/Application.Designer.vb
generated
13
Filesystem/My Project/Application.Designer.vb
generated
@@ -1,13 +0,0 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' Dieser Code wurde von einem Tool generiert.
|
||||
' Laufzeitversion:4.0.30319.42000
|
||||
'
|
||||
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||
' der Code erneut generiert wird.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<MySubMain>false</MySubMain>
|
||||
<SingleInstance>false</SingleInstance>
|
||||
<ShutdownMode>0</ShutdownMode>
|
||||
<EnableVisualStyles>true</EnableVisualStyles>
|
||||
<AuthenticationMode>0</AuthenticationMode>
|
||||
<ApplicationType>1</ApplicationType>
|
||||
<SaveMySettingsOnExit>true</SaveMySettingsOnExit>
|
||||
</MyApplicationData>
|
||||
@@ -1,35 +0,0 @@
|
||||
Imports System
|
||||
Imports System.Reflection
|
||||
Imports System.Runtime.InteropServices
|
||||
|
||||
' Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||
' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||
' die einer Assembly zugeordnet sind.
|
||||
|
||||
' Werte der Assemblyattribute überprüfen
|
||||
|
||||
<Assembly: AssemblyTitle("Modules.Filesystem")>
|
||||
<Assembly: AssemblyDescription("")>
|
||||
<Assembly: AssemblyCompany("Digital Data")>
|
||||
<Assembly: AssemblyProduct("Modules.Filesystem")>
|
||||
<Assembly: AssemblyCopyright("Copyright © 2018")>
|
||||
<Assembly: AssemblyTrademark("")>
|
||||
|
||||
<Assembly: ComVisible(False)>
|
||||
|
||||
'Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird.
|
||||
<Assembly: Guid("2787495c-e65f-4730-be0c-af87bede4b11")>
|
||||
|
||||
' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
||||
'
|
||||
' Hauptversion
|
||||
' Nebenversion
|
||||
' Buildnummer
|
||||
' Revision
|
||||
'
|
||||
' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("0.0.0.1")>
|
||||
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
||||
63
Filesystem/My Project/Resources.Designer.vb
generated
63
Filesystem/My Project/Resources.Designer.vb
generated
@@ -1,63 +0,0 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' Dieser Code wurde von einem Tool generiert.
|
||||
' Laufzeitversion:4.0.30319.42000
|
||||
'
|
||||
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||
' der Code erneut generiert wird.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
Imports System
|
||||
|
||||
Namespace My.Resources
|
||||
|
||||
'Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
|
||||
'-Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
|
||||
'Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
|
||||
'mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
|
||||
'''<summary>
|
||||
''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
|
||||
'''</summary>
|
||||
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0"), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
|
||||
Friend Module Resources
|
||||
|
||||
Private resourceMan As Global.System.Resources.ResourceManager
|
||||
|
||||
Private resourceCulture As Global.System.Globalization.CultureInfo
|
||||
|
||||
'''<summary>
|
||||
''' Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
|
||||
'''</summary>
|
||||
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
|
||||
Get
|
||||
If Object.ReferenceEquals(resourceMan, Nothing) Then
|
||||
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("DigitalData.Modules.Filesystem.Resources", GetType(Resources).Assembly)
|
||||
resourceMan = temp
|
||||
End If
|
||||
Return resourceMan
|
||||
End Get
|
||||
End Property
|
||||
|
||||
'''<summary>
|
||||
''' Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
|
||||
''' Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
|
||||
'''</summary>
|
||||
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Friend Property Culture() As Global.System.Globalization.CultureInfo
|
||||
Get
|
||||
Return resourceCulture
|
||||
End Get
|
||||
Set
|
||||
resourceCulture = value
|
||||
End Set
|
||||
End Property
|
||||
End Module
|
||||
End Namespace
|
||||
@@ -1,117 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
73
Filesystem/My Project/Settings.Designer.vb
generated
73
Filesystem/My Project/Settings.Designer.vb
generated
@@ -1,73 +0,0 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' Dieser Code wurde von einem Tool generiert.
|
||||
' Laufzeitversion:4.0.30319.42000
|
||||
'
|
||||
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||
' der Code erneut generiert wird.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
|
||||
Namespace My
|
||||
|
||||
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0"), _
|
||||
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Partial Friend NotInheritable Class MySettings
|
||||
Inherits Global.System.Configuration.ApplicationSettingsBase
|
||||
|
||||
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings)
|
||||
|
||||
#Region "Automatische My.Settings-Speicherfunktion"
|
||||
#If _MyType = "WindowsForms" Then
|
||||
Private Shared addedHandler As Boolean
|
||||
|
||||
Private Shared addedHandlerLockObject As New Object
|
||||
|
||||
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs)
|
||||
If My.Application.SaveMySettingsOnExit Then
|
||||
My.Settings.Save()
|
||||
End If
|
||||
End Sub
|
||||
#End If
|
||||
#End Region
|
||||
|
||||
Public Shared ReadOnly Property [Default]() As MySettings
|
||||
Get
|
||||
|
||||
#If _MyType = "WindowsForms" Then
|
||||
If Not addedHandler Then
|
||||
SyncLock addedHandlerLockObject
|
||||
If Not addedHandler Then
|
||||
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
|
||||
addedHandler = True
|
||||
End If
|
||||
End SyncLock
|
||||
End If
|
||||
#End If
|
||||
Return defaultInstance
|
||||
End Get
|
||||
End Property
|
||||
End Class
|
||||
End Namespace
|
||||
|
||||
Namespace My
|
||||
|
||||
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
|
||||
Friend Module MySettingsProperty
|
||||
|
||||
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
|
||||
Friend ReadOnly Property Settings() As Global.DigitalData.Modules.Filesystem.My.MySettings
|
||||
Get
|
||||
Return Global.DigitalData.Modules.Filesystem.My.MySettings.Default
|
||||
End Get
|
||||
End Property
|
||||
End Module
|
||||
End Namespace
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" UseMySettingsClassName="true">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NLog" version="4.6.7" targetFramework="net461" />
|
||||
<package id="protobuf-net" version="2.4.0" targetFramework="net461" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user