BacklogTask.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using GeekDesk.Control;
  2. using GeekDesk.Control.Other;
  3. using GeekDesk.ViewModel;
  4. using HandyControl.Controls;
  5. using HandyControl.Data;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Collections.ObjectModel;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading;
  12. using System.Threading.Tasks;
  13. using System.Timers;
  14. namespace GeekDesk.Task
  15. {
  16. public class BacklogTask
  17. {
  18. ///public static ObservableCollection<BacklogInfo> activityBacklog = new ObservableCollection<BacklogInfo>();
  19. public static Dictionary<BacklogInfo, Notification> activityBacklog = new Dictionary<BacklogInfo, Notification>();
  20. public static void BackLogCheck()
  21. {
  22. System.Timers.Timer timer = new System.Timers.Timer();
  23. timer.Enabled = true;
  24. timer.Interval = 5000;
  25. timer.Start();
  26. timer.Elapsed += new System.Timers.ElapsedEventHandler(Check);
  27. }
  28. private static void Check(object source, ElapsedEventArgs e)
  29. {
  30. App.Current.Dispatcher.Invoke((Action)(() =>
  31. {
  32. if (MainWindow.appData.ExeBacklogList.Count > 0)
  33. {
  34. string nowTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  35. ObservableCollection<BacklogInfo> exeBacklogList = MainWindow.appData.ExeBacklogList;
  36. foreach (BacklogInfo info in exeBacklogList)
  37. {
  38. if (info.ExeTime.CompareTo(nowTime) == -1 && !activityBacklog.ContainsKey(info))
  39. {
  40. activityBacklog.Add(info, Notification.Show(new BacklogNotificatin(info), ShowAnimation.Fade, true));
  41. }
  42. }
  43. }
  44. }));
  45. }
  46. }
  47. }