commit 9257927aa705e12a4d78ada3f50995b3aa5a847e Author: frauseo Date: Sat May 30 19:58:21 2020 +0200 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..76c8375 --- /dev/null +++ b/.gitignore @@ -0,0 +1,355 @@ + +# Created by https://www.gitignore.io/api/csharp +# Edit at https://www.gitignore.io/?templates=csharp + +### Csharp ### +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# End of https://www.gitignore.io/api/csharp \ No newline at end of file diff --git a/LoggingClient.sln b/LoggingClient.sln new file mode 100644 index 0000000..df4529f --- /dev/null +++ b/LoggingClient.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29806.167 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoggingClient", "LoggingClient\LoggingClient.csproj", "{F29F34C6-BCAE-48BE-A698-845B1E45DE96}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F29F34C6-BCAE-48BE-A698-845B1E45DE96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F29F34C6-BCAE-48BE-A698-845B1E45DE96}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F29F34C6-BCAE-48BE-A698-845B1E45DE96}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F29F34C6-BCAE-48BE-A698-845B1E45DE96}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {0BD9A3EC-EBC8-48BB-BA13-E0A6DCC7533F} + EndGlobalSection +EndGlobal diff --git a/LoggingClient/LoggingClient.csproj b/LoggingClient/LoggingClient.csproj new file mode 100644 index 0000000..5dbc964 --- /dev/null +++ b/LoggingClient/LoggingClient.csproj @@ -0,0 +1,119 @@ + + + + + Debug + AnyCPU + {F29F34C6-BCAE-48BE-A698-845B1E45DE96} + Library + Properties + LoggingClient + LoggingClient + v4.7.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\BouncyCastle.1.8.3.1\lib\BouncyCastle.Crypto.dll + + + ..\packages\Google.Protobuf.3.6.1\lib\net45\Google.Protobuf.dll + + + ..\packages\K4os.Compression.LZ4.1.1.11\lib\net46\K4os.Compression.LZ4.dll + + + ..\packages\K4os.Compression.LZ4.Streams.1.1.11\lib\net46\K4os.Compression.LZ4.Streams.dll + + + ..\packages\K4os.Hash.xxHash.1.0.6\lib\net46\K4os.Hash.xxHash.dll + + + ..\packages\MySql.Data.8.0.20\lib\net452\MySql.Data.dll + + + + + ..\packages\SSH.NET.2016.1.0\lib\net40\Renci.SshNet.dll + + + + ..\packages\System.Buffers.4.5.0\lib\netstandard2.0\System.Buffers.dll + + + + + + + + + + + ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.6.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + + + + + + + + + + + ..\packages\MySql.Data.8.0.20\lib\net452\Ubiety.Dns.Core.dll + + + + ..\packages\MySql.Data.8.0.20\lib\net452\Zstandard.Net.dll + + + + + + + + + + + + LogView.xaml + + + + + + + + + + Designer + MSBuild:Compile + + + + \ No newline at end of file diff --git a/LoggingClient/Model/LogModel.cs b/LoggingClient/Model/LogModel.cs new file mode 100644 index 0000000..f2e67ed --- /dev/null +++ b/LoggingClient/Model/LogModel.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LoggingClient.Model +{ + public class LogModel + { + public int id { get; set; } + public string pod { get; set; } + public string location { get; set; } + public string hostname { get; set; } + public int severity { get; set; } + public DateTime timestamp { get; set; } + public string message { get; set; } + + public LogModel(int id, string pod, string location, string hostname, int severity, DateTime timestamp, string message) + { + this.id = id; + this.pod = pod; + this.location = location; + this.hostname = hostname; + this.severity = severity; + this.timestamp = timestamp; + this.message = message; + } + } +} diff --git a/LoggingClient/Model/SeverityComboBoxItem.cs b/LoggingClient/Model/SeverityComboBoxItem.cs new file mode 100644 index 0000000..9867ef7 --- /dev/null +++ b/LoggingClient/Model/SeverityComboBoxItem.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; + +namespace LoggingClient.Model +{ + public class SeverityComboBoxItem + { + public int Id { get; set; } + public int Severity { get; set; } + } + +} diff --git a/LoggingClient/Properties/AssemblyInfo.cs b/LoggingClient/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d76fd18 --- /dev/null +++ b/LoggingClient/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("LoggingClient")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("LoggingClient")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("f29f34c6-bcae-48be-a698-845b1e45de96")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/LoggingClient/Validators/IntRangeValidationRule.cs b/LoggingClient/Validators/IntRangeValidationRule.cs new file mode 100644 index 0000000..06470c9 --- /dev/null +++ b/LoggingClient/Validators/IntRangeValidationRule.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Controls; + +namespace LoggingClient.Validators +{ + public class IntRangeValidationRule : ValidationRule + { + private int Min = 1; + private int Max = 3; + + public int MinimumLength + { + get { return Min; } + set { Min = value; } + } + + public int MaximumLength + { + get { return Max; } + set { Max = value; } + } + + public override ValidationResult Validate(object value, + CultureInfo cultureInfo) + { + int parameter = 0; + + try + { + if (((string)value).Length > 0) + { + parameter = Int32.Parse((String)value); + } + } + catch (Exception e) + { + return new ValidationResult(false, "Illegal characters or " + + e.Message); + } + + if ((parameter < this.Min) || (parameter > this.Max)) + { + return new ValidationResult(false, + "Severity must be a number between " + + this.Min + " - " + this.Max + "."); + } + return new ValidationResult(true, null); + } + } +} diff --git a/LoggingClient/Validators/StringRangeValidationRule.cs b/LoggingClient/Validators/StringRangeValidationRule.cs new file mode 100644 index 0000000..098285c --- /dev/null +++ b/LoggingClient/Validators/StringRangeValidationRule.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Controls; + +namespace LoggingClient.Validators +{ + public class StringRangeValidationRule : ValidationRule + { + private int _minimumLength = 3; + private int _maximumLength = 255; + + public int MinimumLength + { + get { return _minimumLength; } + set { _minimumLength = value; } + } + + public int MaximumLength + { + get { return _maximumLength; } + set { _maximumLength = value; } + } + + public string ErrorMessage { get; set; } + + public override ValidationResult Validate(object value, + CultureInfo cultureInfo) + { + ValidationResult result = new ValidationResult(true, null); + string inputString = (value ?? string.Empty).ToString(); + if (inputString.Length < this.MinimumLength || + (this.MaximumLength > 0 && + inputString.Length > this.MaximumLength)) + { + result = new ValidationResult(false, this.ErrorMessage); + } + return result; + } + } +} diff --git a/LoggingClient/ViewModel/Commands/RelayCommand.cs b/LoggingClient/ViewModel/Commands/RelayCommand.cs new file mode 100644 index 0000000..dc670c3 --- /dev/null +++ b/LoggingClient/ViewModel/Commands/RelayCommand.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; + +namespace LoggingClient.ViewModel.Commands +{ + public class RelayCommand : ICommand + { + private readonly Predicate _canExecute; + private readonly Action _execute; + + public RelayCommand(Action execute) + : this(execute, null) + { + _execute = execute; + } + + public RelayCommand(Action execute, Predicate canExecute) + { + if (execute == null) + { + throw new ArgumentNullException("execute"); + } + _execute = execute; + _canExecute = canExecute; + } + + public bool CanExecute(object parameter) + { + return _canExecute == null || _canExecute((T)parameter); + } + + public void Execute(object parameter) + { + _execute((T)parameter); + } + + public event EventHandler CanExecuteChanged + { + add { CommandManager.RequerySuggested += value; } + remove { CommandManager.RequerySuggested -= value; } + } + } + + public class RelayCommand : ICommand + { + private readonly Predicate _canExecute; + private readonly Action _execute; + + public RelayCommand(Action execute) + : this(execute, null) + { + _execute = execute; + } + + public RelayCommand(Action execute, Predicate canExecute) + { + if (execute == null) + { + throw new ArgumentNullException("execute"); + } + _execute = execute; + _canExecute = canExecute; + } + + public bool CanExecute(object parameter) + { + return _canExecute == null || _canExecute(parameter); + } + + public void Execute(object parameter) + { + _execute(parameter); + } + + // Ensures WPF commanding infrastructure asks all RelayCommand objects whether their + // associated views should be enabled whenever a command is invoked + public event EventHandler CanExecuteChanged + { + add + { + CommandManager.RequerySuggested += value; + CanExecuteChangedInternal += value; + } + remove + { + CommandManager.RequerySuggested -= value; + CanExecuteChangedInternal -= value; + } + } + + private event EventHandler CanExecuteChangedInternal; + + public void RaiseCanExecuteChanged() + { + //CanExecuteChangedInternal.Raise(this); + } + } + +} + diff --git a/LoggingClient/ViewModel/LogViewModel.cs b/LoggingClient/ViewModel/LogViewModel.cs new file mode 100644 index 0000000..58e98ab --- /dev/null +++ b/LoggingClient/ViewModel/LogViewModel.cs @@ -0,0 +1,229 @@ +using System; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Data; +using System.Windows; +using System.Windows.Input; +using MySql.Data.MySqlClient; +using LoggingClient.Model; +using LoggingClient.ViewModel.Commands; + +namespace LoggingClient.ViewModel +{ + public class LogViewModel : INotifyPropertyChanged + { + private string _txtConnectionString; + private string _enterPod; + private string _enterHostname; + private int _enterSeverity; + private string _enterMessage; + + private ICommand _btnLoadDataClick; + private ICommand _btnConfirmdataClick; + private ICommand _btnAdddataClick; + + public ObservableCollection Logs { get; set; } + public ObservableCollection SeverityComboBox { get; set; } + + public LogViewModel() + { + TxtConnectionString = "Server=localhost;Database=DATABASENAME;Uid=root;Pwd=MySQLPASSWORD;"; + _enterSeverity = 1; + + Logs = new ObservableCollection(); + SeverityComboBox = new ObservableCollection(){ + new SeverityComboBoxItem(){Id=1, Severity= 1}, + new SeverityComboBoxItem(){Id=2, Severity= 2}, + new SeverityComboBoxItem(){Id=3, Severity= 3} + }; + } + public LogModel MySelectedItem { get; set; } + public event PropertyChangedEventHandler PropertyChanged; + public SeverityComboBoxItem SetSeverity { get; set; } + + public string TxtConnectionString + { + get => _txtConnectionString; + set + { + _txtConnectionString = value; + OnPropertyChanged(nameof(TxtConnectionString)); + } + } + public string EnterPod + { + get => _enterPod; + set + { + _enterPod = value; + OnPropertyChanged(nameof(EnterPod)); + } + } + + public string EnterHostname + { + get => _enterHostname; + set + { + _enterHostname = value; + OnPropertyChanged(nameof(EnterHostname)); + } + } + public int EnterSeverity + { + get => _enterSeverity; + set + { + _enterSeverity = value; + OnPropertyChanged(nameof(EnterSeverity)); + } + } + public string EnterMessage + { + get => _enterMessage; + set + { + _enterMessage = value; + OnPropertyChanged(nameof(EnterMessage)); + } + } + + public ICommand BtnLoadDataClick + { + get + { + return _btnLoadDataClick ?? (_btnLoadDataClick = new RelayCommand( + x => + { + BtnLoadData_Click(); + })); + } + } + public ICommand BtnAddDataClick + { + get + { + return _btnAdddataClick ?? (_btnAdddataClick = new RelayCommand( + x => + { + BtnAdd_Click(); + })); + } + } + public ICommand BtnConfirmDataClick + { + get + { + return _btnConfirmdataClick ?? (_btnConfirmdataClick = new RelayCommand( + x => + { + BtnLogClear_Click(); + })); + } + } + public void BtnLoadData_Click() + { + try + { + LoadData(); + } + catch (Exception ex) + { + MessageBox.Show("Error occurred: " + ex.Message); + } + } + private void LoadData() + { + try + { + Logs.Clear(); + using (var conn = new MySqlConnection(TxtConnectionString)) + { + conn.Open(); + using (var cmd = new MySqlCommand("SELECT id, pod, location, hostname, severity, timestamp, message FROM v_logentries ORDER BY timestamp", conn)) + { + var reader = cmd.ExecuteReader(); + while (reader.Read()) + { + // ISDBNull Check because location can be NULL in Database + var location = ""; + if (!reader.IsDBNull(reader.GetOrdinal("location"))) + { + location = reader.GetString("location"); + } + Logs.Add(new LogModel( + reader.GetInt32("id"), + reader.GetString("pod"), + location, + reader.GetString("hostname"), + reader.GetInt32("severity"), + reader.GetDateTime("timestamp"), + reader.GetString("message") + )); + } + } + conn.Close(); + } + } + catch (Exception ex) + { + MessageBox.Show("Error occurred: " + ex.Message); + } + + } + + private void BtnLogClear_Click() + { + if (MySelectedItem == null) return; + try + { + using (var conn = new MySqlConnection(TxtConnectionString)) + { + conn.Open(); + using (var cmd = conn.CreateCommand()) + { + cmd.CommandText = "LogClear"; + cmd.CommandType = CommandType.StoredProcedure; + cmd.Parameters.AddWithValue("_logentries_id", MySelectedItem.id); + cmd.ExecuteNonQuery(); + } + } + LoadData(); + } + catch (MySqlException ex) + { + MessageBox.Show(ex.ToString()); + } + } + private void BtnAdd_Click() + { + try + { + using (var conn = new MySqlConnection(TxtConnectionString)) + { + using (MySqlCommand cmd = new MySqlCommand("LogMessageAdd", conn)) + { + conn.Open(); + cmd.CommandType = CommandType.StoredProcedure; + + cmd.Parameters.Add("@i_pod", MySqlDbType.String).Value = EnterPod; + cmd.Parameters.Add("@i_hostname", MySqlDbType.String).Value = EnterHostname; + cmd.Parameters.Add("@i_severity", MySqlDbType.Int32).Value = EnterSeverity; + cmd.Parameters.Add("@i_message", MySqlDbType.String).Value = EnterMessage; + + cmd.ExecuteNonQuery(); + } + LoadData(); + } + } + catch (Exception ex) + { + MessageBox.Show("Error occurred: " + ex.Message); + } + } + private void OnPropertyChanged(string propertyName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/LoggingClient/Views/LogView.xaml b/LoggingClient/Views/LogView.xaml new file mode 100644 index 0000000..e6d0773 --- /dev/null +++ b/LoggingClient/Views/LogView.xaml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + diff --git a/LoggingClient/Views/LogView.xaml.cs b/LoggingClient/Views/LogView.xaml.cs new file mode 100644 index 0000000..9d6c361 --- /dev/null +++ b/LoggingClient/Views/LogView.xaml.cs @@ -0,0 +1,17 @@ +using LoggingClient.ViewModel; +using System.Windows.Controls; + +namespace LoggingClient.Views +{ + /// + /// Interaction logic for LogView.xaml + /// + public partial class LogView : UserControl + { + public LogView() + { + InitializeComponent(); + DataContext = new LogViewModel(); + } + } +} diff --git a/LoggingClient/app.config b/LoggingClient/app.config new file mode 100644 index 0000000..d1bd7d0 --- /dev/null +++ b/LoggingClient/app.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/LoggingClient/packages.config b/LoggingClient/packages.config new file mode 100644 index 0000000..61f619c --- /dev/null +++ b/LoggingClient/packages.config @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file