MS 1 GV AppServer

This commit is contained in:
SchreiberM 2020-12-17 16:12:02 +01:00
parent 152ff43f43
commit b4e41e22f3
6 changed files with 68 additions and 22 deletions

View File

@ -12,7 +12,7 @@
<value />
</setting>
<setting name="UseAppConfigConString" serializeAs="String">
<value>False</value>
<value>True</value>
</setting>
</DD_Clipboard_Watcher.My.MySettings>
<DevExpress.LookAndFeel.Design.AppSettings>
@ -84,7 +84,9 @@
</DevExpress.LookAndFeel.Design.AppSettings>
</applicationSettings>
<connectionStrings>
<add name="DD_Clipboard_Watcher.My.MySettings.DD_ECMConnectionString" connectionString="Data Source=172.24.12.41\tests;Initial Catalog=DD_ECM_TEST;Persist Security Info=True;User ID=sa;Password=dd" providerName="System.Data.SqlClient" />
<add name="DD_Clipboard_Watcher.My.MySettings.DD_ECMConnectionString"
connectionString="Data Source=172.24.12.41\tests;Initial Catalog=DD_ECM_TEST;Persist Security Info=True;User ID=sa;Password=dd"
providerName="System.Data.SqlClient" />
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />

View File

@ -4,6 +4,7 @@ Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Config
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.EDMI.API
Imports DigitalData.Modules.EDMI.API.EDMIServiceReference
Public Class ClassInit
Public _lizenzManager As clsLicenseManager
@ -69,6 +70,21 @@ Public Class ClassInit
Return False
End Try
End Function
Public Function InitAppDatabase() As Boolean
Try
DatabaseAppServ = New MSSQLServer(LogConfig, MyConStringAppserv)
If DatabaseAppServ.DBInitialized = True Then
Return True
Else
Return False
End If
Catch ex As Exception
Logger.Error(ex)
Return False
End Try
End Function
Public Function InitBasics()
Dim UserAppDataPath = Application.UserAppDataPath
@ -84,14 +100,17 @@ Public Class ClassInit
With ConfigManager.Config
MyConnectionString = DecryptConnectionString(.ConnectionString)
LogErrorsOnly = .LogErrorsOnly
HotkeyFunctionKey = .HotkeyFunctionKey
HotkeySearchKey = .HotkeySearchKey
LogConfig.Debug = Not .LogErrorsOnly
End With
If HotkeySearchKey_via_Server = False Then
HotkeyFunctionKey = ConfigManager.Config.HotkeyFunctionKey
End If
If ConfigManager.Config.ConnectionStringAppServer <> String.Empty Then
MyConStringAppserv = DecryptConnectionString(ConfigManager.Config.ConnectionStringAppServer)
If InitAppDatabase() Then
Logger.Debug("ConnectionStringAppServer will be used")
CONNECTION_STRING_APP_SERVER = DecryptConnectionString(ConfigManager.Config.ConnectionStringAppServer)
End If
End If
If ConfigManager.Config.AppServerConfig <> String.Empty Then
@ -187,7 +206,14 @@ Public Class ClassInit
Catch ex As Exception
NOMATCH_INFO = False
End Try
ElseIf oMode.StartsWith("HotkeySearchKey") Then
Try
Dim oResult = oMode.Replace("HotkeySearchKeyO=", "")
HotkeySearchKey = oResult
HotkeySearchKey_via_Server = True
Catch ex As Exception
NOMATCH_INFO = "d"
End Try
Else
Logger.Info($"Wrong oMode: {oMode}")
@ -208,7 +234,7 @@ Public Class ClassInit
End Try
End Function
Public Shared Function InitUserLogin(Optional _User As String = "")
Public Async Function InitUserLogin(Optional _User As String = "") As Task(Of Boolean)
Try
If _User = "" Then
USER_USERNAME = Environment.UserName
@ -216,7 +242,18 @@ Public Class ClassInit
USER_USERNAME = _User
End If
Try
If CheckModuleData() = False Then
Return False
End If
If APPSERVER_ACTIVE = True Then
Dim oTableResult As TableResult = Await _Client.GetDatatableByNameAsync("VWDD_USER_CLIENT", $"USER_ID = {USER_ID}")
DT_CLIENT_USER = oTableResult.Table
Else
DT_CLIENT_USER = Database.GetDatatable(String.Format("SELECT * FROM VWDD_USER_CLIENT WHERE UPPER(USERNAME) = UPPER('{0}')", Environment.UserName))
End If
If Not IsNothing(DT_CLIENT_USER) Then
If DT_CLIENT_USER.Rows.Count > 1 Then
frmClientLogin.ShowDialog()
ElseIf DT_CLIENT_USER.Rows.Count = 1 Then
@ -227,14 +264,19 @@ Public Class ClassInit
'ERROR_STATE = "NO CLIENT"
Return False
End If
Else
Logger.Info("User '" & USER_USERNAME & "' not related to a client", True)
ERROR_INIT = "NO CLIENT"
'ERROR_STATE = "NO CLIENT"
Return False
End If
Catch ex As Exception
Logger.Info("Unexpected error in checking CLIENT: " & ex.Message)
CLIENT_SELECTED = 1
End Try
If CheckModuleData() = False Then
Return False
End If
If USER_IN_MODULE = False Then

View File

@ -76,7 +76,7 @@ Namespace My
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("False")> _
Global.System.Configuration.DefaultSettingValueAttribute("True")> _
Public ReadOnly Property UseAppConfigConString() As Boolean
Get
Return CType(Me("UseAppConfigConString"),Boolean)

View File

@ -14,7 +14,7 @@
<Value Profile="(Default)" />
</Setting>
<Setting Name="UseAppConfigConString" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">False</Value>
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -32,7 +32,7 @@ Public NotInheritable Class frmSplash
Return _step * (100 / InitSteps)
End Function
Private Sub bw_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs)
Private Async Function bw_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) As Task
Try
Dim Init = New ClassInit()
Worker.ReportProgress(CalcProgress(1), "Initializing Logger")
@ -48,7 +48,7 @@ Public NotInheritable Class frmSplash
Thread.Sleep(200)
Worker.ReportProgress(CalcProgress(4), "Initializing User-Configuration")
If ClassInit.InitUserLogin = False Then
If Await Init.InitUserLogin = False Then
If ERROR_INIT = "" Then
ERROR_INIT = "INVALID USER"
End If
@ -63,7 +63,7 @@ Public NotInheritable Class frmSplash
Catch ex As Exception
MsgBox("Unexpected Error in bw_DoWork: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
End Function
Private Sub bw_ProgressChanged(sender As Object, e As ProgressChangedEventArgs)
pbStatus.Value = e.ProgressPercentage

View File

@ -8,15 +8,17 @@ Module modCurrent
Public LogConfig As LogConfig
Public Logger As Logger
Public Database As MSSQLServer
Public DatabaseAppServ As MSSQLServer
Public Automation As ClassAutomation
Public ConfigManager As ConfigManager(Of ClassConfig)
Public MyConnectionString As String = ""
Public CONNECTION_STRING_APP_SERVER As String = ""
Public MyConStringAppserv As String = ""
Public HotkeyFunctionKey As String = ClassConstants.HOTKEY_CTRL
Public HotkeySearchKey As String = "d"
Public HotkeySearchKey_via_Server As Boolean = False
Public LogErrorsOnly As Boolean = True
Public CURRENT_WINDOW_NAME As String