forked from ddrilling/AsbCloudServer
Очистка кода
This commit is contained in:
parent
b39be3547c
commit
e3c916bc42
@ -154,7 +154,7 @@ namespace AsbCloudDb.Model
|
||||
FillData(modelBuilder);
|
||||
}
|
||||
|
||||
private void FillData(ModelBuilder modelBuilder)
|
||||
private static void FillData(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<Deposit>(entity =>
|
||||
{
|
||||
@ -210,9 +210,9 @@ namespace AsbCloudDb.Model
|
||||
}).FirstOrDefault();
|
||||
|
||||
if (datesRange is null)
|
||||
return (From: DateTime.MinValue, To: DateTime.MaxValue);
|
||||
return (DateTime.MinValue, DateTime.MaxValue);
|
||||
|
||||
return (From: datesRange.From, To: datesRange.To);
|
||||
return (datesRange.From, datesRange.To);
|
||||
}
|
||||
|
||||
public async Task<int> CreatePartitionAsync<TEntity>(string propertyName, int id, CancellationToken token = default)
|
||||
|
@ -4,6 +4,10 @@
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<NoWarn>1701;1702;IDE0090;IDE0063</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="10.1.1" />
|
||||
<PackageReference Include="itext7" Version="7.1.15" />
|
||||
|
@ -128,7 +128,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
return 0;
|
||||
}
|
||||
|
||||
private string MakeToken(IEnumerable<Claim> claims)
|
||||
private static string MakeToken(IEnumerable<Claim> claims)
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
|
||||
|
@ -6,7 +6,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
class BackgroundQueue : IBackgroundQueue
|
||||
{
|
||||
private ConcurrentQueue<(Action action, int id)> tasks =
|
||||
private readonly ConcurrentQueue<(Action action, int id)> tasks =
|
||||
new ConcurrentQueue<(Action action, int id)>();
|
||||
|
||||
private int id = 0;
|
||||
|
@ -21,7 +21,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
while (!token.IsCancellationRequested)
|
||||
{
|
||||
if (tasksQueue.TryDequeue(out var item))
|
||||
await Task.Run(item.action);
|
||||
await Task.Run(item.action, token);
|
||||
else
|
||||
await Task.Delay(100, token);
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
|
||||
public void UpdateData(string uid, IEnumerable<DataSaubBaseDto> dtos)
|
||||
{
|
||||
if (dtos == default || dtos.Count() <= 0)
|
||||
if (dtos == default || dtos.Any())
|
||||
return;
|
||||
|
||||
var telemetryId = telemetryService.GetOrCreateTemetryIdByUid(uid);
|
||||
@ -102,9 +102,9 @@ namespace AsbCloudInfrastructure.Services
|
||||
if (telemetry is null)
|
||||
return null;
|
||||
|
||||
var result = db.GetDatesRange<DataSaubBase>(telemetry.Id);
|
||||
var (From, To) = db.GetDatesRange<DataSaubBase>(telemetry.Id);
|
||||
|
||||
return new DatesRangeDto { From = result.From, To = result.To};
|
||||
return new DatesRangeDto { From = From, To = To};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,6 @@ namespace AsbCloudInfrastructure.Services
|
||||
private readonly IMapper mapper;
|
||||
private readonly ICacheTable<Event> cacheEvents;
|
||||
private readonly ICacheTable<TelemetryUser> cacheTUsers;
|
||||
private readonly ICacheTable<Telemetry> cacheTelemetry;
|
||||
private readonly ICacheTable<Well> cacheWells;
|
||||
|
||||
public MessageService(IAsbCloudDbContext db, CacheDb cacheDb, ITelemetryService telemetryService, MapperConfiguration mapperConfiguration)
|
||||
{
|
||||
@ -27,8 +25,6 @@ namespace AsbCloudInfrastructure.Services
|
||||
mapper = mapperConfiguration.CreateMapper();
|
||||
cacheEvents = cacheDb.GetCachedTable<Event>((AsbCloudDbContext)db);
|
||||
cacheTUsers = cacheDb.GetCachedTable<TelemetryUser>((AsbCloudDbContext)db);
|
||||
cacheTelemetry = cacheDb.GetCachedTable<Telemetry>((AsbCloudDbContext)db);
|
||||
cacheWells = cacheDb.GetCachedTable<Well>((AsbCloudDbContext)db);
|
||||
}
|
||||
|
||||
public PaginationContainer<MessageDto> GetMessages(int wellId, IEnumerable<int> categoryids = default, DateTime begin = default, DateTime end = default, int skip = 0, int take = 32)
|
||||
@ -39,20 +35,20 @@ namespace AsbCloudInfrastructure.Services
|
||||
|
||||
var events = cacheEvents.Select(e => e.IdTelemetry == telemetry.Id);
|
||||
|
||||
if (events.Count() == 0)
|
||||
if (events.Any())
|
||||
return null;
|
||||
|
||||
var messages = from m in db.Messages
|
||||
where m.IdTelemetry == telemetry.Id
|
||||
select m;
|
||||
|
||||
if ((categoryids != default) && (categoryids.Count() > 0))
|
||||
if ((categoryids != default) && (categoryids.Any()))
|
||||
{
|
||||
var eventIds = from e in events
|
||||
where categoryids.ToList().Contains(e.IdCategory)
|
||||
select e.IdEvent;
|
||||
|
||||
if (eventIds.Count() == 0)
|
||||
if (!eventIds.Any())
|
||||
return null;
|
||||
|
||||
messages = messages.Where(m => eventIds.Contains(m.IdEvent));
|
||||
@ -108,14 +104,14 @@ namespace AsbCloudInfrastructure.Services
|
||||
if (telemetry is null)
|
||||
return null;
|
||||
|
||||
var result = db.GetDatesRange<Message>(telemetry.Id);
|
||||
var (From, To) = db.GetDatesRange<Message>(telemetry.Id);
|
||||
|
||||
return new DatesRangeDto { From = result.From, To = result.To };
|
||||
return new DatesRangeDto { From = From, To = To };
|
||||
}
|
||||
|
||||
public void Insert(string uid, IEnumerable<TelemetryMessageDto> dtos)
|
||||
{
|
||||
if (dtos.Count() == 0)
|
||||
if (dtos.Any())
|
||||
return;
|
||||
|
||||
var telemetryId = telemetryService.GetOrCreateTemetryIdByUid(uid);
|
||||
|
@ -14,16 +14,14 @@ namespace AsbCloudInfrastructure.Services
|
||||
private readonly IAsbCloudDbContext db;
|
||||
private readonly IConfiguration configuration;
|
||||
private readonly ITelemetryService telemetryService;
|
||||
private readonly IServiceProvider serviceProvider;
|
||||
private readonly IBackgroundQueue queue;
|
||||
|
||||
public ReportService(IAsbCloudDbContext db, IConfiguration configuration, ITelemetryService telemetryService, IServiceProvider serviceProvider, IBackgroundQueue queue)
|
||||
public ReportService(IAsbCloudDbContext db, IConfiguration configuration, ITelemetryService telemetryService, IBackgroundQueue queue)
|
||||
{
|
||||
this.db = db;
|
||||
this.configuration = configuration;
|
||||
this.telemetryService = telemetryService;
|
||||
this.queue = queue;
|
||||
this.serviceProvider = serviceProvider;
|
||||
RootPath = "reports";
|
||||
}
|
||||
|
||||
@ -59,9 +57,9 @@ namespace AsbCloudInfrastructure.Services
|
||||
if (telemetry is null)
|
||||
return null;
|
||||
|
||||
var result = db.GetDatesRange<Report>(telemetry.Id);
|
||||
var (From, To) = db.GetDatesRange<Report>(telemetry.Id);
|
||||
|
||||
return new DatesRangeDto { From = result.From, To = result.To };
|
||||
return new DatesRangeDto { From = From, To = To };
|
||||
}
|
||||
|
||||
private IReportGenerator GetReportGenerator(int wellId, DateTime begin, DateTime end, int stepSeconds, int format, AsbCloudDbContext context)
|
||||
|
@ -15,17 +15,13 @@ namespace AsbCloudWebApi.Controllers
|
||||
[ApiController]
|
||||
public class ReportController : ControllerBase
|
||||
{
|
||||
private readonly IAsbCloudDbContext db;
|
||||
private readonly IReportService reportService;
|
||||
private readonly IWellService wellService;
|
||||
private readonly IWebHostEnvironment appEnvironment;
|
||||
|
||||
public ReportController(IAsbCloudDbContext db, IReportService reportService, IWellService wellService, IWebHostEnvironment appEnvironment)
|
||||
public ReportController(IReportService reportService, IWellService wellService)
|
||||
{
|
||||
this.db = db;
|
||||
this.reportService = reportService;
|
||||
this.wellService = wellService;
|
||||
this.appEnvironment = appEnvironment;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -136,9 +136,9 @@ namespace AsbCloudWebApi.Controllers
|
||||
/// cli.ApiTelemetryDbAsync("1", new List<FileParameter> { file }).Wait();
|
||||
/// </example>
|
||||
/// </summary>
|
||||
/// <param name="uid"></param>
|
||||
/// <param name="files"></param>
|
||||
/// <returns></returns>
|
||||
// <param name="uid"></param>
|
||||
// <param name="files"></param>
|
||||
// <returns></returns>
|
||||
//[HttpPost]
|
||||
//[Route("{uid}/db")]
|
||||
//public IActionResult PostDb(string uid, IFormFileCollection files)
|
||||
|
Loading…
Reference in New Issue
Block a user