121 lines
6.7 KiB
VB.net
121 lines
6.7 KiB
VB.net
Imports DevExpress.ExpressApp.Win
|
|
Imports DevExpress.ExpressApp
|
|
Imports DevExpress.ExpressApp.Security
|
|
Imports Nuvolar.Module
|
|
Imports Nuvolar.Module.Win
|
|
Imports Nuvolar.Module.StaticClass
|
|
Imports DevExpress.ExpressApp.Xpo
|
|
Imports System.Configuration
|
|
Imports System.Text
|
|
|
|
Partial Public Class NuvolarWindowsFormsDebranetGL
|
|
Inherits WinApplication
|
|
Implements IApplicationFactory
|
|
Friend WithEvents SystemModule1 As DevExpress.ExpressApp.SystemModule.SystemModule
|
|
Protected Overrides Sub ReadLastLogonParametersCore(ByVal storage As DevExpress.ExpressApp.Utils.SettingsStorage, ByVal logonObject As Object)
|
|
Dim standardLogonParameters As AuthenticationStandardLogonParameters = TryCast(logonObject, AuthenticationStandardLogonParameters)
|
|
If (standardLogonParameters IsNot Nothing) AndAlso String.IsNullOrEmpty(standardLogonParameters.UserName) Then
|
|
MyBase.ReadLastLogonParametersCore(storage, logonObject)
|
|
Try
|
|
TryCast(logonObject, ChangeLogon).DBConnection = TryCast(storage, DevExpress.ExpressApp.Utils.SettingsStorageOnString).Values("\DBConnection")
|
|
TryCast(logonObject, ChangeLogon).SQLServer = TryCast(storage, DevExpress.ExpressApp.Utils.SettingsStorageOnString).Values("\SQLServer")
|
|
Select Case TryCast(storage, DevExpress.ExpressApp.Utils.SettingsStorageOnString).Values("\SQLType")
|
|
Case "MSSQL"
|
|
TryCast(logonObject, ChangeLogon).SQLType = eSQLType.MSSQL
|
|
Case "PostgreSQL"
|
|
TryCast(logonObject, ChangeLogon).SQLType = eSQLType.PostgreSQL
|
|
Case "MySQL"
|
|
TryCast(logonObject, ChangeLogon).SQLType = eSQLType.MySQL
|
|
End Select
|
|
Catch
|
|
End Try
|
|
End If
|
|
End Sub
|
|
Protected Overrides Sub OnLoggingOn(ByVal args As LogonEventArgs)
|
|
MyBase.OnLoggingOn(args)
|
|
|
|
Dim _connectionString As String
|
|
Dim _ChangeLogon As ChangeLogon
|
|
Dim _plattform As String = ""
|
|
|
|
_ChangeLogon = TryCast(args.LogonParameters, ChangeLogon)
|
|
|
|
GLOBAL_SQLType = _ChangeLogon.SQLType
|
|
GLOBAL_SQLServer = _ChangeLogon.SQLServer
|
|
GLOBAL_SQLDatabase = _ChangeLogon.DBConnection
|
|
|
|
Dim _NuvolarServer As String = ConfigurationManager.AppSettings("NuvolarServer")
|
|
If String.IsNullOrEmpty(_NuvolarServer) = False Then
|
|
Dim _EncryptPassword As String = "uO1625m9ftwStO40CwK3mrO17OxsyLe5YDVXAUWC0JZlfMM9YOJYZN8g21nG9HhX"
|
|
Dim _EncryptSalt As String = "IrUMyznsIimD8Ct8EhSQ04PQq00Rje9p"
|
|
Dim _PasswordDecoded As String = EncryptDecrypt.AESDecrypt(Encoding.ASCII.GetString(Convert.FromBase64String(_NuvolarServer)), _EncryptPassword, _EncryptSalt)
|
|
GeneralFunction.GLOBAL_SQLUser = _PasswordDecoded.Split(";"c)(1)
|
|
GeneralFunction.GLOBAL_SQLPassword = _PasswordDecoded.Split(";"c)(2)
|
|
End If
|
|
|
|
|
|
Select Case _ChangeLogon.SQLType
|
|
Case eSQLType.MSSQL
|
|
_connectionString = String.Format(" User ID={0}; " &
|
|
" Application Name=Nuvolar Framework ({1});" &
|
|
" Password={2};" &
|
|
" Pooling=false;" &
|
|
" Data Source={3};" &
|
|
" Initial Catalog={4}", GeneralFunction.GLOBAL_SQLUser, _ChangeLogon.UserName.ToUpper(), GeneralFunction.GLOBAL_SQLPassword,
|
|
_ChangeLogon.SQLServer, _ChangeLogon.DBConnection)
|
|
_plattform = "MS SQL"
|
|
|
|
Case eSQLType.MySQL
|
|
_connectionString = String.Format("XpoProvider=MySql;" &
|
|
"server={0}; " &
|
|
"Port = 3306;" &
|
|
"user id = {1}; " &
|
|
"password = {2}; " &
|
|
"database = {3}; " &
|
|
"Persist Security Info = true; " &
|
|
"CharSet = utf8; " & "Allow User Variables = True", _ChangeLogon.SQLServer, GeneralFunction.GLOBAL_SQLUser,
|
|
GeneralFunction.GLOBAL_SQLPassword, _ChangeLogon.DBConnection)
|
|
_plattform = "MySQL"
|
|
Case eSQLType.PostgreSQL
|
|
_connectionString = DevExpress.Xpo.DB.PostgreSqlConnectionProvider.GetConnectionString(_ChangeLogon.SQLServer & ";Port=5432", GeneralFunction.GLOBAL_SQLUser,
|
|
GeneralFunction.GLOBAL_SQLPassword, _ChangeLogon.DBConnection)
|
|
_plattform = "postgreSQL"
|
|
Case Else
|
|
_connectionString = ""
|
|
End Select
|
|
|
|
Dim anm As System.Reflection.AssemblyName = System.Reflection.AssemblyName.GetAssemblyName(Application.StartupPath & "\Nuvolar.Module.dll")
|
|
|
|
Me.ConnectionString = _connectionString
|
|
|
|
GLOBAL_MainModuleVersion = anm.Version.ToString
|
|
GLOBAL_ConnectionString = _connectionString
|
|
GLOBAL_WINFormCaption = String.Format("Nuvolar Framework version: {0} [{1}]", Application.ProductVersion, anm.Version)
|
|
GLOBAL_WINFormCaption += String.Format(", ({0}) Server: {1}, Database: {2}", _plattform, UCase(_ChangeLogon.SQLServer), UCase(_ChangeLogon.DBConnection))
|
|
GLOBAL_ApplicationStartupPath = Application.StartupPath & "\"
|
|
|
|
Dim _ocur As IObjectSpace = CreateObjectSpace()
|
|
RestAPI.Init(TryCast(_ocur, XPObjectSpace))
|
|
|
|
End Sub
|
|
Protected Overrides Function OnLogonFailed(ByVal logonParameters As Object, ByVal e As Exception) As Boolean
|
|
If WinChangeDatabaseHelper.SkipLogonDialog Then
|
|
Return True
|
|
End If
|
|
Return MyBase.OnLogonFailed(logonParameters, e)
|
|
End Function
|
|
Public Shared Function CreateApplication() As NuvolarWindowsFormsDebranetGL
|
|
Dim winApplication As New NuvolarWindowsFormsDebranetGL
|
|
|
|
CType(winApplication.Security, SecurityBase).Authentication = New WinChangeDatabaseStandardAuthentication()
|
|
Return winApplication
|
|
End Function
|
|
Private Function IApplicationFactory_CreateApplication() As WinApplication Implements IApplicationFactory.CreateApplication
|
|
Return CreateApplication()
|
|
End Function
|
|
Protected Overrides Function GetModelAssemblyFilePath() As String
|
|
Return Nothing
|
|
End Function
|
|
End Class
|
|
|