From f8e3b3628e1fd6d5faf40708de24c61ab98025e8 Mon Sep 17 00:00:00 2001 From: Digital Data - Marlon Schreiber Date: Thu, 16 Aug 2018 14:17:02 +0200 Subject: [PATCH] MS --- DDMonorepo.sln | 7 + Modules.Database/Firebird.vb | 4 + Modules.Database/Modules.Database.vbproj | 118 +++++++++++++++ .../My Project/Application.Designer.vb | 13 ++ Modules.Database/My Project/Application.myapp | 10 ++ Modules.Database/My Project/AssemblyInfo.vb | 35 +++++ .../My Project/Resources.Designer.vb | 62 ++++++++ Modules.Database/My Project/Resources.resx | 117 +++++++++++++++ .../My Project/Settings.Designer.vb | 73 +++++++++ Modules.Database/My Project/Settings.settings | 7 + Modules.Database/Oracle.vb | 6 + Modules.Database/SQLServer.vb | 138 ++++++++++++++++++ Modules.Database/packages.config | 4 + Modules.Windream/Windream.vb | 2 + TestGUI/Form1.vb | 14 +- 15 files changed, 609 insertions(+), 1 deletion(-) create mode 100644 Modules.Database/Firebird.vb create mode 100644 Modules.Database/Modules.Database.vbproj create mode 100644 Modules.Database/My Project/Application.Designer.vb create mode 100644 Modules.Database/My Project/Application.myapp create mode 100644 Modules.Database/My Project/AssemblyInfo.vb create mode 100644 Modules.Database/My Project/Resources.Designer.vb create mode 100644 Modules.Database/My Project/Resources.resx create mode 100644 Modules.Database/My Project/Settings.Designer.vb create mode 100644 Modules.Database/My Project/Settings.settings create mode 100644 Modules.Database/Oracle.vb create mode 100644 Modules.Database/SQLServer.vb create mode 100644 Modules.Database/packages.config diff --git a/DDMonorepo.sln b/DDMonorepo.sln index 9a0d30e6..a7099c06 100644 --- a/DDMonorepo.sln +++ b/DDMonorepo.sln @@ -19,6 +19,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Services", "Services", "{7A EndProject Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TestGUI", "TestGUI\TestGUI.vbproj", "{93130E7D-A950-4CBD-A0D9-7A6FAF94DDC0}" EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Modules.Database", "Modules.Database\Modules.Database.vbproj", "{EAF0EA75-5FA7-485D-89C7-B2D843B03A96}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -41,6 +43,10 @@ Global {93130E7D-A950-4CBD-A0D9-7A6FAF94DDC0}.Debug|Any CPU.Build.0 = Debug|Any CPU {93130E7D-A950-4CBD-A0D9-7A6FAF94DDC0}.Release|Any CPU.ActiveCfg = Release|Any CPU {93130E7D-A950-4CBD-A0D9-7A6FAF94DDC0}.Release|Any CPU.Build.0 = Release|Any CPU + {EAF0EA75-5FA7-485D-89C7-B2D843B03A96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EAF0EA75-5FA7-485D-89C7-B2D843B03A96}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EAF0EA75-5FA7-485D-89C7-B2D843B03A96}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EAF0EA75-5FA7-485D-89C7-B2D843B03A96}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -50,6 +56,7 @@ Global {903B2D7D-3B80-4BE9-8713-7447B704E1B0} = {3E2008C8-27B1-41DD-9B1A-0C4029F6AECC} {4C86DF8F-A280-40D4-85B0-10B1BF66C15C} = {3E2008C8-27B1-41DD-9B1A-0C4029F6AECC} {93130E7D-A950-4CBD-A0D9-7A6FAF94DDC0} = {8FFE925E-8B84-45F1-93CB-32B1C96F41EB} + {EAF0EA75-5FA7-485D-89C7-B2D843B03A96} = {3E2008C8-27B1-41DD-9B1A-0C4029F6AECC} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C1BE4090-A0FD-48AF-86CB-39099D14B286} diff --git a/Modules.Database/Firebird.vb b/Modules.Database/Firebird.vb new file mode 100644 index 00000000..773cdce7 --- /dev/null +++ b/Modules.Database/Firebird.vb @@ -0,0 +1,4 @@ +Public Class Firebird + Private Shared Logger As NLog.Logger = NLog.LogManager.GetCurrentClassLogger + Public DBInitialized As Boolean = False +End Class diff --git a/Modules.Database/Modules.Database.vbproj b/Modules.Database/Modules.Database.vbproj new file mode 100644 index 00000000..7628b780 --- /dev/null +++ b/Modules.Database/Modules.Database.vbproj @@ -0,0 +1,118 @@ + + + + + Debug + AnyCPU + {EAF0EA75-5FA7-485D-89C7-B2D843B03A96} + Library + Modules.Database + Modules.Database + 512 + Windows + v4.6.1 + + + true + full + true + true + bin\Debug\ + Modules.Database.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + Modules.Database.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + + + ..\packages\NLog.4.5.8\lib\net45\NLog.dll + + + P:\Visual Studio Projekte\Bibliotheken\Oracle.ManagedDataAccess.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 + + + + + \ No newline at end of file diff --git a/Modules.Database/My Project/Application.Designer.vb b/Modules.Database/My Project/Application.Designer.vb new file mode 100644 index 00000000..88dd01c7 --- /dev/null +++ b/Modules.Database/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.Database/My Project/Application.myapp b/Modules.Database/My Project/Application.myapp new file mode 100644 index 00000000..758895de --- /dev/null +++ b/Modules.Database/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/Modules.Database/My Project/AssemblyInfo.vb b/Modules.Database/My Project/AssemblyInfo.vb new file mode 100644 index 00000000..efe5c191 --- /dev/null +++ b/Modules.Database/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +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 + + + + + + + + + + +'Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird. + + +' 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: +' + + + diff --git a/Modules.Database/My Project/Resources.Designer.vb b/Modules.Database/My Project/Resources.Designer.vb new file mode 100644 index 00000000..bd038aeb --- /dev/null +++ b/Modules.Database/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("Modules.Database.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.Database/My Project/Resources.resx b/Modules.Database/My Project/Resources.resx new file mode 100644 index 00000000..af7dbebb --- /dev/null +++ b/Modules.Database/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.Database/My Project/Settings.Designer.vb b/Modules.Database/My Project/Settings.Designer.vb new file mode 100644 index 00000000..990e4633 --- /dev/null +++ b/Modules.Database/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.Modules.Database.My.MySettings + Get + Return Global.Modules.Database.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Modules.Database/My Project/Settings.settings b/Modules.Database/My Project/Settings.settings new file mode 100644 index 00000000..85b890b3 --- /dev/null +++ b/Modules.Database/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Modules.Database/Oracle.vb b/Modules.Database/Oracle.vb new file mode 100644 index 00000000..075828b6 --- /dev/null +++ b/Modules.Database/Oracle.vb @@ -0,0 +1,6 @@ +Imports Oracle.ManagedDataAccess.Client +Public Class Oracle + Private Shared Logger As NLog.Logger = NLog.LogManager.GetCurrentClassLogger + Public DBInitialized As Boolean = False + Public CurrentOracleConnectionString As String = "" +End Class diff --git a/Modules.Database/SQLServer.vb b/Modules.Database/SQLServer.vb new file mode 100644 index 00000000..3f7fee1f --- /dev/null +++ b/Modules.Database/SQLServer.vb @@ -0,0 +1,138 @@ +Imports System.Data.SqlClient + +Public Class SQLServer + Private Shared Logger As NLog.Logger = NLog.LogManager.GetCurrentClassLogger + Public DBInitialized As Boolean = False + Public CurrentSQLConnectionString As String = "" + Public Sub New(CONSTRING As String) + Init(CONSTRING) + End Sub + Public Function Init(CONSTRING As String) + Try + Dim oSQLconnect As New SqlClient.SqlConnection + oSQLconnect.ConnectionString = CONSTRING + oSQLconnect.Open() + oSQLconnect.Close() + CurrentSQLConnectionString = CONSTRING + DBInitialized = True + Return True + Catch ex As Exception + Logger.Error(ex) + 'clsLogger.Add("Error in DatabaseInit: " & ex.Message, True) + Return False + End Try + End Function + ''' + ''' Returns a datatable for a sql-statement + ''' + ''' sqlcommand for datatable (select XYZ from TableORView) + ''' Optional Timeout + ''' Returns a datatable + ''' + Public Function GetDatatable(sqlcommand As String, Optional commandtimeout As Integer = 120) As DataTable + Try + Dim oSQLconnect As New SqlClient.SqlConnection + Dim oSQLCOmmand As SqlClient.SqlCommand + oSQLconnect.ConnectionString = CurrentSQLConnectionString + oSQLconnect.Open() + oSQLCOmmand = oSQLconnect.CreateCommand() + oSQLCOmmand.CommandText = sqlcommand + oSQLCOmmand.CommandTimeout = commandtimeout + Dim adapter1 As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(oSQLCOmmand) + Dim dt As DataTable = New DataTable() + adapter1.Fill(dt) + oSQLconnect.Close() + Return dt + Catch ex As Exception + Logger.Error(ex) + Logger.Debug("sqlcommand: " & sqlcommand) + Return Nothing + End Try + End Function + ''' + ''' Executes the passed sql-statement + ''' + ''' the sql statement + ''' Optional Timeout + ''' Returns true if properly executed, else false + ''' + Public Function NewExecutenonQuery(executeStatement As String, Optional commandtimeout As Integer = 120) As Boolean + Try + Dim oSQLconnect As New SqlClient.SqlConnection + Dim oSQLCOmmand As SqlClient.SqlCommand + oSQLconnect.ConnectionString = CurrentSQLConnectionString + oSQLconnect.Open() + oSQLCOmmand = oSQLconnect.CreateCommand() + oSQLCOmmand.CommandText = executeStatement + oSQLCOmmand.CommandTimeout = commandtimeout + oSQLCOmmand.ExecuteNonQuery() + oSQLCOmmand.Dispose() + oSQLconnect.Close() + Return True + Catch ex As Exception + Logger.Error(ex) + Logger.Debug("executeStatement: " & executeStatement) + Return False + End Try + End Function + ''' + ''' Executes the passed sql-statement in asyncmode + ''' + ''' the sql statement + ''' Optional Timeout + ''' + Public Sub NewExecuteNonQueryAsync(executeStatement As String, Optional commandtimeout As Integer = 120) + Dim oSQLconnect As New SqlClient.SqlConnection + Dim oSQLCOmmand As SqlClient.SqlCommand + Dim callback As New AsyncCallback(AddressOf Execute_non_Query_Async_Callback) + Try + oSQLconnect.ConnectionString = CurrentSQLConnectionString + oSQLconnect.Open() + oSQLCOmmand = oSQLconnect.CreateCommand() + oSQLCOmmand.CommandText = executeStatement + oSQLCOmmand.CommandTimeout = commandtimeout + oSQLCOmmand.BeginExecuteNonQuery(callback, oSQLCOmmand) + Catch ex As Exception + Logger.Error(ex) + Logger.Debug("executeStatement: " & executeStatement) + Finally + oSQLCOmmand.Dispose() + oSQLconnect.Close() + End Try + End Sub + + Private Sub Execute_non_Query_Async_Callback(ByVal result As IAsyncResult) + Dim command As SqlClient.SqlCommand = CType(result.AsyncState, SqlClient.SqlCommand) + Dim res = command.EndExecuteNonQuery(result) + Logger.Info(String.Format("Finished executing Async database operation: {0}", command.CommandText)) + End Sub + ''' + ''' Executes the passed sql-statement as Scalar + ''' + ''' the sql statement + ''' Optional Timeout + ''' Returns true if properly executed, else false + ''' + Public Function NewExecuteScalar(executeStatement As String, Optional commandtimeout As Integer = 120) + Dim result + Try + Dim oSQLconnect As New SqlClient.SqlConnection + Dim oSQLCOmmand As SqlClient.SqlCommand + oSQLconnect.ConnectionString = CurrentSQLConnectionString + oSQLconnect.Open() + oSQLCOmmand = oSQLconnect.CreateCommand() + + oSQLCOmmand.CommandText = executeStatement + oSQLCOmmand.CommandTimeout = commandtimeout + result = oSQLCOmmand.ExecuteScalar() + oSQLCOmmand.Dispose() + oSQLconnect.Close() + + Return result + Catch ex As Exception + Logger.Error(ex) + Logger.Debug("executeStatement: " & executeStatement) + Return Nothing + End Try + End Function +End Class diff --git a/Modules.Database/packages.config b/Modules.Database/packages.config new file mode 100644 index 00000000..a3ffb2eb --- /dev/null +++ b/Modules.Database/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Modules.Windream/Windream.vb b/Modules.Windream/Windream.vb index 2ac8853a..6d6f9561 100644 --- a/Modules.Windream/Windream.vb +++ b/Modules.Windream/Windream.vb @@ -650,7 +650,9 @@ Public Class Windream For Each dok As WMObject In WMObjects Dim path As String = dok.aPath Dim DOC_ID = dok.GetVariableValue(NameIndexDocID) + Logger.Info("Adding DocInfo for DocID: " & DOC_ID.ToString) dt.Rows.Add(DOC_ID, path) + Next dt.AcceptChanges() End If diff --git a/TestGUI/Form1.vb b/TestGUI/Form1.vb index 45def2c3..64ec96c3 100644 --- a/TestGUI/Form1.vb +++ b/TestGUI/Form1.vb @@ -20,7 +20,11 @@ Public Class Form1 End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles GetValue.Click - My.Settings.Save + My.Settings.Save() + If IsNothing(_windream) Then + MsgBox("windream initialisieren") + Exit Sub + End If Dim result As DataTable = _windream.GetValueforIndex(txtWMFile.Text, txtWMIndex.Text) If result.Rows.Count = 0 Then MsgBox("No result") @@ -31,6 +35,10 @@ Public Class Form1 Private Sub IndexFile_Click(sender As Object, e As EventArgs) Handles IndexFile.Click My.Settings.Save() + If IsNothing(_windream) Then + MsgBox("windream initialisieren") + Exit Sub + End If Dim arrValue() As String = Nothing ReDim Preserve arrValue(0) arrValue(0) = txtWMValue.Text @@ -44,6 +52,10 @@ Public Class Form1 Private Sub Button2_Click_1(sender As Object, e As EventArgs) Handles Button2.Click My.Settings.Save() + If IsNothing(_windream) Then + MsgBox("windream initialisieren") + Exit Sub + End If Dim DTResults As DataTable = _windream.GetSearchDocuments(txtwmsearch.Text, "Dokument-ID") If DTResults.Rows.Count > 0 Then GridControl1.DataSource = DTResults