终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

69 lines
2.1 KiB

  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. }