diff --git a/DDMonorepo.sln b/DDMonorepo.sln index 00a66b49..69805582 100644 --- a/DDMonorepo.sln +++ b/DDMonorepo.sln @@ -96,6 +96,8 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EDMIAPI", "Modules.EDMIAPI\ EndProject Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Jobs", "Modules.Jobs\Jobs.vbproj", "{39EC839A-3C30-4922-A41E-6B09D1DDE5C3}" EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Filesystem.Test", "Modules\Filesystem.Test\Filesystem.Test.vbproj", "{B29ED6D4-839B-413A-A485-B10F4A4788EA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -246,6 +248,10 @@ Global {39EC839A-3C30-4922-A41E-6B09D1DDE5C3}.Debug|Any CPU.Build.0 = Debug|Any CPU {39EC839A-3C30-4922-A41E-6B09D1DDE5C3}.Release|Any CPU.ActiveCfg = Release|Any CPU {39EC839A-3C30-4922-A41E-6B09D1DDE5C3}.Release|Any CPU.Build.0 = Release|Any CPU + {B29ED6D4-839B-413A-A485-B10F4A4788EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B29ED6D4-839B-413A-A485-B10F4A4788EA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B29ED6D4-839B-413A-A485-B10F4A4788EA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B29ED6D4-839B-413A-A485-B10F4A4788EA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -287,6 +293,7 @@ Global {991D0231-4623-496D-8BD0-9CA906029CBC} = {3E2008C8-27B1-41DD-9B1A-0C4029F6AECC} {5B1171DC-FFFE-4813-A20D-786AAE47B320} = {3E2008C8-27B1-41DD-9B1A-0C4029F6AECC} {39EC839A-3C30-4922-A41E-6B09D1DDE5C3} = {3E2008C8-27B1-41DD-9B1A-0C4029F6AECC} + {B29ED6D4-839B-413A-A485-B10F4A4788EA} = {3E2008C8-27B1-41DD-9B1A-0C4029F6AECC} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C1BE4090-A0FD-48AF-86CB-39099D14B286} diff --git a/DDZUGFeRDService/DDZUGFeRDService.vbproj b/DDZUGFeRDService/DDZUGFeRDService.vbproj index 282492bb..a2bc47fb 100644 --- a/DDZUGFeRDService/DDZUGFeRDService.vbproj +++ b/DDZUGFeRDService/DDZUGFeRDService.vbproj @@ -141,6 +141,10 @@ {ab6f09bf-e794-4f6a-94bb-c97c0ba84d64} Interfaces + + {39ec839a-3c30-4922-a41e-6b09d1dde5c3} + Jobs + {903b2d7d-3b80-4be9-8713-7447b704e1b0} Logging diff --git a/Modules.Filesystem/File.vb b/Modules.Filesystem/File.vb index 814a3424..1d73a274 100644 --- a/Modules.Filesystem/File.vb +++ b/Modules.Filesystem/File.vb @@ -64,6 +64,7 @@ Public Class File Dim oVersion As Integer = 1 Try oVersion = Integer.Parse(oSplitFilename.Last()) + oFileNameWithoutExtension = String.Join("", oSplitFilename.Take(oSplitFilename.Count - 1)) Catch ex As Exception ' oFilenameWithoutExtension does NOT change oFileNameWithoutExtension = oFileNameWithoutExtension @@ -72,7 +73,6 @@ Public Class File End Try Else oFileVersion = 1 - oFileNameWithoutExtension = String.Join(String.Empty, oSplitFilename.Take(oSplitFilename.Count - 1)) End If ' while file exists, increment version diff --git a/Modules.Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb b/Modules.Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb index 663920be..20d4f51e 100644 --- a/Modules.Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb +++ b/Modules.Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb @@ -97,9 +97,27 @@ Public Class ImportZUGFeRDFiles Private Function MoveAndRenameEmailToRejected(Args As WorkerArgs, MessageId As String) As EmailData Dim oEmailData = GetEmailDataForMessageId(MessageId) Dim oSource = GetOriginalEmailPath(Args.OriginalEmailDirectory, MessageId) - Dim oDestination = GetEmailPathWithSubjectAsName(Args.RejectedEmailDirectory, oEmailData.Subject) + Dim oDestination As String + + ' If oEmailData is Nothing, TBEDM_EMAIL_PROFILER_HISTORY for MessageId was not found. + ' This only should happen when testing and db-tables are deleted frequently + If oEmailData Is Nothing Then + oDestination = GetEmailPathWithSubjectAsName(Args.RejectedEmailDirectory, MessageId) + Else + oDestination = GetEmailPathWithSubjectAsName(Args.RejectedEmailDirectory, oEmailData.Subject) + End If + + _logger.Debug("Destination for eml file is {0}", oDestination) + Dim oFinalFileName = _filesystem.GetVersionedFilename(oDestination) + _logger.Debug("Versioned filename for eml file is {0}", oFinalFileName) + + If oEmailData Is Nothing Then + _logger.Warn("Could not get Email Data from database. File {0} will not be moved!", oSource) + Return Nothing + End If + Try _logger.Info("Moving email from {0} to {1}", oSource, oFinalFileName) IO.File.Move(oSource, oFinalFileName) @@ -114,6 +132,11 @@ Public Class ImportZUGFeRDFiles End Function Private Sub AddToEmailQueue(MessageId As String, BodyText As String, EmailData As EmailData) + If EmailData Is Nothing Then + _logger.Warn("EmailData is empty. Email will not be sent!") + Exit Sub + End If + Try Dim oJobId = RandomValue(1, 10000) Dim oReference = MessageId diff --git a/Modules/Filesystem.Test/FileTest.vb b/Modules/Filesystem.Test/FileTest.vb new file mode 100644 index 00000000..b2cbbec3 --- /dev/null +++ b/Modules/Filesystem.Test/FileTest.vb @@ -0,0 +1,20 @@ +Imports System.Text +Imports Microsoft.VisualStudio.TestTools.UnitTesting + + Public Class FileTest + + Public Shared Sub Setup(Context As TestContext) + System.IO.File.Create("E:\Test.txt") + End Sub + + Public Sub TestMethod1() + Dim oLogConfig = New DigitalData.Modules.Logging.LogConfig(DigitalData.Modules.Logging.LogConfig.PathType.CurrentDirectory) + Dim oFilesystem As New DigitalData.Modules.Filesystem.File(oLogConfig) + + Dim oPath = "E:\Test~2345676778697678678967867.txt" + Dim oVersionedPath = oFilesystem.GetVersionedFilename(oPath) + + Assert.AreEqual(oVersionedPath, oPath) + End Sub + +End Class \ No newline at end of file diff --git a/Modules/Filesystem.Test/Filesystem.Test.vbproj b/Modules/Filesystem.Test/Filesystem.Test.vbproj new file mode 100644 index 00000000..9faaceba --- /dev/null +++ b/Modules/Filesystem.Test/Filesystem.Test.vbproj @@ -0,0 +1,137 @@ + + + + + Debug + AnyCPU + {B29ED6D4-839B-413A-A485-B10F4A4788EA} + Library + Filesystem.Test + Filesystem.Test + 512 + Windows + v4.6.1 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + true + full + true + true + bin\Debug\ + Filesystem.Test.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + Filesystem.Test.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + + ..\..\packages\MSTest.TestFramework.1.2.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\..\packages\MSTest.TestFramework.1.2.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + + + + + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + + {991d0231-4623-496d-8bd0-9ca906029cbc} + Filesystem + + + {903b2d7d-3b80-4be9-8713-7447b704e1b0} + Logging + + + + + + + Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Verwenden Sie die Wiederherstellung von NuGet-Paketen, um die fehlenden Dateien herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}". + + + + + + \ No newline at end of file diff --git a/Modules/Filesystem.Test/My Project/Application.Designer.vb b/Modules/Filesystem.Test/My Project/Application.Designer.vb new file mode 100644 index 00000000..88dd01c7 --- /dev/null +++ b/Modules/Filesystem.Test/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/Modules/Filesystem.Test/My Project/Application.myapp b/Modules/Filesystem.Test/My Project/Application.myapp new file mode 100644 index 00000000..758895de --- /dev/null +++ b/Modules/Filesystem.Test/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/Modules/Filesystem.Test/My Project/AssemblyInfo.vb b/Modules/Filesystem.Test/My Project/AssemblyInfo.vb new file mode 100644 index 00000000..954e4783 --- /dev/null +++ b/Modules/Filesystem.Test/My Project/AssemblyInfo.vb @@ -0,0 +1,18 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + + + + + + + + + + + + +' + + diff --git a/Modules/Filesystem.Test/My Project/Resources.Designer.vb b/Modules/Filesystem.Test/My Project/Resources.Designer.vb new file mode 100644 index 00000000..81d342eb --- /dev/null +++ b/Modules/Filesystem.Test/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + 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("Filesystem.Test.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Modules/Filesystem.Test/My Project/Resources.resx b/Modules/Filesystem.Test/My Project/Resources.resx new file mode 100644 index 00000000..af7dbebb --- /dev/null +++ b/Modules/Filesystem.Test/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Modules/Filesystem.Test/My Project/Settings.Designer.vb b/Modules/Filesystem.Test/My Project/Settings.Designer.vb new file mode 100644 index 00000000..365aec20 --- /dev/null +++ b/Modules/Filesystem.Test/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + 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 "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal 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 + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.Filesystem.Test.My.MySettings + Get + Return Global.Filesystem.Test.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Modules/Filesystem.Test/My Project/Settings.settings b/Modules/Filesystem.Test/My Project/Settings.settings new file mode 100644 index 00000000..85b890b3 --- /dev/null +++ b/Modules/Filesystem.Test/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Modules/Filesystem.Test/packages.config b/Modules/Filesystem.Test/packages.config new file mode 100644 index 00000000..09089438 --- /dev/null +++ b/Modules/Filesystem.Test/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file