forked from ddrilling/AsbCloudServer
#nullable enable (part 2)
This commit is contained in:
parent
b8e5a8bf4c
commit
2431557539
@ -16,7 +16,7 @@ namespace AsbCloudApp.Services
|
||||
/// <param name="id"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<FileCategoryDto> GetOrDefaultAsync(int id, CancellationToken token);
|
||||
Task<FileCategoryDto?> GetOrDefaultAsync(int id, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Получение справочника категорий файлов
|
||||
|
@ -24,7 +24,7 @@ namespace AsbCloudApp.Services
|
||||
/// <param name="idCategory"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<MeasureDto> GetLastAsync(int idWell, int idCategory, CancellationToken token);
|
||||
Task<MeasureDto?> GetLastOrDefaultAsync(int idWell, int idCategory, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// История измерений по категории
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace AsbCloudInfrastructure
|
||||
{
|
||||
#nullable enable
|
||||
public static class DateTimeExtentions
|
||||
{
|
||||
/// <summary>
|
||||
@ -77,4 +78,5 @@ namespace AsbCloudInfrastructure
|
||||
return indexOfMiddle;
|
||||
}
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
@ -1,8 +0,0 @@
|
||||
namespace AsbCloudInfrastructure
|
||||
{
|
||||
/// <summary>
|
||||
/// Тип для поиска этой сборки
|
||||
/// </summary>
|
||||
public interface IInfrastructureMarker
|
||||
{ }
|
||||
}
|
@ -81,7 +81,6 @@ 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);
|
||||
|
@ -16,9 +16,7 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram
|
||||
var resultExcelFile = new XLWorkbook(XLEventTracking.Disabled);
|
||||
|
||||
var titleSheet = resultExcelFile.AddWorksheet("Титульный лист");
|
||||
var marks = parts
|
||||
.Where(p => p.File is not null)
|
||||
.SelectMany(p => p.File!.FileMarks);
|
||||
var marks = parts.SelectMany(p => p.File!.FileMarks);
|
||||
var titleSheetMaker = new TitleListSheet(marks, well);
|
||||
titleSheetMaker.Draw(titleSheet);
|
||||
|
||||
|
@ -1,10 +1,12 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Exceptions;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace AsbCloudInfrastructure.Services.Email
|
||||
{
|
||||
#nullable enable
|
||||
public class BaseFactory
|
||||
{
|
||||
private readonly string platformName;
|
||||
@ -23,14 +25,13 @@ namespace AsbCloudInfrastructure.Services.Email
|
||||
public static string GetImageBase64(string resourceFileName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(resourceFileName))
|
||||
return null;
|
||||
throw new ArgumentInvalidException("ResourceFileName doesn`t exist", nameof(resourceFileName));
|
||||
|
||||
var baseDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
|
||||
var baseDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)
|
||||
?? string.Empty;
|
||||
var resoursesDir = "Res";
|
||||
|
||||
var logoFilePath = Path.Combine(baseDir, resoursesDir, resourceFileName);
|
||||
if(!File.Exists(logoFilePath))
|
||||
return string.Empty;
|
||||
var imageBytes = File.ReadAllBytes(logoFilePath);
|
||||
var format = Path.GetExtension(resourceFileName).Trim('.');
|
||||
return "data:image/" + format + ";base64," + Convert.ToBase64String(imageBytes);
|
||||
@ -53,4 +54,5 @@ namespace AsbCloudInfrastructure.Services.Email
|
||||
public virtual string MakeSubject(WellDto well, string action)
|
||||
=> $"{well.Deposit}, {well.Cluster}, {well.Caption}. {action}";
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
@ -6,7 +6,8 @@ using System.IO;
|
||||
|
||||
namespace AsbCloudInfrastructure
|
||||
{
|
||||
class DrillingMailBodyFactory : BaseFactory
|
||||
#nullable enable
|
||||
class DrillingMailBodyFactory : BaseFactory
|
||||
{
|
||||
private readonly string platformName;
|
||||
private readonly string platformUrl;
|
||||
@ -84,4 +85,5 @@ namespace AsbCloudInfrastructure
|
||||
return drillingProgramHref;
|
||||
}
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
@ -6,7 +6,8 @@ using System.IO;
|
||||
|
||||
namespace AsbCloudInfrastructure
|
||||
{
|
||||
class WellFinalDocumentMailBodyFactory : BaseFactory
|
||||
#nullable enable
|
||||
class WellFinalDocumentMailBodyFactory : BaseFactory
|
||||
{
|
||||
private readonly string platformName;
|
||||
|
||||
@ -29,4 +30,5 @@ namespace AsbCloudInfrastructure
|
||||
return body;
|
||||
}
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
#nullable enable
|
||||
public class FileCategoryService : CrudCacheRepositoryBase<FileCategoryDto, FileCategory>, IFileCategoryService
|
||||
{
|
||||
public FileCategoryService(IAsbCloudDbContext context, IMemoryCache memoryCache)
|
||||
@ -28,4 +29,5 @@ namespace AsbCloudInfrastructure.Services
|
||||
return dtos;
|
||||
}
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
@ -1,8 +0,0 @@
|
||||
namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
public interface IConverter<TDto, TModel>
|
||||
{
|
||||
TModel Convert(TDto src);
|
||||
TDto Convert(TModel src);
|
||||
}
|
||||
}
|
@ -6,7 +6,6 @@ using AsbCloudApp.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@ -5,6 +5,7 @@ namespace AsbCloudInfrastructure.Services.ProcessMap;
|
||||
|
||||
internal static class XLExtentions
|
||||
{
|
||||
#nullable enable
|
||||
public static IXLCell SetVal(this IXLCell cell, string value, bool adaptRowHeight = false)
|
||||
{
|
||||
cell.Value = value;
|
||||
@ -47,4 +48,5 @@ internal static class XLExtentions
|
||||
cell.Style.NumberFormat.Format = format;
|
||||
return cell;
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using DocumentFormat.OpenXml.Drawing.Diagrams;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
@ -10,6 +10,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudInfrastructure.Services.SAUB
|
||||
{
|
||||
#nullable enable
|
||||
public class EventService : IEventService
|
||||
{
|
||||
private readonly IAsbCloudDbContext db;
|
||||
@ -42,4 +43,5 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
||||
memoryCache.DropBasic<TelemetryEvent>();
|
||||
}
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
@ -113,4 +113,5 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
||||
public IEnumerable<SetpointInfoDto> GetSetpointsNames()
|
||||
=> SetpointInfos.Values;
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ using Mapster;
|
||||
|
||||
namespace AsbCloudInfrastructure.Services.SAUB
|
||||
{
|
||||
#nullable enable
|
||||
public class TelemetryDataSpinService : TelemetryDataBaseService<TelemetryDataSpinDto, TelemetryDataSpin>
|
||||
{
|
||||
public TelemetryDataSpinService(
|
||||
@ -28,4 +29,5 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
@ -12,13 +12,14 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudInfrastructure.Services.SAUB
|
||||
{
|
||||
#nullable enable
|
||||
public class TelemetryTracker : ITelemetryTracker
|
||||
{
|
||||
class TrackerStat
|
||||
{
|
||||
//public int Id { get; set; }
|
||||
|
||||
public string RemoteUid { get; set; }
|
||||
public string RemoteUid { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Время последнего запроса (по времени сервера)
|
||||
@ -88,10 +89,14 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
||||
|
||||
foreach (var oldReq in oldRequests)
|
||||
{
|
||||
var telemetryStat = telemetriesStats.GetOrAdd(oldReq.Uid, (uid) => new TrackerStat { RemoteUid = uid });
|
||||
telemetryStat.TelemetryDateUtcMin = oldReq.DateMin;
|
||||
telemetryStat.TelemetryDateUtcMax = oldReq.DateMax;
|
||||
telemetryStat.LastTimeServer = oldReq.DateMax;
|
||||
if (oldReq.Uid is not null)
|
||||
{
|
||||
var telemetryStat = telemetriesStats.GetOrAdd(oldReq.Uid, (uid) => new TrackerStat { RemoteUid = uid });
|
||||
telemetryStat.TelemetryDateUtcMin = oldReq.DateMin;
|
||||
telemetryStat.TelemetryDateUtcMax = oldReq.DateMax;
|
||||
telemetryStat.LastTimeServer = oldReq.DateMax;
|
||||
}
|
||||
|
||||
}
|
||||
}).ContinueWith((t) =>
|
||||
{
|
||||
@ -147,4 +152,5 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
||||
public IEnumerable<string> GetTransmittingTelemetriesUids() =>
|
||||
telemetriesStats.Keys;
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
@ -54,4 +54,5 @@ namespace AsbCloudInfrastructure.Services.Trajectory
|
||||
return cartesianCoordinates;
|
||||
}
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Exceptions;
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudDb.Model;
|
||||
using ClosedXML.Excel;
|
||||
@ -11,6 +12,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
{
|
||||
#nullable enable
|
||||
public class ScheduleReportService : IScheduleReportService
|
||||
{
|
||||
private readonly IOperationsStatService operationsStatService;
|
||||
@ -29,11 +31,11 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
{
|
||||
var tvd = await operationsStatService.GetTvdAsync(idWell, token);
|
||||
|
||||
if (!tvd.Any())
|
||||
return null;
|
||||
|
||||
var well = await wellService.GetOrDefaultAsync(idWell, token);
|
||||
|
||||
if(well is null)
|
||||
throw new ArgumentInvalidException("idWell doesn`t exist", nameof(idWell));
|
||||
|
||||
var ecxelTemplateStream = GetExcelTemplateStream();
|
||||
using var workbook = new XLWorkbook(ecxelTemplateStream, XLEventTracking.Disabled);
|
||||
FillScheduleSheetToWorkbook(workbook, tvd, well);
|
||||
@ -236,9 +238,9 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
? operation.DateStart.AddHours(operation.DurationHours)
|
||||
: default;
|
||||
|
||||
var endDatePlan = GetEndDate(planLast);
|
||||
var endDateFact = GetEndDate(factLast);
|
||||
var endDatePredict = GetEndDate(predictLast);
|
||||
var endDatePlan = planLast is not null ? GetEndDate(planLast) : default;
|
||||
var endDateFact = factLast is not null ? GetEndDate(factLast) : default;
|
||||
var endDatePredict = predictLast is not null ? GetEndDate(predictLast) : default;
|
||||
|
||||
var endDate = endDatePredict > endDateFact
|
||||
? endDatePredict
|
||||
@ -301,7 +303,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
return cell;
|
||||
}
|
||||
|
||||
private static IXLCell SetCell(IXLRow row, int colunm, object value)
|
||||
private static IXLCell SetCell(IXLRow row, int colunm, object? value)
|
||||
{
|
||||
var cell = row.Cell(colunm);
|
||||
cell.Value = value;
|
||||
@ -330,8 +332,9 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
private static Stream GetExcelTemplateStream()
|
||||
{
|
||||
var stream = System.Reflection.Assembly.GetExecutingAssembly()
|
||||
.GetManifestResourceStream("AsbCloudInfrastructure.Services.WellOperationService.ScheduleReportTemplate.xlsx");
|
||||
.GetManifestResourceStream("AsbCloudInfrastructure.Services.WellOperationService.ScheduleReportTemplate.xlsx")!;
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var result = await measureService.GetLastAsync(idWell, idCategory, token).ConfigureAwait(false);
|
||||
var result = await measureService.GetLastOrDefaultAsync(idWell, idCategory, token).ConfigureAwait(false);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user