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.

217 lines
7.2 KiB

Imports System.IO
'''<summary>Klasse zum auselesen der Steuerparameter aus der Datei
'''\bin\parameters.cfg</summary>
'''<author>Stefan Hutter</author>
Public Class ClsParameters
#Region "Deklarationen"
'''<summary>Interne Variable zum Auslesen der Datei</summary>
Dim ofile As System.IO.File
'''<summary>Interne Variable zum Auslesen der Datei</summary>
Dim oread As System.IO.StreamReader
'''<summary>Interne Variable für das Property Application ID</summary>
Dim m_applicationid As String
'''<summary>ApplikationsID für die Journalisierung</summary>
Property ApplicationID() As String
Get
Return m_applicationid
End Get
Set(ByVal Value As String)
m_applicationid = Value
End Set
End Property
'''<summary>Interne Variable für das Property Inputverzeichnis</summary>
Dim m_Inputverzeichnis As String
'''<summary>Inputverzeichnis, in welchem die Dokumente und Indexdateien gespeichert
'''sind</summary>
Property Inputverzeichnis() As String
Get
Return m_Inputverzeichnis
End Get
Set(ByVal Value As String)
m_Inputverzeichnis = Value
End Set
End Property
'''<summary>Interne Variable für das Property MailadresseOK</summary>
Dim m_MailadresseOK As String
'''<summary>EMail-Adresse, an die ein Mail gesendet wird, sofern die Verarbeitung
'''ordnungsgemäss durchgelaufen ist</summary>
Property MailAdresseOK() As String
Get
Return m_MailadresseOK
End Get
Set(ByVal Value As String)
m_MailadresseOK = Value
End Set
End Property
'''<summary>Interne Variable für das Property MailadresseNOK</summary>
Dim m_MailadresseNOK As String
'''<summary>Mailadresse, an die im Fehlerfall ein Mail gesendet wird</summary>
Property MailAdresseNOK() As String
Get
Return m_MailadresseNOK
End Get
Set(ByVal Value As String)
m_MailadresseNOK = Value
End Set
End Property
'''<summary>Interne Variable für das Property Meldung</summary>
Dim m_meldung As String
'''<summary>Allfälliger Meldungstext, welcher beim Laden der Parameter generiert
'''wird</summary>
Property Meldung() As String
Get
Return m_meldung
End Get
Set(ByVal Value As String)
m_meldung = Value
End Set
End Property
'''<summary>Interne Variable für das Property Temppfad</summary>
Dim m_temppfad As String
'''<summary>Pfad für temporäre Dateien</summary>
Property TempPfad() As String
Get
Return m_temppfad
End Get
Set(ByVal Value As String)
m_temppfad = Value
End Set
End Property
'''<summary>Interne Variable für das Property Mailserver</summary>
Dim m_mailserver As String
'''<summary>SMTP-Mailserver für den Journalversand</summary>
Property Mailserver() As String
Get
Return m_mailserver
End Get
Set(ByVal Value As String)
m_mailserver = Value
End Set
End Property
Dim m_mailabsender As String
Property Mailabsender() As String
Get
Return m_mailabsender
End Get
Set(ByVal Value As String)
m_mailabsender = Value
End Set
End Property
'''<summary>Interne Variable für das Property Journaltimer_time</summary>
Dim m_journaltimer_time As Integer = 60 * 60 * 1000
'''<summary>Journaltimer-Zeit in Milisekunden</summary>
Property JournalTimer_Time() As Integer
Get
Return m_journaltimer_time
End Get
Set(ByVal Value As Integer)
m_journaltimer_time = Value
End Set
End Property
'''<summary>Interne Variable für das Property DeleteOriginalfiles</summary>
Dim m_deleteoriginalfiles As Integer = 0
'''<summary>DeleteOriginalfiles</summary>
Property DeleteOriginalfiles() As Integer
Get
Return m_deleteoriginalfiles
End Get
Set(ByVal Value As Integer)
m_deleteoriginalfiles = Value
End Set
End Property
'''<summary>Interne Variable für das Property GSF Config File Path</summary>
Dim m_gsf_ConfigPath As String
'''<summary>gsf ConfigPath</summary>
Property Prop_gsf_ConfigPath() As String
Get
Return m_gsf_ConfigPath
End Get
Set(ByVal Value As String)
m_gsf_ConfigPath = Value
End Set
End Property
'''<summary>Interne Variable für das Property GSF Timer Intervall</summary>
Dim m_gsf_TimerInterval As Integer = 0
'''<summary>gsf Timer Interval</summary>
Property Prop_gsf_TimerInterval() As Integer
Get
Return m_gsf_TimerInterval
End Get
Set(ByVal Value As Integer)
m_gsf_TimerInterval = Value
End Set
End Property
'''<summary>Interne Variable für das Property GSF DateiEndung</summary>
Dim m_gsf_ConfigDateiendung As String
'''<summary>gsf DateiEndung</summary>
Property Prop_gsf_ConfigDateiendung() As String
Get
Return m_gsf_ConfigDateiendung
End Get
Set(ByVal Value As String)
m_gsf_ConfigDateiendung = Value
End Set
End Property
#End Region
'''<summary>Laden der Parameterdaten aus parameters.cfg</summary>
'''<remarks>Die Funktion lädt für die Anwendung die notwendigen Parameter aus der
'''Datei "Parameters.cfg"</remarks>
'''<returns>True im OK-Fall
'''False im Fehlerfall</returns>
Public Function Loadparameters() As Boolean
Try
oread = System.IO.File.OpenText(DivFnkt.ApplicationPath + "parameters.cfg")
'oread = ofile.OpenText(args(1) + "parameters.cfg")
Me.ApplicationID = ParamValue(oread.ReadLine)
Me.Inputverzeichnis = ParamValue(oread.ReadLine)
If Right(Me.Inputverzeichnis, 1) <> "\" Then Me.Inputverzeichnis = Me.Inputverzeichnis + "\"
Me.TempPfad = ParamValue(oread.ReadLine)
Me.JournalTimer_Time = ParamValue(oread.ReadLine) * 60 * 1000
Me.Mailabsender = ParamValue(oread.ReadLine)
Me.Mailserver = ParamValue(oread.ReadLine)
Me.DeleteOriginalfiles = ParamValue(oread.ReadLine)
Me.MailAdresseOK = ParamValue(oread.ReadLine)
Me.MailAdresseNOK = ParamValue(oread.ReadLine)
Me.Prop_gsf_ConfigPath = ParamValue(oread.ReadLine)
Me.Prop_gsf_TimerInterval = ParamValue(oread.ReadLine) * 60 * 1000
Me.Prop_gsf_ConfigDateiendung = ParamValue(oread.ReadLine)
oread.Close()
Me.Meldung = "Parameter auslesen i.O."
Return True
Catch ex As Exception
Me.Meldung = ex.Message
Return False
End Try
End Function
'''<summary>Parameterbezeichnung und Parameterwert trennen</summary>
'''<param name="sinput">Inputstring mit Parameterbezeichnung und
'''Parameterwert</param>
'''<returns>Parameterwert als String</returns>
Private Function ParamValue(ByVal sinput As String) As String
Dim splitter As String()
splitter = Split(sinput, "=")
ParamValue = splitter(1)
End Function
End Class