Initial commit
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
Imports System
|
||||
Imports System.Xml
|
||||
Imports System.Data
|
||||
|
||||
Public Class Settings
|
||||
|
||||
#Region "Members"
|
||||
|
||||
Dim _settings As XmlDocument
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "Consts"
|
||||
|
||||
Private Const DSN_DECRYPT_PASSWORD As String = "HutterundMueller"
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "Constructor"
|
||||
|
||||
Public Sub New()
|
||||
Try
|
||||
_settings = New XmlDocument
|
||||
_settings.Load(AppDomain.CurrentDomain.BaseDirectory + "settings.xml")
|
||||
|
||||
Catch ex As Exception
|
||||
Throw ex
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "Public methods"
|
||||
|
||||
'''<summary>Gets the first matching value of a property</summary>
|
||||
'''<param name="propertyName"></param>
|
||||
'''<returns></returns>
|
||||
Public Function GetSettingValue(ByVal propertyName As String) As String
|
||||
Try
|
||||
Dim nodes As XmlNodeList = _settings.GetElementsByTagName(propertyName)
|
||||
If (nodes.Count > 0) Then
|
||||
Return nodes(0).InnerText
|
||||
Else
|
||||
Return ""
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Throw ex
|
||||
End Try
|
||||
End Function
|
||||
|
||||
'''<summary>Sets the first matching value of a property</summary>
|
||||
'''<param name="xpath"></param>
|
||||
'''<param name="value"></param>
|
||||
Public Sub SetSettingsValue(ByVal xpath As String, ByVal value As String)
|
||||
Try
|
||||
_settings.SelectSingleNode(xpath).InnerText = value
|
||||
_settings.Save(AppDomain.CurrentDomain.BaseDirectory + "settings.xml")
|
||||
Catch ex As Exception
|
||||
Throw ex
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
'''<summary>Return the descripted dsn string</summary>
|
||||
'''<returns></returns>
|
||||
Public Function GetDecryptedDSN() As String
|
||||
Try
|
||||
Dim reader As System.IO.StreamReader
|
||||
Dim s As String
|
||||
|
||||
reader = System.IO.File.OpenText(AppDomain.CurrentDomain.BaseDirectory & "bms_conn.cfg")
|
||||
s = reader.ReadLine
|
||||
|
||||
Return ZpCryptography.DsnCrypto.Decrypt(s, DSN_DECRYPT_PASSWORD)
|
||||
Catch ex As Exception
|
||||
Throw ex
|
||||
End Try
|
||||
End Function
|
||||
|
||||
#End Region
|
||||
End Class
|
||||
@@ -0,0 +1,73 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' Dieser Code wurde von einem Tool generiert.
|
||||
' Laufzeitversion:4.0.30319.42000
|
||||
'
|
||||
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||
' der Code erneut generiert wird.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
|
||||
Namespace My
|
||||
|
||||
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0"), _
|
||||
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Partial Friend NotInheritable Class MySettings
|
||||
Inherits Global.System.Configuration.ApplicationSettingsBase
|
||||
|
||||
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()), MySettings)
|
||||
|
||||
#Region "Funktion zum automatischen Speichern von My.Settings"
|
||||
#If _MyType = "WindowsForms" Then
|
||||
Private Shared addedHandler As Boolean
|
||||
|
||||
Private Shared addedHandlerLockObject As New Object
|
||||
|
||||
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
|
||||
If My.Application.SaveMySettingsOnExit Then
|
||||
My.Settings.Save()
|
||||
End If
|
||||
End Sub
|
||||
#End If
|
||||
#End Region
|
||||
|
||||
Public Shared ReadOnly Property [Default]() As MySettings
|
||||
Get
|
||||
|
||||
#If _MyType = "WindowsForms" Then
|
||||
If Not addedHandler Then
|
||||
SyncLock addedHandlerLockObject
|
||||
If Not addedHandler Then
|
||||
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
|
||||
addedHandler = True
|
||||
End If
|
||||
End SyncLock
|
||||
End If
|
||||
#End If
|
||||
Return defaultInstance
|
||||
End Get
|
||||
End Property
|
||||
End Class
|
||||
End Namespace
|
||||
|
||||
Namespace My
|
||||
|
||||
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
|
||||
Friend Module MySettingsProperty
|
||||
|
||||
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
|
||||
Friend ReadOnly Property Settings() As Global.BLAushaendigungen.My.MySettings
|
||||
Get
|
||||
Return Global.BLAushaendigungen.My.MySettings.Default
|
||||
End Get
|
||||
End Property
|
||||
End Module
|
||||
End Namespace
|
||||
Binary file not shown.
Reference in New Issue
Block a user