aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-04-15 19:51:07 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-04-15 19:51:07 +0300
commitca293b80c52a54c73251fbf3cd50741fb5653ae9 (patch)
treef1168fa167a26bf8455e601291b8a19945a70187 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs
parent9ff8293b603f72c5faa8d238b3005524c31cc5a8 (diff)
downloadTango-ca293b80c52a54c73251fbf3cd50741fb5653ae9.tar.gz
Tango-ca293b80c52a54c73251fbf3cd50741fb5653ae9.zip
Lots Of Work !
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs99
1 files changed, 99 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs
new file mode 100644
index 000000000..8ddc544c0
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs
@@ -0,0 +1,99 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Core.Commands;
+using Tango.Logging;
+using Tango.MachineStudio.Logging.Navigation;
+using Tango.MachineStudio.Logging.Parsing;
+using Tango.SharedUI;
+
+namespace Tango.MachineStudio.Logging.ViewModels
+{
+ public class ApplicationLogsViewVM : ViewModel
+ {
+ private ApplicationLogFileParser _parser;
+ private List<LogFile> _logFiles;
+
+ private ObservableCollection<MessageLogItem> _logs;
+ public ObservableCollection<MessageLogItem> Logs
+ {
+ get { return _logs; }
+ set { _logs = value; RaisePropertyChangedAuto(); }
+ }
+
+ private ObservableCollection<DateTime> _dates;
+ public ObservableCollection<DateTime> Dates
+ {
+ get { return _dates; }
+ set { _dates = value; RaisePropertyChangedAuto(); }
+ }
+
+ private DateTime _selectedDate;
+ public DateTime SelectedDate
+ {
+ get { return _selectedDate; }
+ set { _selectedDate = value; RaisePropertyChangedAuto(); OnSelectedDateChanged(); }
+ }
+
+ private DateTime _minDate;
+ public DateTime MinDate
+ {
+ get { return _minDate; }
+ set { _minDate = value; RaisePropertyChangedAuto(); }
+ }
+
+ private DateTime _maxDate;
+ public DateTime MaxDate
+ {
+ get { return _maxDate; }
+ set { _maxDate = value; RaisePropertyChangedAuto(); }
+ }
+
+
+ private bool _isRealTime;
+ public bool IsRealTime
+ {
+ get { return _isRealTime; }
+ set { _isRealTime = value; RaisePropertyChangedAuto(); OnSelectedDateChanged(); }
+ }
+
+ public RelayCommand NavigateToHomeCommand { get; set; }
+
+ public ApplicationLogsViewVM(LoggingNavigationManager navigation)
+ {
+ NavigateToHomeCommand = new RelayCommand(() => navigation.NavigateTo(LoggingNavigationView.HomeView));
+
+ _parser = new ApplicationLogFileParser();
+
+ _logFiles = _parser.GetLogFiles();
+ Dates = new ObservableCollection<DateTime>(_logFiles.Select(x => x.DateTime).OrderBy(x => x));
+
+ SelectedDate = Dates.Last();
+
+ MinDate = Dates.Min();
+ MaxDate = Dates.Max();
+ }
+
+ private void OnSelectedDateChanged()
+ {
+ if (IsRealTime)
+ {
+ //Events = _realTimeEvents;
+ }
+ else
+ {
+ List<MessageLogItem> logs = new List<MessageLogItem>();
+
+ foreach (var logFile in _logFiles.Where(x => x.DateTime.Date == SelectedDate.Date))
+ {
+ logs.AddRange(_parser.Parse(logFile));
+ }
+
+ Logs = logs.ToObservableCollection();
+ }
+ }
+ }
+}