终端一体化运控平台
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

MessageLog.cs 2.1 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using BPASmartClient.Helper;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Collections.ObjectModel;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. namespace BPASmartClient.CustomResource.Pages.Model
  10. {
  11. public class MessageLog
  12. {
  13. private volatile static MessageLog _Instance;
  14. public static MessageLog GetInstance => _Instance ?? (_Instance = new MessageLog());
  15. private MessageLog() { }
  16. public Action<string> UserLog { get; set; }
  17. public Action<string> RunLog { get; set; }
  18. public ObservableCollection<RunLog> runLogs { get; set; } = new ObservableCollection<RunLog>();
  19. public ObservableCollection<UserLog> userLogs { get; set; } = new ObservableCollection<UserLog>();
  20. public void LogSave()
  21. {
  22. Sqlite<UserLog>.GetInstance.Save();
  23. Sqlite<RunLog>.GetInstance.Save();
  24. }
  25. //public void GetLog()
  26. //{
  27. // Sqlite<UserLog>.GetInstance.GetData();
  28. // Sqlite<RunLog>.GetInstance.GetData();
  29. //}
  30. public void ShowUserLog(string info)
  31. {
  32. UserLog userLog = new UserLog()
  33. {
  34. Date = DateTime.Now.ToString("yyyy-MM-dd"),
  35. Time = DateTime.Now.ToString("HH:mm:ss"),
  36. Permission = Global.userInfo.permission.ToString(),
  37. UserName = Global.userInfo.UserName,
  38. LogInfo = info
  39. };
  40. Sqlite<UserLog>.GetInstance.Base.Add(userLog);
  41. Application.Current.Dispatcher.Invoke(new Action(() => { userLogs.Insert(0, userLog); }));
  42. UserLog?.Invoke(info);
  43. }
  44. public void ShowRunLog(string info)
  45. {
  46. RunLog runLog = new RunLog()
  47. {
  48. Date = DateTime.Now.ToString("yyyy-MM-dd"),
  49. Time = DateTime.Now.ToString("HH:mm:ss"),
  50. RunLogInfo = info
  51. };
  52. Sqlite<RunLog>.GetInstance.Base.Add(runLog);
  53. Application.Current.Dispatcher.Invoke(new Action(() => { runLogs.Insert(0, runLog); }));
  54. RunLog?.Invoke(info);
  55. }
  56. }
  57. }