VPatchStation.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace MeterVision.db
  8. {
  9. public class VPatchStation : INotifyPropertyChanged
  10. {
  11. public event PropertyChangedEventHandler PropertyChanged;
  12. protected void OnPropertyChanged(string propertyName)
  13. {
  14. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  15. }
  16. public string PatchId{ get; set;}
  17. public string StationId { get; set; }
  18. public int TotalCount { get; set; }
  19. private int _errorCount;
  20. public int ErrorCount
  21. {
  22. get => _errorCount;
  23. set
  24. {
  25. if(_errorCount != value)
  26. {
  27. _errorCount = value;
  28. OnPropertyChanged(nameof(ErrorCount));
  29. OnPropertyChanged(nameof(RunCount));
  30. OnPropertyChanged(nameof(TotalRunRateColor));
  31. OnPropertyChanged(nameof(InvalidRateName));
  32. OnPropertyChanged(nameof(EqualRateName));
  33. OnPropertyChanged(nameof(ErrorRateName));
  34. }
  35. }
  36. }
  37. private int _equalCount;
  38. public int EqualCount
  39. {
  40. get => _equalCount;
  41. set
  42. {
  43. if (_equalCount != value)
  44. {
  45. _equalCount = value;
  46. OnPropertyChanged(nameof(EqualCount));
  47. OnPropertyChanged(nameof(RunCount));
  48. OnPropertyChanged(nameof(TotalRunRateColor));
  49. OnPropertyChanged(nameof(InvalidRateName));
  50. OnPropertyChanged(nameof(EqualRateName));
  51. OnPropertyChanged(nameof(ErrorRateName));
  52. }
  53. }
  54. }
  55. private int _invalidCount;
  56. public int InvalidCount
  57. {
  58. get => _invalidCount;
  59. set
  60. {
  61. if (_invalidCount != value)
  62. {
  63. _invalidCount = value;
  64. OnPropertyChanged(nameof(InvalidCount));
  65. OnPropertyChanged(nameof(RunCount));
  66. OnPropertyChanged(nameof(TotalRunRateColor));
  67. OnPropertyChanged(nameof(InvalidRateName));
  68. OnPropertyChanged(nameof(EqualRateName));
  69. OnPropertyChanged(nameof(ErrorRateName));
  70. }
  71. }
  72. }
  73. public int Index { get; set; }
  74. //总数
  75. public int RunCount => (EqualCount + InvalidCount + ErrorCount);
  76. private float EqualRate => RunCount > 0 ? (float)EqualCount / RunCount : 0.0f;
  77. public string EqualRateName => $"{EqualCount} ({EqualRate.ToString("P1")})";
  78. private float ErrorRate => RunCount > 0 ? (float)ErrorCount / RunCount : 0.0f;
  79. public string ErrorRateName => $"{ErrorCount} ({ErrorRate.ToString("P1")})";
  80. private float InvalidRate => RunCount > 0 ? (float)InvalidCount / RunCount : 0.0f;
  81. public string InvalidRateName => $"{InvalidCount} ({InvalidRate.ToString("P1")})";
  82. public string TotalRunRateColor => (TotalCount == RunCount) ? "#1E90FF" : "#000000";
  83. public string StationIdName
  84. {
  85. get
  86. {
  87. if (StationId == "")
  88. {
  89. return "全部站点";
  90. }
  91. return StationId;
  92. }
  93. }
  94. public VPatchStation()
  95. {
  96. }
  97. //-------------------------------------------------------
  98. }
  99. }