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