15-08-2023
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
Imports System.ComponentModel
|
||||
Imports System.Runtime.Remoting.Messaging
|
||||
Imports DevExpress.XtraEditors.ViewInfo
|
||||
Imports DigitalData.Modules.Config
|
||||
Imports DigitalData.Modules.Database
|
||||
@@ -11,6 +12,25 @@ Partial Public Class frmMain
|
||||
Private Database As MSSQLServer
|
||||
Private Sync As ISync
|
||||
|
||||
Private FilesProcessed As Integer = 0
|
||||
Private ErrorsOccurred As Integer = 0
|
||||
|
||||
Public Enum LogLevel
|
||||
Info
|
||||
Warning
|
||||
[Error]
|
||||
End Enum
|
||||
|
||||
Private Class LogLine
|
||||
Public Message As String
|
||||
Public Level As LogLevel
|
||||
Public CreatedWhen As Date = Now
|
||||
|
||||
Public Overrides Function ToString() As String
|
||||
Return $"{CreatedWhen.ToShortDateString} {CreatedWhen.ToShortTimeString} {Message}"
|
||||
End Function
|
||||
End Class
|
||||
|
||||
Public Sub New()
|
||||
InitializeComponent()
|
||||
End Sub
|
||||
@@ -31,6 +51,7 @@ Partial Public Class frmMain
|
||||
|
||||
' Load Form Title from Module
|
||||
Text = Sync.Name
|
||||
TrayIcon.Text = Sync.Name
|
||||
|
||||
If Sync Is Nothing Then
|
||||
AddWarnEntry("ActiveModule '{0}' is not implemented!", ConfigManager.Config.ActiveModule)
|
||||
@@ -60,7 +81,7 @@ Partial Public Class frmMain
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
AddWarnEntry($"Error while loading the application: {ex.Message}")
|
||||
AddErrorEntry($"Error while loading the application: {ex.Message}")
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -128,17 +149,43 @@ Partial Public Class frmMain
|
||||
|
||||
Private Sub AddInfoEntry(pMessage As String, ParamArray pArgs As Object())
|
||||
Logger.Info(pMessage, pArgs)
|
||||
ListBoxControl1.Items.Add(Now & " " & String.Format(pMessage, pArgs))
|
||||
|
||||
Dim oItem = New LogLine With {
|
||||
.Message = String.Format(pMessage, pArgs),
|
||||
.Level = LogLevel.Info
|
||||
}
|
||||
|
||||
ListBoxControl1.Items.Add(oItem)
|
||||
ListBoxControl1.MakeItemVisible(ListBoxControl1.Items.Count - 1)
|
||||
End Sub
|
||||
|
||||
Private Sub AddWarnEntry(pMessage As String, ParamArray pArgs As Object())
|
||||
Logger.Info(pMessage, pArgs)
|
||||
ListBoxControl1.Items.Add(String.Format(pMessage, pArgs))
|
||||
|
||||
Dim oItem = New LogLine With {
|
||||
.Message = String.Format(pMessage, pArgs),
|
||||
.Level = LogLevel.Warning
|
||||
}
|
||||
|
||||
ListBoxControl1.Items.Add(oItem)
|
||||
End Sub
|
||||
|
||||
Private Sub AddErrorEntry(pMessage As String, ParamArray pArgs As Object())
|
||||
Logger.Info(pMessage, pArgs)
|
||||
|
||||
Dim oItem = New LogLine With {
|
||||
.Message = String.Format(pMessage, pArgs),
|
||||
.Level = LogLevel.Error
|
||||
}
|
||||
|
||||
ListBoxControl1.Items.Add(oItem)
|
||||
End Sub
|
||||
|
||||
Private Sub AddDivider()
|
||||
ListBoxControl1.Items.Add("=====================================")
|
||||
ListBoxControl1.Items.Add(New LogLine With {
|
||||
.Message = "-------------------------------------",
|
||||
.Level = LogLevel.Info
|
||||
})
|
||||
End Sub
|
||||
|
||||
Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick
|
||||
@@ -185,4 +232,17 @@ Partial Public Class frmMain
|
||||
Await Sync.Run()
|
||||
btnForceSync.Enabled = True
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Private Sub ListBoxControl1_DrawItem(sender As Object, e As DevExpress.XtraEditors.ListBoxDrawItemEventArgs) Handles ListBoxControl1.DrawItem
|
||||
Dim oItem As LogLine = DirectCast(e.Item, LogLine)
|
||||
|
||||
Select Case oItem.Level
|
||||
Case LogLevel.Warning
|
||||
e.Appearance.ForeColor = Color.DarkOrange
|
||||
e.Appearance.FontStyleDelta = FontStyle.Bold
|
||||
Case LogLevel.Error
|
||||
e.Appearance.ForeColor = Color.DarkRed
|
||||
e.Appearance.FontStyleDelta = FontStyle.Bold
|
||||
End Select
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user