LogDataService.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows.Data;
  8. namespace SKMC.Api.Common.Logger
  9. {
  10. public class LogDataService
  11. {
  12. private static LogDataService instance;
  13. private readonly object lockEventObject = new object();
  14. private readonly object lockProductionObject = new object();
  15. private readonly object lockParameterObject = new object();
  16. private readonly object lockProcessObject = new object();
  17. private readonly object lockActionObject = new object();
  18. public ObservableCollection<LoggingEventModel> LogEventModels { get; set; } = new ObservableCollection<LoggingEventModel>();
  19. public ObservableCollection<LoggingEventModel> LogProductionModels { get; set; } = new ObservableCollection<LoggingEventModel>();
  20. public ObservableCollection<LoggingEventModel> LogParameterModels { get; set; } = new ObservableCollection<LoggingEventModel>();
  21. public ObservableCollection<LoggingEventModel> LogProcessModels { get; set; } = new ObservableCollection<LoggingEventModel>();
  22. public ObservableCollection<LoggingEventModel> LogActionModels { get; set; } = new ObservableCollection<LoggingEventModel>();
  23. public static LogDataService Instance()
  24. {
  25. if (instance == null) instance = new LogDataService();
  26. return instance;
  27. }
  28. private LogDataService()
  29. {
  30. BindingOperations.EnableCollectionSynchronization(LogEventModels, lockEventObject);
  31. BindingOperations.EnableCollectionSynchronization(LogProductionModels, lockProductionObject);
  32. BindingOperations.EnableCollectionSynchronization(LogParameterModels, lockParameterObject);
  33. BindingOperations.EnableCollectionSynchronization(LogProcessModels, lockProcessObject);
  34. BindingOperations.EnableCollectionSynchronization(LogActionModels, lockActionObject);
  35. }
  36. }
  37. }