From bc35e187038838881f52367c7ab5f4b1f789833f Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Wed, 22 Feb 2023 15:31:16 +0500 Subject: [PATCH 1/2] fix nullable --- AsbCloudApp/Data/MapPointBaseDto.cs | 2 +- AsbCloudApp/Data/MessageDto.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AsbCloudApp/Data/MapPointBaseDto.cs b/AsbCloudApp/Data/MapPointBaseDto.cs index f4580983..2a3a7ff0 100644 --- a/AsbCloudApp/Data/MapPointBaseDto.cs +++ b/AsbCloudApp/Data/MapPointBaseDto.cs @@ -11,7 +11,7 @@ /// /// Название /// - public string Caption { get; set; } = string.Empty; + public string Caption { get; set; } = null!; /// public double? Latitude { get; set; } diff --git a/AsbCloudApp/Data/MessageDto.cs b/AsbCloudApp/Data/MessageDto.cs index a8b982c2..b8d930c5 100644 --- a/AsbCloudApp/Data/MessageDto.cs +++ b/AsbCloudApp/Data/MessageDto.cs @@ -28,7 +28,7 @@ namespace AsbCloudApp.Data /// /// пользователь панели оператора /// - public string User { get; set; } = null!; + public string? User { get; set; } /// /// текст сообщения From 1e86c24258d4d50b270a2fb7fd5b0a505a932917 Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Wed, 22 Feb 2023 17:10:29 +0500 Subject: [PATCH 2/2] Fix comparators implementation and revise some dtos --- AsbCloudApp/Comparators/ComparerIId.cs | 16 ++++++---------- .../Comparators/TelemetryUserDtoComparer.cs | 10 ++++------ AsbCloudApp/Data/ReportProgressDto.cs | 2 +- AsbCloudApp/Data/ReportPropertiesDto.cs | 1 - AsbCloudApp/Data/RequestLogDto.cs | 2 -- AsbCloudApp/Data/RequestLogUserDto.cs | 2 -- AsbCloudApp/Data/ScheduleDto.cs | 6 +++--- AsbCloudApp/Data/SimpleTimezoneDto.cs | 1 - AsbCloudApp/Data/StatClusterDto.cs | 5 +++-- AsbCloudApp/Data/StatSectionDto.cs | 2 +- AsbCloudApp/Data/StatWellDto.cs | 13 +++++++------ AsbCloudApp/Data/TelemetryDto.cs | 8 ++++---- AsbCloudApp/Data/TimeDto.cs | 6 +++--- 13 files changed, 32 insertions(+), 42 deletions(-) diff --git a/AsbCloudApp/Comparators/ComparerIId.cs b/AsbCloudApp/Comparators/ComparerIId.cs index 93b0d91a..4c02af80 100644 --- a/AsbCloudApp/Comparators/ComparerIId.cs +++ b/AsbCloudApp/Comparators/ComparerIId.cs @@ -25,12 +25,8 @@ namespace AsbCloudApp.Comparators /// /// public int Compare(IId? x, IId? y) - { - if (x is null || y is null) - return 0; - else - return x.Id.CompareTo(y.Id); - } + => (x?.Id??0).CompareTo(y?.Id??0); + /// /// @@ -39,11 +35,11 @@ namespace AsbCloudApp.Comparators /// /// public bool Equals(IId? x, IId? y) - { - if (x is null || y is null) - return false; - else + { + if (x is not null && y is not null) return x.Id == y.Id; + + return x == y; } /// diff --git a/AsbCloudApp/Comparators/TelemetryUserDtoComparer.cs b/AsbCloudApp/Comparators/TelemetryUserDtoComparer.cs index eac2d83d..2c8035ed 100644 --- a/AsbCloudApp/Comparators/TelemetryUserDtoComparer.cs +++ b/AsbCloudApp/Comparators/TelemetryUserDtoComparer.cs @@ -9,12 +9,10 @@ namespace AsbCloudApp.Comparators /// public bool Equals(TelemetryUserDto? prevUser, TelemetryUserDto? nextUser) { - if (prevUser is null || nextUser is null) - return false; - else if (prevUser.Id == nextUser.Id) - return true; - else - return false; + if (prevUser is not null && nextUser is not null) + return prevUser.Id == nextUser.Id; + + return prevUser == nextUser; } /// diff --git a/AsbCloudApp/Data/ReportProgressDto.cs b/AsbCloudApp/Data/ReportProgressDto.cs index 6a3caa51..c7bf4cbb 100644 --- a/AsbCloudApp/Data/ReportProgressDto.cs +++ b/AsbCloudApp/Data/ReportProgressDto.cs @@ -13,7 +13,7 @@ /// /// название текущей операции генерации /// - public string Operation { get; set; } + public string? Operation { get; set; } /// /// номер текущей страницы diff --git a/AsbCloudApp/Data/ReportPropertiesDto.cs b/AsbCloudApp/Data/ReportPropertiesDto.cs index e8527d90..217f7598 100644 --- a/AsbCloudApp/Data/ReportPropertiesDto.cs +++ b/AsbCloudApp/Data/ReportPropertiesDto.cs @@ -2,7 +2,6 @@ namespace AsbCloudApp.Data { -#nullable enable /// /// DTO формирования рапорта /// diff --git a/AsbCloudApp/Data/RequestLogDto.cs b/AsbCloudApp/Data/RequestLogDto.cs index eb3231c0..ecdb183e 100644 --- a/AsbCloudApp/Data/RequestLogDto.cs +++ b/AsbCloudApp/Data/RequestLogDto.cs @@ -2,7 +2,6 @@ namespace AsbCloudApp.Data { -#nullable enable /// /// DTO журнала запросов /// @@ -63,5 +62,4 @@ namespace AsbCloudApp.Data /// public string? ExceptionStack { get; set; } = null!; } -#nullable disable } \ No newline at end of file diff --git a/AsbCloudApp/Data/RequestLogUserDto.cs b/AsbCloudApp/Data/RequestLogUserDto.cs index bd39eaef..3f5d6a39 100644 --- a/AsbCloudApp/Data/RequestLogUserDto.cs +++ b/AsbCloudApp/Data/RequestLogUserDto.cs @@ -2,7 +2,6 @@ namespace AsbCloudApp.Data { -#nullable enable /// /// DTO статистики запросов по пользователю /// @@ -48,5 +47,4 @@ namespace AsbCloudApp.Data /// public UserDto User { get; set; } = null!; } -#nullable disable } diff --git a/AsbCloudApp/Data/ScheduleDto.cs b/AsbCloudApp/Data/ScheduleDto.cs index 00fb51bb..cd0175b1 100644 --- a/AsbCloudApp/Data/ScheduleDto.cs +++ b/AsbCloudApp/Data/ScheduleDto.cs @@ -21,12 +21,12 @@ namespace AsbCloudApp.Data /// /// Начало смены /// - public TimeDto ShiftStart { get; set; } + public TimeDto ShiftStart { get; set; } = null!; /// /// Конец смены /// - public TimeDto ShiftEnd { get; set; } + public TimeDto ShiftEnd { get; set; } = null!; /// /// Начало бурения @@ -41,6 +41,6 @@ namespace AsbCloudApp.Data /// /// Бурильщик /// - public DrillerDto Driller { get; set; } + public DrillerDto? Driller { get; set; } } } diff --git a/AsbCloudApp/Data/SimpleTimezoneDto.cs b/AsbCloudApp/Data/SimpleTimezoneDto.cs index 100ede09..3ec75814 100644 --- a/AsbCloudApp/Data/SimpleTimezoneDto.cs +++ b/AsbCloudApp/Data/SimpleTimezoneDto.cs @@ -1,6 +1,5 @@ namespace AsbCloudApp.Data { -#nullable enable /// /// /// diff --git a/AsbCloudApp/Data/StatClusterDto.cs b/AsbCloudApp/Data/StatClusterDto.cs index 0bcbfe65..db768ab1 100644 --- a/AsbCloudApp/Data/StatClusterDto.cs +++ b/AsbCloudApp/Data/StatClusterDto.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; namespace AsbCloudApp.Data { @@ -13,11 +14,11 @@ namespace AsbCloudApp.Data /// /// название куста /// - public string Caption { get; set; } + public string Caption { get; set; } = string.Empty; /// /// список статистик скважин куста /// - public IEnumerable StatsWells { get; set; } + public IEnumerable StatsWells { get; set; } = Enumerable.Empty(); } } diff --git a/AsbCloudApp/Data/StatSectionDto.cs b/AsbCloudApp/Data/StatSectionDto.cs index f0da2188..58fff71b 100644 --- a/AsbCloudApp/Data/StatSectionDto.cs +++ b/AsbCloudApp/Data/StatSectionDto.cs @@ -11,6 +11,6 @@ /// /// название секции /// - public string Caption { get; set; } + public string Caption { get; set; } = string.Empty; } } diff --git a/AsbCloudApp/Data/StatWellDto.cs b/AsbCloudApp/Data/StatWellDto.cs index 08581313..9793e858 100644 --- a/AsbCloudApp/Data/StatWellDto.cs +++ b/AsbCloudApp/Data/StatWellDto.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; namespace AsbCloudApp.Data { @@ -14,12 +15,12 @@ namespace AsbCloudApp.Data /// /// название /// - public string Caption { get; set; } + public string Caption { get; set; } = string.Empty; /// /// тип скважины /// - public string WellType { get; set; } + public string WellType { get; set; } = string.Empty; /// /// ИД состояния скважины @@ -29,7 +30,7 @@ namespace AsbCloudApp.Data /// /// текст состояния скважины /// - public string State { get; set; } + public string State { get; set; } = string.Empty; /// /// дата прихода последней телеметрии @@ -39,16 +40,16 @@ namespace AsbCloudApp.Data /// /// Статистика по секциям /// - public IEnumerable Sections { get; set; } + public IEnumerable Sections { get; set; } = Enumerable.Empty(); /// /// статистика за всю скважину /// - public PlanFactBase Total { get; set; } + public PlanFactBase Total { get; set; } = new(); /// /// компании участвующие в строительстве скважины /// - public IEnumerable Companies { get; set; } + public IEnumerable Companies { get; set; } = Enumerable.Empty(); } } diff --git a/AsbCloudApp/Data/TelemetryDto.cs b/AsbCloudApp/Data/TelemetryDto.cs index d71afdd4..d243c749 100644 --- a/AsbCloudApp/Data/TelemetryDto.cs +++ b/AsbCloudApp/Data/TelemetryDto.cs @@ -9,16 +9,16 @@ namespace AsbCloudApp.Data { /// public int Id { get; set; } - + /// /// уникальный идентификатор телеметрии по которому панель оператора присылает данные /// - public string RemoteUid { get; set; } + public string RemoteUid { get; set; } = null!; /// /// информация о бурении, панели оператора и контроллерах /// - public TelemetryInfoDto Info { get; set; } + public TelemetryInfoDto? Info { get; set; } } /// @@ -34,6 +34,6 @@ namespace AsbCloudApp.Data /// /// DTO скважины /// - public WellInfoDto Well { get; set; } + public WellInfoDto? Well { get; set; } } } diff --git a/AsbCloudApp/Data/TimeDto.cs b/AsbCloudApp/Data/TimeDto.cs index faf99427..6a3620f2 100644 --- a/AsbCloudApp/Data/TimeDto.cs +++ b/AsbCloudApp/Data/TimeDto.cs @@ -118,11 +118,11 @@ namespace AsbCloudApp.Data public static bool operator >(TimeDto a, TimeDto b) => a.TotalSeconds > b.TotalSeconds; /// - public int CompareTo(TimeDto other) - => TotalSeconds - other.TotalSeconds; + public int CompareTo(TimeDto? other) + => TotalSeconds - other?.TotalSeconds??0; /// - public override bool Equals(object obj) + public override bool Equals(object? obj) { if (ReferenceEquals(this, obj)) {