63 lines
2.1 KiB
VB.net
63 lines
2.1 KiB
VB.net
Imports System.IO
|
|
Imports DigitalData.Modules.Config
|
|
Imports DigitalData.Modules.Logging
|
|
|
|
Public Class frmMain
|
|
Public LogConfig As LogConfig
|
|
Public Logger As Logger
|
|
Public Config As ConfigManager(Of DummyConfig)
|
|
|
|
|
|
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
LogConfig = New LogConfig(LogConfig.PathType.AppData) With {
|
|
.Debug = True
|
|
}
|
|
|
|
Dim productName As String = My.Application.Info.ProductName
|
|
Dim companyName As String = My.Application.Info.CompanyName
|
|
|
|
Dim appDataDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
|
|
Dim basePath = Path.Combine(appDataDir, companyName, productName, "Log")
|
|
|
|
Logger = LogConfig.GetLogger()
|
|
Logger.Info("Initializing Config")
|
|
Logger.Info("Logging Path: {0}", basePath)
|
|
Logger.Info("UserConfig.xml Path: {0}", Application.UserAppDataPath)
|
|
Logger.Info("ComputerConfig.xml Path: {0}", Application.CommonAppDataPath)
|
|
|
|
Config = New ConfigManager(Of DummyConfig)(LogConfig, Application.UserAppDataPath, Application.CommonAppDataPath)
|
|
|
|
RefreshLogs()
|
|
End Sub
|
|
|
|
Private Sub RefreshLogs()
|
|
GridControlLogs.DataSource = LogConfig.Logs
|
|
End Sub
|
|
|
|
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnRefresh.Click
|
|
RefreshLogs()
|
|
End Sub
|
|
|
|
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
|
|
Try
|
|
Logger.Info("Value of TestSetting is: {0}", Config.Config.SomeSetting)
|
|
TextBox1.Text = Config.Config.SomeSetting
|
|
RefreshLogs()
|
|
Catch ex As Exception
|
|
Logger.Error(ex)
|
|
RefreshLogs()
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
|
|
Try
|
|
Config.Config.SomeSetting = TextBox1.Text
|
|
Config.Save()
|
|
RefreshLogs()
|
|
Catch ex As Exception
|
|
Logger.Error(ex)
|
|
RefreshLogs()
|
|
End Try
|
|
End Sub
|
|
End Class
|