Public Class Form1 Inherits System.Windows.Forms.Form Private m_Log As bms.Logging Private m_AppName As String #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents start As System.Windows.Forms.Button Friend WithEvents stopp As System.Windows.Forms.Button Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents log As System.Windows.Forms.Button Friend WithEvents logerror As System.Windows.Forms.Button Friend WithEvents startTimer As System.Windows.Forms.Timer Friend WithEvents stoppTimer As System.Windows.Forms.Timer Friend WithEvents logTimer As System.Windows.Forms.Timer Friend WithEvents lblError As System.Windows.Forms.Label Friend WithEvents btnSendAsMail As System.Windows.Forms.Button Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container Me.start = New System.Windows.Forms.Button Me.stopp = New System.Windows.Forms.Button Me.TextBox1 = New System.Windows.Forms.TextBox Me.log = New System.Windows.Forms.Button Me.logerror = New System.Windows.Forms.Button Me.startTimer = New System.Windows.Forms.Timer(Me.components) Me.stoppTimer = New System.Windows.Forms.Timer(Me.components) Me.logTimer = New System.Windows.Forms.Timer(Me.components) Me.lblError = New System.Windows.Forms.Label Me.btnSendAsMail = New System.Windows.Forms.Button Me.SuspendLayout() ' 'start ' Me.start.Location = New System.Drawing.Point(40, 24) Me.start.Name = "start" Me.start.TabIndex = 0 Me.start.Text = "start" ' 'stopp ' Me.stopp.Location = New System.Drawing.Point(144, 24) Me.stopp.Name = "stopp" Me.stopp.TabIndex = 1 Me.stopp.Text = "stopp" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(40, 72) Me.TextBox1.Multiline = True Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(184, 144) Me.TextBox1.TabIndex = 2 Me.TextBox1.Text = "" ' 'log ' Me.log.Location = New System.Drawing.Point(248, 72) Me.log.Name = "log" Me.log.TabIndex = 3 Me.log.Text = "log" ' 'logerror ' Me.logerror.Location = New System.Drawing.Point(248, 112) Me.logerror.Name = "logerror" Me.logerror.TabIndex = 4 Me.logerror.Text = "log as error" ' 'startTimer ' ' 'stoppTimer ' ' 'logTimer ' ' 'lblError ' Me.lblError.Location = New System.Drawing.Point(240, 152) Me.lblError.Name = "lblError" Me.lblError.Size = New System.Drawing.Size(208, 104) Me.lblError.TabIndex = 5 Me.lblError.Text = "Errors are shown here..." ' 'btnSendAsMail ' Me.btnSendAsMail.Location = New System.Drawing.Point(336, 112) Me.btnSendAsMail.Name = "btnSendAsMail" Me.btnSendAsMail.TabIndex = 6 Me.btnSendAsMail.Text = "SendAsMail" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(464, 266) Me.Controls.Add(Me.btnSendAsMail) Me.Controls.Add(Me.lblError) Me.Controls.Add(Me.logerror) Me.Controls.Add(Me.log) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.stopp) Me.Controls.Add(Me.start) Me.Name = "Form1" Me.Text = "proggy 01" Me.ResumeLayout(False) End Sub #End Region Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try ' Dim appId As Integer ' Dim random As New Random(DateTime.Now.Millisecond) ' Randomize() ' appId = random.Next ' If appId.ToString().Length = 1 Then ' m_AppName = "Test Proggy 0" & appId.ToString ' Else ' m_AppName = "Test Proggy " & appId.ToString ' End If ' startTimer.Interval = random.Next( ' logTimer.Interval = CDbl(xmlDoc.SelectSingleNode("/root/config/LogTimer").InnerText) ' stoppTimer.Interval = CDbl(xmlDoc.SelectSingleNode("/root/config/StoppTimer").InnerText) ' appId = CInt(xmlDoc.SelectSingleNode("/root/config/AppId").InnerText) ' m_AppName = xmlDoc.SelectSingleNode("/root/config/AppName").InnerText ' startTimer.Enabled = True ' logTimer.Enabled = True ' stoppTimer.Enabled = True 'm_Log = New bms.Logging(1, 2) m_Log = New bms.Logging(2, Common.Common.JobType.WatchJob) 'm_Log.InitLogging(1, 2) ' lblError.Text = "TestApp: " & m_AppName & " Id: " & appId.ToString() + Environment.NewLine ' lblError.Text += "Start: " & startTimer.Interval & Environment.NewLine ' lblError.Text += "Log: " & logTimer.Interval & Environment.NewLine ' lblError.Text += "Stopp: " & stoppTimer.Interval Catch ex As Exception MsgBox(ex.Message) Close() ' 'lblError.Text = ex.Message ' 'System.Threading.Thread.CurrentThread.Sleep(10000) ' Dim fs As New System.IO.FileStream("D:\BMS Test Framework\Logs\" & m_AppName & ".txt", IO.FileMode.Append, IO.FileAccess.Write) ' Dim writer As New System.IO.StreamWriter(fs) ' writer.BaseStream.Seek(0, IO.SeekOrigin.End) ' writer.WriteLine("Datum: " & DateTime.Now) ' writer.WriteLine("Meldung: " & ex.Message) ' writer.WriteLine("Stack: " & ex.StackTrace) ' writer.WriteLine("-------------------------------------------") ' writer.Close() ' Close() End Try End Sub Private Sub start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles start.Click m_Log.Start() End Sub Private Sub stopp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles stopp.Click m_Log.Ende() End Sub Private Sub log_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles log.Click m_Log.Log(TextBox1.Text) End Sub Private Sub logerror_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles logerror.Click m_Log.Log(TextBox1.Text, 3) End Sub Private Sub startTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles startTimer.Tick m_Log.Start() End Sub Private Sub logTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles logTimer.Tick m_Log.Log("Normaler Log-Eintrag von " & m_AppName & " um " & DateTime.Now) m_Log.Log("ERROR Log-Eintrag von " & m_AppName & " um " & DateTime.Now, 3) End Sub Private Sub stoppTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles stoppTimer.Tick m_Log.Ende() Close() End Sub Private Sub btnSendAsMail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSendAsMail.Click Dim common As New Common.Common common.SendMail("rsteimen@zubler.ch", "hans", "worscht") End Sub End Class