forked from ddrilling/AsbCloudServer
better names for db entities
This commit is contained in:
parent
7eed929f33
commit
0f08d71ddb
@ -14,7 +14,7 @@ namespace AsbSaubReport
|
|||||||
private readonly int? idTelemetry;
|
private readonly int? idTelemetry;
|
||||||
private readonly WellInfoReport info;
|
private readonly WellInfoReport info;
|
||||||
|
|
||||||
private readonly Dictionary<int, Event> events;
|
private readonly Dictionary<int, TelemetryEvent> events;
|
||||||
private readonly Dictionary<int, TelemetryUser> users;
|
private readonly Dictionary<int, TelemetryUser> users;
|
||||||
private readonly Dictionary<int, string> categories = new Dictionary<int, string>
|
private readonly Dictionary<int, string> categories = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
@ -38,7 +38,7 @@ namespace AsbSaubReport
|
|||||||
if (idTelemetry is null)
|
if (idTelemetry is null)
|
||||||
throw new ArgumentException($"Well {idWell} doesn't contain telemetry", nameof(idWell));
|
throw new ArgumentException($"Well {idWell} doesn't contain telemetry", nameof(idWell));
|
||||||
|
|
||||||
events = context.Events
|
events = context.TelemetryEvents
|
||||||
.Where(e => e.IdTelemetry == idTelemetry)
|
.Where(e => e.IdTelemetry == idTelemetry)
|
||||||
.ToDictionary(e => e.IdEvent, e => e);
|
.ToDictionary(e => e.IdEvent, e => e);
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ namespace AsbSaubReport
|
|||||||
|
|
||||||
public AnalyzeResult Analyze()
|
public AnalyzeResult Analyze()
|
||||||
{
|
{
|
||||||
var messagesQuery = from item in context.Messages
|
var messagesQuery = from item in context.TelemetryMessages
|
||||||
where item.IdTelemetry == idTelemetry
|
where item.IdTelemetry == idTelemetry
|
||||||
select item;
|
select item;
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ namespace AsbSaubReport
|
|||||||
};
|
};
|
||||||
|
|
||||||
public IQueryable<MessageReport> GetMessages(DateTime begin, DateTime end)
|
public IQueryable<MessageReport> GetMessages(DateTime begin, DateTime end)
|
||||||
=> from item in context.Messages
|
=> from item in context.TelemetryMessages
|
||||||
where item.IdTelemetry == idTelemetry
|
where item.IdTelemetry == idTelemetry
|
||||||
&& item.Date >= begin
|
&& item.Date >= begin
|
||||||
&& item.Date <= end
|
&& item.Date <= end
|
||||||
|
@ -162,7 +162,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
var operations = (from a in db.TelemetryAnalysis
|
var operations = (from a in db.TelemetryAnalysis
|
||||||
where a.IdTelemetry == telemetryId &&
|
where a.IdTelemetry == telemetryId &&
|
||||||
a.UnixDate > unixBegin && a.UnixDate < unixEnd
|
a.UnixDate > unixBegin && a.UnixDate < unixEnd
|
||||||
join o in db.Operations on a.IdOperation equals o.Id
|
join o in db.TelemetryOperations on a.IdOperation equals o.Id
|
||||||
group a by new { a.IdOperation, o.Name } into g
|
group a by new { a.IdOperation, o.Name } into g
|
||||||
select new TelemetryOperationDurationDto
|
select new TelemetryOperationDurationDto
|
||||||
{
|
{
|
||||||
@ -188,7 +188,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
var operations = (from a in db.TelemetryAnalysis
|
var operations = (from a in db.TelemetryAnalysis
|
||||||
where a.IdTelemetry == telemetryId
|
where a.IdTelemetry == telemetryId
|
||||||
join o in db.Operations on a.IdOperation equals o.Id
|
join o in db.TelemetryOperations on a.IdOperation equals o.Id
|
||||||
group a by new
|
group a by new
|
||||||
{
|
{
|
||||||
Interval = Math.Floor((a.UnixDate - workBeginSeconds + timezoneOffset) / intervalSeconds),
|
Interval = Math.Floor((a.UnixDate - workBeginSeconds + timezoneOffset) / intervalSeconds),
|
||||||
|
@ -10,12 +10,12 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
public class EventService : IEventService
|
public class EventService : IEventService
|
||||||
{
|
{
|
||||||
private readonly ITelemetryService telemetryService;
|
private readonly ITelemetryService telemetryService;
|
||||||
private readonly CacheTable<Event> cacheEvents;
|
private readonly CacheTable<TelemetryEvent> cacheEvents;
|
||||||
|
|
||||||
public EventService(IAsbCloudDbContext db, CacheDb cacheDb, ITelemetryService telemetryService)
|
public EventService(IAsbCloudDbContext db, CacheDb cacheDb, ITelemetryService telemetryService)
|
||||||
{
|
{
|
||||||
this.telemetryService = telemetryService;
|
this.telemetryService = telemetryService;
|
||||||
cacheEvents = cacheDb.GetCachedTable<Event>((AsbCloudDbContext)db);
|
cacheEvents = cacheDb.GetCachedTable<TelemetryEvent>((AsbCloudDbContext)db);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Upsert(string uid, IEnumerable<EventDto> dtos)
|
public void Upsert(string uid, IEnumerable<EventDto> dtos)
|
||||||
@ -25,7 +25,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
var telemetryId = telemetryService.GetOrCreateTemetryIdByUid(uid);
|
var telemetryId = telemetryService.GetOrCreateTemetryIdByUid(uid);
|
||||||
|
|
||||||
var entities = dtos.Select(dto => new Event
|
var entities = dtos.Select(dto => new TelemetryEvent
|
||||||
{
|
{
|
||||||
IdEvent = dto.Id,
|
IdEvent = dto.Id,
|
||||||
IdTelemetry = telemetryId,
|
IdTelemetry = telemetryId,
|
||||||
|
@ -14,14 +14,14 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
{
|
{
|
||||||
private readonly IAsbCloudDbContext db;
|
private readonly IAsbCloudDbContext db;
|
||||||
private readonly ITelemetryService telemetryService;
|
private readonly ITelemetryService telemetryService;
|
||||||
private readonly CacheTable<Event> cacheEvents;
|
private readonly CacheTable<TelemetryEvent> cacheEvents;
|
||||||
private readonly CacheTable<TelemetryUser> cacheTUsers;
|
private readonly CacheTable<TelemetryUser> cacheTUsers;
|
||||||
|
|
||||||
public MessageService(IAsbCloudDbContext db, CacheDb cacheDb, ITelemetryService telemetryService)
|
public MessageService(IAsbCloudDbContext db, CacheDb cacheDb, ITelemetryService telemetryService)
|
||||||
{
|
{
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.telemetryService = telemetryService;
|
this.telemetryService = telemetryService;
|
||||||
cacheEvents = cacheDb.GetCachedTable<Event>((AsbCloudDbContext)db);
|
cacheEvents = cacheDb.GetCachedTable<TelemetryEvent>((AsbCloudDbContext)db);
|
||||||
cacheTUsers = cacheDb.GetCachedTable<TelemetryUser>((AsbCloudDbContext)db);
|
cacheTUsers = cacheDb.GetCachedTable<TelemetryUser>((AsbCloudDbContext)db);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
if (!events.Any())
|
if (!events.Any())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var query = db.Messages.Where(m => m.IdTelemetry == telemetryId);
|
var query = db.TelemetryMessages.Where(m => m.IdTelemetry == telemetryId);
|
||||||
|
|
||||||
if ((categoryids?.Any() == true) || !string.IsNullOrEmpty(searchString))
|
if ((categoryids?.Any() == true) || !string.IsNullOrEmpty(searchString))
|
||||||
{
|
{
|
||||||
@ -114,7 +114,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
if (telemetryId is null)
|
if (telemetryId is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var (From, To) = db.GetDatesRange<Message>((int)telemetryId);
|
var (From, To) = db.GetDatesRange<TelemetryMessage>((int)telemetryId);
|
||||||
|
|
||||||
return new DatesRangeDto { From = From, To = To };
|
return new DatesRangeDto { From = From, To = To };
|
||||||
}
|
}
|
||||||
@ -128,10 +128,10 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
foreach (var dto in dtos)
|
foreach (var dto in dtos)
|
||||||
{
|
{
|
||||||
var entity = dto.Adapt<Message>();
|
var entity = dto.Adapt<TelemetryMessage>();
|
||||||
entity.Id = 0;
|
entity.Id = 0;
|
||||||
entity.IdTelemetry = telemetryId;
|
entity.IdTelemetry = telemetryId;
|
||||||
db.Messages.Add(entity);
|
db.TelemetryMessages.Add(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
db.SaveChanges();
|
db.SaveChanges();
|
||||||
|
@ -119,7 +119,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
var datesRange = (from d in db.DataSaubBases
|
var datesRange = (from d in db.DataSaubBases
|
||||||
where d.IdTelemetry == telemetryId
|
where d.IdTelemetry == telemetryId
|
||||||
select d.Date).Union(
|
select d.Date).Union(
|
||||||
from m in db.Messages
|
from m in db.TelemetryMessages
|
||||||
where m.IdTelemetry == telemetryId
|
where m.IdTelemetry == telemetryId
|
||||||
select m.Date).DefaultIfEmpty().GroupBy(g => true)
|
select m.Date).DefaultIfEmpty().GroupBy(g => true)
|
||||||
.Select(g => new
|
.Select(g => new
|
||||||
|
Loading…
Reference in New Issue
Block a user