diff --git a/AsbCloudInfrastructure/Repository/QueryContainer.cs b/AsbCloudInfrastructure/Repository/QueryContainer.cs index a1586220..80838c31 100644 --- a/AsbCloudInfrastructure/Repository/QueryContainer.cs +++ b/AsbCloudInfrastructure/Repository/QueryContainer.cs @@ -5,6 +5,7 @@ using System.Linq; namespace AsbCloudInfrastructure.Repository { +#nullable enable public class QueryContainer where TEntity : class, IId { protected readonly IAsbCloudDbContext dbContext; @@ -25,4 +26,5 @@ namespace AsbCloudInfrastructure.Repository GetQuery = () => makeQuery(dbSet); } } +#nullable disable } \ No newline at end of file diff --git a/AsbCloudInfrastructure/Repository/SetpointsRequestRepository.cs b/AsbCloudInfrastructure/Repository/SetpointsRequestRepository.cs index 844ebcfe..38c00559 100644 --- a/AsbCloudInfrastructure/Repository/SetpointsRequestRepository.cs +++ b/AsbCloudInfrastructure/Repository/SetpointsRequestRepository.cs @@ -11,6 +11,7 @@ using System.Linq; namespace AsbCloudInfrastructure.Repository { +#nullable enable public class SetpointsRequestRepository : CrudWellRelatedCacheRepositoryBase { private readonly IWellService wellService; @@ -61,4 +62,5 @@ namespace AsbCloudInfrastructure.Repository return result; } } +#nullable disable } diff --git a/AsbCloudInfrastructure/Repository/WitsRecordRepository.cs b/AsbCloudInfrastructure/Repository/WitsRecordRepository.cs index 35c2fabb..eeac93d9 100644 --- a/AsbCloudInfrastructure/Repository/WitsRecordRepository.cs +++ b/AsbCloudInfrastructure/Repository/WitsRecordRepository.cs @@ -11,6 +11,7 @@ using System.Threading.Tasks; namespace AsbCloudInfrastructure.Repository { +#nullable enable public class WitsRecordRepository : IWitsRecordRepository where TEntity : AsbCloudDb.Model.WITS.RecordBase, ITelemetryData where TDto : AsbCloudApp.Data.ITelemetryData @@ -53,7 +54,9 @@ namespace AsbCloudInfrastructure.Repository .Where(d => d.DateTime <= end) .AsNoTracking(); var data = await query.ToListAsync(token); - return data.Select(d => Convert(d, timezoneHours)); + return data + .Where(d => d is not null) + .Select(d => Convert(d, timezoneHours)); } public async Task> GetLastAsync(int idTelemetry, CancellationToken token) @@ -64,7 +67,10 @@ namespace AsbCloudInfrastructure.Repository .OrderBy(d => d.DateTime) .AsNoTracking(); var data = await query.LastOrDefaultAsync(token); - return new TDto[] { Convert(data, timezoneHours) }; + if(data is not null) + return new TDto[] { Convert(data, timezoneHours) }; + + return new TDto[] { }; } public async Task SaveDataAsync(int idTelemetry, IEnumerable dtos, CancellationToken token) @@ -75,6 +81,7 @@ namespace AsbCloudInfrastructure.Repository var timezoneHours = telemetryService.GetTimezone(idTelemetry).Hours; var entities = dtos .DistinctBy(d => d.DateTime) + .Where(dto => dto is not null) .Select(dto => Convert(dto, idTelemetry, timezoneHours)); var dateMin = entities.Min(e => e.DateTime); @@ -128,9 +135,6 @@ namespace AsbCloudInfrastructure.Repository private static TEntity Convert(TDto dto, int idTelemetry, double timezoneHours) { - if (dto is null) - return null; - var entity = dto.Adapt(); entity.Recid = GetRecId(dto); entity.IdTelemetry = idTelemetry; @@ -140,13 +144,11 @@ namespace AsbCloudInfrastructure.Repository private static TDto Convert(TEntity entity, double timezoneHours) { - if (entity is null) - return default; - var data = entity.Adapt(); data.DateTime = entity.DateTime.ToRemoteDateTime(timezoneHours); return data; } } +#nullable disable } diff --git a/AsbCloudInfrastructure/Services/DailyReport/BlockAbstract.cs b/AsbCloudInfrastructure/Services/DailyReport/BlockAbstract.cs index cebcb11f..5814914f 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/BlockAbstract.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/BlockAbstract.cs @@ -2,10 +2,12 @@ namespace AsbCloudInfrastructure.Services.DailyReport { +#nullable enable abstract class BlockAbstract { public abstract CellAddress AddressBlockBegin { get; } public abstract CellAddress AddressBlockEnd { get; } public abstract void Draw(IXLWorksheet sheet); } +#nullable disable } diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/BhaBlock.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/BhaBlock.cs index cd859b00..f38e498e 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/BhaBlock.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/BhaBlock.cs @@ -3,6 +3,7 @@ using ClosedXML.Excel; namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks { +#nullable enable class BhaBlock : BlockAbstract { private readonly BhaDto blockDto; @@ -110,7 +111,8 @@ namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks .SetFormulaA1($"{FormulaBhaBlock(AddressDurationDataStart[4], AddressDurationDataFinish[4])}").Style.SetAllBorders(); } } +#nullable disable } - + diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/DimensionlessBlock.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/DimensionlessBlock.cs index f10c046e..28318820 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/DimensionlessBlock.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/DimensionlessBlock.cs @@ -3,12 +3,12 @@ using ClosedXML.Excel; namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks { - +#nullable enable internal class DimensionlessBlock : BlockAbstract { private readonly NoDrillingDto blockDto; - public SaubBlock SaubBlock { get; set; } + public SaubBlock SaubBlock { get; set; } = null!; public CellAddress AddressDimensionTitle { get; } public CellAddress AddressPreparationTitle { get; } @@ -19,7 +19,7 @@ namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks public CellAddress[] AddressPreparationValue { get; } public CellAddress[] AddressExtensionHead { get; } public CellAddress[] AddressExtensionValue { get; } - public CellAddress AddressBlockFormula { get; } + public CellAddress AddressBlockFormula { get; } = null!; public override CellAddress AddressBlockBegin { get; } public override CellAddress AddressBlockEnd { get; } public DimensionlessBlock(CellAddress addressBlockBegin, NoDrillingDto blockDto) @@ -114,6 +114,6 @@ namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks ._SetValue("Наращивание"); } } - +#nullable disable } diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/HeadBlock.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/HeadBlock.cs index 2acc1160..a306413f 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/HeadBlock.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/HeadBlock.cs @@ -3,7 +3,7 @@ using ClosedXML.Excel; namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks { - +#nullable enable class HeadBlock : BlockAbstract { private readonly HeadDto blockDto; @@ -175,6 +175,7 @@ namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks ._SetValue($"{blockDto.CountLaunchesMSE}"); } } +#nullable disable } diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/SaubBlock.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/SaubBlock.cs index 84ad001a..2f3b0588 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/SaubBlock.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/SaubBlock.cs @@ -3,6 +3,7 @@ using ClosedXML.Excel; namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks { +#nullable enable internal class SaubBlock : BlockAbstract { private readonly SaubDto blockDto; @@ -224,5 +225,6 @@ namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks ._SetValue($"Примечание: {blockDto.DeclinesReasonsROP}"); } } +#nullable disable } diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/SignBlock.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/SignBlock.cs index b4fd4e8f..4461b9d4 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/SignBlock.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportBlocks/SignBlock.cs @@ -3,6 +3,7 @@ using ClosedXML.Excel; namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks { +#nullable enable internal class SignBlock : BlockAbstract { private readonly SignDto blockDto; @@ -10,7 +11,6 @@ namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks public CellAddress AddressDrillMaster { get; } public CellAddress AddressSupervisorHead { get; } public CellAddress AddressSupervisor { get; } - public CellAddress[] AddressPeriodTableDataArray { get; } public override CellAddress AddressBlockBegin { get; } public override CellAddress AddressBlockEnd { get; } @@ -45,7 +45,7 @@ namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks .SetValue($"{blockDto.Supervisor}"); } } - +#nullable disable } diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportMakerExcel.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportMakerExcel.cs index 201b1341..500c260a 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportMakerExcel.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportMakerExcel.cs @@ -6,9 +6,10 @@ using System.Collections.Generic; using System.IO; namespace AsbCloudInfrastructure.Services.DailyReport { +#nullable enable public class DailyReportMakerExcel { - private IEnumerable OperationCategories; + private IEnumerable OperationCategories = null!; public Stream MakeReportFromBlocks(DailyReportDto dto, IEnumerable operationCategories) { @@ -55,5 +56,6 @@ namespace AsbCloudInfrastructure.Services.DailyReport sheet.Rows().AdjustToContents(); } } +#nullable disable } diff --git a/AsbCloudInfrastructure/Services/DailyReport/XLExtentions.cs b/AsbCloudInfrastructure/Services/DailyReport/XLExtentions.cs index 5297b0e1..23f902a7 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/XLExtentions.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/XLExtentions.cs @@ -3,6 +3,7 @@ using System; namespace AsbCloudInfrastructure.Services.DailyReport { +#nullable enable internal static class XLExtentions { public static IXLRange _SetValue(this IXLRange range, object value) @@ -156,4 +157,5 @@ namespace AsbCloudInfrastructure.Services.DailyReport => sheet.Range(begin.RowNumber, begin.ColumnNumber, end.RowNumber, end.ColumnNumber); } +#nullable disable } diff --git a/AsbCloudInfrastructure/Services/DetectOperations/DetectableTelemetry.cs b/AsbCloudInfrastructure/Services/DetectOperations/DetectableTelemetry.cs index 1ed08c7a..87f3defe 100644 --- a/AsbCloudInfrastructure/Services/DetectOperations/DetectableTelemetry.cs +++ b/AsbCloudInfrastructure/Services/DetectOperations/DetectableTelemetry.cs @@ -2,6 +2,7 @@ namespace AsbCloudInfrastructure.Services.DetectOperations { +#nullable enable public class DetectableTelemetry { public DateTimeOffset DateTime { get; set; } @@ -13,4 +14,5 @@ namespace AsbCloudInfrastructure.Services.DetectOperations public float BitDepth { get; set; } public float RotorSpeed { get; set; } } +#nullable disable } diff --git a/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationExportService.cs b/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationExportService.cs index ffca6b9f..c261e87d 100644 --- a/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationExportService.cs +++ b/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationExportService.cs @@ -12,6 +12,7 @@ using System.Threading.Tasks; namespace AsbCloudInfrastructure.Services.DetectOperations { +#nullable enable internal class DetectedOperationExportService { private readonly IAsbCloudDbContext db; @@ -41,7 +42,8 @@ namespace AsbCloudInfrastructure.Services.DetectOperations return; var wells = idsWells.Select(i => wellService.GetOrDefault(i)) - .Where(w => w is not null && w.IdTelemetry is not null); + .Where(w => w is not null && w.IdTelemetry is not null) + .Select(w => w!); if (!wells.Any()) return; @@ -114,4 +116,5 @@ namespace AsbCloudInfrastructure.Services.DetectOperations sheet.Cell(rowNumber, 6).Value = operation.Value; } } +#nullable enable } diff --git a/AsbCloudInfrastructure/Services/DetectOperations/Detectors/OperationDetectorResult.cs b/AsbCloudInfrastructure/Services/DetectOperations/Detectors/OperationDetectorResult.cs index f0391b4f..94ee7fc7 100644 --- a/AsbCloudInfrastructure/Services/DetectOperations/Detectors/OperationDetectorResult.cs +++ b/AsbCloudInfrastructure/Services/DetectOperations/Detectors/OperationDetectorResult.cs @@ -2,10 +2,12 @@ namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors { +#nullable enable class OperationDetectorResult { public int TelemetryBegin { get; set; } public int TelemetryEnd { get; set; } - public DetectedOperation Operation { get; set; } + public DetectedOperation Operation { get; set; } = null!; } +#nullable enable } diff --git a/AsbCloudInfrastructure/Services/DetectOperations/InterpolationLine.cs b/AsbCloudInfrastructure/Services/DetectOperations/InterpolationLine.cs index 1dc99547..cc49c079 100644 --- a/AsbCloudInfrastructure/Services/DetectOperations/InterpolationLine.cs +++ b/AsbCloudInfrastructure/Services/DetectOperations/InterpolationLine.cs @@ -2,6 +2,7 @@ namespace AsbCloudInfrastructure.Services.DetectOperations { +#nullable enable public class InterpolationLine { private readonly double xSum; @@ -52,4 +53,5 @@ namespace AsbCloudInfrastructure.Services.DetectOperations public bool IsAverageYGreaterThan(double bound) => (ySum / count) >= bound; } +#nullable disable } diff --git a/AsbCloudInfrastructure/Services/DrillingProgram/DrillingProgramMaker.cs b/AsbCloudInfrastructure/Services/DrillingProgram/DrillingProgramMaker.cs index dae5ff4f..032895c9 100644 --- a/AsbCloudInfrastructure/Services/DrillingProgram/DrillingProgramMaker.cs +++ b/AsbCloudInfrastructure/Services/DrillingProgram/DrillingProgramMaker.cs @@ -6,6 +6,7 @@ using System.Linq; namespace AsbCloudInfrastructure.Services.DrillingProgram { +#nullable enable internal class DrillingProgramMaker { private const int maxAllowedColumns = 256; @@ -15,7 +16,9 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram var resultExcelFile = new XLWorkbook(XLEventTracking.Disabled); var titleSheet = resultExcelFile.AddWorksheet("Титульный лист"); - var marks = parts.SelectMany(p => p.File.FileMarks); + var marks = parts + .Where(p => p.File is not null) + .SelectMany(p => p.File!.FileMarks); var titleSheetMaker = new TitleListSheet(marks, well); titleSheetMaker.Draw(titleSheet); @@ -128,4 +131,5 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram return rngData; } } +#nullable disable } diff --git a/AsbCloudInfrastructure/Services/DrillingProgram/ImageInfo.cs b/AsbCloudInfrastructure/Services/DrillingProgram/ImageInfo.cs index 8f9265f9..aeedd213 100644 --- a/AsbCloudInfrastructure/Services/DrillingProgram/ImageInfo.cs +++ b/AsbCloudInfrastructure/Services/DrillingProgram/ImageInfo.cs @@ -2,14 +2,16 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram { +#nullable enable class ImageInfo { public int Id { get; set; } - public byte[] Data { get; set; } + public byte[] Data { get; set; } = null!; public int Height { get; set; } public int Width { get; set; } - public IXLAddress TopLeftCellAddress { get; set; } + public IXLAddress TopLeftCellAddress { get; set; } = null!; public int Left { get; set; } public int Top { get; set; } } +#nullable disable } \ No newline at end of file