You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.0 KiB
82 lines
2.0 KiB
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
|