forked from ddrilling/AsbCloudServer
Убрана часть warnings
This commit is contained in:
parent
3038a2c52a
commit
c8c504b3be
@ -3,6 +3,9 @@ using AsbCloudApp.Data.WellOperation;
|
||||
|
||||
namespace AsbCloudApp.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// dto для хранения данных статистики сауб
|
||||
/// </summary>
|
||||
public class DataSaubStatDto:IId
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -72,7 +72,7 @@ public class ProcessMapPlanReamDto : ProcessMapPlanBaseDto, IValidatableObject
|
||||
public double Torque { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
public override IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if (DepthEnd < DepthStart)
|
||||
yield return new ValidationResult(
|
||||
|
@ -8,5 +8,5 @@ public class ReportProgressFinalDto : ReportProgressDto
|
||||
/// <summary>
|
||||
/// файл
|
||||
/// </summary>
|
||||
public FileInfoDto file { get; set; }
|
||||
public FileInfoDto? file { get; set; }
|
||||
}
|
||||
|
@ -4,6 +4,9 @@ using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace AsbCloudApp.Data.WellOperation;
|
||||
|
||||
/// <summary>
|
||||
/// Операция по скважине
|
||||
/// </summary>
|
||||
public class WellOperationDto : ItemInfoDto,
|
||||
IId,
|
||||
IWellRelated,
|
||||
|
@ -70,6 +70,13 @@ namespace AsbCloudApp.Services
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> MergeAsync(int from, int to, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Получить телеметрию по последней дате
|
||||
/// </summary>
|
||||
/// <param name="from"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<Stream> GetTelemetriesInfoByLastData(DateTimeOffset from, CancellationToken token);
|
||||
}
|
||||
}
|
@ -47,13 +47,17 @@ namespace AsbCloudInfrastructure
|
||||
public static Task<IEnumerable<T>> GetOrCreateBasicAsync<T>(this IMemoryCache memoryCache, Func<CancellationToken, Task<IEnumerable<T>>> getterAsync, CancellationToken token)
|
||||
{
|
||||
var key = typeof(T).FullName;
|
||||
var cache = memoryCache.GetOrCreateAsync(key, async (cacheEntry) => {
|
||||
if (key == null)
|
||||
return Task.FromResult(Enumerable.Empty<T>());
|
||||
|
||||
var cache = memoryCache.GetOrCreateAsync(key, async (cacheEntry) =>
|
||||
{
|
||||
cacheEntry.AbsoluteExpirationRelativeToNow = CacheOlescence;
|
||||
cacheEntry.SlidingExpiration = CacheOlescence;
|
||||
var entities = await getterAsync(token);
|
||||
return entities;
|
||||
});
|
||||
return cache;
|
||||
return cache!;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -84,12 +88,13 @@ namespace AsbCloudInfrastructure
|
||||
public static IEnumerable<T> GetOrCreateBasic<T>(this IMemoryCache memoryCache, Func<IEnumerable<T>> getter)
|
||||
{
|
||||
var key = typeof(T).FullName;
|
||||
var cache = memoryCache.GetOrCreate(key, cacheEntry => {
|
||||
var cache = memoryCache.GetOrCreate(key, cacheEntry =>
|
||||
{
|
||||
cacheEntry.AbsoluteExpirationRelativeToNow = CacheOlescence;
|
||||
cacheEntry.SlidingExpiration = CacheOlescence;
|
||||
return getter();
|
||||
});
|
||||
return cache;
|
||||
return cache!;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -102,6 +107,10 @@ namespace AsbCloudInfrastructure
|
||||
where T : class
|
||||
{
|
||||
var key = typeof(T).FullName;
|
||||
|
||||
if (key == null)
|
||||
return;
|
||||
|
||||
memoryCache.Remove(key);
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ namespace AsbCloudInfrastructure.Repository
|
||||
cacheEntry.Value = entities;
|
||||
return entities;
|
||||
});
|
||||
return cache;
|
||||
return cache!;
|
||||
}
|
||||
|
||||
protected virtual Task<IEnumerable<TEntity>> GetCacheAsync(CancellationToken token)
|
||||
|
@ -77,7 +77,7 @@ public class NotificationRepository : CrudRepositoryBase<NotificationDto, Notifi
|
||||
.ToArrayAsync(cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<int> UpdateRangeAsync(IEnumerable<NotificationDto> notifications, CancellationToken cancellationToken)
|
||||
public override async Task<int> UpdateRangeAsync(IEnumerable<NotificationDto> notifications, CancellationToken cancellationToken)
|
||||
{
|
||||
if (!notifications.Any())
|
||||
return 0;
|
||||
|
@ -16,10 +16,10 @@ namespace AsbCloudInfrastructure.Services.Email
|
||||
|
||||
public BaseFactory(IConfiguration configuration)
|
||||
{
|
||||
platformName = configuration.GetValue("email:platformName", "Цифровое бурение");
|
||||
platformUrl = configuration.GetValue("email:platformUrl", "https://cloud.digitaldrilling.ru/");
|
||||
companyName = configuration.GetValue("email:companyName", "ООО \"Цифровое бурение\"");
|
||||
supportMail = configuration.GetValue("email:supportMail", "support@digitaldrilling.ru");
|
||||
platformName = configuration.GetValue("email:platformName", "Цифровое бурение") ?? string.Empty;
|
||||
platformUrl = configuration.GetValue("email:platformUrl", "https://cloud.digitaldrilling.ru/") ?? string.Empty;
|
||||
companyName = configuration.GetValue("email:companyName", "ООО \"Цифровое бурение\"") ?? string.Empty;
|
||||
supportMail = configuration.GetValue("email:supportMail", "support@digitaldrilling.ru") ?? string.Empty;
|
||||
}
|
||||
|
||||
public static string GetOrEmptyImageBase64(string resourceFileName)
|
||||
|
@ -12,8 +12,8 @@ namespace AsbCloudInfrastructure.Services.Email
|
||||
public DrillingMailBodyFactory(IConfiguration configuration)
|
||||
: base(configuration)
|
||||
{
|
||||
platformName = configuration.GetValue("email:platformName", "Цифровое бурение");
|
||||
platformUrl = configuration.GetValue("email:platformUrl", "https://cloud.digitaldrilling.ru/");
|
||||
platformName = configuration.GetValue("email:platformName", "Цифровое бурение") ?? string.Empty;
|
||||
platformUrl = configuration.GetValue("email:platformUrl", "https://cloud.digitaldrilling.ru/") ?? string.Empty;
|
||||
}
|
||||
|
||||
public override string MakeSubject(WellDto well, string action)
|
||||
|
@ -29,9 +29,9 @@ namespace AsbCloudInfrastructure.Services.Email
|
||||
{
|
||||
this.userRepository = userRepository;
|
||||
|
||||
this.sender = configuration.GetValue("email:sender", string.Empty);
|
||||
this.smtpPassword = configuration.GetValue("email:password", string.Empty);
|
||||
this.smtpServer = configuration.GetValue("email:smtpServer", string.Empty);
|
||||
this.sender = configuration.GetValue("email:sender", string.Empty) ?? string.Empty;
|
||||
this.smtpPassword = configuration.GetValue("email:password", string.Empty) ?? string.Empty;
|
||||
this.smtpServer = configuration.GetValue("email:smtpServer", string.Empty) ?? string.Empty;
|
||||
|
||||
var configError = string.IsNullOrEmpty(this.sender) ||
|
||||
string.IsNullOrEmpty(this.smtpPassword) ||
|
||||
|
@ -14,7 +14,7 @@ namespace AsbCloudInfrastructure
|
||||
public WellFinalDocumentMailBodyFactory(IConfiguration configuration)
|
||||
: base(configuration)
|
||||
{
|
||||
platformName = configuration.GetValue("email:platformName", "Цифровое бурение");
|
||||
platformName = configuration.GetValue("email:platformName", "Цифровое бурение") ?? string.Empty;
|
||||
}
|
||||
|
||||
public override string MakeSubject(WellDto well, string action)
|
||||
|
@ -30,7 +30,7 @@ public class HelpPageService : IHelpPageService
|
||||
{
|
||||
this.helpPageRepository = helpPageRepository;
|
||||
this.fileStorageRepository = fileStorageRepository;
|
||||
directoryNameHelpPageFiles = configuration.GetValue<string>("DirectoryNameHelpPageFiles");
|
||||
directoryNameHelpPageFiles = configuration.GetValue<string>("DirectoryNameHelpPageFiles") ?? string.Empty;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(directoryNameHelpPageFiles))
|
||||
directoryNameHelpPageFiles = "helpPages";
|
||||
|
@ -35,7 +35,7 @@ public class ManualCatalogService : IManualCatalogService
|
||||
this.fileStorageRepository = fileStorageRepository;
|
||||
this.manualDirectoryRepository = manualDirectoryRepository;
|
||||
this.manualRepository = manualRepository;
|
||||
directoryFiles = configuration.GetValue<string>("DirectoryManualFiles");
|
||||
directoryFiles = configuration.GetValue<string>("DirectoryManualFiles") ?? string.Empty;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(directoryFiles))
|
||||
directoryFiles = "manuals";
|
||||
|
@ -38,7 +38,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
.ToDictionaryAsync(e => e.Id, e => e.Name, token);
|
||||
return entities;
|
||||
});
|
||||
return cache;
|
||||
return cache!;
|
||||
}
|
||||
|
||||
public async Task<MeasureDto?> GetLastOrDefaultAsync(int idWell, int idCategory, CancellationToken token)
|
||||
|
@ -36,7 +36,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
|
||||
private ReduceSamplingService(IConfiguration configuration)
|
||||
{
|
||||
connectionString = configuration.GetConnectionString("DefaultConnection");
|
||||
connectionString = configuration.GetConnectionString("DefaultConnection") ?? string.Empty;
|
||||
}
|
||||
|
||||
~ReduceSamplingService()
|
||||
|
@ -84,7 +84,7 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
||||
var entities = db.Set<TelemetryUser>().ToArray();
|
||||
return entities;
|
||||
});
|
||||
return cache;
|
||||
return cache!;
|
||||
}
|
||||
|
||||
private void DropCache()
|
||||
|
@ -21,7 +21,7 @@ public interface IDrillTestControllerClient
|
||||
int id,
|
||||
CancellationToken cancellationToken);
|
||||
|
||||
[HttpGet("/api/well/{idWell}/DrillTest/all")]
|
||||
[Get("/api/well/{idWell}/DrillTest/all")]
|
||||
Task<IApiResponse<PaginationContainer<DrillTestReportInfoDto>>> GetListAsync(
|
||||
int idWell,
|
||||
FileReportRequest request,
|
||||
|
@ -55,7 +55,6 @@ public class DetectedOperationControllerTests : BaseIntegrationTest
|
||||
|
||||
//assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.NotNull(response.Content);
|
||||
Assert.Equal(1, response.Content);
|
||||
}
|
||||
|
||||
@ -76,7 +75,6 @@ public class DetectedOperationControllerTests : BaseIntegrationTest
|
||||
|
||||
//assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.NotNull(response.Content);
|
||||
Assert.Equal(1, response.Content);
|
||||
}
|
||||
|
||||
@ -112,7 +110,6 @@ public class DetectedOperationControllerTests : BaseIntegrationTest
|
||||
|
||||
//assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.NotNull(response.Content);
|
||||
Assert.Equal(1, response.Content);
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class ProcessMapReportDrillingControllerTest : BaseIntegrationTest
|
||||
//assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.NotNull(response.Content);
|
||||
Assert.Equal(1, response.Content.Count());
|
||||
Assert.Single(response.Content);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -118,7 +118,7 @@ public class WellOperationControllerTest : BaseIntegrationTest
|
||||
var response = await client.GetPageOperationsAsync(well.Id, request);
|
||||
|
||||
//assert
|
||||
Assert.Equal(response.StatusCode, HttpStatusCode.OK);
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.NotNull(response.Content);
|
||||
|
||||
var totalExpected = response.Content.Count - pageSize * pageIndex;
|
||||
@ -230,10 +230,8 @@ public class WellOperationControllerTest : BaseIntegrationTest
|
||||
Assert.True(notExistedInDb.Count() == 0);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(WellOperation.IdOperationTypePlan)]
|
||||
[InlineData(WellOperation.IdOperationTypeFact)]
|
||||
public async Task GetPageOperationsAsyncWithDaysAndNpv_returns_success(int idType)
|
||||
[Fact]
|
||||
public async Task GetPageOperationsAsyncWithDaysAndNpv_returns_success()
|
||||
{
|
||||
//arrange
|
||||
const int pageSize = 10;
|
||||
|
@ -48,7 +48,7 @@ public class BackgroundWorkerTest
|
||||
backgroundWorker.Enqueue(work);
|
||||
}
|
||||
|
||||
await backgroundWorker.ExecuteTask;
|
||||
await backgroundWorker.ExecuteTask!;
|
||||
|
||||
//assert
|
||||
Assert.Equal(workCount, result);
|
||||
@ -79,7 +79,7 @@ public class BackgroundWorkerTest
|
||||
backgroundWorker.Enqueue(badWork);
|
||||
backgroundWorker.Enqueue(goodWork);
|
||||
|
||||
await backgroundWorker.ExecuteTask;
|
||||
await backgroundWorker.ExecuteTask!;
|
||||
|
||||
//assert
|
||||
Assert.Equal(expectadResult, result);
|
||||
@ -109,7 +109,7 @@ public class BackgroundWorkerTest
|
||||
|
||||
var removed = backgroundWorker.TryRemoveFromQueue((workCount - 1).ToString());
|
||||
|
||||
await backgroundWorker.ExecuteTask;
|
||||
await backgroundWorker.ExecuteTask!;
|
||||
|
||||
//assert
|
||||
Assert.True(removed);
|
||||
|
@ -1,13 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Repositories;
|
||||
using AsbCloudInfrastructure.Services;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using NSubstitute;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace AsbCloudWebApi.Tests.Services;
|
||||
@ -18,7 +18,7 @@ public class HelpPageServiceTest
|
||||
private const string fileName = "Справка_для_страницы_test.pdf";
|
||||
private const int idCategory = 20000;
|
||||
|
||||
private static Dictionary<string, string> configSettings = new()
|
||||
private static Dictionary<string, string?> configSettings = new()
|
||||
{
|
||||
{ "DirectoryNameHelpPageFiles", "helpPages" }
|
||||
};
|
||||
|
@ -43,7 +43,7 @@ namespace AsbCloudWebApi.Tests.Services.Notification
|
||||
Surname = "Test",
|
||||
};
|
||||
|
||||
private static Dictionary<string, string> configSettings = new()
|
||||
private static Dictionary<string, string?> configSettings = new()
|
||||
{
|
||||
{ "email:sender", "bot@digitaldrilling.ru" },
|
||||
{ "email:password", "8wZrXSfP" },
|
||||
|
@ -46,9 +46,9 @@ namespace AsbCloudWebApi.Controllers
|
||||
var drillers = schedulePage
|
||||
.Select(s => s.Driller)
|
||||
.Where(d => d is not null)
|
||||
.GroupBy(d => d.Id)
|
||||
.GroupBy(d => d!.Id)
|
||||
.Select(group => group.First())
|
||||
.OrderBy(d => d.Surname);
|
||||
.OrderBy(d => d!.Surname);
|
||||
|
||||
return Ok(drillers);
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ public static class Extensions
|
||||
/// <summary>
|
||||
/// Получение Excel
|
||||
/// </summary>
|
||||
/// <param name="files"></param>
|
||||
/// <param name="file"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentInvalidException"></exception>
|
||||
public static Stream GetExcelFile(this IFormFile file)
|
||||
|
Loading…
Reference in New Issue
Block a user