WIP - DB-Clls failing on Locations (Add, Update)
This commit is contained in:
parent
08a53739ee
commit
b8549bb60a
@ -3,13 +3,9 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:views="clr-namespace:LoggingClient.Views"
|
||||
xmlns:local="clr-namespace:LoggingClient.ViewModel"
|
||||
Title="MainWindow" Height="450" Width="800" ResizeMode="NoResize">
|
||||
<!--<Grid>
|
||||
<views:LogView x:Name = "LogView"/>
|
||||
</Grid>-->
|
||||
Title="MainWindow" Height="470" Width="800" ResizeMode="NoResize">
|
||||
|
||||
<Window.Resources>
|
||||
|
||||
<DataTemplate DataType="{x:Type local:LogViewModel}">
|
||||
<views:LogView/>
|
||||
</DataTemplate>
|
||||
@ -20,7 +16,6 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
</Window.Resources>
|
||||
|
||||
<DockPanel LastChildFill="True">
|
||||
|
||||
<Grid x:Name="Navigation" DockPanel.Dock="Top">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
@ -30,12 +25,8 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Button Grid.Row="0" Width="400" Content="Locations" Command="{Binding LocationsCommand}" Margin="394,0,-393,0"/>
|
||||
|
||||
<Button HorizontalAlignment="Right" Width="400" Content="Log Reader" Command="{Binding LogsCommand}" Margin="0,0,2,0"/>
|
||||
|
||||
</Grid>
|
||||
|
||||
<ContentControl x:Name="Pages" DockPanel.Dock="Right" Content="{Binding SelectedViewModel}"/>
|
||||
|
||||
</DockPanel>
|
||||
</Window>
|
20
LoggingClient/LoggingClient/MainWindow.xaml.cs
Normal file → Executable file
20
LoggingClient/LoggingClient/MainWindow.xaml.cs
Normal file → Executable file
@ -1,20 +1,5 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,10 @@
|
||||
namespace LoggingClient.Model
|
||||
using System;
|
||||
|
||||
namespace LoggingClient.Model
|
||||
{
|
||||
public class Location : Model<Location>
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +1,23 @@
|
||||
using System;
|
||||
using DuplicateCheckerLib;
|
||||
|
||||
namespace LoggingClient.Model
|
||||
{
|
||||
public class Logging : Model<Logging>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,11 @@ using System.Windows;
|
||||
|
||||
namespace LoggingClient.Repository
|
||||
{
|
||||
class LocationRepository : RepositoryBase<Location>
|
||||
public class LocationRepository : RepositoryBase<Location>
|
||||
{
|
||||
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<Location> 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"),
|
||||
|
@ -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
|
||||
));
|
||||
|
24
LoggingClient/LoggingClient/Validators/IntRangeValidationRule.cs
Normal file → Executable file
24
LoggingClient/LoggingClient/Validators/IntRangeValidationRule.cs
Normal file → Executable file
@ -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);
|
||||
}
|
||||
|
16
LoggingClient/LoggingClient/Validators/StringRangeValidationRule.cs
Normal file → Executable file
16
LoggingClient/LoggingClient/Validators/StringRangeValidationRule.cs
Normal file → Executable file
@ -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; }
|
||||
|
||||
|
11
LoggingClient/LoggingClient/ViewModel/Commands/RelayCommand.cs
Normal file → Executable file
11
LoggingClient/LoggingClient/ViewModel/Commands/RelayCommand.cs
Normal file → Executable file
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,12 +93,5 @@ namespace LoggingClient.ViewModel.Commands
|
||||
}
|
||||
|
||||
private event EventHandler CanExecuteChangedInternal;
|
||||
|
||||
public void RaiseCanExecuteChanged()
|
||||
{
|
||||
//CanExecuteChangedInternal.Raise(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -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<Location>();
|
||||
NewLocationModelEntry = new Location();
|
||||
|
||||
}
|
||||
public Logging MySelectedItem { get; set; }
|
||||
public Location MySelectedItem { get; set; }
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
public string TxtConnectionString
|
||||
{
|
||||
|
@ -9,24 +9,22 @@ 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<Logging> Logs
|
||||
public List<Logging> Logs
|
||||
{
|
||||
get => _logs;
|
||||
set
|
||||
@ -35,21 +33,22 @@ namespace LoggingClient.ViewModel
|
||||
OnPropertyChanged("Logs");
|
||||
}
|
||||
}
|
||||
private ObservableCollection<Logging> _logs;
|
||||
private List<Logging> _logs;
|
||||
public Logging NewLogModelEntry { get; set; }
|
||||
public ObservableCollection<SeverityComboBoxItem> 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<Logging>();
|
||||
Logs = new List<Logging>();
|
||||
NewLogModelEntry = new Logging();
|
||||
SeverityComboBox = new ObservableCollection<SeverityComboBoxItem>(){
|
||||
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<Logging> BtnFindDuplicates_Click()
|
||||
{
|
||||
var logModelRepository = new LoggingRepository(TxtConnectionString);
|
||||
this.Logs = logModelRepository.GetAll();
|
||||
var dupList = _dupChecker.FindDuplicates(Logs);
|
||||
Logs = new List<Logging>(dupList.Cast<Logging>());
|
||||
|
||||
return Logs;
|
||||
}
|
||||
public void BtnLoadData_Click()
|
||||
{
|
||||
try
|
||||
@ -162,28 +131,8 @@ 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)
|
||||
{
|
||||
@ -191,24 +140,14 @@ namespace LoggingClient.ViewModel
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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,37 +158,15 @@ 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<Logging> BtnFindDuplicate_Click()
|
||||
{
|
||||
LoadData();
|
||||
|
||||
var duplicateList = _duplicateChecker.FindDuplicates(Logs);
|
||||
Logs = new ObservableCollection<Logging>(duplicateList.Cast<Logging>());
|
||||
|
||||
return Logs;
|
||||
}
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
|
@ -59,30 +59,30 @@
|
||||
<TextBox HorizontalAlignment="Left" Height="23" Margin="248,22,0,0" TextWrapping="Wrap" Text="{Binding TxtConnectionString}" Name="TxtConnectionString" VerticalAlignment="Top" Width="525" />
|
||||
<TextBox HorizontalAlignment="Left" Height="25" Margin="10,366,0,0" TextWrapping="Wrap" x:Name="LocationId" VerticalAlignment="Top" Width="80" >
|
||||
<Binding Path="NewLocationModelEntry.AddressId" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<!--<Binding.ValidationRules>
|
||||
<validators:IntRangeValidationRule
|
||||
MinimumLength="1" MaximumLength="10000"/>
|
||||
</Binding.ValidationRules>
|
||||
</Binding.ValidationRules>-->
|
||||
</Binding>
|
||||
</TextBox>
|
||||
<TextBox HorizontalAlignment="Left" Height="25" Margin="95,366,0,0" TextWrapping="Wrap" Name="EnterParentId" VerticalAlignment="Top" Width="80">
|
||||
<TextBox.Text>
|
||||
<Binding Path="NewLocationModelEntry.ParentId" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<!--<Binding.ValidationRules>
|
||||
<validators:IntRangeValidationRule
|
||||
validators:MinimumLength="1" validators:MaximumLength="10000"/>
|
||||
</Binding.ValidationRules>
|
||||
</Binding.ValidationRules>-->
|
||||
</Binding>
|
||||
</TextBox.Text>
|
||||
</TextBox>
|
||||
<TextBox HorizontalAlignment="Left" Height="25" Margin="180,366,0,0" TextWrapping="Wrap" Name="EnterDesignation" VerticalAlignment="Top" Width="80">
|
||||
<TextBox.Text>
|
||||
<Binding Path="NewLocationModelEntry.Designation" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<!--<Binding.ValidationRules>
|
||||
<validators:StringRangeValidationRule
|
||||
validators:MinimumLength="1" validators:MaximumLength="45"
|
||||
ErrorMessage="Designation must contain at least 1 characters up to 45" />
|
||||
</Binding.ValidationRules>
|
||||
</Binding.ValidationRules>-->
|
||||
</Binding>
|
||||
</TextBox.Text>
|
||||
</TextBox>
|
||||
@ -90,20 +90,20 @@
|
||||
<TextBox HorizontalAlignment="Left" Height="25" Margin="265,366,0,0" TextWrapping="Wrap" Name="EnterBuildingNr" VerticalAlignment="Top" Width="80">
|
||||
<TextBox.Text>
|
||||
<Binding Path="NewLocationModelEntry.BuildingNr" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<!--<Binding.ValidationRules>
|
||||
<validators:IntRangeValidationRule
|
||||
validators:MinimumLength="1" validators:MaximumLength="10000"/>
|
||||
</Binding.ValidationRules>
|
||||
</Binding.ValidationRules>-->
|
||||
</Binding>
|
||||
</TextBox.Text>
|
||||
</TextBox>
|
||||
<TextBox HorizontalAlignment="Left" Height="25" Margin="350,366,0,0" TextWrapping="Wrap" Name="EnterRoomNr" VerticalAlignment="Top" Width="80" >
|
||||
<TextBox.Text>
|
||||
<Binding Path="NewLocationModelEntry.RoomNr" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<!--<Binding.ValidationRules>
|
||||
<validators:IntRangeValidationRule
|
||||
validators:MinimumLength="1" validators:MaximumLength="10000"/>
|
||||
</Binding.ValidationRules>
|
||||
</Binding.ValidationRules>-->
|
||||
</Binding>
|
||||
</TextBox.Text>
|
||||
</TextBox>
|
||||
|
@ -55,39 +55,39 @@ CanUserResizeRows="False">
|
||||
<TextBox HorizontalAlignment="Left" Height="25" Margin="10,350,0,0" TextWrapping="Wrap" Name="EnterPod" VerticalAlignment="Top" Width="110">
|
||||
<TextBox.Text>
|
||||
<Binding Path="EnterPod" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<!--<Binding.ValidationRules>
|
||||
<validators:StringRangeValidationRule
|
||||
ErrorMessage="Pod must contain atleast 3 characters up to 255" />
|
||||
</Binding.ValidationRules>
|
||||
</Binding.ValidationRules>-->
|
||||
</Binding>
|
||||
</TextBox.Text>
|
||||
</TextBox>
|
||||
<TextBox HorizontalAlignment="Left" Height="25" Margin="125,350,0,0" TextWrapping="Wrap" Name="EnterHostname" VerticalAlignment="Top" Width="110">
|
||||
<TextBox.Text>
|
||||
<Binding Path="EnterHostname" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<!--<Binding.ValidationRules>
|
||||
<validators:StringRangeValidationRule
|
||||
ErrorMessage="Hostname must contain atleast 3 characters up to 255" />
|
||||
</Binding.ValidationRules>
|
||||
</Binding.ValidationRules>-->
|
||||
</Binding>
|
||||
</TextBox.Text>
|
||||
</TextBox>
|
||||
<TextBox HorizontalAlignment="Left" Height="25" Margin="240,350,0,0" TextWrapping="Wrap" Name="EnterSeverity" VerticalAlignment="Top" Width="110" >
|
||||
<TextBox.Text>
|
||||
<Binding Path="EnterSeverity" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<!--<Binding.ValidationRules>
|
||||
<validators:IntRangeValidationRule/>
|
||||
</Binding.ValidationRules>
|
||||
</Binding.ValidationRules>-->
|
||||
</Binding>
|
||||
</TextBox.Text>
|
||||
</TextBox>
|
||||
<TextBox HorizontalAlignment="Left" Height="25" Margin="355,350,0,0" TextWrapping="Wrap" Name="EnterMessage" VerticalAlignment="Top" Width="418" RenderTransformOrigin="0.5,0.5">
|
||||
<TextBox.Text>
|
||||
<Binding Path="EnterMessage" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<!--<Binding.ValidationRules>
|
||||
<validators:StringRangeValidationRule
|
||||
ErrorMessage="Message must contain atleast 3 characters up to 255" />
|
||||
</Binding.ValidationRules>
|
||||
</Binding.ValidationRules>-->
|
||||
</Binding>
|
||||
</TextBox.Text>
|
||||
</TextBox>
|
||||
|
Loading…
Reference in New Issue
Block a user