4 Commits

Author SHA1 Message Date
Jonathan Jenne
095b79be96 ClipboardWatcher: Actually use configured connection strings 2020-06-02 16:19:24 +02:00
Jonathan Jenne
66ad52ba26 Chat: WIP 2020-06-02 16:12:10 +02:00
Jonathan Jenne
3a61685882 Database: Version 1.0.0.6 2020-06-02 16:11:55 +02:00
Jonathan Jenne
21802dcfa2 Database/MSSQL: Support connection string per query, for now only for datatable 2020-06-02 16:11:42 +02:00
12 changed files with 116 additions and 32 deletions

View File

@@ -30,14 +30,14 @@ Partial Class Form1
Me.ChatControl1.Dock = System.Windows.Forms.DockStyle.Fill
Me.ChatControl1.Location = New System.Drawing.Point(0, 0)
Me.ChatControl1.Name = "ChatControl1"
Me.ChatControl1.Size = New System.Drawing.Size(305, 324)
Me.ChatControl1.Size = New System.Drawing.Size(397, 384)
Me.ChatControl1.TabIndex = 0
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(305, 324)
Me.ClientSize = New System.Drawing.Size(397, 384)
Me.Controls.Add(Me.ChatControl1)
Me.Name = "Form1"
Me.Text = "Form1"

View File

@@ -52,6 +52,8 @@ Partial Class ChatControl
Me.columnUsername = New DevExpress.XtraGrid.Columns.TileViewColumn()
Me.columnMessage = New DevExpress.XtraGrid.Columns.TileViewColumn()
Me.columnDate = New DevExpress.XtraGrid.Columns.TileViewColumn()
Me.RepositoryItemHypertextLabel1 = New DevExpress.XtraEditors.Repository.RepositoryItemHypertextLabel()
Me.RepositoryItemHyperLinkEdit1 = New DevExpress.XtraEditors.Repository.RepositoryItemHyperLinkEdit()
Me.SplitContainerControl1 = New DevExpress.XtraEditors.SplitContainerControl()
Me.GridChat = New DevExpress.XtraGrid.GridControl()
Me.ChatView = New DevExpress.XtraGrid.Views.Tile.TileView()
@@ -60,6 +62,8 @@ Partial Class ChatControl
Me.txtMessage = New DevExpress.XtraEditors.MemoEdit()
Me.btnSendMessage = New DevExpress.XtraEditors.SimpleButton()
Me.ChatSource = New System.Windows.Forms.BindingSource(Me.components)
CType(Me.RepositoryItemHypertextLabel1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.RepositoryItemHyperLinkEdit1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.SplitContainerControl1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SplitContainerControl1.SuspendLayout()
CType(Me.GridChat, System.ComponentModel.ISupportInitialize).BeginInit()
@@ -91,6 +95,15 @@ Partial Class ChatControl
Me.columnDate.Visible = True
Me.columnDate.VisibleIndex = 2
'
'RepositoryItemHypertextLabel1
'
Me.RepositoryItemHypertextLabel1.Name = "RepositoryItemHypertextLabel1"
'
'RepositoryItemHyperLinkEdit1
'
Me.RepositoryItemHyperLinkEdit1.AutoHeight = False
Me.RepositoryItemHyperLinkEdit1.Name = "RepositoryItemHyperLinkEdit1"
'
'SplitContainerControl1
'
Me.SplitContainerControl1.Dock = System.Windows.Forms.DockStyle.Fill
@@ -116,6 +129,7 @@ Partial Class ChatControl
Me.GridChat.Location = New System.Drawing.Point(0, 20)
Me.GridChat.MainView = Me.ChatView
Me.GridChat.Name = "GridChat"
Me.GridChat.RepositoryItems.AddRange(New DevExpress.XtraEditors.Repository.RepositoryItem() {Me.RepositoryItemHyperLinkEdit1, Me.RepositoryItemHypertextLabel1})
Me.GridChat.Size = New System.Drawing.Size(317, 234)
Me.GridChat.TabIndex = 0
Me.GridChat.ViewCollection.AddRange(New DevExpress.XtraGrid.Views.Base.BaseView() {Me.ChatView})
@@ -123,15 +137,19 @@ Partial Class ChatControl
'ChatView
'
Me.ChatView.Columns.AddRange(New DevExpress.XtraGrid.Columns.GridColumn() {Me.columnMessage, Me.columnUsername, Me.columnDate})
Me.ChatView.ContextButtonOptions.HoverStateOpacity = 0.75!
Me.ChatView.ContextButtonOptions.TopPanelColor = System.Drawing.Color.White
Me.ChatView.GridControl = Me.GridChat
Me.ChatView.Name = "ChatView"
Me.ChatView.OptionsTiles.GroupTextPadding = New System.Windows.Forms.Padding(0)
Me.ChatView.OptionsTiles.ColumnCount = 1
Me.ChatView.OptionsTiles.GroupTextPadding = New System.Windows.Forms.Padding(0, 8, 12, 8)
Me.ChatView.OptionsTiles.IndentBetweenGroups = 0
Me.ChatView.OptionsTiles.IndentBetweenItems = 0
Me.ChatView.OptionsTiles.IndentBetweenItems = 10
Me.ChatView.OptionsTiles.ItemPadding = New System.Windows.Forms.Padding(0)
Me.ChatView.OptionsTiles.ItemSize = New System.Drawing.Size(374, 64)
Me.ChatView.OptionsTiles.LayoutMode = DevExpress.XtraGrid.Views.Tile.TileViewLayoutMode.List
Me.ChatView.OptionsTiles.LayoutMode = DevExpress.XtraGrid.Views.Tile.TileViewLayoutMode.Kanban
Me.ChatView.OptionsTiles.Orientation = System.Windows.Forms.Orientation.Vertical
Me.ChatView.OptionsTiles.Padding = New System.Windows.Forms.Padding(5)
Me.ChatView.OptionsTiles.RowCount = 0
Me.ChatView.OptionsTiles.ScrollMode = DevExpress.XtraEditors.TileControlScrollMode.ScrollBar
TableColumnDefinition7.Length.Value = 250.0R
@@ -243,7 +261,7 @@ Partial Class ChatControl
'
Me.btnSendMessage.Dock = System.Windows.Forms.DockStyle.Right
Me.btnSendMessage.ImageOptions.Location = DevExpress.XtraEditors.ImageLocation.MiddleCenter
Me.btnSendMessage.ImageOptions.SvgImage = CType(resources.GetObject("SimpleButton1.ImageOptions.SvgImage"), DevExpress.Utils.Svg.SvgImage)
Me.btnSendMessage.ImageOptions.SvgImage = CType(resources.GetObject("btnSendMessage.ImageOptions.SvgImage"), DevExpress.Utils.Svg.SvgImage)
Me.btnSendMessage.Location = New System.Drawing.Point(275, 0)
Me.btnSendMessage.Name = "btnSendMessage"
Me.btnSendMessage.PaintStyle = DevExpress.XtraEditors.Controls.PaintStyles.Light
@@ -257,6 +275,8 @@ Partial Class ChatControl
Me.Controls.Add(Me.SplitContainerControl1)
Me.Name = "ChatControl"
Me.Size = New System.Drawing.Size(317, 314)
CType(Me.RepositoryItemHypertextLabel1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.RepositoryItemHyperLinkEdit1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.SplitContainerControl1, System.ComponentModel.ISupportInitialize).EndInit()
Me.SplitContainerControl1.ResumeLayout(False)
CType(Me.GridChat, System.ComponentModel.ISupportInitialize).EndInit()
@@ -280,4 +300,6 @@ Partial Class ChatControl
Friend WithEvents lookupConversations As LookupGrid.LookupControl2
Friend WithEvents LookupControl21View As DevExpress.XtraGrid.Views.Grid.GridView
Friend WithEvents btnSendMessage As DevExpress.XtraEditors.SimpleButton
Friend WithEvents RepositoryItemHyperLinkEdit1 As DevExpress.XtraEditors.Repository.RepositoryItemHyperLinkEdit
Friend WithEvents RepositoryItemHypertextLabel1 As DevExpress.XtraEditors.Repository.RepositoryItemHypertextLabel
End Class

View File

@@ -127,7 +127,7 @@
</value>
</data>
<assembly alias="DevExpress.Data.v19.2" name="DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<data name="SimpleButton1.ImageOptions.SvgImage" type="DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2" mimetype="application/x-microsoft.net.object.bytearray.base64">
<data name="btnSendMessage.ImageOptions.SvgImage" type="DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFlEZXZFeHByZXNzLkRhdGEudjE5LjIsIFZlcnNpb249MTkuMi4z
LjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjg4ZDE3NTRkNzAwZTQ5YQUBAAAAHURl

View File

@@ -92,7 +92,9 @@ Public Class ChatControl
Private Sub ChatView_ItemCustomize(sender As Object, e As TileViewItemCustomizeEventArgs) Handles ChatView.ItemCustomize
Dim oRow As DataRow = ChatView.GetDataRow(e.RowHandle)
Dim oUsername As String = oRow.Item(UsernameColumn)
Dim oMessage As String = oRow.Item(MessageColumn)
Dim oColor As Color = UsernameColorsDict.Item(oUsername)
If oUsername = CurrentUser Then
@@ -102,12 +104,6 @@ Public Class ChatControl
e.Item.Item(UsernameColumn).Appearance.Normal.ForeColor = oColor
End Sub
Private Sub txtMessage_KeyUp(sender As Object, e As KeyEventArgs) Handles txtMessage.KeyUp
If e.Control And e.KeyCode = Keys.Enter And txtMessage.Text.Count > 0 Then
SendMessage(txtMessage.Text)
End If
End Sub
Private Sub lookupConversations_SelectedValuesChanged(sender As Object, SelectedValues As List(Of String)) Handles lookupConversations.SelectedValuesChanged
If SelectedValues.Count > 0 Then
CurrentConversation = SelectedValues.First()
@@ -115,6 +111,12 @@ Public Class ChatControl
End If
End Sub
Private Sub txtMessage_KeyUp(sender As Object, e As KeyEventArgs) Handles txtMessage.KeyUp
If e.Control And e.KeyCode = Keys.Enter And txtMessage.Text.Count > 0 Then
SendMessage(txtMessage.Text)
End If
End Sub
Private Sub SimpleButton1_Click(sender As Object, e As EventArgs) Handles btnSendMessage.Click
If txtMessage.Text.Count > 0 Then
SendMessage(txtMessage.Text)

View File

@@ -6,8 +6,8 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B7D465A2-AE31-4CDF-A8B2-34B42D3EA84E}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>DigitalData.Modules.ClipboardWatcher</RootNamespace>
<AssemblyName>DigitalData.Modules.ClipboardWatcher</AssemblyName>
<RootNamespace>DigitalData.GUIs.ClipboardWatcher</RootNamespace>
<AssemblyName>DigitalData.GUIs.ClipboardWatcher</AssemblyName>
<FileAlignment>512</FileAlignment>
<MyType>Windows</MyType>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
@@ -18,7 +18,7 @@
<DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace>
<OutputPath>bin\Debug\</OutputPath>
<DocumentationFile>DigitalData.Modules.ClipboardWatcher.xml</DocumentationFile>
<DocumentationFile>DigitalData.GUIs.ClipboardWatcher.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
@@ -27,7 +27,7 @@
<DefineTrace>true</DefineTrace>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DocumentationFile>DigitalData.Modules.ClipboardWatcher.xml</DocumentationFile>
<DocumentationFile>DigitalData.GUIs.ClipboardWatcher.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
</PropertyGroup>
<PropertyGroup>

View File

@@ -22,7 +22,7 @@ Namespace My.Resources
'''<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.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0"), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
@@ -39,7 +39,7 @@ Namespace My.Resources
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.ClipboardWatcher.Resources", GetType(Resources).Assembly)
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("DigitalData.GUIs.ClipboardWatcher.Resources", GetType(Resources).Assembly)
resourceMan = temp
End If
Return resourceMan

View File

@@ -15,7 +15,7 @@ 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.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.4.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase
@@ -64,9 +64,9 @@ Namespace My
Friend Module MySettingsProperty
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
Friend ReadOnly Property Settings() As Global.DigitalData.Modules.ClipboardWatcher.My.MySettings
Friend ReadOnly Property Settings() As Global.DigitalData.GUIs.ClipboardWatcher.My.MySettings
Get
Return Global.DigitalData.Modules.ClipboardWatcher.My.MySettings.Default
Return Global.DigitalData.GUIs.ClipboardWatcher.My.MySettings.Default
End Get
End Property
End Module

View File

@@ -0,0 +1 @@
DevExpress.XtraEditors.TileControl, DevExpress.XtraEditors.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a

View File

@@ -1,5 +1,7 @@
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.ZooFlow
Imports DigitalData.Modules.Patterns
Public Class ProfileSearches
Private _LogConfig As LogConfig
@@ -34,7 +36,7 @@ Public Class ProfileSearches
Dim oSearchesDataTable = _Environment.Database.GetDatatable(oSQL)
Dim oDocSearches As New List(Of Search)
Dim oCounter As Integer = 0
Dim oPatterns As New Patterns.ClassPatterns(_LogConfig)
Dim oPatterns As New ClassPatterns(_LogConfig)
For Each oRow As DataRow In oSearchesDataTable.Rows
Dim oProfileId As Integer = oRow.Item("PROFILE_ID")
@@ -47,7 +49,8 @@ Public Class ProfileSearches
oSQL = oPatterns.ReplaceInternalValues(oSQL)
oSQL = oPatterns.ReplaceClipboardContents(oSQL, _Params.ClipboardContents)
Dim oDatatable As DataTable = _Environment.Database.GetDatatable(oSQL, oConnectionId)
Dim oConnectionString = GetConnectionString(oConnectionId)
Dim oDatatable As DataTable = _Environment.Database.GetDatatableWithConnection(oSQL, oConnectionString)
If oDatatable Is Nothing Then
_Logger.Warn("Error in SQL-Query '{0}'", oSQL)
@@ -69,6 +72,26 @@ Public Class ProfileSearches
Return oDocSearches
End Function
Private Function GetConnectionString(ConnectionId As Integer) As String
Dim oDatatable As DataTable = _Environment.Database.GetDatatable($"SELECT * FROM TBDD_CONNECTION WHERE GUID = {ConnectionId}")
If oDatatable.Rows.Count > 0 Then
Dim oRow As DataRow = oDatatable.Rows.Item(0)
Select Case oRow.Item("SQL_PROVIDER")
Case "MS-SQL"
Dim oConnectionString = MSSQLServer.GetConnectionString(oRow.Item("SERVER"), oRow.Item("DATENBANK"), oRow.Item("USERNAME"), oRow.Item("PASSWORD"))
Return oConnectionString
Case Else
Return Nothing
End Select
Else
Return Nothing
End If
End Function
Public Async Function LoadDataSearchesAsync(ProfileId As Integer) As Task(Of List(Of Search))
Return Await Task.Run(Function()
Return DoLoadDataSearches(ProfileId)
@@ -83,7 +106,7 @@ Public Class ProfileSearches
Dim oSearchesDataTable = _Environment.Database.GetDatatable(oSQL)
Dim oCounter As Integer = 0
Dim oPatterns As New Patterns.ClassPatterns(_LogConfig)
Dim oPatterns As New ClassPatterns(_LogConfig)
For Each oRow As DataRow In oSearchesDataTable.Rows
Try
@@ -95,7 +118,8 @@ Public Class ProfileSearches
oSQL = oPatterns.ReplaceUserValues(oSQL, _Environment.User)
oSQL = oPatterns.ReplaceInternalValues(oSQL)
Dim oDatatable As DataTable = _Environment.Database.GetDatatable(oSQL, oConnectionId)
Dim oConnectionString = GetConnectionString(oConnectionId)
Dim oDatatable As DataTable = _Environment.Database.GetDatatableWithConnection(oSQL, oConnectionString)
If oDatatable Is Nothing Then
_Logger.Warn("Error in SQL-Query '{0}'", oSQL)

View File

@@ -7,6 +7,7 @@ Imports DigitalData.Modules.Windows
Imports DigitalData.Modules.Language
Imports DigitalData.Modules.ZooFlow
Imports DigitalData.Modules.ZooFlow.Params
Imports DigitalData.Modules
''' <summary>
'''

View File

@@ -51,8 +51,12 @@ Public Class MSSQLServer
End Function
Private Function TestCanConnect() As Boolean
Return TestCanConnect(CurrentSQLConnectionString)
End Function
Private Function TestCanConnect(ConnectionString As String) As Boolean
Try
Dim oConnection As New SqlConnection(CurrentSQLConnectionString)
Dim oConnection As New SqlConnection(ConnectionString)
oConnection.Open()
oConnection.Close()
Return True
@@ -63,13 +67,17 @@ Public Class MSSQLServer
End Function
Private Function GetSQLConnection() As SqlConnection
Return GetSQLConnection(CurrentSQLConnectionString)
End Function
Private Function GetSQLConnection(ConnectionString As String) As SqlConnection
Try
Dim oBuilder As New SqlConnectionStringBuilder() With {.ConnectionString = CurrentSQLConnectionString}
Dim oConnection As New SqlConnection(CurrentSQLConnectionString)
Dim oBuilder As New SqlConnectionStringBuilder() With {.ConnectionString = ConnectionString}
Dim oConnection As New SqlConnection(ConnectionString)
oConnection.Open()
Try
Dim oConnectionString = CurrentSQLConnectionString.Replace(oBuilder.Password, "XXXXX")
Dim oConnectionString = ConnectionString.Replace(oBuilder.Password, "XXXXX")
_Logger.Debug($"Following Connectionstring is open: {oConnectionString}")
Catch ex As Exception
End Try
@@ -117,6 +125,32 @@ Public Class MSSQLServer
Return GetDatatable(SqlCommand, _Timeout)
End Function
Public Function GetDatatableWithConnection(SqlCommand As String, ConnectionString As String) As DataTable
Try
If TestCanConnect(ConnectionString) = False Then
Return Nothing
End If
_Logger.Debug("Running Query: {0}", SqlCommand)
Using oConnection = GetSQLConnection(ConnectionString)
Using oSQLCOmmand = oConnection.CreateCommand()
oSQLCOmmand.CommandText = SqlCommand
oSQLCOmmand.CommandTimeout = _Timeout
Dim dt As DataTable = New DataTable()
Dim oAdapter As SqlDataAdapter = New SqlDataAdapter(oSQLCOmmand)
oAdapter.Fill(dt)
Return dt
End Using
End Using
Catch ex As Exception
_Logger.Error(ex)
_Logger.Warn("sqlcommand: " & SqlCommand)
Return Nothing
End Try
End Function
''' <summary>
''' Executes the passed sql-statement
''' </summary>

View File

@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.0.0.5")>
<Assembly: AssemblyVersion("1.0.0.6")>
<Assembly: AssemblyFileVersion("1.0.0.0")>