diff --git a/LoggingClient/LoggingClient.sln b/LoggingClient/LoggingClient.sln new file mode 100644 index 0000000..19d7900 --- /dev/null +++ b/LoggingClient/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", "{2622C2FC-3522-4D6F-B021-F63A243E77F1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2622C2FC-3522-4D6F-B021-F63A243E77F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2622C2FC-3522-4D6F-B021-F63A243E77F1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2622C2FC-3522-4D6F-B021-F63A243E77F1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2622C2FC-3522-4D6F-B021-F63A243E77F1}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8C37463B-EC8C-4A07-A780-29B77120BD68} + EndGlobalSection +EndGlobal diff --git a/LoggingClient/LoggingClient/App.config b/LoggingClient/LoggingClient/App.config new file mode 100644 index 0000000..920b09d --- /dev/null +++ b/LoggingClient/LoggingClient/App.config @@ -0,0 +1,15 @@ + + + + +
+ + + + + + + + + + \ No newline at end of file diff --git a/LoggingClient/LoggingClient/App.xaml b/LoggingClient/LoggingClient/App.xaml new file mode 100644 index 0000000..bba60b0 --- /dev/null +++ b/LoggingClient/LoggingClient/App.xaml @@ -0,0 +1,36 @@ + + + + + diff --git a/LoggingClient/LoggingClient/App.xaml.cs b/LoggingClient/LoggingClient/App.xaml.cs new file mode 100644 index 0000000..87019bc --- /dev/null +++ b/LoggingClient/LoggingClient/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace WpfControlNugget +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/LoggingClient/LoggingClient/LoggingClient.csproj b/LoggingClient/LoggingClient/LoggingClient.csproj new file mode 100644 index 0000000..64bde42 --- /dev/null +++ b/LoggingClient/LoggingClient/LoggingClient.csproj @@ -0,0 +1,135 @@ + + + + + Debug + AnyCPU + {2622C2FC-3522-4D6F-B021-F63A243E77F1} + WinExe + LoggingClient + LoggingClient + v4.6.1 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + 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\MySql.Data.8.0.16\lib\net452\MySql.Data.dll + + + + + + + + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + + + + + LogView.xaml + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + + + MainWindow.xaml + Code + + + Designer + MSBuild:Compile + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + Designer + + + + + \ No newline at end of file diff --git a/LoggingClient/LoggingClient/MainWindow.xaml b/LoggingClient/LoggingClient/MainWindow.xaml new file mode 100644 index 0000000..56acf2f --- /dev/null +++ b/LoggingClient/LoggingClient/MainWindow.xaml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/LoggingClient/LoggingClient/MainWindow.xaml.cs b/LoggingClient/LoggingClient/MainWindow.xaml.cs new file mode 100644 index 0000000..f85a487 --- /dev/null +++ b/LoggingClient/LoggingClient/MainWindow.xaml.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Data; +using MySql.Data.MySqlClient; +using System.Configuration; + +namespace LoggingClient +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/LoggingClient/LoggingClient/Model/LogModel.cs b/LoggingClient/LoggingClient/Model/LogModel.cs new file mode 100644 index 0000000..f2e67ed --- /dev/null +++ b/LoggingClient/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/LoggingClient/Model/SeverityComboBoxItem.cs b/LoggingClient/LoggingClient/Model/SeverityComboBoxItem.cs new file mode 100644 index 0000000..9867ef7 --- /dev/null +++ b/LoggingClient/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/LoggingClient/Properties/AssemblyInfo.cs b/LoggingClient/LoggingClient/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..74da76c --- /dev/null +++ b/LoggingClient/LoggingClient/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// 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)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// 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/LoggingClient/Properties/Resources.Designer.cs b/LoggingClient/LoggingClient/Properties/Resources.Designer.cs new file mode 100644 index 0000000..1f1cf82 --- /dev/null +++ b/LoggingClient/LoggingClient/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WpfControlNugget.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WpfControlNugget.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/LoggingClient/LoggingClient/Properties/Resources.resx b/LoggingClient/LoggingClient/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/LoggingClient/LoggingClient/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/LoggingClient/LoggingClient/Properties/Settings.Designer.cs b/LoggingClient/LoggingClient/Properties/Settings.Designer.cs new file mode 100644 index 0000000..28eab21 --- /dev/null +++ b/LoggingClient/LoggingClient/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WpfControlNugget.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/LoggingClient/LoggingClient/Properties/Settings.settings b/LoggingClient/LoggingClient/Properties/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/LoggingClient/LoggingClient/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/LoggingClient/LoggingClient/Validators/IntRangeValidationRule.cs b/LoggingClient/LoggingClient/Validators/IntRangeValidationRule.cs new file mode 100644 index 0000000..06470c9 --- /dev/null +++ b/LoggingClient/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/LoggingClient/Validators/StringRangeValidationRule.cs b/LoggingClient/LoggingClient/Validators/StringRangeValidationRule.cs new file mode 100644 index 0000000..098285c --- /dev/null +++ b/LoggingClient/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/LoggingClient/ViewModel/Commands/RelayCommand.cs b/LoggingClient/LoggingClient/ViewModel/Commands/RelayCommand.cs new file mode 100644 index 0000000..dc670c3 --- /dev/null +++ b/LoggingClient/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/LoggingClient/ViewModel/LogViewModel.cs b/LoggingClient/LoggingClient/ViewModel/LogViewModel.cs new file mode 100644 index 0000000..67dac29 --- /dev/null +++ b/LoggingClient/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=inventarisierungsloesung;Uid=root;Pwd=MySQLPassword1234!;"; + _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/LoggingClient/Views/LogView.xaml b/LoggingClient/LoggingClient/Views/LogView.xaml new file mode 100644 index 0000000..9c65790 --- /dev/null +++ b/LoggingClient/LoggingClient/Views/LogView.xaml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/LoggingClient/LoggingClient/Views/LogView.xaml.cs b/LoggingClient/LoggingClient/Views/LogView.xaml.cs new file mode 100644 index 0000000..1a560fa --- /dev/null +++ b/LoggingClient/LoggingClient/Views/LogView.xaml.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Data; +using MySql.Data.MySqlClient; +using System.Configuration; +using System.Security.Cryptography.X509Certificates; +using LoggingClient.ViewModel; + +namespace LoggingClient.Views +{ + public partial class LogView : UserControl + { + public LogView() + { + InitializeComponent(); + DataContext = new LogViewModel(); + } + } +} + + diff --git a/LoggingClient/LoggingClient/packages.config b/LoggingClient/LoggingClient/packages.config new file mode 100644 index 0000000..a1ada4f --- /dev/null +++ b/LoggingClient/LoggingClient/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file