diff --git a/Controls.DocumentViewer/DocumentViewer.vbproj b/Controls.DocumentViewer/DocumentViewer.vbproj index 61ee5a40..bc124fe1 100644 --- a/Controls.DocumentViewer/DocumentViewer.vbproj +++ b/Controls.DocumentViewer/DocumentViewer.vbproj @@ -92,8 +92,8 @@ D:\ProgramFiles\GdPicture.NET 14\Redist\GdPicture.NET (.NET Framework 4.5)\GdPicture.NET.14.dll - - ..\packages\NLog.4.7.10\lib\net45\NLog.dll + + ..\packages\NLog.5.0.5\lib\net46\NLog.dll diff --git a/Controls.DocumentViewer/packages.config b/Controls.DocumentViewer/packages.config index 63f3075e..37cb9210 100644 --- a/Controls.DocumentViewer/packages.config +++ b/Controls.DocumentViewer/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/DDMonorepo.sln b/DDMonorepo.sln index e98fd03a..a0e54c47 100644 --- a/DDMonorepo.sln +++ b/DDMonorepo.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29728.190 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33103.184 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GUIs", "GUIs", "{8FFE925E-8B84-45F1-93CB-32B1C96F41EB}" EndProject diff --git a/GUIs.ClipboardWatcher/ClipboardWatcher.vbproj b/GUIs.ClipboardWatcher/ClipboardWatcher.vbproj index a64fb03f..3e716ad6 100644 --- a/GUIs.ClipboardWatcher/ClipboardWatcher.vbproj +++ b/GUIs.ClipboardWatcher/ClipboardWatcher.vbproj @@ -90,8 +90,8 @@ ..\..\DDModules\ZooFlow\bin\Debug\DigitalData.Modules.ZooFlow.dll - - ..\packages\NLog.4.7.10\lib\net45\NLog.dll + + ..\packages\NLog.5.0.5\lib\net46\NLog.dll diff --git a/GUIs.ClipboardWatcher/My Project/AssemblyInfo.vb b/GUIs.ClipboardWatcher/My Project/AssemblyInfo.vb index 1cfeed82..6cdd1fb8 100644 --- a/GUIs.ClipboardWatcher/My Project/AssemblyInfo.vb +++ b/GUIs.ClipboardWatcher/My Project/AssemblyInfo.vb @@ -12,8 +12,8 @@ Imports System.Runtime.InteropServices - - + + @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - - + + diff --git a/GUIs.ClipboardWatcher/ProfileSearches.vb b/GUIs.ClipboardWatcher/ProfileSearches.vb index 8a700a60..fcd1359c 100644 --- a/GUIs.ClipboardWatcher/ProfileSearches.vb +++ b/GUIs.ClipboardWatcher/ProfileSearches.vb @@ -12,10 +12,10 @@ Imports DigitalData.Modules.ZooFlow.Params Public Class ProfileSearches Inherits BaseClass - Private _Environment As Environment - Private _Client As Client - - Private _ClipboardContents As String + Private ReadOnly _Environment As Environment + Private ReadOnly _Client As Client + Private ReadOnly _ClipboardContents As String + Private ReadOnly _ClientIsOnline As Boolean = False Public Class Search Public Guid As Integer @@ -31,8 +31,10 @@ Public Class ProfileSearches _Environment = pEnvironment _ClipboardContents = pClipboardContents + _ClientIsOnline = _Environment.Service.Client IsNot Nothing AndAlso _Environment.Service.Client.IsOnline = True + Try - If _Environment.Service.Client.IsOnline = True Then + If _ClientIsOnline Then Try Dim oSplit() As String = _Environment.Service.Address.Split(":") Dim oAppServerAddress As String = oSplit(0) @@ -50,6 +52,8 @@ Public Class ProfileSearches Logger.Warn($"Could not initialize the AppServer: {ex.Message}") Logger.Error(ex) End Try + Else + Logger.Debug("No client found in Env.") End If Catch ex As Exception Logger.Error(ex) @@ -82,15 +86,14 @@ Public Class ProfileSearches End Function Public Async Function LoadDocumentSearchesAsync(ProfileId As Integer) As Task(Of List(Of Search)) - Return Await Task.Run(Function() - Return DoLoadDocumentSearches(ProfileId) - End Function) + Return Await Task.Run(Function() DoLoadDocumentSearches(ProfileId)) End Function Private Function DoLoadDocumentSearches(ProfileId As Integer) As List(Of Search) Dim oSQL As String = $"SELECT * FROM TBCW_PROF_DOC_SEARCH WHERE ACTIVE = 1 AND PROFILE_ID = {ProfileId} ORDER BY TAB_INDEX" Dim oSearchesDataTable As DataTable - If _Environment.Service.Client.IsOnline = True Then + + If _ClientIsOnline Then Dim oTableResult As TableResult = _Client.GetDatatableByName("TBCW_PROF_DOC_SEARCH", $"PROFILE_ID = {ProfileId} AND ACTIVE = 1", "TAB_INDEX") oSearchesDataTable = oTableResult.Table If oSearchesDataTable Is Nothing Then @@ -100,6 +103,7 @@ Public Class ProfileSearches Else oSearchesDataTable = _Environment.Database.GetDatatable(oSQL) End If + Dim oDocSearches As New List(Of Search) If Not IsNothing(oSearchesDataTable) Then Dim oCounter As Integer = 0 @@ -146,9 +150,7 @@ Public Class ProfileSearches End Function Public Async Function LoadDataSearchesAsync(ProfileId As Integer) As Task(Of List(Of Search)) - Return Await Task.Run(Function() - Return DoLoadDataSearches(ProfileId) - End Function) + Return Await Task.Run(Function() DoLoadDataSearches(ProfileId)) End Function Private Function DoLoadDataSearches(ProfileId As Integer) As List(Of Search) @@ -157,7 +159,7 @@ Public Class ProfileSearches Try Dim oSQL As String = $"SELECT * FROM TBCW_PROF_DATA_SEARCH WHERE ACTIVE = 1 AND PROFILE_ID = {ProfileId} ORDER BY TAB_INDEX" Dim oSearchesDataTable As DataTable - If _Environment.Service.Client.IsOnline = True Then + If _ClientIsOnline Then Dim oTableResult As TableResult = _Client.GetDatatableByName("TBCW_PROF_DATA_SEARCH", $"PROFILE_ID = {ProfileId} AND ACTIVE = 1", "TAB_INDEX") oSearchesDataTable = oTableResult.Table If oSearchesDataTable Is Nothing Then diff --git a/GUIs.ClipboardWatcher/app.config b/GUIs.ClipboardWatcher/app.config index a35f8999..c942cb81 100644 --- a/GUIs.ClipboardWatcher/app.config +++ b/GUIs.ClipboardWatcher/app.config @@ -51,6 +51,10 @@ + + + + \ No newline at end of file diff --git a/GUIs.ClipboardWatcher/packages.config b/GUIs.ClipboardWatcher/packages.config index 63f3075e..37cb9210 100644 --- a/GUIs.ClipboardWatcher/packages.config +++ b/GUIs.ClipboardWatcher/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/GUIs.Common/Common.vbproj b/GUIs.Common/Common.vbproj index de823af7..2c99722c 100644 --- a/GUIs.Common/Common.vbproj +++ b/GUIs.Common/Common.vbproj @@ -98,8 +98,8 @@ D:\ProgramFiles\GdPicture.NET 14\Redist\GdPicture.NET (.NET Framework 4.5)\GdPicture.NET.14.dll - - ..\packages\NLog.4.7.10\lib\net45\NLog.dll + + ..\packages\NLog.5.0.5\lib\net46\NLog.dll diff --git a/GUIs.Common/DocumentResultList/frmDocumentResultList.vb b/GUIs.Common/DocumentResultList/frmDocumentResultList.vb index cdd2ee02..17bcc508 100644 --- a/GUIs.Common/DocumentResultList/frmDocumentResultList.vb +++ b/GUIs.Common/DocumentResultList/frmDocumentResultList.vb @@ -55,6 +55,8 @@ Public Class frmDocumentResultList Private Property ResultLists As List(Of DocumentResult) Private IsLoading As Boolean = True + Private ClientIsOnline As Boolean = False + Private _DragBoxFromMouseDown As Rectangle Private _ScreenOffset As Point Private _CurrentDocument As DocumentResultList.Document = Nothing @@ -125,17 +127,28 @@ Public Class frmDocumentResultList End Sub Private Function GetOperationMode() As OperationMode - Dim oOperationMode As OperationMode + Dim oOperationMode As OperationMode = OperationMode.NoAppServer - If Environment.Service IsNot Nothing AndAlso Environment.Service.Client.IsOnline AndAlso Environment.Service.Address <> String.Empty Then - oOperationMode = OperationMode.WithAppServer - Else - oOperationMode = OperationMode.NoAppServer - End If + Try + If Environment.Service.Client IsNot Nothing AndAlso Environment.Service.Client.IsOnline Then + oOperationMode = OperationMode.WithAppServer + Else + oOperationMode = OperationMode.NoAppServer + End If - If Params.OperationModeOverride <> OperationMode.None Then - oOperationMode = Params.OperationModeOverride - End If + Logger.Debug("OperationMode set to [{0}]", oOperationMode) + + If Params.OperationModeOverride <> OperationMode.None Then + Logger.Debug("Overriding OperationMode with [{0}]", Params.OperationModeOverride) + oOperationMode = Params.OperationModeOverride + End If + + Logger.Debug("OperationMode is now [{0}]", oOperationMode) + + Catch ex As Exception + Logger.Error(ex) + Logger.Warn("Error while determining OperationMode. Setting to [{0}]", oOperationMode) + End Try Return oOperationMode End Function diff --git a/GUIs.Common/My Project/AssemblyInfo.vb b/GUIs.Common/My Project/AssemblyInfo.vb index faadfd51..98ed3f4e 100644 --- a/GUIs.Common/My Project/AssemblyInfo.vb +++ b/GUIs.Common/My Project/AssemblyInfo.vb @@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices - + @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - - + + diff --git a/GUIs.Common/packages.config b/GUIs.Common/packages.config index 63f3075e..37cb9210 100644 --- a/GUIs.Common/packages.config +++ b/GUIs.Common/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/GUIs.GlobalIndexer/GlobalIndexer.vbproj b/GUIs.GlobalIndexer/GlobalIndexer.vbproj index 60aa8c82..63012606 100644 --- a/GUIs.GlobalIndexer/GlobalIndexer.vbproj +++ b/GUIs.GlobalIndexer/GlobalIndexer.vbproj @@ -62,8 +62,8 @@ ..\..\DDModules\Logging\bin\Debug\DigitalData.Modules.Logging.dll - - ..\packages\NLog.4.7.10\lib\net45\NLog.dll + + ..\packages\NLog.5.0.5\lib\net46\NLog.dll diff --git a/GUIs.GlobalIndexer/packages.config b/GUIs.GlobalIndexer/packages.config index 63f3075e..37cb9210 100644 --- a/GUIs.GlobalIndexer/packages.config +++ b/GUIs.GlobalIndexer/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/GUIs.Test.TestGUI/TestGUI.vbproj b/GUIs.Test.TestGUI/TestGUI.vbproj index bf9f35fc..66208b76 100644 --- a/GUIs.Test.TestGUI/TestGUI.vbproj +++ b/GUIs.Test.TestGUI/TestGUI.vbproj @@ -105,11 +105,11 @@ ..\packages\Microsoft.Extensions.Logging.Abstractions.2.1.1\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll - - ..\packages\NLog.4.7.10\lib\net45\NLog.dll + + ..\packages\NLog.5.0.5\lib\net46\NLog.dll - - ..\packages\Quartz.3.3.2\lib\net472\Quartz.dll + + ..\packages\Quartz.3.5.0\lib\net472\Quartz.dll diff --git a/GUIs.Test.TestGUI/packages.config b/GUIs.Test.TestGUI/packages.config index 22ea4667..bf432ae4 100644 --- a/GUIs.Test.TestGUI/packages.config +++ b/GUIs.Test.TestGUI/packages.config @@ -1,8 +1,8 @@  - - + + diff --git a/Service.EDMIService/App.config b/Service.EDMIService/App.config index 0860ee11..4d0338b6 100644 --- a/Service.EDMIService/App.config +++ b/Service.EDMIService/App.config @@ -33,6 +33,6 @@ - + diff --git a/Service.EDMIService/BaseMethod.vb b/Service.EDMIService/BaseMethod.vb index 7e4d85a2..42a0ad21 100644 --- a/Service.EDMIService/BaseMethod.vb +++ b/Service.EDMIService/BaseMethod.vb @@ -7,14 +7,14 @@ Public MustInherit Class BaseMethod Friend ReadOnly DatabaseIDB As MSSQLServer Friend ReadOnly DatabaseECM As MSSQLServer - Friend ReadOnly Helpers As Helpers + Friend ReadOnly Helpers As IDB.Helpers Friend ReadOnly GlobalState As GlobalState Public Sub New(pLogConfig As LogConfig, pDatabaseIDB As MSSQLServer, pDatabaseECM As MSSQLServer, pGlobalState As GlobalState) MyBase.New(pLogConfig) DatabaseIDB = pDatabaseIDB DatabaseECM = pDatabaseECM - Helpers = New Helpers(pLogConfig, pDatabaseIDB) + Helpers = New IDB.Helpers(pLogConfig, pDatabaseIDB) GlobalState = pGlobalState End Sub End Class diff --git a/Service.EDMIService/EDMIService.vbproj b/Service.EDMIService/EDMIService.vbproj index 933ca6f3..2cd77fc8 100644 --- a/Service.EDMIService/EDMIService.vbproj +++ b/Service.EDMIService/EDMIService.vbproj @@ -11,7 +11,7 @@ EDMIService 512 Console - v4.7.2 + v4.6.2 true false @@ -100,11 +100,11 @@ ..\packages\Microsoft.Extensions.Logging.Abstractions.2.1.1\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll - - ..\packages\NLog.4.7.10\lib\net45\NLog.dll + + ..\packages\NLog.5.0.5\lib\net46\NLog.dll - - ..\packages\Quartz.3.3.2\lib\net472\Quartz.dll + + ..\packages\Quartz.3.5.0\lib\net462\Quartz.dll @@ -235,6 +235,7 @@ True Application.myapp + True True diff --git a/Service.EDMIService/My Project/Resources.Designer.vb b/Service.EDMIService/My Project/Resources.Designer.vb index 3cd07b10..e94ec25a 100644 --- a/Service.EDMIService/My Project/Resources.Designer.vb +++ b/Service.EDMIService/My Project/Resources.Designer.vb @@ -22,7 +22,7 @@ Namespace My.Resources ''' ''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. ''' - _ diff --git a/Service.EDMIService/My Project/Settings.Designer.vb b/Service.EDMIService/My Project/Settings.Designer.vb index 63f0e69c..7596224c 100644 --- a/Service.EDMIService/My Project/Settings.Designer.vb +++ b/Service.EDMIService/My Project/Settings.Designer.vb @@ -15,7 +15,7 @@ Option Explicit On Namespace My _ Partial Friend NotInheritable Class MySettings Inherits Global.System.Configuration.ApplicationSettingsBase diff --git a/Service.EDMIService/packages.config b/Service.EDMIService/packages.config index 8571a474..b27d6005 100644 --- a/Service.EDMIService/packages.config +++ b/Service.EDMIService/packages.config @@ -2,8 +2,8 @@ - - + + diff --git a/Service.JobRunner/App.config b/Service.JobRunner/App.config index ed5b24ea..15f5c465 100644 --- a/Service.JobRunner/App.config +++ b/Service.JobRunner/App.config @@ -1,50 +1,13 @@ - + - -
- - - - - - - - - - - - - - - - - - - - - - - False - - - False|0 0 0/1 * * ?|RootPath::LDAP://DIGITALDATA,UserFilter::(&(samaccountname=@SAMACCOUNTNAME)),GroupFilter::(&(samaccountname=*)) - - - False|10/0 * * * * ?|Foo::Bar - - - False|0 0 0/1 * * ?|QueryConfigFolder::E:\JenneJ\GraphQL - - - - - + + - \ No newline at end of file + diff --git a/Service.JobRunner/Config.vb b/Service.JobRunner/Config.vb new file mode 100644 index 00000000..c1836561 --- /dev/null +++ b/Service.JobRunner/Config.vb @@ -0,0 +1,25 @@ +Imports DigitalData.Modules.Jobs + +Public Class Config + Public Property Debug As Boolean = False + + Public Property SQLConnectionString As String = "" + + Public Property Firebird As New FirebirdConfig + Public Property Jobs As New List(Of JobConfig) + + 'Public Enum JobType + ' ADSync + ' GraphQL + ' Test + 'End Enum + + + + Public Class FirebirdConfig + Public Property DataSource As String = "172.24.12.41" + Public Property Database As String = "172.24.12.41:E:\DB\Firebird\Databases\EDMI_TEMPLATE\EDMI_MASTER.FDB" + Public Property User As String = "sysdba" + Public Property Password As String = "dd" + End Class +End Class diff --git a/Service.JobRunner/JobRunner.vb b/Service.JobRunner/JobRunner.vb index 93ed80c0..72cfd780 100644 --- a/Service.JobRunner/JobRunner.vb +++ b/Service.JobRunner/JobRunner.vb @@ -1,44 +1,29 @@ Imports System.Collections.Specialized +Imports DigitalData.Modules.Config Imports DigitalData.Modules.Database Imports DigitalData.Modules.Jobs Imports DigitalData.Modules.Logging +Imports DigitalData.Services.JobRunner.Config Imports Quartz Imports Quartz.Impl Imports Quartz.Logging Public Class JobRunner - Private _LogConfig As LogConfig - Private _Logger As DigitalData.Modules.Logging.Logger - Private _firebird As Firebird - Private _mssql As MSSQLServer + Private ReadOnly _LogConfig As LogConfig + Private ReadOnly _Logger As DigitalData.Modules.Logging.Logger + Private ReadOnly _firebird As Firebird + Private ReadOnly _mssql As MSSQLServer + Private ReadOnly _config As Config - Private _Props As New NameValueCollection From { - {"quartz.serializer.type", "binary"}, - {"quartz.threadPool.threadCount", 10} - } Private _factory As StdSchedulerFactory Private _scheduler As IScheduler - Public Sub New(LogConfig As LogConfig, MSSQL As MSSQLServer, Firebird As Firebird) - _LogConfig = LogConfig - _Logger = LogConfig.GetLogger() - _firebird = Firebird - _mssql = MSSQL - Try - Dim directory As New IO.DirectoryInfo(_LogConfig.LogDirectory) - - For Each file As IO.FileInfo In directory.GetFiles - If (Now - file.CreationTime).Days > 29 Then - file.Delete() - Else - Exit For - End If - - - Next - Catch ex As Exception - - End Try + Public Sub New(pLogConfig As LogConfig, pConfig As Config, pMSSQL As MSSQLServer, pFirebird As Firebird) + _LogConfig = pLogConfig + _Logger = pLogConfig.GetLogger() + _firebird = pFirebird + _mssql = pMSSQL + _config = pConfig End Sub Public Async Sub Start() @@ -48,7 +33,8 @@ Public Class JobRunner _Logger.Info("Starting JobRunner") Dim oProps As New NameValueCollection From { - {"quartz.serializer.type", "binary"} + {"quartz.serializer.type", "binary"}, + {"quartz.threadPool.threadCount", 10} } _factory = New StdSchedulerFactory(oProps) _scheduler = Await _factory.GetScheduler() @@ -57,26 +43,30 @@ Public Class JobRunner Await _scheduler.Start() ' [START] Job Scheduling - Await ScheduleJob(Of ADJob)("ADSync", My.Settings.ADSYNC_CONFIG) - Await ScheduleJob(Of TestJob)("TestJob", My.Settings.TEST_CONFIG) - Await ScheduleJob(Of GraphQLJob)("GraphQLJob", My.Settings.GRAPHQL_CONFIG) + Await ScheduleJob(Of ADJob)("ADSync", GetJobConfig(JobConfig.JobType.ADSync)) + Await ScheduleJob(Of TestJob)("TestJob", GetJobConfig(JobConfig.JobType.Test)) + Await ScheduleJob(Of GraphQLJob)("GraphQLJob", GetJobConfig(JobConfig.JobType.GraphQL)) ' [END] Job Scheduling Catch ex As Exception - _Logger.Warn("Job Failed.") + _Logger.Warn("Job Failed with message: [{0}].", ex.Message) _Logger.Error(ex) End Try End Sub - Public Async Function ScheduleJob(Of T As Quartz.IJob)(JobName As String, JobConfigString As String) As Task + Public Function GetJobConfig(pName As JobConfig.JobType) As JobConfig + Return _config.Jobs.Where(Function(j) j.Name = pName).SingleOrDefault() + End Function + + Public Async Function ScheduleJob(Of T As Quartz.IJob)(JobName As String, pJobConfig As JobConfig) As Task Dim oJobIdentity As String = JobName Dim oTriggerIdentity As String = JobName & "-Trigger" - Dim oJobConfig As JobConfig = JobConfigParser.ParseConfig(JobConfigString) + Dim oJobConfig As JobConfig = JobConfigParser.ParseConfig(pJobConfig) Dim oJobData As New JobDataMap From { {"LogConfig", _LogConfig}, {"Firebird", _firebird}, {"MSSQL", _mssql}, - {"Args", oJobConfig.Arguments} + {"Args", oJobConfig.Args} } Dim oJob = JobBuilder.Create(Of T)(). @@ -87,7 +77,7 @@ Public Class JobRunner Dim oTrigger = TriggerBuilder.Create(). WithIdentity(oTriggerIdentity). StartNow(). - WithCronSchedule(oJobConfig.CronExpression). + WithCronSchedule(oJobConfig.CronSchedule). Build() If oJobConfig.Enabled Then @@ -98,8 +88,8 @@ Public Class JobRunner _Logger.Info("Job {0} is disabled.", JobName) End If - ' If StartImmediately is True, start Job after 10 Seconds - If oJobConfig.StartImmediately Then + ' If StartWithoutDelay is True, start Job after 10 Seconds + If oJobConfig.StartWithoutDelay Then Dim oDebugJob = JobBuilder.Create(Of T)(). WithIdentity(oJobIdentity & "-DEBUG"). UsingJobData(oJobData). @@ -130,8 +120,6 @@ Public Class JobRunner _Logger = Logger End Sub - - Private Function GetLogger(name As String) As Logging.Logger Implements ILogProvider.GetLogger Return Function(level, func, exception, parameters) If exception IsNot Nothing Then diff --git a/Service.JobRunner/JobRunner.vbproj b/Service.JobRunner/JobRunner.vbproj index 38256adb..faa52385 100644 --- a/Service.JobRunner/JobRunner.vbproj +++ b/Service.JobRunner/JobRunner.vbproj @@ -11,8 +11,9 @@ DigitalData.Services.JobRunner 512 Console - v4.6.1 + v4.6.2 true + AnyCPU @@ -50,6 +51,10 @@ My Project\app.manifest + + False + ..\..\DDModules\Config\bin\Debug\DigitalData.Modules.Config.dll + False ..\..\DDModules\Database\bin\Debug\DigitalData.Modules.Database.dll @@ -66,11 +71,11 @@ ..\packages\Microsoft.Extensions.Logging.Abstractions.2.1.1\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll - - ..\packages\NLog.4.7.10\lib\net45\NLog.dll + + ..\packages\NLog.5.0.5\lib\net46\NLog.dll - - ..\packages\Quartz.3.3.2\lib\net461\Quartz.dll + + ..\packages\Quartz.3.5.0\lib\net462\Quartz.dll @@ -101,6 +106,7 @@ + @@ -108,6 +114,7 @@ True Application.myapp + True Component diff --git a/Service.JobRunner/JobRunnerService.vb b/Service.JobRunner/JobRunnerService.vb index 24106e2a..a4d770b8 100644 --- a/Service.JobRunner/JobRunnerService.vb +++ b/Service.JobRunner/JobRunnerService.vb @@ -1,31 +1,37 @@ -Imports DigitalData.Modules.Logging +Imports System.IO +Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging.LogConfig Imports DigitalData.Modules.Database -Imports DigitalData.Services.JobRunner +Imports DigitalData.Modules.Config Public Class JobRunnerService Private _logConfig As LogConfig Private _logger As Logger + Private _config As ConfigManager(Of Config) Private _mssql As MSSQLServer Private _firebird As Firebird Private _jobrunner As JobRunner Protected Overrides Sub OnStart(ByVal args() As String) - _logConfig = New LogConfig(PathType.CustomPath, My.Settings.LOG_PATH) With { - .Debug = My.Settings.LOG_DEBUG - } + _logConfig = New LogConfig(PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log")) With {.Debug = True} _logger = _logConfig.GetLogger() - _logger.Info("Starting Service {0}", ServiceName) Try - _mssql = New MSSQLServer(_logConfig, My.Settings.SQL_CONNECTIONSTRING) - _firebird = New Firebird(_logConfig, My.Settings.FIREBIRD_SERVER, My.Settings.FIREBIRD_DATABASE, My.Settings.FIREBIRD_USER, My.Settings.FIREBIRD_PASSWORD) - Catch ex As Exception - _logger.Error(ex) - End Try - Try - _jobrunner = New JobRunner(_logConfig, _mssql, _firebird) + _logger.Info("Starting Service {0}", ServiceName) + _config = New ConfigManager(Of Config)(_logConfig, My.Application.Info.DirectoryPath) + _logConfig.Debug = _config.Config.Debug + + Dim oFirebird = _config.Config.Firebird + + _logger.Debug("Connecting to Database..") + + _mssql = New MSSQLServer(_logConfig, _config.Config.SQLConnectionString) + _firebird = New Firebird(_logConfig, oFirebird.DataSource, oFirebird.Database, oFirebird.User, oFirebird.Password) + + _logger.Debug("Starting Jobrunner..") + + _jobrunner = New JobRunner(_logConfig, _config.Config, _mssql, _firebird) _jobrunner.Start() Catch ex As Exception _logger.Error(ex) diff --git a/Service.JobRunner/My Project/AssemblyInfo.vb b/Service.JobRunner/My Project/AssemblyInfo.vb index 6981d788..6f4dd46c 100644 --- a/Service.JobRunner/My Project/AssemblyInfo.vb +++ b/Service.JobRunner/My Project/AssemblyInfo.vb @@ -12,8 +12,8 @@ Imports System.Runtime.InteropServices - - + + @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - + diff --git a/Service.JobRunner/My Project/Resources.Designer.vb b/Service.JobRunner/My Project/Resources.Designer.vb index 7fb8b450..c7bdd0c1 100644 --- a/Service.JobRunner/My Project/Resources.Designer.vb +++ b/Service.JobRunner/My Project/Resources.Designer.vb @@ -22,7 +22,7 @@ Namespace My.Resources ''' ''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. ''' - _ diff --git a/Service.JobRunner/My Project/Settings.Designer.vb b/Service.JobRunner/My Project/Settings.Designer.vb index 592b0e32..0821b68c 100644 --- a/Service.JobRunner/My Project/Settings.Designer.vb +++ b/Service.JobRunner/My Project/Settings.Designer.vb @@ -15,7 +15,7 @@ Option Explicit On Namespace My _ Partial Friend NotInheritable Class MySettings Inherits Global.System.Configuration.ApplicationSettingsBase @@ -53,97 +53,6 @@ Namespace My Return defaultInstance End Get End Property - - _ - Public ReadOnly Property LOG_PATH() As String - Get - Return CType(Me("LOG_PATH"),String) - End Get - End Property - - _ - Public ReadOnly Property SQL_CONNECTIONSTRING() As String - Get - Return CType(Me("SQL_CONNECTIONSTRING"),String) - End Get - End Property - - _ - Public ReadOnly Property FIREBIRD_SERVER() As String - Get - Return CType(Me("FIREBIRD_SERVER"),String) - End Get - End Property - - _ - Public ReadOnly Property FIREBIRD_DATABASE() As String - Get - Return CType(Me("FIREBIRD_DATABASE"),String) - End Get - End Property - - _ - Public ReadOnly Property FIREBIRD_USER() As String - Get - Return CType(Me("FIREBIRD_USER"),String) - End Get - End Property - - _ - Public ReadOnly Property FIREBIRD_PASSWORD() As String - Get - Return CType(Me("FIREBIRD_PASSWORD"),String) - End Get - End Property - - _ - Public ReadOnly Property LOG_DEBUG() As Boolean - Get - Return CType(Me("LOG_DEBUG"),Boolean) - End Get - End Property - - _ - Public ReadOnly Property TEST_CONFIG() As String - Get - Return CType(Me("TEST_CONFIG"),String) - End Get - End Property - - _ - Public ReadOnly Property GRAPHQL_CONFIG() As String - Get - Return CType(Me("GRAPHQL_CONFIG"),String) - End Get - End Property - - _ - Public ReadOnly Property ADSYNC_CONFIG() As String - Get - Return CType(Me("ADSYNC_CONFIG"),String) - End Get - End Property End Class End Namespace diff --git a/Service.JobRunner/My Project/Settings.settings b/Service.JobRunner/My Project/Settings.settings index 98b0505b..f7f176ac 100644 --- a/Service.JobRunner/My Project/Settings.settings +++ b/Service.JobRunner/My Project/Settings.settings @@ -1,36 +1,5 @@  - + - - - - - - - - - - - - - - - - - - - - - False - - - False|0 0 0/1 * * ?|RootPath::LDAP://DIGITALDATA,UserFilter::(&(samaccountname=@SAMACCOUNTNAME)),GroupFilter(&(samaccountname=*)) - - - True|10/0 * * * * ?|Foo::Bar - - - False|0 0 0/1 * * ?|QueryConfigFolder::E:\JenneJ\GraphQL - - + \ No newline at end of file diff --git a/Service.JobRunner/packages.config b/Service.JobRunner/packages.config index 365826dc..924bd0ab 100644 --- a/Service.JobRunner/packages.config +++ b/Service.JobRunner/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/Services.EmailService/DDEmailService.vbproj b/Services.EmailService/DDEmailService.vbproj index b81143e8..f584eba2 100644 --- a/Services.EmailService/DDEmailService.vbproj +++ b/Services.EmailService/DDEmailService.vbproj @@ -81,8 +81,8 @@ ..\packages\FirebirdSql.Data.FirebirdClient.7.5.0\lib\net452\FirebirdSql.Data.FirebirdClient.dll - - ..\packages\NLog.4.7.10\lib\net45\NLog.dll + + ..\packages\NLog.5.0.5\lib\net46\NLog.dll diff --git a/Services.EmailService/EmailService.vb b/Services.EmailService/EmailService.vb index 45b40d43..017c6727 100644 --- a/Services.EmailService/EmailService.vb +++ b/Services.EmailService/EmailService.vb @@ -308,10 +308,10 @@ Public Class EmailService Select Case Database Case DatabaseType.Firebird - oSQL = "SELECT * FROM TBEDM_EMAIL_QUEUE WHERE EMAIL_SENT IS NULL and EMAIL_TO <> '' ORDER BY EMAIL_ACCOUNT_ID, CREATEDWHEN DESC" + oSQL = "SELECT * FROM TBEDM_EMAIL_QUEUE WHERE EMAIL_SENT IS NULL and EMAIL_TO <> ''" oEmailQueue = _Firebird.GetDatatable(oSQL) Case DatabaseType.MSSQL - oSQL = "SELECT * FROM TBEMLP_EMAIL_OUT WHERE EMAIL_SENT IS NULL and EMAIL_ADRESS <> '' ORDER BY SENDING_PROFILE, ADDED_WHEN DESC" + oSQL = "SELECT * FROM TBEMLP_EMAIL_OUT WHERE EMAIL_SENT IS NULL and EMAIL_ADRESS <> ''" oEmailQueue = MSSQLInstance.GetDatatable(oSQL) End Select @@ -337,9 +337,9 @@ Public Class EmailService Select Case Database Case DatabaseType.Firebird - oAccountQueue = oEmailQueue.Select($"EMAIL_ACCOUNT_ID = {oAccount.Guid}") + oAccountQueue = oEmailQueue.Select($"EMAIL_ACCOUNT_ID = {oAccount.Guid}", "GUID ASC") Case Else - oAccountQueue = oEmailQueue.Select($"SENDING_PROFILE = {oAccount.Guid}") + oAccountQueue = oEmailQueue.Select($"SENDING_PROFILE = {oAccount.Guid}", "GUID ASC") End Select ' No mails for this profile diff --git a/Services.EmailService/My Project/AssemblyInfo.vb b/Services.EmailService/My Project/AssemblyInfo.vb index 89d7f171..480c0e1a 100644 --- a/Services.EmailService/My Project/AssemblyInfo.vb +++ b/Services.EmailService/My Project/AssemblyInfo.vb @@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices - + @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - - + + diff --git a/Services.EmailService/packages.config b/Services.EmailService/packages.config index f5252b7d..52c707c3 100644 --- a/Services.EmailService/packages.config +++ b/Services.EmailService/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/Services.LicenseService/DDEDMLicenseService.vbproj b/Services.LicenseService/DDEDMLicenseService.vbproj index e39e4787..cc26af94 100644 --- a/Services.LicenseService/DDEDMLicenseService.vbproj +++ b/Services.LicenseService/DDEDMLicenseService.vbproj @@ -56,8 +56,8 @@ ..\..\DDModules\Logging\bin\Debug\DigitalData.Modules.Logging.dll - - ..\packages\NLog.4.7.10\lib\net45\NLog.dll + + ..\packages\NLog.5.0.5\lib\net46\NLog.dll diff --git a/Services.LicenseService/packages.config b/Services.LicenseService/packages.config index 63f3075e..37cb9210 100644 --- a/Services.LicenseService/packages.config +++ b/Services.LicenseService/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/Services.ZUGFeRDService/Config.vb b/Services.ZUGFeRDService/Config.vb index 1281e170..26f2b27e 100644 --- a/Services.ZUGFeRDService/Config.vb +++ b/Services.ZUGFeRDService/Config.vb @@ -34,6 +34,10 @@ Public Property RejectionTransferEnabled As Boolean = True Public Property RejectionTransferTimeUnit As String = "HOUR" Public Property RejectionTransferTimeValue As Integer = 12 + + Public Property AllowFacturX As Boolean = True + Public Property AllowXRechnung As Boolean = True + End Class Public Class FirebirdConfig diff --git a/Services.ZUGFeRDService/DDZUGFeRDService.vbproj b/Services.ZUGFeRDService/DDZUGFeRDService.vbproj index 06f4b385..30c5138a 100644 --- a/Services.ZUGFeRDService/DDZUGFeRDService.vbproj +++ b/Services.ZUGFeRDService/DDZUGFeRDService.vbproj @@ -71,8 +71,8 @@ ..\packages\FirebirdSql.Data.FirebirdClient.7.5.0\lib\net452\FirebirdSql.Data.FirebirdClient.dll - - ..\packages\NLog.4.7.10\lib\net45\NLog.dll + + ..\packages\NLog.5.0.5\lib\net46\NLog.dll diff --git a/Services.ZUGFeRDService/My Project/AssemblyInfo.vb b/Services.ZUGFeRDService/My Project/AssemblyInfo.vb index 78d35980..708a09eb 100644 --- a/Services.ZUGFeRDService/My Project/AssemblyInfo.vb +++ b/Services.ZUGFeRDService/My Project/AssemblyInfo.vb @@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices - + @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - - + + diff --git a/Services.ZUGFeRDService/ThreadRunner.vb b/Services.ZUGFeRDService/ThreadRunner.vb index 1a2a7e44..8897e943 100644 --- a/Services.ZUGFeRDService/ThreadRunner.vb +++ b/Services.ZUGFeRDService/ThreadRunner.vb @@ -50,8 +50,12 @@ Public Class ThreadRunner .ExceptionEmailAddress = _config.Config.ExceptionEmailAddress, .IgnoreRejectionStatus = _config.Config.Custom.IgnoreRejectionStatus, .MaxAttachmentSizeInMegaBytes = _config.Config.Custom.MaxAttachmentSizeInMegaBytes, - .NamePortal = _config.Config.PORTAL_NAME + .NamePortal = _config.Config.PORTAL_NAME, + .EmailOutProfileId = _config.Config.MSSQLEmailOutAccountID, + .AllowFacturX = _config.Config.Custom.AllowFacturX, + .AllowXRechnung = _config.Config.Custom.AllowXRechnung } + oArgs = LoadFolderConfig(oArgs) oArgs = LoadPropertyMapFor(oArgs, "DEFAULT") @@ -191,7 +195,7 @@ Public Class ThreadRunner Dim oArgs As WorkerArgs = e.Argument _logger.Debug("Background worker running..") - Dim oJob As New ImportZUGFeRDFiles(_logConfig, _firebird, _config.Config.MSSQLEmailOutAccountID, _config.Config.PORTAL_NAME, _mssql) + Dim oJob As New ImportZUGFeRDFiles(_logConfig, _firebird, _mssql) oJob.Start(oArgs) Catch ex As Exception _logger.Warn("Background worker failed!") diff --git a/Services.ZUGFeRDService/ZUGFeRDService.vb b/Services.ZUGFeRDService/ZUGFeRDService.vb index 2f946317..96fba05b 100644 --- a/Services.ZUGFeRDService/ZUGFeRDService.vb +++ b/Services.ZUGFeRDService/ZUGFeRDService.vb @@ -18,19 +18,6 @@ Public Class ZUGFeRDService _config = New ConfigManager(Of Config)(_logConfig, My.Application.Info.DirectoryPath) _logConfig.Debug = _config.Config.Debug _logger = _logConfig.GetLogger() - Try - Dim directory As New IO.DirectoryInfo(_logConfig.LogDirectory) - - For Each file As IO.FileInfo In directory.GetFiles - If (Now - file.CreationTime).Days > 29 Then - file.Delete() - Else - Exit For - End If - Next - Catch ex As Exception - - End Try _logger.Info($"{Constants.SERVICE_NAME} is starting.") Dim oDataSource As String = _config.Config.Firebird.DataSource diff --git a/Services.ZUGFeRDService/packages.config b/Services.ZUGFeRDService/packages.config index f5252b7d..52c707c3 100644 --- a/Services.ZUGFeRDService/packages.config +++ b/Services.ZUGFeRDService/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/WEBSERVICES/ZUGFeRDRESTService/Config.cs b/WEBSERVICES/ZUGFeRDRESTService/Config.cs index 599cc0d6..f9734783 100644 --- a/WEBSERVICES/ZUGFeRDRESTService/Config.cs +++ b/WEBSERVICES/ZUGFeRDRESTService/Config.cs @@ -1,15 +1,20 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace ZUGFeRDRESTService +namespace ZUGFeRDRESTService { public class Config { public string Name { get; set; } public string LogPath { get; set; } - public string MSSQLConnectionString { get; set; } + + public FirebirdConfig Firebird { get; set; } } + + public class FirebirdConfig + { + public string Datasource { get; set; } + public string Database { get; set; } + public string Username { get; set; } + public string Password { get; set; } + } + } diff --git a/WEBSERVICES/ZUGFeRDRESTService/Controllers/ValidationController.cs b/WEBSERVICES/ZUGFeRDRESTService/Controllers/ValidationController.cs index 3c7e7446..77299759 100644 --- a/WEBSERVICES/ZUGFeRDRESTService/Controllers/ValidationController.cs +++ b/WEBSERVICES/ZUGFeRDRESTService/Controllers/ValidationController.cs @@ -1,24 +1,26 @@ using System; using System.IO; using System.Linq; -using System.Threading.Tasks; using System.Collections.Generic; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Options; using DigitalData.Modules.Interfaces; -using DigitalData.Modules.Logging; using static DigitalData.Modules.Interfaces.Exceptions; using static DigitalData.Modules.Interfaces.ZUGFeRDInterface; +using static DigitalData.Modules.Interfaces.PropertyValues; +using System.Data.SqlClient; namespace ZUGFeRDRESTService.Controllers -{ +{ [Route("api/[controller]")] [ApiController] public class ValidationController : ControllerBase { - public static string RESPONSE_OK = "OK"; - public static string RESPONSE_ERROR = "ERROR"; + public const string RESPONSE_OK = "OK"; + public const string RESPONSE_ERROR = "ERROR"; + + public const string ADDED_WHO = "ZUGFeRD REST Service"; + public const string MESSAGEID_DOMAIN = "test.wisag.de"; private readonly ZUGFeRDInterface _zugferd; private readonly IDatabase _database; @@ -29,34 +31,6 @@ namespace ZUGFeRDRESTService.Controllers private readonly PropertyValues _props; private readonly Dictionary _propertyMap; - public class ValidationResponse - { - public string status; - public string message; - public List errors; - - public ValidationResponse() - { - status = RESPONSE_OK; - message = string.Empty; - errors = new List(); - } - - public ValidationResponse(string Status, string Message) - { - status = Status; - message = Message; - errors = new List(); - } - - public ValidationResponse(string Status, string Message, List Errors) - { - status = Status; - message = Message; - errors = Errors; - } - } - public ValidationController(ILogging logging, IDatabase database) { _logConfig = logging.LogConfig; @@ -79,57 +53,81 @@ namespace ZUGFeRDRESTService.Controllers /// /// POST: /api/validation /// - /// This parameter's name needs to correspond to the html form's file-input name + /// This parameter's name needs to correspond to the html form's file-input name + /// This is the email address which the user supplied [HttpPost] - public async Task Post(IFormFile file, string user_id) + public ValidationResponse Post(IFormFile file, string user_id) { - _logger.Debug("Start processing request to ValidationController"); + _logger.Info("Start processing request to ValidationController"); object oDocument; PropertyValues.CheckPropertyValuesResult oResult = new PropertyValues.CheckPropertyValuesResult(); try - { + { using Stream oStream = file.OpenReadStream(); { - _logger.Debug("Extracting ZUGFeRD Data from file [{0}]", file.FileName); + _logger.Info("Extracting ZUGFeRD Data from file [{0}]", file.FileName); oDocument = _zugferd.ExtractZUGFeRDFileWithGDPicture(oStream); - _logger.Debug("Checking ZUGFeRD Data against the database"); + _logger.Info("Starting structural check against the database."); oResult = _props.CheckPropertyValues(oDocument, _propertyMap, "MESSAGEID"); var oRequiredProperties = _propertyMap. - Where(prop => {return prop.Value.IsRequired == true;}). + Where(prop => { return prop.Value.IsRequired == true; }). Select(prop => { return prop.Value.Description; }) .ToList(); _logger.Debug("Found [{0}] required properties", oRequiredProperties.Count); - _logger.Debug(String.Join(",", oRequiredProperties.ToArray())); + _logger.Debug(string.Join(",", oRequiredProperties.ToArray())); - _logger.Debug("Result of checking against the database: {0} valid properties, {1} missing properties", + _logger.Info("Result of checking against the database: {0} valid properties, {1} missing properties", oResult.ValidProperties.Count, oResult.MissingProperties.Count); if (oResult.MissingProperties.Count > 0) { - throw new ZUGFeRDExecption(ZUGFeRDInterface.ErrorType.MissingProperties, + throw new ZUGFeRDExecption(ErrorType.MissingProperties, "Die hochgeladene Datei ist eine gültige ZUGFeRD-Rechnung, allerdings fehlen benötigte Daten."); } - string oMessage = "Die hochgeladene Datei ist eine gültige-ZUGFeRD Rechnung"; + Tuple oValidateResult = ValidateBuyerOrderReference(oResult.ValidProperties); - _logger.Debug($"Replying with: [{oMessage}]"); - - return new ValidationResponse() + if (oValidateResult.Item1 == false) { - status = RESPONSE_OK, - message = oMessage - }; + throw new ZUGFeRDExecption(ErrorType.UnknownError, "Die hochgeladene Datei kann nicht validiert werden, weil ein unbekannter Fehler aufgetreten ist."); + } + + string oValidateResultString = oValidateResult.Item2; + + if (oValidateResultString == "ALL REFERENCES CHECKED POSITIVE") + { + string oMessage = "Die hochgeladene Datei ist eine gültige-ZUGFeRD Rechnung"; + + _logger.Info($"Responding with message: [{oMessage}]"); + + return new ValidationResponse() + { + status = RESPONSE_OK, + message = oMessage + }; + } else + { + string oMessage = oValidateResultString; + + _logger.Info($"Responding with message: [{oMessage}]"); + + return new ValidationResponse() + { + status = RESPONSE_ERROR, + message = oMessage + }; + } }; } catch (ZUGFeRDExecption ex) - { + { _logger.Error(ex); // Determine which message should be sent in the response @@ -150,7 +148,7 @@ namespace ZUGFeRDRESTService.Controllers _ => new List() }; - _logger.Debug($"Replying with: [{oMessage}]"); + _logger.Info($"Responding with message: [{oMessage}]"); return new ValidationResponse() { @@ -165,14 +163,96 @@ namespace ZUGFeRDRESTService.Controllers string oMessage = "Die hochgeladene Datei kann nicht validiert werden, weil ein unbekannter Fehler aufgetreten ist."; - _logger.Debug($"Replying with: [{oMessage}]"); + _logger.Info($"Responding with message: [{oMessage}]"); return new ValidationResponse() { status = RESPONSE_ERROR, message = oMessage }; - } + } } + + private Tuple ValidateBuyerOrderReference(List pProperties) + { + var oMessageId = GetMessageId(); + _logger.Debug("Created new MessageId: [{0}]", oMessageId); + + _logger.Debug("Inserting properties into database."); + foreach (var oItem in pProperties) + { + var oResult = InsertPropertyMap(oItem, oMessageId); + + if (oResult == false) + { + _logger.Warn("Error while inserting the Property [{0}] into the Database!", oItem.Description); + } + } + + _logger.Debug("Calling validation prodecure."); + try + { + using SqlCommand oCommand = new SqlCommand("PRCUST_INV_CHECK_FROM_PORTAL"); + oCommand.CommandType = System.Data.CommandType.StoredProcedure; + + oCommand.Parameters.Clear(); + oCommand.Parameters.Add("@REF_GUID", System.Data.SqlDbType.VarChar, 250).Value = oMessageId; + oCommand.Parameters.Add("@MSG_OUTPUT", System.Data.SqlDbType.VarChar, 500).Direction = System.Data.ParameterDirection.Output; + + if (_database.MSSQL.ExecuteNonQuery(oCommand)) + { + string oReturnValue = (string)oCommand.Parameters["@MSG_OUTPUT"].Value; + return new Tuple(true, oReturnValue); + + } + else + { + return new Tuple(false, string.Empty); + + } + } + catch (Exception e) + { + _logger.Error(e); + return new Tuple(false, string.Empty); + } + } + + public string GetMessageId() + { + return $"{Guid.NewGuid()}@{MESSAGEID_DOMAIN}"; + } + + public bool InsertPropertyMap(ValidProperty pProperty, string pMessageId) + { + try + { + var oSql = $"INSERT INTO {pProperty.TableName} " + + "(REFERENCE_GUID, ITEM_DESCRIPTION, ITEM_VALUE, CREATEDWHO, SPEC_NAME, GROUP_COUNTER, IS_REQUIRED) VALUES " + + "(@REFERENCE_GUID, @ITEM_DESCRIPTION, @ITEM_VALUE, @CREATEDWHO, @SPEC_NAME, @GROUP_COUNTER, @IS_REQUIRED)"; + + var oParams = new SqlParameter[] + { + new SqlParameter("@REFERENCE_GUID", pMessageId), + new SqlParameter("@ITEM_DESCRIPTION", pProperty.Description), + new SqlParameter("@ITEM_VALUE", pProperty.Value), + new SqlParameter("@CREATEDWHO", ADDED_WHO), + new SqlParameter("@GROUP_COUNTER", pProperty.GroupCounter), + new SqlParameter("@SPEC_NAME", pProperty.TableColumn), + new SqlParameter("@IS_REQUIRED", pProperty.ISRequired) + }; + + var oCommand = new SqlCommand(oSql); + oCommand.Parameters.AddRange(oParams); + + return _database.MSSQL.ExecuteNonQuery(oCommand); + } + catch (Exception ex) + { + _logger.Error(ex); + return false; + } + } + } } diff --git a/WEBSERVICES/ZUGFeRDRESTService/Controllers/ValidationResponse.cs b/WEBSERVICES/ZUGFeRDRESTService/Controllers/ValidationResponse.cs new file mode 100644 index 00000000..5acbe493 --- /dev/null +++ b/WEBSERVICES/ZUGFeRDRESTService/Controllers/ValidationResponse.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; + +namespace ZUGFeRDRESTService.Controllers +{ + + public class ValidationResponse + { + public string status; + public string message; + public List errors; + + public ValidationResponse() + { + status = ValidationController.RESPONSE_OK; + message = string.Empty; + errors = new List(); + } + + public ValidationResponse(string Status, string Message) + { + status = Status; + message = Message; + errors = new List(); + } + + public ValidationResponse(string Status, string Message, List Errors) + { + status = Status; + message = Message; + errors = Errors; + } + } +} diff --git a/WEBSERVICES/ZUGFeRDRESTService/Database.cs b/WEBSERVICES/ZUGFeRDRESTService/Database.cs index 4278058b..31f56346 100644 --- a/WEBSERVICES/ZUGFeRDRESTService/Database.cs +++ b/WEBSERVICES/ZUGFeRDRESTService/Database.cs @@ -1,18 +1,21 @@ using System; using System.Collections.Generic; using System.Data; +using System.Data.SqlClient; using System.Linq; using System.Threading.Tasks; using DigitalData.Modules.Database; using DigitalData.Modules.Interfaces; +using Microsoft.AspNetCore.Mvc.Formatters; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Options; namespace ZUGFeRDRESTService { public class Database: IDatabase { private string _gdPictureKey = null; - private Dictionary _propertyMap = null; + private Dictionary _propertyMap = null; private const string QUERY_GET_GDPICTURE_KEY = "SELECT LICENSE FROM TBDD_3RD_PARTY_MODULES WHERE NAME = 'GDPICTURE'"; private const string QUERY_GET_PROPERTY_MAP = "SELECT * FROM TBEDM_XML_ITEMS WHERE SPECIFICATION = '{0}' AND ACTIVE = True ORDER BY XML_PATH"; @@ -22,16 +25,23 @@ namespace ZUGFeRDRESTService public Database(ILogging Logging, IConfiguration Config) { - var LogConfig = Logging.LogConfig; - var Logger = Logging.LogConfig.GetLogger(); - var AppConfig = Config.GetSection("Config"); - var FBConfig = AppConfig.GetSection("Firebird"); + var oLogConfig = Logging.LogConfig; + var oLogger = Logging.LogConfig.GetLogger(); + var oAppConfig = Config.GetSection("Config"); + var oFirebirdConfig = oAppConfig.GetSection("Firebird"); - MSSQL = new MSSQLServer(LogConfig, AppConfig["MSSQLConnectionString"]); - Firebird = new Firebird(LogConfig, FBConfig["Datasource"], FBConfig["Database"], FBConfig["Username"], FBConfig["Password"]); + oLogger.Debug("Establishing MSSQL Database connection.."); + MSSQL = new MSSQLServer(oLogConfig, oAppConfig["MSSQLConnectionString"]); - Logger.Debug("MSSQL Connection: [{0}]", MSSQL.CurrentConnectionString); - Logger.Debug("Firebird Connection: [{0}]", Firebird.ConnectionString); + oLogger.Debug("Establishing Firebird Database connection.."); + Firebird = new Firebird(oLogConfig, + oFirebirdConfig["Datasource"], + oFirebirdConfig["Database"], + oFirebirdConfig["Username"], + oFirebirdConfig["Password"]); + + oLogger.Debug("MSSQL Connection: [{0}]", MSSQL.CurrentConnectionString); + oLogger.Debug("Firebird Connection: [{0}]", Firebird.ConnectionString); } public string GetGDPictureKey() diff --git a/WEBSERVICES/ZUGFeRDRESTService/ZUGFeRDRESTService.csproj b/WEBSERVICES/ZUGFeRDRESTService/ZUGFeRDRESTService.csproj index 888619ca..311cfff2 100644 --- a/WEBSERVICES/ZUGFeRDRESTService/ZUGFeRDRESTService.csproj +++ b/WEBSERVICES/ZUGFeRDRESTService/ZUGFeRDRESTService.csproj @@ -9,9 +9,9 @@ - + - +