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"
'''Gets the first matching value of a property
'''
'''
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
'''Sets the first matching value of a property
'''
'''
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
'''Return the descripted dsn string
'''
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