diff --git a/LoggingClient/LoggingClient/MainWindow.xaml b/LoggingClient/LoggingClient/MainWindow.xaml
index 8a9132f..83fd525 100755
--- a/LoggingClient/LoggingClient/MainWindow.xaml
+++ b/LoggingClient/LoggingClient/MainWindow.xaml
@@ -1,15 +1,11 @@
-
-
+ Title="MainWindow" Height="470" Width="800" ResizeMode="NoResize">
+
-
@@ -20,7 +16,6 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-
@@ -30,12 +25,8 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-
-
-
-
\ No newline at end of file
diff --git a/LoggingClient/LoggingClient/MainWindow.xaml.cs b/LoggingClient/LoggingClient/MainWindow.xaml.cs
old mode 100644
new mode 100755
index f85a487..1905dfe
--- a/LoggingClient/LoggingClient/MainWindow.xaml.cs
+++ b/LoggingClient/LoggingClient/MainWindow.xaml.cs
@@ -1,21 +1,6 @@
-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.Windows;
+using WpfControlNugget.ViewModel;
+
namespace LoggingClient
{
///
@@ -26,6 +11,7 @@ namespace LoggingClient
public MainWindow()
{
InitializeComponent();
+ this.DataContext = new NavigationViewModel();
}
}
}
\ No newline at end of file
diff --git a/LoggingClient/LoggingClient/Model/Location.cs b/LoggingClient/LoggingClient/Model/Location.cs
index fdb4dec..3b2514d 100755
--- a/LoggingClient/LoggingClient/Model/Location.cs
+++ b/LoggingClient/LoggingClient/Model/Location.cs
@@ -1,7 +1,10 @@
-namespace LoggingClient.Model
+using System;
+
+namespace LoggingClient.Model
{
public class Location : Model
{
+ public new int Id { get; set; }
public int ParentId { get; set; }
public int AddressId { get; set; }
public string Designation { get; set; }
@@ -10,9 +13,8 @@
public Location()
{
- // Emty Constructor
- }
+ }
public Location(int id, int parentId, int addressId, string designation, int buildingNr, int roomNr)
{
this.Id = id;
@@ -22,5 +24,56 @@
this.BuildingNr = buildingNr;
this.RoomNr = roomNr;
}
+ public bool Equals(Location location)
+ {
+ if (Object.ReferenceEquals(null, location)) return false;
+ if (Object.ReferenceEquals(this, location)) return true;
+
+ return String.Equals(Designation, location.Designation) && String.Equals(BuildingNr, location.BuildingNr) && String.Equals(RoomNr, location.RoomNr);
+ }
+ public override bool Equals(object value)
+ {
+ return Equals(value as Location);
+ }
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ // Choose large primes to avoid hashing collisions
+ const int hashingBase = (int)2166136261;
+ const int hashingMultiplier = 16777619;
+
+ int hash = hashingBase;
+ hash = (hash * hashingMultiplier) ^ (!Object.ReferenceEquals(null, Designation) ? Designation.GetHashCode() : 0);
+ hash = (hash * hashingMultiplier) ^ (!Object.ReferenceEquals(null, BuildingNr) ? BuildingNr.GetHashCode() : 0);
+ hash = (hash * hashingMultiplier) ^ (!Object.ReferenceEquals(null, RoomNr) ? RoomNr.GetHashCode() : 0);
+ return hash;
+ }
+ }
+ public static bool operator ==(Location locA, Location locB)
+ {
+ if (Object.ReferenceEquals(locA, locB))
+ {
+ return true;
+ }
+
+ //Ensure that A isnt Null
+ if (Object.ReferenceEquals(null, locA))
+ {
+ return false;
+ }
+
+ return (locA.Equals(locB));
+ }
+
+ public static bool operator !=(Location locA, Location locB)
+ {
+ return !(locA == locB);
+ }
+
+ public override string ToString()
+ {
+ return Designation;
+ }
}
-}
+}
\ No newline at end of file
diff --git a/LoggingClient/LoggingClient/Model/Logging.cs b/LoggingClient/LoggingClient/Model/Logging.cs
index 3653203..59df878 100755
--- a/LoggingClient/LoggingClient/Model/Logging.cs
+++ b/LoggingClient/LoggingClient/Model/Logging.cs
@@ -1,17 +1,23 @@
using System;
+using DuplicateCheckerLib;
namespace LoggingClient.Model
-{
- public class Logging : Model
+{
+ public class Logging : IEntity
{
+ 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 string Severity { get; set; }
public DateTime Timestamp { get; set; }
public string Message { get; set; }
- public Logging(int id, string pod, string location, string hostname, int severity, DateTime timestamp, string message)
+ public Logging()
+ {
+ this.Severity = "1";
+ }
+ public Logging(int id, string pod, string location, string hostname, string severity, DateTime timestamp, string message)
{
this.Id = id;
this.Pod = pod;
@@ -37,12 +43,12 @@ namespace LoggingClient.Model
unchecked
{
// Choose large primes to avoid hashing collisions
- const int HashingBase = (int)2166136261;
- const int HashingMultiplier = 16777619;
+ const int hashingBase = (int)2166136261;
+ const int hashingMultiplier = 16777619;
- int hash = HashingBase;
- hash = (hash * HashingMultiplier) ^ (!Object.ReferenceEquals(null, Message) ? Message.GetHashCode() : 0);
- hash = (hash * HashingMultiplier) ^ (!Object.ReferenceEquals(null, Severity) ? Severity.GetHashCode() : 0);
+ int hash = hashingBase;
+ hash = (hash * hashingMultiplier) ^ (!Object.ReferenceEquals(null, Message) ? Message.GetHashCode() : 0);
+ hash = (hash * hashingMultiplier) ^ (!Object.ReferenceEquals(null, Severity) ? Severity.GetHashCode() : 0);
return hash;
}
}
diff --git a/LoggingClient/LoggingClient/Repository/LocationRepository.cs b/LoggingClient/LoggingClient/Repository/LocationRepository.cs
index 56f2b08..55f1635 100755
--- a/LoggingClient/LoggingClient/Repository/LocationRepository.cs
+++ b/LoggingClient/LoggingClient/Repository/LocationRepository.cs
@@ -6,11 +6,11 @@ using System.Windows;
namespace LoggingClient.Repository
{
- class LocationRepository : RepositoryBase
+ public class LocationRepository : RepositoryBase
{
public override string TableName => "Location";
- public override string ColumnsForSelect => "location_id, parent_location, address_fk, designation, building, room";
- public override string ColumnsForAdd => "parent_location, address_fk, designation, building, room";
+ public override string ColumnsForSelect => "location_id, parentId, address_fk, designation, building, room";
+ public override string ColumnsForAdd => "parentId, address_fk, designation, building, room";
public override string PrimaryKeyFromTable => "location_id";
public List Locations { get; set; }
@@ -86,7 +86,7 @@ namespace LoggingClient.Repository
Locations.Add(new Location(
reader.GetInt32("location_id"),
- reader.GetInt32("parent_location"),
+ reader.GetInt32("parentId"),
reader.GetInt32("address_fk"),
reader.GetValue(reader.GetOrdinal("designation")) as string,
reader.GetInt32("building"),
@@ -119,7 +119,7 @@ namespace LoggingClient.Repository
Locations.Add(new Location(
reader.GetInt32("location_id"),
- reader.GetInt32("parent_location"),
+ reader.GetInt32("parentId"),
reader.GetInt32("address_fk"),
reader.GetValue(reader.GetOrdinal("designation")) as string,
reader.GetInt32("building"),
@@ -157,7 +157,7 @@ namespace LoggingClient.Repository
_Locations = (new Location(
reader.GetInt32("location_id"),
- reader.GetInt32("parent_location"),
+ reader.GetInt32("parentId"),
reader.GetInt32("address_fk"),
reader.GetValue(reader.GetOrdinal("designation")) as string,
reader.GetInt32("building"),
@@ -195,4 +195,4 @@ namespace LoggingClient.Repository
}
}
}
-}
+}
\ No newline at end of file
diff --git a/LoggingClient/LoggingClient/Repository/LoggingRepository.cs b/LoggingClient/LoggingClient/Repository/LoggingRepository.cs
index f1a2a31..6da4e24 100755
--- a/LoggingClient/LoggingClient/Repository/LoggingRepository.cs
+++ b/LoggingClient/LoggingClient/Repository/LoggingRepository.cs
@@ -45,7 +45,7 @@ namespace LoggingClient.Repository
reader.GetValue(reader.GetOrdinal("pod")) as string,
reader.GetValue(reader.GetOrdinal("location")) as string,
reader.GetValue(reader.GetOrdinal("hostname")) as string,
- reader.GetInt32("severity"),
+ reader.GetString("severity"),
reader.GetDateTime("timestamp"),
reader.GetValue(reader.GetOrdinal("message")) as string
));
@@ -59,7 +59,7 @@ namespace LoggingClient.Repository
}
return _Logs;
}
- public override void Add(Logging newLogging)
+ public override void Add(Logging newLogModelEntry)
{
try
{
@@ -71,10 +71,10 @@ namespace LoggingClient.Repository
cmd.CommandText = "LogMessageAdd";
cmd.CommandType = CommandType.StoredProcedure;
- cmd.Parameters.Add("@i_pod", MySqlDbType.String).Value = newLogging.Pod;
- cmd.Parameters.Add("@i_hostname", MySqlDbType.String).Value = newLogging.Hostname;
- cmd.Parameters.Add("@i_severity", MySqlDbType.Int32).Value = newLogging.Severity;
- cmd.Parameters.Add("@i_message", MySqlDbType.String).Value = newLogging.Message;
+ cmd.Parameters.Add("@i_pod", MySqlDbType.String).Value = newLogModelEntry.Pod;
+ cmd.Parameters.Add("@i_hostname", MySqlDbType.String).Value = newLogModelEntry.Hostname;
+ cmd.Parameters.Add("@i_severity", MySqlDbType.Int32).Value = newLogModelEntry.Severity;
+ cmd.Parameters.Add("@i_message", MySqlDbType.String).Value = newLogModelEntry.Message;
cmd.ExecuteNonQuery();
}
@@ -120,7 +120,7 @@ namespace LoggingClient.Repository
reader.GetValue(reader.GetOrdinal("pod")) as string,
reader.GetValue(reader.GetOrdinal("location")) as string,
reader.GetValue(reader.GetOrdinal("hostname")) as string,
- reader.GetInt32("severity"),
+ reader.GetString("severity"),
reader.GetDateTime("timestamp"),
reader.GetValue(reader.GetOrdinal("message")) as string
));
@@ -153,7 +153,7 @@ namespace LoggingClient.Repository
reader.GetValue(reader.GetOrdinal("pod")) as string,
reader.GetValue(reader.GetOrdinal("location")) as string,
reader.GetValue(reader.GetOrdinal("hostname")) as string,
- reader.GetInt32("severity"),
+ reader.GetString("severity"),
reader.GetDateTime("timestamp"),
reader.GetValue(reader.GetOrdinal("message")) as string
));
diff --git a/LoggingClient/LoggingClient/Validators/IntRangeValidationRule.cs b/LoggingClient/LoggingClient/Validators/IntRangeValidationRule.cs
old mode 100644
new mode 100755
index 06470c9..487f8e2
--- a/LoggingClient/LoggingClient/Validators/IntRangeValidationRule.cs
+++ b/LoggingClient/LoggingClient/Validators/IntRangeValidationRule.cs
@@ -10,21 +10,9 @@ 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 int MinimumLength { get; set; }
+ public int MaximumLength { get; set; }
+ public string ErrorMessage { get; set; }
public override ValidationResult Validate(object value,
CultureInfo cultureInfo)
{
@@ -43,11 +31,11 @@ namespace LoggingClient.Validators
+ e.Message);
}
- if ((parameter < this.Min) || (parameter > this.Max))
+ if ((parameter < this.MinimumLength) || (parameter > this.MaximumLength))
{
return new ValidationResult(false,
- "Severity must be a number between "
- + this.Min + " - " + this.Max + ".");
+ "Input must be a number between "
+ + this.MinimumLength + " - " + this.MaximumLength + ".");
}
return new ValidationResult(true, null);
}
diff --git a/LoggingClient/LoggingClient/Validators/StringRangeValidationRule.cs b/LoggingClient/LoggingClient/Validators/StringRangeValidationRule.cs
old mode 100644
new mode 100755
index 098285c..2e285ff
--- a/LoggingClient/LoggingClient/Validators/StringRangeValidationRule.cs
+++ b/LoggingClient/LoggingClient/Validators/StringRangeValidationRule.cs
@@ -10,20 +10,8 @@ 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 int MinimumLength { get; set; }
+ public int MaximumLength { get; set; }
public string ErrorMessage { get; set; }
@@ -41,4 +29,4 @@ namespace LoggingClient.Validators
return result;
}
}
-}
+}
\ No newline at end of file
diff --git a/LoggingClient/LoggingClient/ViewModel/Commands/BaseCommand.cs b/LoggingClient/LoggingClient/ViewModel/Commands/BaseCommand.cs
index dc5c328..e394e5c 100755
--- a/LoggingClient/LoggingClient/ViewModel/Commands/BaseCommand.cs
+++ b/LoggingClient/LoggingClient/ViewModel/Commands/BaseCommand.cs
@@ -27,4 +27,4 @@ namespace WpfControlNugget.ViewModel.Commands
_method.Invoke(parameter);
}
}
-}
+}
\ No newline at end of file
diff --git a/LoggingClient/LoggingClient/ViewModel/Commands/RelayCommand.cs b/LoggingClient/LoggingClient/ViewModel/Commands/RelayCommand.cs
old mode 100644
new mode 100755
index dc670c3..839d227
--- a/LoggingClient/LoggingClient/ViewModel/Commands/RelayCommand.cs
+++ b/LoggingClient/LoggingClient/ViewModel/Commands/RelayCommand.cs
@@ -40,8 +40,8 @@ namespace LoggingClient.ViewModel.Commands
public event EventHandler CanExecuteChanged
{
- add { CommandManager.RequerySuggested += value; }
- remove { CommandManager.RequerySuggested -= value; }
+ add => CommandManager.RequerySuggested += value;
+ remove => CommandManager.RequerySuggested -= value;
}
}
@@ -90,15 +90,8 @@ namespace LoggingClient.ViewModel.Commands
CommandManager.RequerySuggested -= value;
CanExecuteChangedInternal -= value;
}
- }
-
- private event EventHandler CanExecuteChangedInternal;
-
- public void RaiseCanExecuteChanged()
- {
- //CanExecuteChangedInternal.Raise(this);
- }
+ }
+
+ private event EventHandler CanExecuteChangedInternal;
}
-
}
-
diff --git a/LoggingClient/LoggingClient/ViewModel/LocationTreeBuilder.cs b/LoggingClient/LoggingClient/ViewModel/LocationTreeBuilder.cs
index 964a051..4229d79 100755
--- a/LoggingClient/LoggingClient/ViewModel/LocationTreeBuilder.cs
+++ b/LoggingClient/LoggingClient/ViewModel/LocationTreeBuilder.cs
@@ -51,4 +51,4 @@ namespace LoggingClient.ViewModel
};
}
}
-}
+}
\ No newline at end of file
diff --git a/LoggingClient/LoggingClient/ViewModel/LocationViewModel.cs b/LoggingClient/LoggingClient/ViewModel/LocationViewModel.cs
index a61cfba..651e990 100755
--- a/LoggingClient/LoggingClient/ViewModel/LocationViewModel.cs
+++ b/LoggingClient/LoggingClient/ViewModel/LocationViewModel.cs
@@ -9,7 +9,7 @@ using LoggingClient.ViewModel.Commands;
namespace LoggingClient.ViewModel
{
- class LocationViewModel : INotifyPropertyChanged
+ public class LocationViewModel : INotifyPropertyChanged
{
private string _txtConnectionString;
@@ -34,12 +34,12 @@ namespace LoggingClient.ViewModel
public LocationViewModel()
{
- TxtConnectionString = "Server=localhost;Database=inventarisierungsloesung;Uid=root;Pwd=MySQLPassword1234!;";
+ TxtConnectionString = "Server=localhost;Database=;Uid=root;Pwd=;";
Locations = new List();
NewLocationModelEntry = new Location();
}
- public Logging MySelectedItem { get; set; }
+ public Location MySelectedItem { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
public string TxtConnectionString
{
@@ -188,4 +188,4 @@ namespace LoggingClient.ViewModel
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
-}
+}
\ No newline at end of file
diff --git a/LoggingClient/LoggingClient/ViewModel/LogViewModel.cs b/LoggingClient/LoggingClient/ViewModel/LogViewModel.cs
index 730ed3e..a65945c 100755
--- a/LoggingClient/LoggingClient/ViewModel/LogViewModel.cs
+++ b/LoggingClient/LoggingClient/ViewModel/LogViewModel.cs
@@ -9,47 +9,46 @@ using LoggingClient.Model;
using LoggingClient.ViewModel.Commands;
using DuplicateCheckerLib;
using System.Linq;
+using System.Collections.Generic;
+using LoggingClient.Repository;
namespace LoggingClient.ViewModel
-{
+{
public class LogViewModel : INotifyPropertyChanged
{
private string _txtConnectionString;
- private string _enterPod;
- private string _enterHostname;
- private int _enterSeverity;
- private string _enterMessage;
- private readonly DuplicateChecker _duplicateChecker;
+ private readonly DuplicateChecker _dupChecker;
private ICommand _btnLoadDataClick;
- private ICommand _btnConfirmdataClick;
- private ICommand _btnAdddataClick;
- private ICommand _btnFindDuplicateClick;
+ private ICommand _btnConfirmDataClick;
+ private ICommand _btnAddDataClick;
+ private ICommand _btnFindDuplicatesClick;
- public ObservableCollection Logs
- {
+ public List Logs
+ {
get => _logs;
set
{
_logs = value;
OnPropertyChanged("Logs");
- }
+ }
}
- private ObservableCollection _logs;
+ private List _logs;
+ public Logging NewLogModelEntry { get; set; }
public ObservableCollection SeverityComboBox { get; set; }
public LogViewModel()
{
- TxtConnectionString = "Server=localhost;Database=inventarisierungsloesung;Uid=root;Pwd=MySQLPassword1234!;";
- _enterSeverity = 1;
+ TxtConnectionString = "Server=localhost;Database=;Uid=root;Pwd=;";
- Logs = new ObservableCollection();
+ Logs = new List();
+ NewLogModelEntry = new Logging();
SeverityComboBox = new ObservableCollection(){
new SeverityComboBoxItem(){Id=1, Severity= 1},
new SeverityComboBoxItem(){Id=2, Severity= 2},
new SeverityComboBoxItem(){Id=3, Severity= 3}
};
- _duplicateChecker = new DuplicateChecker();
+ _dupChecker = new DuplicateChecker();
}
public Logging MySelectedItem { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
@@ -64,44 +63,17 @@ namespace LoggingClient.ViewModel
OnPropertyChanged(nameof(TxtConnectionString));
}
}
- public string EnterPod
+ public ICommand BtnFindDuplicatesClick
{
- get => _enterPod;
- set
+ get
{
- _enterPod = value;
- OnPropertyChanged(nameof(EnterPod));
+ return _btnFindDuplicatesClick ?? (_btnFindDuplicatesClick = new RelayCommand(
+ x =>
+ {
+ BtnFindDuplicates_Click();
+ }));
}
}
-
- 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
@@ -117,36 +89,33 @@ namespace LoggingClient.ViewModel
{
get
{
- return _btnAdddataClick ?? (_btnAdddataClick = new RelayCommand(
+ return _btnAddDataClick ?? (_btnAddDataClick = new RelayCommand(
x =>
{
BtnAdd_Click();
}));
}
}
-
- public ICommand BtnFindDuplicateClick
- {
- get
- {
- return _btnFindDuplicateClick ?? (_btnFindDuplicateClick = new RelayCommand(
- x =>
- {
- BtnFindDuplicate_Click();
- }));
- }
- }
public ICommand BtnConfirmDataClick
{
get
{
- return _btnConfirmdataClick ?? (_btnConfirmdataClick = new RelayCommand(
+ return _btnConfirmDataClick ?? (_btnConfirmDataClick = new RelayCommand(
x =>
{
BtnLogClear_Click();
}));
}
}
+ public List BtnFindDuplicates_Click()
+ {
+ var logModelRepository = new LoggingRepository(TxtConnectionString);
+ this.Logs = logModelRepository.GetAll();
+ var dupList = _dupChecker.FindDuplicates(Logs);
+ Logs = new List(dupList.Cast());
+
+ return Logs;
+ }
public void BtnLoadData_Click()
{
try
@@ -162,53 +131,23 @@ namespace LoggingClient.ViewModel
{
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 Logging(
- reader.GetInt32(reader.GetOrdinal("id")),
- reader.GetValue(reader.GetOrdinal("pod")) as string,
- reader.GetValue(reader.GetOrdinal("location")) as string,
- reader.GetValue(reader.GetOrdinal("hostname")) as string,
- reader.GetInt32(reader.GetOrdinal("severity")),
- reader.GetDateTime(reader.GetOrdinal("timestamp")),
- reader.GetValue(reader.GetOrdinal("message")) as string
- )) ;
- }
- }
- conn.Close();
- }
+ var logModelRepository = new LoggingRepository(TxtConnectionString);
+ this.Logs = logModelRepository.GetAll();
}
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();
+ var logModelRepository = new LoggingRepository(TxtConnectionString);
+ logModelRepository.CallStoredProcedure(MySelectedItem);
+ this.Logs = logModelRepository.GetAll();
}
catch (MySqlException ex)
{
@@ -219,40 +158,18 @@ namespace LoggingClient.ViewModel
{
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();
- }
+ var logModelRepository = new LoggingRepository(TxtConnectionString);
+ logModelRepository.Add(this.NewLogModelEntry);
+ this.Logs = logModelRepository.GetAll();
}
catch (Exception ex)
{
MessageBox.Show("Error occurred: " + ex.Message);
}
- }
- public ObservableCollection BtnFindDuplicate_Click()
- {
- LoadData();
-
- var duplicateList = _duplicateChecker.FindDuplicates(Logs);
- Logs = new ObservableCollection(duplicateList.Cast());
-
- return Logs;
}
private void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
-}
+}
\ No newline at end of file
diff --git a/LoggingClient/LoggingClient/Views/LocationView.xaml b/LoggingClient/LoggingClient/Views/LocationView.xaml
index 6ff6d4b..1947a04 100755
--- a/LoggingClient/LoggingClient/Views/LocationView.xaml
+++ b/LoggingClient/LoggingClient/Views/LocationView.xaml
@@ -59,30 +59,30 @@
-
+
-
+
-
+
@@ -90,20 +90,20 @@
-
+
-
+
diff --git a/LoggingClient/LoggingClient/Views/LogView.xaml b/LoggingClient/LoggingClient/Views/LogView.xaml
index 4e5cc6e..c152b9c 100755
--- a/LoggingClient/LoggingClient/Views/LogView.xaml
+++ b/LoggingClient/LoggingClient/Views/LogView.xaml
@@ -55,39 +55,39 @@ CanUserResizeRows="False">
-
+
-
+
-
+
-
+