blob: b46c6477e7f548836965e3e95fff53e1e8086519 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core;
using Tango.Logging;
using Tango.PPC.Common;
namespace Tango.PPC.Technician.ViewModels
{
public class LoggingViewVM : PPCViewModel
{
public SynchronizedObservableCollection<LogItemBase> ApplicationLogs { get; set; }
public SynchronizedObservableCollection<LogItemBase> EmbeddedLogs { get; set; }
public LoggingViewVM()
{
ApplicationLogs = new SynchronizedObservableCollection<LogItemBase>();
EmbeddedLogs = new SynchronizedObservableCollection<LogItemBase>();
LogManager.NewLog += LogManager_NewLog;
}
private void LogManager_NewLog(object sender, LogItemBase log)
{
ApplicationLogs.Insert(0, log);
var now = DateTime.Now;
try
{
foreach (var l in ApplicationLogs.ToList())
{
if (l.TimeStamp.Date < DateTime.Now.Date)
{
ApplicationLogs.Remove(l);
}
}
}
catch
{
//I don't know if this will cause an exception but I'm tired.
}
}
public override void OnApplicationStarted()
{
}
}
}
|