MS Changes Switch ClientConnection

This commit is contained in:
Digital Data - Marlon Schreiber 2018-07-13 14:25:23 +02:00
parent c77608c5e5
commit 2bdb7d1512
4 changed files with 55 additions and 4 deletions

View File

@ -35,6 +35,12 @@ Public Class ClassDatabase
connectionString = "Server=" & DTConnection.Rows(0).Item("SERVER") & ";Database=" & DTConnection.Rows(0).Item("DATENBANK") & ";User Id=" & DTConnection.Rows(0).Item("USERNAME") & ";Password=" & DTConnection.Rows(0).Item("USERNAME") & ";Password=" & DTConnection.Rows(0).Item("PASSWORD") & ";"
End If
' connectionString = "Server=" & DTConnection.Rows(0).Item("SERVER") & ";Database=" & DTConnection.Rows(0).Item("DATENBANK") & ";User Id=" & DTConnection.Rows(0).Item("USERNAME") & ";Password=" & DTConnection.Rows(0).Item("PASSWORD") & ";"
Case "MS-SQLServer"
If DTConnection.Rows(0).Item("USERNAME") = "WINAUTH" Then
connectionString = "Server=" & DTConnection.Rows(0).Item("SERVER") & ";Database=" & DTConnection.Rows(0).Item("DATENBANK") & ";Trusted_Connection=True;"
Else
connectionString = "Server=" & DTConnection.Rows(0).Item("SERVER") & ";Database=" & DTConnection.Rows(0).Item("DATENBANK") & ";User Id=" & DTConnection.Rows(0).Item("USERNAME") & ";Password=" & DTConnection.Rows(0).Item("USERNAME") & ";Password=" & DTConnection.Rows(0).Item("PASSWORD") & ";"
End If
Case "Oracle"
If DTConnection.Rows(0).Item("BEMERKUNG").ToString.Contains("without tnsnames") Then
connectionString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" & DTConnection.Rows(0).Item("SERVER") & ")(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" &

View File

@ -586,6 +586,7 @@ Partial Class frmMain
Me.RibbonPageGroupConnManager.ItemLinks.Add(Me.BarButtonItemSwitchCon)
Me.RibbonPageGroupConnManager.Name = "RibbonPageGroupConnManager"
resources.ApplyResources(Me.RibbonPageGroupConnManager, "RibbonPageGroupConnManager")
Me.RibbonPageGroupConnManager.Visible = False
'
'pageForms
'

View File

@ -2656,7 +2656,7 @@
<value>Weitere Views</value>
</data>
<data name="RibbonPageGroupConnManager.Text" xml:space="preserve">
<value>Connection Manager</value>
<value>Client Connection</value>
</data>
<data name="pageHome.Text" xml:space="preserve">
<value>Home</value>

View File

@ -1004,6 +1004,7 @@ Public Class frmMain
Dim sqlcon_Proxy = ""
Dim WM_ALIAS = ""
Dim INACTIVE_GUID
Dim ACTIVE_GUID
For Each row As DataRow In drInActive
INACTIVE_GUID = row.Item("GUID")
name = row.Item("DESCRIPTION")
@ -1011,6 +1012,9 @@ Public Class frmMain
sqlcon_Proxy = row.Item("SQL_CONNECTION_PROXY")
WM_ALIAS = row.Item("WM_ALIAS")
Next
For Each row As DataRow In drActive
ACTIVE_GUID = row.Item("GUID")
Next
If name <> "" Then
@ -1022,15 +1026,55 @@ Public Class frmMain
result = MessageBox.Show(msg, "Confirmation:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If result = MsgBoxResult.Yes Then
BarButtonItemSwitchCon.Caption = "Switch Connection to: " & name
Try
My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\A.I.S. GmbH\windream\3.6\ServerShareSelector", "CurrentAlias", WM_ALIAS)
My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\A.I.S. GmbH\windream\3.6\ServerShareSelector", "VFSAlias", WM_ALIAS)
Catch ex As Exception
ClassLogger.Add("Unexpected error in Changing WMAlias: " & ex.Message, True)
Exit Sub
End Try
Try
Dim IndexService = CreateObject("WMIndexServer.WMIdxSvControl")
IndexService.shutdown
IndexService.Start
Catch ex As Exception
ClassLogger.Add("Unexpected error in Restarting IndexService: " & ex.Message, True)
Exit Sub
End Try
Try
Dim ControlCenter = CreateObject("Wmcc.ControlCenter")
ControlCenter.StartVFSService(0)
ControlCenter.StartVFSService(1)
Catch ex As Exception
ClassLogger.Add("Unexpected error in Restarting ControlCenter: " & ex.Message, True)
Exit Sub
End Try
SaveMySettingsValue("MyConnectionString", sqlcon, "ConfigMain")
If sqlcon_Proxy <> String.Empty Then
SaveMySettingsValue("MyProxyConnectionString", sqlcon_Proxy, "ConfigMain")
End If
Dim sql = String.Format("UPDATE TBPMO_CLIENT_CONN_SWITCH_USER SET ACTIVE = 1 WHERE GUID = {0}", INACTIVE_GUID)
ClassDatabase.Execute_Scalar(sql)
ClassInit.Init_CONN_SWITCH()
If ClassInit.InitDatabase = True Then
ClassInit.InitUserLogin()
Load_Connection_Dep_Data()
msg = "Die Client-Verbindung wurde erfolgreich gewechselt!"
If USER_LANGUAGE <> "de-DE" Then
msg = "The Client-Connection was changed successfully!"
End If
MsgBox(msg, MsgBoxStyle.Information)
sql = String.Format("UPDATE TBPMO_CLIENT_CONN_SWITCH_USER SET ACTIVE = 1 WHERE DESCRIPTION = {0} AND USER_ID = {1}", name, USER_GUID)
ClassDatabase.Execute_Scalar(sql)
ClassInit.Init_CONN_SWITCH()
CONN_Manager()
End If
End If
End If
Catch ex As Exception
MsgBox("Unexpected error in BarButtonItemSwitchCon.ItemClick: " & ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
End Class