Files
GeekDesk/Task/BacklogTask.cs

58 lines
1.8 KiB
C#
Raw Normal View History

using GeekDesk.Control;
using GeekDesk.Control.Other;
using GeekDesk.ViewModel;
using HandyControl.Controls;
using HandyControl.Data;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
2021-06-17 23:06:46 +08:00
using System.Threading;
using System.Threading.Tasks;
2021-06-17 23:06:46 +08:00
using System.Timers;
namespace GeekDesk.Task
{
2021-06-17 23:06:46 +08:00
public class BacklogTask
{
2021-06-17 23:06:46 +08:00
///public static ObservableCollection<BacklogInfo> activityBacklog = new ObservableCollection<BacklogInfo>();
public static Dictionary<BacklogInfo, Notification> activityBacklog = new Dictionary<BacklogInfo, Notification>();
public static void BackLogCheck()
{
System.Timers.Timer timer = new System.Timers.Timer();
timer.Enabled = true;
timer.Interval = 5000;
timer.Start();
timer.Elapsed += new System.Timers.ElapsedEventHandler(Check);
}
private static void Check(object source, ElapsedEventArgs e)
{
2021-06-17 23:06:46 +08:00
App.Current.Dispatcher.Invoke((Action)(() =>
{
2021-06-17 23:06:46 +08:00
if (MainWindow.appData.ExeBacklogList.Count > 0)
{
2021-06-17 23:06:46 +08:00
string nowTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
ObservableCollection<BacklogInfo> exeBacklogList = MainWindow.appData.ExeBacklogList;
foreach (BacklogInfo info in exeBacklogList)
{
2021-06-17 23:06:46 +08:00
if (info.ExeTime.CompareTo(nowTime) == -1 && !activityBacklog.ContainsKey(info))
{
activityBacklog.Add(info, Notification.Show(new BacklogNotificatin(info), ShowAnimation.Fade, true));
}
}
}
2021-06-17 23:06:46 +08:00
}));
}
2021-06-17 23:06:46 +08:00
}
}