From e1ce5a851b8511f4e937119aa23030606fd9360d Mon Sep 17 00:00:00 2001 From: frauseo Date: Sat, 23 May 2020 17:09:13 +0200 Subject: [PATCH 1/6] create solution --- LoggingClient/LoggingClient.sln | 25 ++++ .../LoggingClient/LoggingClient.csproj | 103 +++++++++++++++ .../LoggingClient/Properties/AssemblyInfo.cs | 55 ++++++++ .../Properties/Resources.Designer.cs | 62 ++++++++++ .../LoggingClient/Properties/Resources.resx | 117 ++++++++++++++++++ .../Properties/Settings.Designer.cs | 30 +++++ .../Properties/Settings.settings | 7 ++ LoggingClient/LoggingClient/UserControl1.xaml | 12 ++ .../LoggingClient/UserControl1.xaml.cs | 28 +++++ 9 files changed, 439 insertions(+) create mode 100644 LoggingClient/LoggingClient.sln create mode 100644 LoggingClient/LoggingClient/LoggingClient.csproj create mode 100644 LoggingClient/LoggingClient/Properties/AssemblyInfo.cs create mode 100644 LoggingClient/LoggingClient/Properties/Resources.Designer.cs create mode 100644 LoggingClient/LoggingClient/Properties/Resources.resx create mode 100644 LoggingClient/LoggingClient/Properties/Settings.Designer.cs create mode 100644 LoggingClient/LoggingClient/Properties/Settings.settings create mode 100644 LoggingClient/LoggingClient/UserControl1.xaml create mode 100644 LoggingClient/LoggingClient/UserControl1.xaml.cs 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/LoggingClient.csproj b/LoggingClient/LoggingClient/LoggingClient.csproj new file mode 100644 index 0000000..39a9a88 --- /dev/null +++ b/LoggingClient/LoggingClient/LoggingClient.csproj @@ -0,0 +1,103 @@ + + + + + Debug + AnyCPU + {2622c2fc-3522-4d6f-b021-f63a243e77f1} + library + LoggingClient + LoggingClient + v4.7.2 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + 4.0 + + + + + + + + + + + + MSBuild:Compile + Designer + + + UserControl1.xaml + Code + + + + + + Code + + + + True + True + Resources.resx + + + + True + Settings.settings + True + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + diff --git a/LoggingClient/LoggingClient/Properties/AssemblyInfo.cs b/LoggingClient/LoggingClient/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ce8ef88 --- /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..5e1b3b1 --- /dev/null +++ b/LoggingClient/LoggingClient/Properties/Resources.Designer.cs @@ -0,0 +1,62 @@ +//------------------------------------------------------------------------------ +// +// 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 LoggingClient.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("LoggingClient.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..ffecec8 --- /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..b83156f --- /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 LoggingClient.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..8f2fd95 --- /dev/null +++ b/LoggingClient/LoggingClient/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/LoggingClient/LoggingClient/UserControl1.xaml b/LoggingClient/LoggingClient/UserControl1.xaml new file mode 100644 index 0000000..3710d05 --- /dev/null +++ b/LoggingClient/LoggingClient/UserControl1.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/LoggingClient/LoggingClient/UserControl1.xaml.cs b/LoggingClient/LoggingClient/UserControl1.xaml.cs new file mode 100644 index 0000000..92ab8d7 --- /dev/null +++ b/LoggingClient/LoggingClient/UserControl1.xaml.cs @@ -0,0 +1,28 @@ +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; + +namespace LoggingClient +{ + /// + /// Interaction logic for UserControl1.xaml + /// + public partial class UserControl1 : UserControl + { + public UserControl1() + { + InitializeComponent(); + } + } +} From f6be9f23f8a65fe87238449c5da687502fdcd1c9 Mon Sep 17 00:00:00 2001 From: frauseo Date: Sat, 23 May 2020 18:54:14 +0200 Subject: [PATCH 2/6] Created GUI; functionality of Load Data and Confirm --- LoggingClient/LoggingClient/App.config | 15 ++ LoggingClient/LoggingClient/App.xaml | 36 +++ LoggingClient/LoggingClient/App.xaml.cs | 17 ++ .../LoggingClient/LoggingClient.csproj | 92 ++++--- LoggingClient/LoggingClient/MainWindow.xaml | 9 + ...serControl1.xaml.cs => MainWindow.xaml.cs} | 59 ++--- LoggingClient/LoggingClient/Model/LogModel.cs | 32 +++ .../Model/SeverityComboBoxItem.cs | 17 ++ .../LoggingClient/Properties/AssemblyInfo.cs | 110 ++++----- .../Properties/Resources.Designer.cs | 133 +++++----- .../LoggingClient/Properties/Resources.resx | 232 +++++++++--------- .../Properties/Settings.Designer.cs | 60 ++--- .../Properties/Settings.settings | 12 +- LoggingClient/LoggingClient/UserControl1.xaml | 12 - .../Validators/IntRangeValidationRule.cs | 55 +++++ .../Validators/StringRangeValidationRule.cs | 44 ++++ .../ViewModel/Commands/RelayCommand.cs | 104 ++++++++ .../LoggingClient/ViewModel/LogViewModel.cs | 221 +++++++++++++++++ .../LoggingClient/Views/LogView.xaml | 100 ++++++++ .../LoggingClient/Views/LogView.xaml.cs | 33 +++ LoggingClient/LoggingClient/packages.config | 6 + 21 files changed, 1060 insertions(+), 339 deletions(-) create mode 100644 LoggingClient/LoggingClient/App.config create mode 100644 LoggingClient/LoggingClient/App.xaml create mode 100644 LoggingClient/LoggingClient/App.xaml.cs create mode 100644 LoggingClient/LoggingClient/MainWindow.xaml rename LoggingClient/LoggingClient/{UserControl1.xaml.cs => MainWindow.xaml.cs} (72%) create mode 100644 LoggingClient/LoggingClient/Model/LogModel.cs create mode 100644 LoggingClient/LoggingClient/Model/SeverityComboBoxItem.cs delete mode 100644 LoggingClient/LoggingClient/UserControl1.xaml create mode 100644 LoggingClient/LoggingClient/Validators/IntRangeValidationRule.cs create mode 100644 LoggingClient/LoggingClient/Validators/StringRangeValidationRule.cs create mode 100644 LoggingClient/LoggingClient/ViewModel/Commands/RelayCommand.cs create mode 100644 LoggingClient/LoggingClient/ViewModel/LogViewModel.cs create mode 100644 LoggingClient/LoggingClient/Views/LogView.xaml create mode 100644 LoggingClient/LoggingClient/Views/LogView.xaml.cs create mode 100644 LoggingClient/LoggingClient/packages.config 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 index 39a9a88..64bde42 100644 --- a/LoggingClient/LoggingClient/LoggingClient.csproj +++ b/LoggingClient/LoggingClient/LoggingClient.csproj @@ -1,21 +1,22 @@ - + Debug AnyCPU - {2622c2fc-3522-4d6f-b021-f63a243e77f1} - library + {2622C2FC-3522-4D6F-B021-F63A243E77F1} + WinExe LoggingClient LoggingClient - v4.7.2 + v4.6.1 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4 + true true - + AnyCPU true full false @@ -25,6 +26,7 @@ 4 + AnyCPU pdbonly true bin\Release\ @@ -32,72 +34,102 @@ 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 + + MSBuild:Compile + Designer + + + + + + + LogView.xaml + + + MSBuild:Compile + Designer - - UserControl1.xaml + + 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/UserControl1.xaml.cs b/LoggingClient/LoggingClient/MainWindow.xaml.cs similarity index 72% rename from LoggingClient/LoggingClient/UserControl1.xaml.cs rename to LoggingClient/LoggingClient/MainWindow.xaml.cs index 92ab8d7..f85a487 100644 --- a/LoggingClient/LoggingClient/UserControl1.xaml.cs +++ b/LoggingClient/LoggingClient/MainWindow.xaml.cs @@ -1,28 +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; - -namespace LoggingClient -{ - /// - /// Interaction logic for UserControl1.xaml - /// - public partial class UserControl1 : UserControl - { - public UserControl1() - { - InitializeComponent(); - } - } -} +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..d8b30a2 --- /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 string severity { get; set; } + public DateTime timestamp { get; set; } + public string message { get; set; } + + public LogModel(int id, string pod, string location, string hostname, string 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 index ce8ef88..221f67d 100644 --- a/LoggingClient/LoggingClient/Properties/AssemblyInfo.cs +++ b/LoggingClient/LoggingClient/Properties/AssemblyInfo.cs @@ -1,55 +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")] +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("WpfControlNugget")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("WpfControlNugget")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[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 index 5e1b3b1..1f1cf82 100644 --- a/LoggingClient/LoggingClient/Properties/Resources.Designer.cs +++ b/LoggingClient/LoggingClient/Properties/Resources.Designer.cs @@ -1,62 +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 LoggingClient.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("LoggingClient.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; - } - } - } -} +//------------------------------------------------------------------------------ +// +// 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 index ffecec8..af7dbeb 100644 --- a/LoggingClient/LoggingClient/Properties/Resources.resx +++ b/LoggingClient/LoggingClient/Properties/Resources.resx @@ -1,117 +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 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 index b83156f..28eab21 100644 --- a/LoggingClient/LoggingClient/Properties/Settings.Designer.cs +++ b/LoggingClient/LoggingClient/Properties/Settings.Designer.cs @@ -1,30 +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 LoggingClient.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; - } - } - } -} +//------------------------------------------------------------------------------ +// +// 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 index 8f2fd95..033d7a5 100644 --- a/LoggingClient/LoggingClient/Properties/Settings.settings +++ b/LoggingClient/LoggingClient/Properties/Settings.settings @@ -1,7 +1,7 @@ - - - - - - + + + + + + \ No newline at end of file diff --git a/LoggingClient/LoggingClient/UserControl1.xaml b/LoggingClient/LoggingClient/UserControl1.xaml deleted file mode 100644 index 3710d05..0000000 --- a/LoggingClient/LoggingClient/UserControl1.xaml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - 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..e379c92 --- /dev/null +++ b/LoggingClient/LoggingClient/ViewModel/LogViewModel.cs @@ -0,0 +1,221 @@ +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=;Uid=root;Pwd=;"; + _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()) + { + Logs.Add(new LogModel( + reader.GetInt32("id"), + reader.GetString("pod"), + reader.GetString("location"), + reader.GetString("hostname"), + reader.GetString("severity"), + reader.GetDateTime("timestamp"), + reader.GetString("message") + )); + } + } + } + } + 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..1dac998 --- /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 From d73dc261e7a21a18b831065793687a2a9c4a9fe0 Mon Sep 17 00:00:00 2001 From: frauseo Date: Tue, 26 May 2020 19:01:13 +0200 Subject: [PATCH 3/6] Uncomented Validators, Add Credentials for Testing --- .../LoggingClient/ViewModel/LogViewModel.cs | 2 +- LoggingClient/LoggingClient/Views/LogView.xaml | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/LoggingClient/LoggingClient/ViewModel/LogViewModel.cs b/LoggingClient/LoggingClient/ViewModel/LogViewModel.cs index e379c92..dfe3321 100644 --- a/LoggingClient/LoggingClient/ViewModel/LogViewModel.cs +++ b/LoggingClient/LoggingClient/ViewModel/LogViewModel.cs @@ -27,7 +27,7 @@ namespace LoggingClient.ViewModel public LogViewModel() { - TxtConnectionString = "Server=localhost;Database=;Uid=root;Pwd=;"; + TxtConnectionString = "Server=localhost;Database=inventarisierungsloesung;Uid=root;Pwd=MySQLPassword1234!;"; _enterSeverity = 1; Logs = new ObservableCollection(); diff --git a/LoggingClient/LoggingClient/Views/LogView.xaml b/LoggingClient/LoggingClient/Views/LogView.xaml index 1dac998..9c65790 100644 --- a/LoggingClient/LoggingClient/Views/LogView.xaml +++ b/LoggingClient/LoggingClient/Views/LogView.xaml @@ -54,39 +54,39 @@ CanUserResizeRows="False"> - + - + - + - + From ba5aef38d02217a1448e5c6bb3956dcdb1eb3879 Mon Sep 17 00:00:00 2001 From: frauseo Date: Tue, 26 May 2020 19:58:51 +0200 Subject: [PATCH 4/6] Corrected Tadatype, Errorhandling of System.Data.SqlTypes.SqlNullValueException --- LoggingClient/LoggingClient/Model/LogModel.cs | 4 ++-- LoggingClient/LoggingClient/ViewModel/LogViewModel.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/LoggingClient/LoggingClient/Model/LogModel.cs b/LoggingClient/LoggingClient/Model/LogModel.cs index d8b30a2..f2e67ed 100644 --- a/LoggingClient/LoggingClient/Model/LogModel.cs +++ b/LoggingClient/LoggingClient/Model/LogModel.cs @@ -14,11 +14,11 @@ namespace LoggingClient.Model public string pod { get; set; } public string location { get; set; } public string hostname { get; set; } - public string severity { 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, string severity, DateTime timestamp, string message) + public LogModel(int id, string pod, string location, string hostname, int severity, DateTime timestamp, string message) { this.id = id; this.pod = pod; diff --git a/LoggingClient/LoggingClient/ViewModel/LogViewModel.cs b/LoggingClient/LoggingClient/ViewModel/LogViewModel.cs index dfe3321..fefa987 100644 --- a/LoggingClient/LoggingClient/ViewModel/LogViewModel.cs +++ b/LoggingClient/LoggingClient/ViewModel/LogViewModel.cs @@ -150,7 +150,7 @@ namespace LoggingClient.ViewModel reader.GetString("pod"), reader.GetString("location"), reader.GetString("hostname"), - reader.GetString("severity"), + reader.GetInt32("severity"), reader.GetDateTime("timestamp"), reader.GetString("message") )); @@ -160,7 +160,7 @@ namespace LoggingClient.ViewModel } catch (Exception ex) { - MessageBox.Show("Error occurred: " + ex.Message); + //MessageBox.Show("Error occurred: " + ex.Message); } } From cd162d1ee6b0bfca59a8dadc4b51ecaaa47c7396 Mon Sep 17 00:00:00 2001 From: frauseo Date: Tue, 26 May 2020 20:21:21 +0200 Subject: [PATCH 5/6] modified: LoggingClient/LoggingClient/LoggingClient.csproj modified: LoggingClient/LoggingClient/Properties/AssemblyInfo.cs --- LoggingClient/LoggingClient/LoggingClient.csproj | 2 +- LoggingClient/LoggingClient/Properties/AssemblyInfo.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/LoggingClient/LoggingClient/LoggingClient.csproj b/LoggingClient/LoggingClient/LoggingClient.csproj index 64bde42..a928bb3 100644 --- a/LoggingClient/LoggingClient/LoggingClient.csproj +++ b/LoggingClient/LoggingClient/LoggingClient.csproj @@ -5,7 +5,7 @@ Debug AnyCPU {2622C2FC-3522-4D6F-B021-F63A243E77F1} - WinExe + Library LoggingClient LoggingClient v4.6.1 diff --git a/LoggingClient/LoggingClient/Properties/AssemblyInfo.cs b/LoggingClient/LoggingClient/Properties/AssemblyInfo.cs index 221f67d..74da76c 100644 --- a/LoggingClient/LoggingClient/Properties/AssemblyInfo.cs +++ b/LoggingClient/LoggingClient/Properties/AssemblyInfo.cs @@ -7,12 +7,12 @@ 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("WpfControlNugget")] +[assembly: AssemblyTitle("LoggingClient")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("WpfControlNugget")] -[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyProduct("LoggingClient")] +[assembly: AssemblyCopyright("Copyright © 2020")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] From 43aa4006138c253c8ca3071994a797f1b03a355c Mon Sep 17 00:00:00 2001 From: frauseo Date: Tue, 26 May 2020 21:18:56 +0200 Subject: [PATCH 6/6] Fix SqlNullValueException --- .../LoggingClient/LoggingClient.csproj | 2 +- .../LoggingClient/ViewModel/LogViewModel.cs | 38 +++++++++++-------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/LoggingClient/LoggingClient/LoggingClient.csproj b/LoggingClient/LoggingClient/LoggingClient.csproj index a928bb3..64bde42 100644 --- a/LoggingClient/LoggingClient/LoggingClient.csproj +++ b/LoggingClient/LoggingClient/LoggingClient.csproj @@ -5,7 +5,7 @@ Debug AnyCPU {2622C2FC-3522-4D6F-B021-F63A243E77F1} - Library + WinExe LoggingClient LoggingClient v4.6.1 diff --git a/LoggingClient/LoggingClient/ViewModel/LogViewModel.cs b/LoggingClient/LoggingClient/ViewModel/LogViewModel.cs index fefa987..67dac29 100644 --- a/LoggingClient/LoggingClient/ViewModel/LogViewModel.cs +++ b/LoggingClient/LoggingClient/ViewModel/LogViewModel.cs @@ -10,7 +10,7 @@ using LoggingClient.ViewModel.Commands; namespace LoggingClient.ViewModel { - public class LogViewModel : INotifyPropertyChanged + public class LogViewModel : INotifyPropertyChanged { private string _txtConnectionString; private string _enterPod; @@ -142,28 +142,36 @@ namespace LoggingClient.ViewModel 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()) - { - Logs.Add(new LogModel( - reader.GetInt32("id"), - reader.GetString("pod"), - reader.GetString("location"), - reader.GetString("hostname"), - reader.GetInt32("severity"), - reader.GetDateTime("timestamp"), - reader.GetString("message") - )); + 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); + MessageBox.Show("Error occurred: " + ex.Message); } - } + } + private void BtnLogClear_Click() { if (MySelectedItem == null) return;