momoERP.Win.HA Hozzáadása
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
Imports Microsoft.VisualBasic
|
||||
Imports System
|
||||
Imports System.Collections.Generic
|
||||
Imports System.ComponentModel
|
||||
Imports DevExpress.ExpressApp.Win
|
||||
Imports DevExpress.ExpressApp.Updating
|
||||
Imports DevExpress.ExpressApp
|
||||
Imports System.Configuration
|
||||
Imports DevExpress.ExpressApp.Security
|
||||
Imports Nuvolar.Module
|
||||
Imports DevExpress.Persistent.BaseImpl
|
||||
Imports Nuvolar.Module.Win
|
||||
Imports DevExpress.Xpo
|
||||
Imports DevExpress.Xpo.DB
|
||||
Imports System.Net
|
||||
Imports System.IO
|
||||
Imports System.Text
|
||||
Imports Newtonsoft.Json
|
||||
|
||||
Partial Public Class NuvolarWindowsFormsApplication
|
||||
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
|
||||
'MsgBox(System.Configuration.ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
|
||||
|
||||
TryCast(logonObject, ChangeLogon).DBConnection = TryCast(storage, DevExpress.ExpressApp.Utils.SettingsStorageOnString).Values("\DBConnection")
|
||||
TryCast(logonObject, ChangeLogon).SQLServer = TryCast(storage, DevExpress.ExpressApp.Utils.SettingsStorageOnString).Values("\SQLServer")
|
||||
TryCast(logonObject, ChangeLogon).Company = TryCast(storage, DevExpress.ExpressApp.Utils.SettingsStorageOnString).Values("\Company")
|
||||
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)
|
||||
Dim connstr As String = ""
|
||||
Dim _ChangeLogon As ChangeLogon
|
||||
|
||||
|
||||
MyBase.OnLoggingOn(args)
|
||||
|
||||
_ChangeLogon = TryCast(args.LogonParameters, ChangeLogon)
|
||||
|
||||
GLOBAL_Company = _ChangeLogon.Company
|
||||
|
||||
'Me.ConnectionString = GetConnectionGLOBAL()
|
||||
Me.ConnectionString = GetSISSecurity()
|
||||
SISGetInfoSSL()
|
||||
Dim anm As System.Reflection.AssemblyName = System.Reflection.AssemblyName.GetAssemblyName(Application.StartupPath & "\Nuvolar.Module.dll")
|
||||
|
||||
GLOBAL_MainModuleVersion = anm.Version.ToString
|
||||
GLOBAL_ConnectionString = connstr
|
||||
GLOBAL_WINFormCaption = String.Format("Nuvolar Framework version: {0} [{1}]", Application.ProductVersion, anm.Version.ToString)
|
||||
GLOBAL_WINFormCaption += String.Format(", ({0})", GLOBAL_Company_Info)
|
||||
GLOBAL_ApplicationStartupPath = Application.StartupPath & "\"
|
||||
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 NuvolarWindowsFormsApplication
|
||||
Dim winApplication As New NuvolarWindowsFormsApplication
|
||||
|
||||
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
|
||||
|
||||
Private Function GetSISSecurity() As String
|
||||
Dim _ConnectionString As String = ""
|
||||
Try
|
||||
|
||||
Dim _url = "http://sis-r.hu/SISChat/SISSecuritySSL.ashx?id=" & UCase(GLOBAL_Company)
|
||||
'Dim _url = "http://nuvolar.azurewebsites.net/SISSecuritySSL.ashx?id=" & UCase(GLOBAL_Company)
|
||||
Dim _request As HttpWebRequest = TryCast(WebRequest.Create(_url), HttpWebRequest)
|
||||
Dim _response As HttpWebResponse = TryCast(_request.GetResponse, HttpWebResponse)
|
||||
Dim _reader As StreamReader = New StreamReader(_response.GetResponseStream())
|
||||
_ConnectionString = _reader.ReadToEnd
|
||||
|
||||
_ConnectionString = Encoding.UTF8.GetString(Convert.FromBase64String(_ConnectionString))
|
||||
_ConnectionString = AESDecrypt(_ConnectionString, "HrX12!!0Zm7764W2", "vXm657YS+!0@mmT")
|
||||
|
||||
Dim sArray() As String = _ConnectionString.Split(New Char() {";", "="}, StringSplitOptions.RemoveEmptyEntries)
|
||||
|
||||
If String.IsNullOrEmpty(sArray(1)) = False Then
|
||||
Select Case UCase(sArray(1))
|
||||
Case "MYSQL"
|
||||
GLOBAL_SQLType = eSQLType.MySQL
|
||||
Case "MSSQL"
|
||||
GLOBAL_SQLType = eSQLType.MSSQL
|
||||
Case "POSTGRESQL"
|
||||
GLOBAL_SQLType = eSQLType.PostgreSQL
|
||||
Case Else
|
||||
GLOBAL_SQLType = eSQLType.MSSQL
|
||||
|
||||
End Select
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
|
||||
End Try
|
||||
Return _ConnectionString
|
||||
End Function
|
||||
Private Sub SISGetInfoSSL()
|
||||
Dim _InfoString As String = ""
|
||||
Dim _GetInfoClass As New GetInfoClass
|
||||
Try
|
||||
Dim _url = "http://sis-r.hu/SISChat/SISGetInfoSSL.ashx?id=" & UCase(GLOBAL_Company)
|
||||
'Dim _url = "http://nuvolar.azurewebsites.net/SISGetInfoSSL.ashx?id=" & UCase(GLOBAL_Company)
|
||||
Dim _request As HttpWebRequest = TryCast(WebRequest.Create(_url), HttpWebRequest)
|
||||
Dim _response As HttpWebResponse = TryCast(_request.GetResponse, HttpWebResponse)
|
||||
Dim _reader As StreamReader = New StreamReader(_response.GetResponseStream())
|
||||
_InfoString = _reader.ReadToEnd
|
||||
|
||||
_InfoString = Encoding.UTF8.GetString(Convert.FromBase64String(_InfoString))
|
||||
_InfoString = AESDecrypt(_InfoString, "HrX12!!0Zm7764W2", "vXm657YS+!0@mmT")
|
||||
|
||||
_GetInfoClass = JsonConvert.DeserializeObject(Of GetInfoClass)(_InfoString)
|
||||
|
||||
|
||||
GLOBAL_Company_Info = String.Format("Server: {0}, Database: {1}", _GetInfoClass.SQLServer, _GetInfoClass.SQLDatabase)
|
||||
GLOBAL_SQLType = _GetInfoClass.SQLType
|
||||
Catch ex As Exception
|
||||
End Try
|
||||
End Sub
|
||||
End Class
|
||||
Public Class GetInfoClass
|
||||
Property SQLType As eSQLType
|
||||
Property SQLServer As String
|
||||
Property SQLDatabase As String
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user