#nullable enable (устранение warnings)

This commit is contained in:
Olga Nemt 2023-04-14 15:23:43 +05:00
parent e77f542207
commit 4ac3afdabf
4 changed files with 34 additions and 13 deletions

View File

@ -1,5 +1,4 @@
using AsbCloudApp.Services; using AsbCloudApp.Services;
using AsbCloudDb;
using AsbCloudDb.Model; using AsbCloudDb.Model;
using Mapster; using Mapster;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@ -54,9 +53,7 @@ namespace AsbCloudInfrastructure.Repository
.Where(d => d.DateTime <= end) .Where(d => d.DateTime <= end)
.AsNoTracking(); .AsNoTracking();
var data = await query.ToListAsync(token); var data = await query.ToListAsync(token);
return data return data.Select(d => Convert(d, timezoneHours));
.Where(d => d is not null)
.Select(d => Convert(d, timezoneHours));
} }
public async Task<IEnumerable<TDto>> GetLastAsync(int idTelemetry, CancellationToken token) public async Task<IEnumerable<TDto>> GetLastAsync(int idTelemetry, CancellationToken token)

View File

@ -369,10 +369,13 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram
{ {
var file = await fileService.GetOrDefaultAsync(fileMark.IdFile, token); var file = await fileService.GetOrDefaultAsync(fileMark.IdFile, token);
var well = await wellService.GetOrDefaultAsync(file!.IdWell, token); var well = await wellService.GetOrDefaultAsync(file!.IdWell, token);
if (well is null)
throw new ArgumentInvalidException("idWell doesn`t exist", nameof(file.IdWell));
var user = file.Author!; var user = file.Author!;
var factory = new DrillingMailBodyFactory(configuration); var factory = new DrillingMailBodyFactory(configuration);
var subject = factory.MakeSubject(well, "Загруженный вами документ полностью согласован"); var subject = factory.MakeSubject(well, "Загруженный вами документ полностью согласован");
var body = factory.MakeMailBodyForPublisherOnFullAccept(well, user.Name, file.Id, file.Name); var body = factory.MakeMailBodyForPublisherOnFullAccept(well, user.Name ?? string.Empty, file.Id, file.Name);
emailService.EnqueueSend(user.Email, subject, body); emailService.EnqueueSend(user.Email, subject, body);
} }
@ -381,10 +384,13 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram
{ {
var file = await fileService.GetOrDefaultAsync(fileMark.IdFile, token); var file = await fileService.GetOrDefaultAsync(fileMark.IdFile, token);
var well = await wellService.GetOrDefaultAsync(file!.IdWell, token); var well = await wellService.GetOrDefaultAsync(file!.IdWell, token);
if (well is null)
throw new ArgumentInvalidException("idWell doesn`t exist", nameof(file.IdWell));
var user = file.Author!; var user = file.Author!;
var factory = new DrillingMailBodyFactory(configuration); var factory = new DrillingMailBodyFactory(configuration);
var subject = factory.MakeSubject(well, "Загруженный вами документ отклонен"); var subject = factory.MakeSubject(well, "Загруженный вами документ отклонен");
var body = factory.MakeMailBodyForPublisherOnReject(well, user.Name, file.Id, file.Name, fileMark); var body = factory.MakeMailBodyForPublisherOnReject(well, user.Name ?? string.Empty, file.Id, file.Name, fileMark);
emailService.EnqueueSend(user.Email, subject, body); emailService.EnqueueSend(user.Email, subject, body);
} }
@ -392,6 +398,9 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram
private async Task NotifyApproversAsync(DrillingProgramPart part, int idFile, string fileName, CancellationToken token) private async Task NotifyApproversAsync(DrillingProgramPart part, int idFile, string fileName, CancellationToken token)
{ {
var well = await wellService.GetOrDefaultAsync(part.IdWell, token); var well = await wellService.GetOrDefaultAsync(part.IdWell, token);
if (well is null)
throw new ArgumentInvalidException("idWell doesn`t exist", nameof(part.IdWell));
var factory = new DrillingMailBodyFactory(configuration); var factory = new DrillingMailBodyFactory(configuration);
var subject = factory.MakeSubject(well, "Загружен новый документ для согласования."); var subject = factory.MakeSubject(well, "Загружен новый документ для согласования.");
var users = part.RelatedUsers var users = part.RelatedUsers
@ -400,7 +409,7 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram
foreach (var user in users) foreach (var user in users)
{ {
var body = factory.MakeMailBodyForApproverNewFile(well, user.Name, idFile, fileName); var body = factory.MakeMailBodyForApproverNewFile(well, user.Name ?? string.Empty, idFile, fileName);
emailService.EnqueueSend(user.Email, subject, body); emailService.EnqueueSend(user.Email, subject, body);
} }
} }
@ -408,9 +417,12 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram
private async Task NotifyNewPublisherAsync(int idWell, UserDto user, string documentCategory, CancellationToken token) private async Task NotifyNewPublisherAsync(int idWell, UserDto user, string documentCategory, CancellationToken token)
{ {
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 factory = new DrillingMailBodyFactory(configuration); var factory = new DrillingMailBodyFactory(configuration);
var subject = factory.MakeSubject(well, $"От вас ожидается загрузка на портал документа «{documentCategory}»"); var subject = factory.MakeSubject(well, $"От вас ожидается загрузка на портал документа «{documentCategory}»");
var body = factory.MakeMailBodyForNewPublisher(well, user.Name, documentCategory); var body = factory.MakeMailBodyForNewPublisher(well, user.Name ?? string.Empty, documentCategory);
emailService.EnqueueSend(user.Email, subject, body); emailService.EnqueueSend(user.Email, subject, body);
} }

View File

@ -125,19 +125,31 @@ namespace AsbCloudInfrastructure.Services
{ {
var category = await fileCategoryService.GetOrDefaultAsync(item.IdCategory, token); var category = await fileCategoryService.GetOrDefaultAsync(item.IdCategory, token);
var well = await wellService.GetOrDefaultAsync(item.IdWell, token); var well = await wellService.GetOrDefaultAsync(item.IdWell, token);
if(well is null)
throw new ArgumentInvalidException("idWell doesn`t exist", nameof(item.IdWell));
SendMessage(well, user, category.Name, message); SendMessage(well, user, category?.Name ?? string.Empty, message);
} }
} }
} }
private void SendMessage(WellDto? well, UserDto user, string documentCategory, string message) private void SendMessage(WellDto well, UserDto user, string documentCategory, string message)
{ {
var factory = new WellFinalDocumentMailBodyFactory(configuration); var factory = new WellFinalDocumentMailBodyFactory(configuration);
var subject = factory.MakeSubject(well, documentCategory); var subject = factory.MakeSubject(well, documentCategory);
var body = factory.MakeMailBodyForWellFinalDocument(well, user.Name ?? user.Surname, string.Format(message, documentCategory));
if(!string.IsNullOrEmpty(user.Email))
{
var body = factory.MakeMailBodyForWellFinalDocument(
well,
(user.Name ?? user.Surname ?? string.Empty),
string.Format(message, documentCategory)
);
emailService.EnqueueSend(user.Email, subject, body); emailService.EnqueueSend(user.Email, subject, body);
} }
}
} }
#nullable disable #nullable disable
} }

View File

@ -82,7 +82,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
var tvdList = tvd.ToList(); var tvdList = tvd.ToList();
var facts = tvd var facts = tvd
.Where(t => t.Fact is not null) .Where(t => t.Fact is not null)
.Select(t => t.Fact) .Select(t => t.Fact!)
.ToList(); .ToList();
DateTime lastFactDate = default; DateTime lastFactDate = default;