diff --git a/AsbCloudDb/EFExtentions.cs b/AsbCloudDb/EFExtentions.cs index 5114120b..fdf22fbc 100644 --- a/AsbCloudDb/EFExtentions.cs +++ b/AsbCloudDb/EFExtentions.cs @@ -33,8 +33,11 @@ namespace AsbCloudDb s => System.Text.Json.JsonSerializer.Deserialize(s, jsonSerializerOptions)!); ValueComparer valueComparer = new ( - (a,b) => a.GetHashCode() == b.GetHashCode(), - i => i.GetHashCode(), + (a,b) => + (a!=null) && (b != null) + ? a.GetHashCode() == b.GetHashCode() + : (a == null) && (b == null), + i => (i == null) ?-1 : i.GetHashCode(), i => i); builder.Metadata.SetValueComparer(valueComparer); diff --git a/AsbCloudDb/Model/AsbCloudDbContext.cs b/AsbCloudDb/Model/AsbCloudDbContext.cs index b225572f..3fc9fa73 100644 --- a/AsbCloudDb/Model/AsbCloudDbContext.cs +++ b/AsbCloudDb/Model/AsbCloudDbContext.cs @@ -345,14 +345,15 @@ namespace AsbCloudDb.Model FillData(modelBuilder); } - public Task RefreshMaterializedViewAsync(CancellationToken token = default) + public Task RefreshMaterializedViewAsync(CancellationToken token) where TEntity : class { - var materializedViewName = Set().EntityType.GetViewName(); - return RefreshMaterializedViewAsync(materializedViewName!, token); + var materializedViewName = Set().EntityType.GetViewName() + ?? throw new System.Exception($"RefreshMaterializedViewAsync<{typeof(TEntity).Name}>(..) db table for this type does not found."); + return RefreshMaterializedViewAsync(materializedViewName, token); } - public Task RefreshMaterializedViewAsync(string materializedViewName, CancellationToken token = default) + public Task RefreshMaterializedViewAsync(string materializedViewName, CancellationToken token) { var sql = $"REFRESH MATERIALIZED VIEW {materializedViewName};"; return Database.ExecuteSqlRawAsync(sql, token); diff --git a/AsbCloudDb/Model/IAsbCloudDbContext.cs b/AsbCloudDb/Model/IAsbCloudDbContext.cs index 84f4a824..ce965004 100644 --- a/AsbCloudDb/Model/IAsbCloudDbContext.cs +++ b/AsbCloudDb/Model/IAsbCloudDbContext.cs @@ -56,8 +56,8 @@ namespace AsbCloudDb.Model DatabaseFacade Database { get; } - Task RefreshMaterializedViewAsync(string? mwName = null, CancellationToken token = default); - Task RefreshMaterializedViewAsync(CancellationToken token = default) where TEntity : class; + Task RefreshMaterializedViewAsync(string mwName, CancellationToken token); + Task RefreshMaterializedViewAsync(CancellationToken token) where TEntity : class; int SaveChanges(); int SaveChanges(bool acceptAllChangesOnSuccess); Task SaveChangesAsync(CancellationToken cancellationToken); diff --git a/AsbCloudInfrastructure/Repository/CrudCacheServiceBase.cs b/AsbCloudInfrastructure/Repository/CrudCacheServiceBase.cs index 142367ec..94142e9d 100644 --- a/AsbCloudInfrastructure/Repository/CrudCacheServiceBase.cs +++ b/AsbCloudInfrastructure/Repository/CrudCacheServiceBase.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; namespace AsbCloudInfrastructure.Repository { +#nullable enable /// /// CRUD сервис с кешем в оперативке /// diff --git a/AsbCloudInfrastructure/Repository/CrudServiceBase.cs b/AsbCloudInfrastructure/Repository/CrudServiceBase.cs index 3163d86e..15c8dc4f 100644 --- a/AsbCloudInfrastructure/Repository/CrudServiceBase.cs +++ b/AsbCloudInfrastructure/Repository/CrudServiceBase.cs @@ -10,7 +10,7 @@ using System.Threading.Tasks; namespace AsbCloudInfrastructure.Repository { - +#nullable enable /// /// CRUD сервис для работы СЃ БД /// diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs index 221e5d3c..09c06643 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs @@ -126,7 +126,7 @@ namespace AsbCloudInfrastructure.Services.DailyReport var dto = new DailyReportDto() { ReportDate = date, - WellName = well.Caption, + WellName = well!.Caption, ClusterName = well.Cluster, }; DailyReportDto result = dto; diff --git a/AsbCloudInfrastructure/Services/DetectOperations/OperationDetectionBackgroundService.cs b/AsbCloudInfrastructure/Services/DetectOperations/OperationDetectionBackgroundService.cs index 2e44e1e8..7c2f73af 100644 --- a/AsbCloudInfrastructure/Services/DetectOperations/OperationDetectionBackgroundService.cs +++ b/AsbCloudInfrastructure/Services/DetectOperations/OperationDetectionBackgroundService.cs @@ -12,6 +12,7 @@ using AsbCloudInfrastructure.Services.DetectOperations.Detectors; namespace AsbCloudInfrastructure.Services.DetectOperations { +#nullable enable public class OperationDetectionBackgroundService : BackgroundService { private readonly string connectionString; @@ -116,12 +117,12 @@ namespace AsbCloudInfrastructure.Services.DetectOperations { DateTime = d.DateTime, IdUser = d.IdUser, - WellDepth = (float)d.WellDepth, - Pressure = (float)d.Pressure, - HookWeight = (float)d.HookWeight, - BlockPosition = (float)d.BlockPosition, - BitDepth = (float)d.BitDepth, - RotorSpeed = (float)d.RotorSpeed, + WellDepth = d.WellDepth ?? float.NaN, + Pressure = d.Pressure ?? float.NaN, + HookWeight = d.HookWeight ?? float.NaN, + BlockPosition = d.BlockPosition ?? float.NaN, + BitDepth = d.BitDepth ?? float.NaN, + RotorSpeed = d.RotorSpeed ?? float.NaN, }) .OrderBy(d => d.DateTime); @@ -150,9 +151,9 @@ namespace AsbCloudInfrastructure.Services.DetectOperations { for (int i = 0; i < detectors.Length; i++) { - if (detectors[i].TryDetect(idTelemetry, data, positionBegin, positionEnd, lastDetectedOperation, out OperationDetectorResult result)) + if (detectors[i].TryDetect(idTelemetry, data, positionBegin, positionEnd, lastDetectedOperation, out OperationDetectorResult? result)) { - detectedOperations.Add(result.Operation); + detectedOperations.Add(result!.Operation); lastDetectedOperation = result.Operation; isDetected = true; positionBegin = result.TelemetryEnd; @@ -163,7 +164,7 @@ namespace AsbCloudInfrastructure.Services.DetectOperations } if (isDetected) - startDate = lastDetectedOperation.DateEnd; + startDate = lastDetectedOperation!.DateEnd; else startDate = data[positionEnd].DateTime; } @@ -171,4 +172,5 @@ namespace AsbCloudInfrastructure.Services.DetectOperations return detectedOperations; } } +#nullable disable } diff --git a/AsbCloudInfrastructure/Services/WellOperationService/WellOperationService.cs b/AsbCloudInfrastructure/Services/WellOperationService/WellOperationService.cs index 67f4e8fc..9ad570b4 100644 --- a/AsbCloudInfrastructure/Services/WellOperationService/WellOperationService.cs +++ b/AsbCloudInfrastructure/Services/WellOperationService/WellOperationService.cs @@ -12,6 +12,7 @@ using System.Threading.Tasks; namespace AsbCloudInfrastructure.Services.WellOperationService { +#nullable enable public class WellOperationService : IWellOperationService { private readonly IAsbCloudDbContext db; @@ -219,4 +220,5 @@ namespace AsbCloudInfrastructure.Services.WellOperationService .ConfigureAwait(false); } } +#nullable disable }