forked from ddrilling/AsbCloudServer
авточистка проекта
This commit is contained in:
parent
d0378e4f1d
commit
6abbf476b1
@ -1,12 +1,6 @@
|
|||||||
using System;
|
namespace AsbCloudApp.Data
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AsbCloudApp.Data
|
|
||||||
{
|
{
|
||||||
public class ClusterDto: IMapPoint
|
public class ClusterDto : IMapPoint
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
namespace AsbCloudApp.Data
|
namespace AsbCloudApp.Data
|
||||||
{
|
{
|
||||||
public class DepositDto: IMapPoint
|
public class DepositDto : IMapPoint
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace AsbCloudApp.Data
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AsbCloudApp.Data
|
|
||||||
{
|
{
|
||||||
public interface IMapPoint
|
public interface IMapPoint
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace AsbCloudApp.Data
|
namespace AsbCloudApp.Data
|
||||||
{
|
{
|
||||||
public class WellDrillingStatDto: WellDto
|
public class WellDrillingStatDto : WellDto
|
||||||
{
|
{
|
||||||
public DateTime? PlanStart { get; set; }
|
public DateTime? PlanStart { get; set; }
|
||||||
public DateTime? PlanEnd { get; set; }
|
public DateTime? PlanEnd { get; set; }
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using AsbCloudApp.Data;
|
||||||
using System.Collections.Generic;
|
|
||||||
using AsbCloudApp.Data;
|
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace AsbCloudApp.Services
|
namespace AsbCloudApp.Services
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AsbCloudApp.Services
|
namespace AsbCloudApp.Services
|
||||||
{
|
{
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
using System;
|
using AsbCloudApp.Data;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using AsbCloudApp.Data;
|
|
||||||
|
|
||||||
namespace AsbCloudApp.Services
|
namespace AsbCloudApp.Services
|
||||||
{
|
{
|
||||||
public interface IReportService
|
public interface IReportService
|
||||||
{
|
{
|
||||||
string RootPath { get; }
|
string RootPath { get; }
|
||||||
int CreateReport(int wellId, int stepSeconds, int format, DateTime begin, DateTime end,
|
int CreateReport(int wellId, int stepSeconds, int format, DateTime begin, DateTime end,
|
||||||
Action<float, string, int> handleReportProgress, Action<string, int> handleReportName);
|
Action<float, string, int> handleReportProgress, Action<string, int> handleReportName);
|
||||||
int GetReportPagesCount(int wellId, DateTime begin, DateTime end, int stepSeconds, int format);
|
int GetReportPagesCount(int wellId, DateTime begin, DateTime end, int stepSeconds, int format);
|
||||||
IEnumerable<ReportPropertiesDto> GetSuitableReports(int wellId, DateTime begin, DateTime end, int stepSeconds, int format);
|
IEnumerable<ReportPropertiesDto> GetSuitableReports(int wellId, DateTime begin, DateTime end, int stepSeconds, int format);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudDb.Model;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace AsbCloudApp.Services
|
namespace AsbCloudApp.Services
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Security.Claims;
|
|
||||||
|
|
||||||
namespace AsbCloudApp.Services
|
namespace AsbCloudApp.Services
|
||||||
{
|
{
|
||||||
|
@ -26,7 +26,7 @@ namespace AsbCloudDb.Model
|
|||||||
public virtual DbSet<Well> Wells { get; set; }
|
public virtual DbSet<Well> Wells { get; set; }
|
||||||
public virtual DbSet<Report> Reports { get; set; }
|
public virtual DbSet<Report> Reports { get; set; }
|
||||||
public virtual DbSet<Operation> Operations { get; set; }
|
public virtual DbSet<Operation> Operations { get; set; }
|
||||||
public virtual DbSet<TelemetryAnalysis> TelemetryAnalysis { get; set; }
|
public virtual DbSet<TelemetryAnalysis> TelemetryAnalysis { get; set; }
|
||||||
public virtual DbSet<WellSection> SectionAnalysis { get; set; }
|
public virtual DbSet<WellSection> SectionAnalysis { get; set; }
|
||||||
public virtual DbSet<WellType> WellTypes { get; set; }
|
public virtual DbSet<WellType> WellTypes { get; set; }
|
||||||
|
|
||||||
@ -256,19 +256,19 @@ namespace AsbCloudDb.Model
|
|||||||
.Include(e => e.Company)
|
.Include(e => e.Company)
|
||||||
.Where(e => e.Login == login);
|
.Where(e => e.Login == login);
|
||||||
|
|
||||||
public (DateTime From, DateTime To) GetDatesRange<TEntity>(int idTelemetry)
|
public (DateTime From, DateTime To) GetDatesRange<TEntity>(int idTelemetry)
|
||||||
where TEntity : class, IIdTelemetryDate
|
where TEntity : class, IIdTelemetryDate
|
||||||
{
|
{
|
||||||
var dbSet = Set<TEntity>();
|
var dbSet = Set<TEntity>();
|
||||||
|
|
||||||
var datesRange = (from m in dbSet
|
var datesRange = (from m in dbSet
|
||||||
where m.IdTelemetry == idTelemetry
|
where m.IdTelemetry == idTelemetry
|
||||||
group m by m.IdTelemetry into g
|
group m by m.IdTelemetry into g
|
||||||
select new
|
select new
|
||||||
{
|
{
|
||||||
From = g.Min(d => d.Date),
|
From = g.Min(d => d.Date),
|
||||||
To = g.Max(d => d.Date)
|
To = g.Max(d => d.Date)
|
||||||
}).FirstOrDefault();
|
}).FirstOrDefault();
|
||||||
|
|
||||||
if (datesRange is null)
|
if (datesRange is null)
|
||||||
return (DateTime.MinValue, DateTime.MaxValue);
|
return (DateTime.MinValue, DateTime.MaxValue);
|
||||||
@ -276,7 +276,7 @@ namespace AsbCloudDb.Model
|
|||||||
return (datesRange.From, datesRange.To);
|
return (datesRange.From, datesRange.To);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<(double? MinDepth, double? MaxDepth, DateTime BeginPeriodDate)> GetDepthToInterval (int telemetryId,
|
public IEnumerable<(double? MinDepth, double? MaxDepth, DateTime BeginPeriodDate)> GetDepthToInterval(int telemetryId,
|
||||||
int intervalHoursTimestamp, int workStartTimestamp, double timezoneOffset)
|
int intervalHoursTimestamp, int workStartTimestamp, double timezoneOffset)
|
||||||
{
|
{
|
||||||
//TODO: Сменить на LINQ группирование
|
//TODO: Сменить на LINQ группирование
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace AsbCloudDb.Model
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AsbCloudDb.Model
|
|
||||||
{
|
{
|
||||||
public interface IMapPoint
|
public interface IMapPoint
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace AsbCloudDb.Model
|
namespace AsbCloudDb.Model
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using System;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ namespace AsbCloudDb.Model
|
|||||||
[ForeignKey(nameof(IdWellType))]
|
[ForeignKey(nameof(IdWellType))]
|
||||||
[InverseProperty(nameof(Model.WellType.Wells))]
|
[InverseProperty(nameof(Model.WellType.Wells))]
|
||||||
public virtual WellType WellType { get; set; }
|
public virtual WellType WellType { get; set; }
|
||||||
|
|
||||||
[InverseProperty(nameof(WellSection.Well))]
|
[InverseProperty(nameof(WellSection.Well))]
|
||||||
public virtual ICollection<WellSection> Sections { get; set; }
|
public virtual ICollection<WellSection> Sections { get; set; }
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
@ -19,7 +18,7 @@ namespace AsbCloudDb.Model
|
|||||||
public int IdWellSectionType { get; set; }
|
public int IdWellSectionType { get; set; }
|
||||||
|
|
||||||
[Column("id_well")]
|
[Column("id_well")]
|
||||||
public int IdWell{ get; set; }
|
public int IdWell { get; set; }
|
||||||
|
|
||||||
[Column("well_depth_plan"), Comment("глубина план")]
|
[Column("well_depth_plan"), Comment("глубина план")]
|
||||||
public double WellDepthPlan { get; set; }
|
public double WellDepthPlan { get; set; }
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using System.Collections.Generic;
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace AsbCloudDb.Model
|
namespace AsbCloudDb.Model
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using System.Collections.Generic;
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace AsbCloudDb.Model
|
namespace AsbCloudDb.Model
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
using AsbSaubReport.Model;
|
using AsbCloudDb.Model;
|
||||||
|
using AsbSaubReport.Model;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using AsbCloudDb.Model;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace AsbSaubReport
|
namespace AsbSaubReport
|
||||||
{
|
{
|
||||||
@ -27,9 +27,9 @@ namespace AsbSaubReport
|
|||||||
{
|
{
|
||||||
this.context = context;
|
this.context = context;
|
||||||
var well = context.Wells
|
var well = context.Wells
|
||||||
.Include(w=>w.Cluster)
|
.Include(w => w.Cluster)
|
||||||
.ThenInclude(c=>c.Deposit)
|
.ThenInclude(c => c.Deposit)
|
||||||
.Include(w=>w.Companies)
|
.Include(w => w.Companies)
|
||||||
.Include(w => w.Telemetry)
|
.Include(w => w.Telemetry)
|
||||||
.FirstOrDefault(w => w.Id == wellId);
|
.FirstOrDefault(w => w.Id == wellId);
|
||||||
|
|
||||||
@ -50,56 +50,56 @@ namespace AsbSaubReport
|
|||||||
Deposit = well.Cluster.Deposit.Caption,
|
Deposit = well.Cluster.Deposit.Caption,
|
||||||
Cluster = well.Cluster.Caption,
|
Cluster = well.Cluster.Caption,
|
||||||
Well = well.Caption,
|
Well = well.Caption,
|
||||||
Customer = well.Companies.First(c=>c.IdCompanyType == 1)?.Caption,
|
Customer = well.Companies.First(c => c.IdCompanyType == 1)?.Caption,
|
||||||
DrillingStartDate = well.Telemetry?.Info?.DrillingStartDate??default,
|
DrillingStartDate = well.Telemetry?.Info?.DrillingStartDate ?? default,
|
||||||
TimeZoneId = well.Telemetry?.Info?.TimeZoneId??default,
|
TimeZoneId = well.Telemetry?.Info?.TimeZoneId ?? default,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public IQueryable<DataSaubReport> GetDataSaubItems(DateTime begin, DateTime end)
|
public IQueryable<DataSaubReport> GetDataSaubItems(DateTime begin, DateTime end)
|
||||||
=> from item in context.DataSaubBases
|
=> from item in context.DataSaubBases
|
||||||
where item.IdTelemetry == idTelemetry
|
where item.IdTelemetry == idTelemetry
|
||||||
&& item.Date >= begin
|
&& item.Date >= begin
|
||||||
&& item.Date <= end
|
&& item.Date <= end
|
||||||
select new DataSaubReport
|
select new DataSaubReport
|
||||||
{
|
{
|
||||||
Id = item.Id,
|
Id = item.Id,
|
||||||
Date = item.Date,
|
Date = item.Date,
|
||||||
Mode = item.Mode,
|
Mode = item.Mode,
|
||||||
WellDepth = item.WellDepth,
|
WellDepth = item.WellDepth,
|
||||||
BitDepth = item.BitDepth,
|
BitDepth = item.BitDepth,
|
||||||
BlockPosition = item.BlockPosition,
|
BlockPosition = item.BlockPosition,
|
||||||
BlockSpeed = item.BlockSpeed,
|
BlockSpeed = item.BlockSpeed,
|
||||||
BlockSpeedSp = item.BlockSpeedSp,
|
BlockSpeedSp = item.BlockSpeedSp,
|
||||||
BlockSpeedSpDevelop = item.BlockSpeedSpDevelop,
|
BlockSpeedSpDevelop = item.BlockSpeedSpDevelop,
|
||||||
Pressure = item.Pressure,
|
Pressure = item.Pressure,
|
||||||
PressureSp = item.PressureSp,
|
PressureSp = item.PressureSp,
|
||||||
AxialLoad = item.AxialLoad,
|
AxialLoad = item.AxialLoad,
|
||||||
AxialLoadSp = item.AxialLoadSp,
|
AxialLoadSp = item.AxialLoadSp,
|
||||||
AxialLoadLimitMax = item.AxialLoadLimitMax,
|
AxialLoadLimitMax = item.AxialLoadLimitMax,
|
||||||
HookWeight = item.HookWeight,
|
HookWeight = item.HookWeight,
|
||||||
RotorTorque = item.RotorTorque,
|
RotorTorque = item.RotorTorque,
|
||||||
RotorTorqueSp = item.RotorTorqueSp,
|
RotorTorqueSp = item.RotorTorqueSp,
|
||||||
RotorSpeed = item.RotorSpeed,
|
RotorSpeed = item.RotorSpeed,
|
||||||
Flow = item.Flow,
|
Flow = item.Flow,
|
||||||
PressureSpDevelop = item.PressureSpDevelop,
|
PressureSpDevelop = item.PressureSpDevelop,
|
||||||
};
|
};
|
||||||
|
|
||||||
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.Messages
|
||||||
where item.IdTelemetry == idTelemetry
|
where item.IdTelemetry == idTelemetry
|
||||||
&& item.Date >= begin
|
&& item.Date >= begin
|
||||||
&& item.Date <= end
|
&& item.Date <= end
|
||||||
select new MessageReport
|
select new MessageReport
|
||||||
{
|
{
|
||||||
Id = item.Id,
|
Id = item.Id,
|
||||||
Date = item.Date,
|
Date = item.Date,
|
||||||
Category = categories[events[item.IdEvent].IdCategory],
|
Category = categories[events[item.IdEvent].IdCategory],
|
||||||
User = item.IdTelemetryUser == null
|
User = item.IdTelemetryUser == null
|
||||||
? ""
|
? ""
|
||||||
: users[(int)item.IdTelemetryUser].MakeDisplayName(),
|
: users[(int)item.IdTelemetryUser].MakeDisplayName(),
|
||||||
Text = events[item.IdEvent].MakeMessageText(item)
|
Text = events[item.IdEvent].MakeMessageText(item)
|
||||||
};
|
};
|
||||||
|
|
||||||
public WellInfoReport GetWellInfo()
|
public WellInfoReport GetWellInfo()
|
||||||
=> info;
|
=> info;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
using System;
|
using AsbCloudApp.Data;
|
||||||
using System.Linq;
|
|
||||||
using AsbCloudApp.Data;
|
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudInfrastructure.Services.Cache;
|
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
|
using AsbCloudInfrastructure.Services.Cache;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
namespace AsbCloudInfrastructure.Services
|
||||||
{
|
{
|
||||||
@ -17,7 +17,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
private readonly OperationDetectorService operationDetectorService;
|
private readonly OperationDetectorService operationDetectorService;
|
||||||
private readonly IEnumerable<Operation> operations;
|
private readonly IEnumerable<Operation> operations;
|
||||||
|
|
||||||
public AnalyticsService(IAsbCloudDbContext db, ITelemetryService telemetryService,
|
public AnalyticsService(IAsbCloudDbContext db, ITelemetryService telemetryService,
|
||||||
ISaubDataCache saubDataCache, CacheDb cacheDb)
|
ISaubDataCache saubDataCache, CacheDb cacheDb)
|
||||||
{
|
{
|
||||||
this.db = db;
|
this.db = db;
|
||||||
@ -116,7 +116,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
var unixEnd = (end - new DateTime(1970, 1, 1)).TotalSeconds;
|
var unixEnd = (end - new DateTime(1970, 1, 1)).TotalSeconds;
|
||||||
|
|
||||||
var operations = (from a in db.TelemetryAnalysis
|
var operations = (from a in db.TelemetryAnalysis
|
||||||
where a.IdTelemetry == telemetry.Id &&
|
where a.IdTelemetry == telemetry.Id &&
|
||||||
a.UnixDate > unixBegin && a.UnixDate < unixEnd &&
|
a.UnixDate > unixBegin && a.UnixDate < unixEnd &&
|
||||||
a.IdOperation != null
|
a.IdOperation != null
|
||||||
join o in db.Operations on a.IdOperation equals o.Id
|
join o in db.Operations on a.IdOperation equals o.Id
|
||||||
@ -147,10 +147,12 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
where a.IdTelemetry == telemetry.Id &&
|
where a.IdTelemetry == telemetry.Id &&
|
||||||
a.IdOperation != null
|
a.IdOperation != null
|
||||||
join o in db.Operations on a.IdOperation equals o.Id
|
join o in db.Operations 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),
|
||||||
OperationId = a.IdOperation,
|
OperationId = a.IdOperation,
|
||||||
o.Name } into g
|
o.Name
|
||||||
|
} into g
|
||||||
select new
|
select new
|
||||||
{
|
{
|
||||||
IntervalStart = g.Min(d => d.UnixDate),
|
IntervalStart = g.Min(d => d.UnixDate),
|
||||||
@ -159,14 +161,16 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
var operationsGroupedByInterval = operations.GroupBy(op => op.IntervalStart)
|
var operationsGroupedByInterval = operations.GroupBy(op => op.IntervalStart)
|
||||||
.Select(o => new OperationInfoDto {
|
.Select(o => new OperationInfoDto
|
||||||
IntervalBegin = DateTimeOffset.FromUnixTimeSeconds(o.Key),
|
{
|
||||||
Operations = o.Select(opr => new OperationDetailsDto {
|
IntervalBegin = DateTimeOffset.FromUnixTimeSeconds(o.Key),
|
||||||
OperationName = opr.OperationName,
|
Operations = o.Select(opr => new OperationDetailsDto
|
||||||
Duration = opr.OperationsDuration
|
{
|
||||||
|
OperationName = opr.OperationName,
|
||||||
|
Duration = opr.OperationsDuration
|
||||||
}).ToList()
|
}).ToList()
|
||||||
})
|
})
|
||||||
.OrderBy(ops => ops.IntervalBegin);
|
.OrderBy(ops => ops.IntervalBegin);
|
||||||
|
|
||||||
return operationsGroupedByInterval;
|
return operationsGroupedByInterval;
|
||||||
}
|
}
|
||||||
@ -205,22 +209,22 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
var lastSaubDate = dataSaubBases.Last().Date;
|
var lastSaubDate = dataSaubBases.Last().Date;
|
||||||
|
|
||||||
var saubWellDepths = dataSaubBases.Where(sw => sw.WellDepth is not null)
|
var saubWellDepths = dataSaubBases.Where(sw => sw.WellDepth is not null)
|
||||||
.Select(s => (Value: (double)s.WellDepth,
|
.Select(s => (Value: (double)s.WellDepth,
|
||||||
(s.Date - dataSaubBases.First().Date).TotalSeconds));
|
(s.Date - dataSaubBases.First().Date).TotalSeconds));
|
||||||
var saubBitDepths = dataSaubBases.Where(sw => sw.BitDepth is not null)
|
var saubBitDepths = dataSaubBases.Where(sw => sw.BitDepth is not null)
|
||||||
.Select(s => (Value: (double)s.BitDepth,
|
.Select(s => (Value: (double)s.BitDepth,
|
||||||
(s.Date - dataSaubBases.First().Date).TotalSeconds));
|
(s.Date - dataSaubBases.First().Date).TotalSeconds));
|
||||||
var saubBlockPositions = dataSaubBases.Where(sw => sw.BlockPosition is not null)
|
var saubBlockPositions = dataSaubBases.Where(sw => sw.BlockPosition is not null)
|
||||||
.Select(s => (Value: (double)s.BlockPosition,
|
.Select(s => (Value: (double)s.BlockPosition,
|
||||||
(s.Date - dataSaubBases.First().Date).TotalSeconds));
|
(s.Date - dataSaubBases.First().Date).TotalSeconds));
|
||||||
var saubRotorSpeeds = dataSaubBases.Where(sw => sw.RotorSpeed is not null)
|
var saubRotorSpeeds = dataSaubBases.Where(sw => sw.RotorSpeed is not null)
|
||||||
.Select(s => (Value: (double)s.RotorSpeed,
|
.Select(s => (Value: (double)s.RotorSpeed,
|
||||||
(s.Date - dataSaubBases.First().Date).TotalSeconds));
|
(s.Date - dataSaubBases.First().Date).TotalSeconds));
|
||||||
var saubPressures = dataSaubBases.Where(sw => sw.Pressure is not null)
|
var saubPressures = dataSaubBases.Where(sw => sw.Pressure is not null)
|
||||||
.Select(s => (Value: (double)s.Pressure,
|
.Select(s => (Value: (double)s.Pressure,
|
||||||
(s.Date - dataSaubBases.First().Date).TotalSeconds));
|
(s.Date - dataSaubBases.First().Date).TotalSeconds));
|
||||||
var saubHookWeights = dataSaubBases.Where(sw => sw.HookWeight is not null)
|
var saubHookWeights = dataSaubBases.Where(sw => sw.HookWeight is not null)
|
||||||
.Select(s => (Value: (double)s.HookWeight,
|
.Select(s => (Value: (double)s.HookWeight,
|
||||||
(s.Date - dataSaubBases.First().Date).TotalSeconds));
|
(s.Date - dataSaubBases.First().Date).TotalSeconds));
|
||||||
|
|
||||||
var wellDepthChangingIndex = new InterpolationLine(saubWellDepths).GetAForLinearFormula();
|
var wellDepthChangingIndex = new InterpolationLine(saubWellDepths).GetAForLinearFormula();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using AsbCloudApp.Services;
|
||||||
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using AsbCloudApp.Services;
|
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
namespace AsbCloudInfrastructure.Services
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System.Threading;
|
using AsbCloudApp.Services;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using AsbCloudApp.Services;
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
namespace AsbCloudInfrastructure.Services
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ namespace AsbCloudInfrastructure.Services.Cache
|
|||||||
var dbEntities = context.Set<TEntity>().ToList();
|
var dbEntities = context.Set<TEntity>().ToList();
|
||||||
cached.AddRange(dbEntities);
|
cached.AddRange(dbEntities);
|
||||||
data.refreshDate = DateTime.Now;
|
data.refreshDate = DateTime.Now;
|
||||||
return cached.Count;
|
return cached.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> RefreshAsync(CancellationToken token = default)
|
public async Task<int> RefreshAsync(CancellationToken token = default)
|
||||||
@ -228,7 +228,7 @@ namespace AsbCloudInfrastructure.Services.Cache
|
|||||||
else
|
else
|
||||||
updated = dbSet.Add(entity);
|
updated = dbSet.Add(entity);
|
||||||
upsertedEntries.Add(updated.Entity);
|
upsertedEntries.Add(updated.Entity);
|
||||||
}
|
}
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
Refresh();
|
Refresh();
|
||||||
return upsertedEntries;
|
return upsertedEntries;
|
||||||
@ -296,7 +296,7 @@ namespace AsbCloudInfrastructure.Services.Cache
|
|||||||
dbEntities.Add(dbSet.Add(item).Entity);
|
dbEntities.Add(dbSet.Add(item).Entity);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
cached.AddRange(dbEntities);
|
cached.AddRange(dbEntities);
|
||||||
return dbEntities;
|
return dbEntities;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<TEntity>> InsertAsync(IEnumerable<TEntity> newEntities, CancellationToken token = default)
|
public async Task<IEnumerable<TEntity>> InsertAsync(IEnumerable<TEntity> newEntities, CancellationToken token = default)
|
||||||
|
@ -19,7 +19,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
private readonly CacheTable<Well> cacheWells;
|
private readonly CacheTable<Well> cacheWells;
|
||||||
|
|
||||||
public DataService(IAsbCloudDbContext db, ITelemetryService telemetryService,
|
public DataService(IAsbCloudDbContext db, ITelemetryService telemetryService,
|
||||||
IAnalyticsService analyticsService, ISaubDataCache saubDataCache,
|
IAnalyticsService analyticsService, ISaubDataCache saubDataCache,
|
||||||
CacheDb cacheDb, MapperConfiguration mapperConfiguration)
|
CacheDb cacheDb, MapperConfiguration mapperConfiguration)
|
||||||
{
|
{
|
||||||
this.db = db;
|
this.db = db;
|
||||||
@ -57,8 +57,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
if (fullDataCount > 1.75 * approxPointsCount)
|
if (fullDataCount > 1.75 * approxPointsCount)
|
||||||
{
|
{
|
||||||
var m = (int)Math.Round(1d*fullDataCount / approxPointsCount);
|
var m = (int)Math.Round(1d * fullDataCount / approxPointsCount);
|
||||||
if(m > 1)
|
if (m > 1)
|
||||||
fullData = fullData.Where(d => d.Id % m == 0);
|
fullData = fullData.Where(d => d.Id % m == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,10 +81,10 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
var dtoMaxDate = dtos.Max(d => d.Date);
|
var dtoMaxDate = dtos.Max(d => d.Date);
|
||||||
|
|
||||||
var oldDataSaubBase = (from d in db.DataSaubBases
|
var oldDataSaubBase = (from d in db.DataSaubBases
|
||||||
where d.IdTelemetry == telemetryId
|
where d.IdTelemetry == telemetryId
|
||||||
&& d.Date > dtoMinDate
|
&& d.Date > dtoMinDate
|
||||||
&& d.Date < dtoMaxDate
|
&& d.Date < dtoMaxDate
|
||||||
select d).ToList();
|
select d).ToList();
|
||||||
|
|
||||||
if (oldDataSaubBase.Any())
|
if (oldDataSaubBase.Any())
|
||||||
{
|
{
|
||||||
@ -111,7 +111,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
var (From, To) = db.GetDatesRange<DataSaubBase>(telemetry.Id);
|
var (From, To) = db.GetDatesRange<DataSaubBase>(telemetry.Id);
|
||||||
|
|
||||||
return new DatesRangeDto { From = From, To = To};
|
return new DatesRangeDto { From = From, To = To };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
return (double)result;
|
return (double)result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsValueNotChanges(double value,
|
public static bool IsValueNotChanges(double value,
|
||||||
(double upperBound, double lowerBound) bounds) =>
|
(double upperBound, double lowerBound) bounds) =>
|
||||||
value < bounds.upperBound && value > bounds.lowerBound;
|
value < bounds.upperBound && value > bounds.lowerBound;
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
public static bool IsValueDecreases(double value, double bound) =>
|
public static bool IsValueDecreases(double value, double bound) =>
|
||||||
value < bound;
|
value < bound;
|
||||||
|
|
||||||
public static bool IsAverageLessThanBound(IEnumerable<(double Value, double TotalSeconds)> values,
|
public static bool IsAverageLessThanBound(IEnumerable<(double Value, double TotalSeconds)> values,
|
||||||
double bound) =>
|
double bound) =>
|
||||||
(values.Sum(s => s.Value) / values.Count()) < bound;
|
(values.Sum(s => s.Value) / values.Count()) < bound;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using System;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudDb.Model;
|
using System;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
namespace AsbCloudInfrastructure.Services
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using AsbCloudDb.Model;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using AsbCloudDb.Model;
|
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
namespace AsbCloudInfrastructure.Services
|
||||||
{
|
{
|
||||||
@ -18,7 +18,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
Operation = operations.FirstOrDefault(o => o.Name.Equals("На поверхности")),
|
Operation = operations.FirstOrDefault(o => o.Name.Equals("На поверхности")),
|
||||||
Detect = (data) =>
|
Detect = (data) =>
|
||||||
{
|
{
|
||||||
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing
|
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing
|
||||||
&& data.IsBitDepthLess20 && data.IsHookWeightLt3;
|
&& data.IsBitDepthLess20 && data.IsHookWeightLt3;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -29,8 +29,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
Detect = (data) =>
|
Detect = (data) =>
|
||||||
{
|
{
|
||||||
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
|
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
|
||||||
!data.IsBitPositionIncreasing && !data.IsBitPositionDecreasing &&
|
!data.IsBitPositionIncreasing && !data.IsBitPositionDecreasing &&
|
||||||
data.IsBlockPositionDecreasing && !data.IsBlockPositionIncreasing &&
|
data.IsBlockPositionDecreasing && !data.IsBlockPositionIncreasing &&
|
||||||
data.IsHookWeightLt3;
|
data.IsHookWeightLt3;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -41,7 +41,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
Detect = (data) =>
|
Detect = (data) =>
|
||||||
{
|
{
|
||||||
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
|
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
|
||||||
data.IsBitPositionDecreasing && data.IsBlockPositionDecreasing &&
|
data.IsBitPositionDecreasing && data.IsBlockPositionDecreasing &&
|
||||||
data.IsRotorSpeedGt3 && data.IsPressureGt20;
|
data.IsRotorSpeedGt3 && data.IsPressureGt20;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -52,7 +52,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
Detect = (data) =>
|
Detect = (data) =>
|
||||||
{
|
{
|
||||||
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
|
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
|
||||||
data.IsBitPositionIncreasing && data.IsBitPositionIncreasing &&
|
data.IsBitPositionIncreasing && data.IsBitPositionIncreasing &&
|
||||||
data.IsRotorSpeedGt3 && data.IsPressureGt20;
|
data.IsRotorSpeedGt3 && data.IsPressureGt20;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -63,7 +63,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
Detect = (data) =>
|
Detect = (data) =>
|
||||||
{
|
{
|
||||||
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
|
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
|
||||||
data.IsBitPositionDecreasing && data.IsBitPositionDecreasing &&
|
data.IsBitPositionDecreasing && data.IsBitPositionDecreasing &&
|
||||||
data.IsRotorSpeedLt3 && data.IsPressureGt20;
|
data.IsRotorSpeedLt3 && data.IsPressureGt20;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -73,8 +73,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
Operation = operations.FirstOrDefault(o => o.Name.Equals("Спуск с промывкой")),
|
Operation = operations.FirstOrDefault(o => o.Name.Equals("Спуск с промывкой")),
|
||||||
Detect = (data) =>
|
Detect = (data) =>
|
||||||
{
|
{
|
||||||
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
|
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
|
||||||
data.IsBitPositionIncreasing && data.IsBlockPositionIncreasing &&
|
data.IsBitPositionIncreasing && data.IsBlockPositionIncreasing &&
|
||||||
data.IsRotorSpeedLt3 && data.IsPressureGt20;
|
data.IsRotorSpeedLt3 && data.IsPressureGt20;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -84,8 +84,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
Operation = operations.FirstOrDefault(o => o.Name.Equals("Спуск в скважину")),
|
Operation = operations.FirstOrDefault(o => o.Name.Equals("Спуск в скважину")),
|
||||||
Detect = (data) =>
|
Detect = (data) =>
|
||||||
{
|
{
|
||||||
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
|
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
|
||||||
data.IsBitPositionIncreasing && data.IsBlockPositionIncreasing &&
|
data.IsBitPositionIncreasing && data.IsBlockPositionIncreasing &&
|
||||||
data.IsRotorSpeedLt3 && data.IsPressureLt20;
|
data.IsRotorSpeedLt3 && data.IsPressureLt20;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -130,7 +130,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
{
|
{
|
||||||
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
|
return !data.IsWellDepthDecreasing && !data.IsWellDepthIncreasing &&
|
||||||
!data.IsBitPositionDecreasing && !data.IsBitPositionIncreasing &&
|
!data.IsBitPositionDecreasing && !data.IsBitPositionIncreasing &&
|
||||||
!data.IsBlockPositionDecreasing && !data.IsBlockPositionIncreasing &&
|
!data.IsBlockPositionDecreasing && !data.IsBlockPositionIncreasing &&
|
||||||
data.IsRotorSpeedLt3 && data.IsPressureGt20;
|
data.IsRotorSpeedLt3 && data.IsPressureGt20;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using System;
|
using AsbSaubReport;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.IO;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using AsbSaubReport;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
namespace AsbCloudInfrastructure.Services
|
||||||
{
|
{
|
||||||
@ -27,10 +27,10 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
RootPath = "reports";
|
RootPath = "reports";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string RootPath { get ; private set; }
|
public string RootPath { get; private set; }
|
||||||
|
|
||||||
public int CreateReport(int wellId, int stepSeconds, int format, DateTime begin,
|
public int CreateReport(int wellId, int stepSeconds, int format, DateTime begin,
|
||||||
DateTime end, Action<float , string , int> progressHandler, Action<string, int> reportNameHandler)
|
DateTime end, Action<float, string, int> progressHandler, Action<string, int> reportNameHandler)
|
||||||
{
|
{
|
||||||
var newReportId = queue.EnqueueTask((id) =>
|
var newReportId = queue.EnqueueTask((id) =>
|
||||||
{
|
{
|
||||||
@ -40,9 +40,9 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
using (var context = new AsbCloudDbContext(optionsBuilder.Options))
|
using (var context = new AsbCloudDbContext(optionsBuilder.Options))
|
||||||
{
|
{
|
||||||
var generator = GetReportGenerator(wellId, begin, end, stepSeconds, format, context);
|
var generator = GetReportGenerator(wellId, begin, end, stepSeconds, format, context);
|
||||||
generator.OnProgress += (s,e) => progressHandler.Invoke(e.progress, e.operation, id);
|
generator.OnProgress += (s, e) => progressHandler.Invoke(e.progress, e.operation, id);
|
||||||
var newReportName = generator.Make();
|
var newReportName = generator.Make();
|
||||||
if(newReportName is not null)
|
if (newReportName is not null)
|
||||||
{
|
{
|
||||||
var shorReportName = Path.GetFileName(newReportName);
|
var shorReportName = Path.GetFileName(newReportName);
|
||||||
reportNameHandler.Invoke(shorReportName, id);
|
reportNameHandler.Invoke(shorReportName, id);
|
||||||
@ -76,7 +76,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
{
|
{
|
||||||
var suitableReportsFromDb = GetSuitableReportsFromDb(wellId, begin, end, stepSeconds, format);
|
var suitableReportsFromDb = GetSuitableReportsFromDb(wellId, begin, end, stepSeconds, format);
|
||||||
|
|
||||||
var suitableReportsProperties = suitableReportsFromDb.Select(r => new ReportPropertiesDto
|
var suitableReportsProperties = suitableReportsFromDb.Select(r => new ReportPropertiesDto
|
||||||
{
|
{
|
||||||
Id = r.Id,
|
Id = r.Id,
|
||||||
Name = Path.GetFileName(r.Name),
|
Name = Path.GetFileName(r.Name),
|
||||||
@ -100,8 +100,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
var datesRange = (from d in db.DataSaubBases
|
var datesRange = (from d in db.DataSaubBases
|
||||||
where d.IdTelemetry == telemetry.Id
|
where d.IdTelemetry == telemetry.Id
|
||||||
select d.Date).Union(
|
select d.Date).Union(
|
||||||
from m in db.Messages
|
from m in db.Messages
|
||||||
where m.IdTelemetry == telemetry.Id
|
where m.IdTelemetry == telemetry.Id
|
||||||
select m.Date).DefaultIfEmpty().GroupBy(g => true)
|
select m.Date).DefaultIfEmpty().GroupBy(g => true)
|
||||||
@ -109,10 +109,11 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
{
|
{
|
||||||
From = g.Min(),
|
From = g.Min(),
|
||||||
To = g.Max()
|
To = g.Max()
|
||||||
}).OrderBy(gr => gr.From).FirstOrDefault();
|
}).OrderBy(gr => gr.From).FirstOrDefault();
|
||||||
|
|
||||||
return new DatesRangeDto {
|
return new DatesRangeDto
|
||||||
From = datesRange.From,
|
{
|
||||||
|
From = datesRange.From,
|
||||||
To = datesRange.To.Year == 1 ? DateTime.MaxValue : datesRange.To
|
To = datesRange.To.Year == 1 ? DateTime.MaxValue : datesRange.To
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -143,7 +144,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
WithEvents = true
|
WithEvents = true
|
||||||
};
|
};
|
||||||
|
|
||||||
switch(format)
|
switch (format)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
return generator;
|
return generator;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudApp.Services;
|
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
namespace AsbCloudInfrastructure.Services
|
||||||
{
|
{
|
||||||
@ -8,7 +8,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
{
|
{
|
||||||
public TelemetryAnalysis CurrentAnalysis { get; set; }
|
public TelemetryAnalysis CurrentAnalysis { get; set; }
|
||||||
|
|
||||||
private readonly Dictionary<int, List<DataSaubBase>> saubData =
|
private readonly Dictionary<int, List<DataSaubBase>> saubData =
|
||||||
new Dictionary<int, List<DataSaubBase>>();
|
new Dictionary<int, List<DataSaubBase>>();
|
||||||
|
|
||||||
public IEnumerable<DataSaubBase> GetOrCreateCache(int telemetryId)
|
public IEnumerable<DataSaubBase> GetOrCreateCache(int telemetryId)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using AsbCloudApp.Services;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using AsbCloudApp.Services;
|
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
namespace AsbCloudInfrastructure.Services
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Comparators;
|
||||||
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudApp.Comparators;
|
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudInfrastructure.Services.Cache;
|
using AsbCloudInfrastructure.Services.Cache;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudInfrastructure.Services.Cache;
|
using AsbCloudInfrastructure.Services.Cache;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
namespace AsbCloudInfrastructure.Services
|
||||||
{
|
{
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudInfrastructure.Services.Cache;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
namespace AsbCloudInfrastructure.Services
|
||||||
{
|
{
|
||||||
@ -23,7 +19,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
public IEnumerable<DepositDto> GetDeposits(int idCompany)
|
public IEnumerable<DepositDto> GetDeposits(int idCompany)
|
||||||
{
|
{
|
||||||
var entities = db.GetWellsForCompany(idCompany)
|
var entities = db.GetWellsForCompany(idCompany)
|
||||||
.Select(e=>e.Cluster.Deposit)
|
.Select(e => e.Cluster.Deposit)
|
||||||
.Distinct()
|
.Distinct()
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
@ -60,7 +56,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
{
|
{
|
||||||
var entities = db.GetWellsForCompany(idCompany)
|
var entities = db.GetWellsForCompany(idCompany)
|
||||||
.Select(e => e.Cluster)
|
.Select(e => e.Cluster)
|
||||||
.Where(e=>e.IdDeposit == depositId)
|
.Where(e => e.IdDeposit == depositId)
|
||||||
.Distinct()
|
.Distinct()
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
@ -120,7 +116,8 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
RateOfPenetrationPlan = e.RateOfPenetrationPlan,
|
RateOfPenetrationPlan = e.RateOfPenetrationPlan,
|
||||||
RouteSpeedFact = e.RouteSpeedFact,
|
RouteSpeedFact = e.RouteSpeedFact,
|
||||||
RouteSpeedPlan = e.RouteSpeedPlan,
|
RouteSpeedPlan = e.RouteSpeedPlan,
|
||||||
Sections = e.Sections.Select(s => new WellSectionDto {
|
Sections = e.Sections.Select(s => new WellSectionDto
|
||||||
|
{
|
||||||
BhaDownSpeedFact = s.BhaDownSpeedFact,
|
BhaDownSpeedFact = s.BhaDownSpeedFact,
|
||||||
BhaDownSpeedPlan = s.BhaDownSpeedPlan,
|
BhaDownSpeedPlan = s.BhaDownSpeedPlan,
|
||||||
BhaUpSpeedFact = s.BhaUpSpeedFact,
|
BhaUpSpeedFact = s.BhaUpSpeedFact,
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
using System;
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Services;
|
||||||
|
using AsbCloudWebApi.Controllers;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Moq;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using Moq;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using AsbCloudWebApi.Controllers;
|
|
||||||
using AsbCloudApp.Services;
|
|
||||||
using AsbCloudApp.Data;
|
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Tests.ControllersTests
|
namespace AsbCloudWebApi.Tests.ControllersTests
|
||||||
{
|
{
|
||||||
@ -56,7 +56,7 @@ namespace AsbCloudWebApi.Tests.ControllersTests
|
|||||||
{
|
{
|
||||||
var result = controller.GetWellDepthToDay(1);
|
var result = controller.GetWellDepthToDay(1);
|
||||||
var okResult = result as OkObjectResult;
|
var okResult = result as OkObjectResult;
|
||||||
|
|
||||||
Assert.NotNull(okResult);
|
Assert.NotNull(okResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ namespace AsbCloudWebApi.Tests.ControllersTests
|
|||||||
var result = controller.GetWellDepthToDay(1);
|
var result = controller.GetWellDepthToDay(1);
|
||||||
var okResult = result as OkObjectResult;
|
var okResult = result as OkObjectResult;
|
||||||
var resultCount = ((List<WellDepthToDayDto>)okResult.Value).Count;
|
var resultCount = ((List<WellDepthToDayDto>)okResult.Value).Count;
|
||||||
|
|
||||||
Assert.Equal(3, resultCount);
|
Assert.Equal(3, resultCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,17 +75,17 @@ namespace AsbCloudWebApi.Tests.ControllersTests
|
|||||||
{
|
{
|
||||||
var emptyUserController = new AnalyticsController(analyticsService.Object,
|
var emptyUserController = new AnalyticsController(analyticsService.Object,
|
||||||
wellService.Object);
|
wellService.Object);
|
||||||
|
|
||||||
var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { }, "mock"));
|
var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { }, "mock"));
|
||||||
|
|
||||||
emptyUserController.ControllerContext = new ControllerContext()
|
emptyUserController.ControllerContext = new ControllerContext()
|
||||||
{
|
{
|
||||||
HttpContext = new DefaultHttpContext() { User = user }
|
HttpContext = new DefaultHttpContext() { User = user }
|
||||||
};
|
};
|
||||||
|
|
||||||
var result = emptyUserController.GetWellDepthToDay(1);
|
var result = emptyUserController.GetWellDepthToDay(1);
|
||||||
var forbidResult = result as ForbidResult;
|
var forbidResult = result as ForbidResult;
|
||||||
|
|
||||||
Assert.NotNull(forbidResult);
|
Assert.NotNull(forbidResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,23 +96,23 @@ namespace AsbCloudWebApi.Tests.ControllersTests
|
|||||||
|
|
||||||
wellServiceReturnsFalse.Setup(s => s.CheckWellOwnership(It.IsAny<int>(), It.IsAny<int>()))
|
wellServiceReturnsFalse.Setup(s => s.CheckWellOwnership(It.IsAny<int>(), It.IsAny<int>()))
|
||||||
.Returns(false);
|
.Returns(false);
|
||||||
|
|
||||||
var newControllerInstance = new AnalyticsController(analyticsService.Object,
|
var newControllerInstance = new AnalyticsController(analyticsService.Object,
|
||||||
wellServiceReturnsFalse.Object);
|
wellServiceReturnsFalse.Object);
|
||||||
|
|
||||||
var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
|
var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
|
||||||
{
|
{
|
||||||
new Claim("idCompany", "1"),
|
new Claim("idCompany", "1"),
|
||||||
}, "mock"));
|
}, "mock"));
|
||||||
|
|
||||||
newControllerInstance.ControllerContext = new ControllerContext()
|
newControllerInstance.ControllerContext = new ControllerContext()
|
||||||
{
|
{
|
||||||
HttpContext = new DefaultHttpContext() { User = user }
|
HttpContext = new DefaultHttpContext() { User = user }
|
||||||
};
|
};
|
||||||
|
|
||||||
var result = newControllerInstance.GetWellDepthToDay(1);
|
var result = newControllerInstance.GetWellDepthToDay(1);
|
||||||
var forbidResult = result as ForbidResult;
|
var forbidResult = result as ForbidResult;
|
||||||
|
|
||||||
Assert.NotNull(forbidResult);
|
Assert.NotNull(forbidResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,26 +120,26 @@ namespace AsbCloudWebApi.Tests.ControllersTests
|
|||||||
public void It_should_return_204_if_dtos_is_empty()
|
public void It_should_return_204_if_dtos_is_empty()
|
||||||
{
|
{
|
||||||
var emptyAnalyticsService = new Mock<IAnalyticsService>();
|
var emptyAnalyticsService = new Mock<IAnalyticsService>();
|
||||||
|
|
||||||
emptyAnalyticsService.Setup(s => s.GetWellDepthToDay(It.IsAny<int>()))
|
emptyAnalyticsService.Setup(s => s.GetWellDepthToDay(It.IsAny<int>()))
|
||||||
.Returns(new List<WellDepthToDayDto>());
|
.Returns(new List<WellDepthToDayDto>());
|
||||||
|
|
||||||
var newControllerInstance = new AnalyticsController(emptyAnalyticsService.Object,
|
var newControllerInstance = new AnalyticsController(emptyAnalyticsService.Object,
|
||||||
wellService.Object);
|
wellService.Object);
|
||||||
|
|
||||||
var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
|
var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
|
||||||
{
|
{
|
||||||
new Claim("idCompany", "1"),
|
new Claim("idCompany", "1"),
|
||||||
}, "mock"));
|
}, "mock"));
|
||||||
|
|
||||||
newControllerInstance.ControllerContext = new ControllerContext()
|
newControllerInstance.ControllerContext = new ControllerContext()
|
||||||
{
|
{
|
||||||
HttpContext = new DefaultHttpContext() { User = user }
|
HttpContext = new DefaultHttpContext() { User = user }
|
||||||
};
|
};
|
||||||
|
|
||||||
var result = newControllerInstance.GetWellDepthToDay(1);
|
var result = newControllerInstance.GetWellDepthToDay(1);
|
||||||
var notFoundResult = result as NoContentResult;
|
var notFoundResult = result as NoContentResult;
|
||||||
|
|
||||||
Assert.NotNull(notFoundResult);
|
Assert.NotNull(notFoundResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,26 +147,26 @@ namespace AsbCloudWebApi.Tests.ControllersTests
|
|||||||
public void It_should_return_204_if_dtos_is_null()
|
public void It_should_return_204_if_dtos_is_null()
|
||||||
{
|
{
|
||||||
var emptyAnalyticsService = new Mock<IAnalyticsService>();
|
var emptyAnalyticsService = new Mock<IAnalyticsService>();
|
||||||
|
|
||||||
emptyAnalyticsService.Setup(s => s.GetWellDepthToDay(It.IsAny<int>()))
|
emptyAnalyticsService.Setup(s => s.GetWellDepthToDay(It.IsAny<int>()))
|
||||||
.Returns(value: null);
|
.Returns(value: null);
|
||||||
|
|
||||||
var newControllerInstance = new AnalyticsController(emptyAnalyticsService.Object,
|
var newControllerInstance = new AnalyticsController(emptyAnalyticsService.Object,
|
||||||
wellService.Object);
|
wellService.Object);
|
||||||
|
|
||||||
var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
|
var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
|
||||||
{
|
{
|
||||||
new Claim("idCompany", "1"),
|
new Claim("idCompany", "1"),
|
||||||
}, "mock"));
|
}, "mock"));
|
||||||
|
|
||||||
newControllerInstance.ControllerContext = new ControllerContext()
|
newControllerInstance.ControllerContext = new ControllerContext()
|
||||||
{
|
{
|
||||||
HttpContext = new DefaultHttpContext() { User = user }
|
HttpContext = new DefaultHttpContext() { User = user }
|
||||||
};
|
};
|
||||||
|
|
||||||
var result = newControllerInstance.GetWellDepthToDay(1);
|
var result = newControllerInstance.GetWellDepthToDay(1);
|
||||||
var notFoundResult = result as NoContentResult;
|
var notFoundResult = result as NoContentResult;
|
||||||
|
|
||||||
Assert.NotNull(notFoundResult);
|
Assert.NotNull(notFoundResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
using System;
|
using AsbCloudApp.Data;
|
||||||
using System.Linq;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using AsbCloudApp.Data;
|
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
@ -78,7 +78,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("{wellId}/wellDepthToInterval")]
|
[Route("{wellId}/wellDepthToInterval")]
|
||||||
[ProducesResponseType(typeof(IEnumerable<WellDepthToIntervalDto>), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(IEnumerable<WellDepthToIntervalDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public IActionResult GetWellDepthToInterval(int wellId,
|
public IActionResult GetWellDepthToInterval(int wellId,
|
||||||
int intervalSeconds, int workBeginSeconds)
|
int intervalSeconds, int workBeginSeconds)
|
||||||
{
|
{
|
||||||
int? idCompany = User.GetCompanyId();
|
int? idCompany = User.GetCompanyId();
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
@ -45,36 +41,36 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение доступных пользователю скважин
|
/// Получение доступных пользователю скважин
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="clusterId"></param>
|
/// <param name="idCluster"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("{clusterId}")]
|
[HttpGet("{idCluster}")]
|
||||||
[ProducesResponseType(typeof(IEnumerable<WellDto>), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(IEnumerable<WellDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public IActionResult GetWells(int clusterId)
|
public IActionResult GetWells(int idCluster)
|
||||||
{
|
{
|
||||||
int? idCompany = User.GetCompanyId();
|
int? idCompany = User.GetCompanyId();
|
||||||
|
|
||||||
if (idCompany is null)
|
if (idCompany is null)
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var result = clusterService.GetWells((int)idCompany, clusterId);
|
var result = clusterService.GetWells((int)idCompany, idCluster);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение обопщенной аналитики по кусту (лучшая/худшая скважина)
|
/// Получение обопщенной статистики по кусту (лучшая/худшая скважина)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="clusterId"></param>
|
/// <param name="idCluster"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("{clusterId}/Analysis")]
|
[HttpGet("{idCluster}/Stat")]
|
||||||
[ProducesResponseType(typeof(IEnumerable<WellDrillingStatDto>), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(IEnumerable<WellDrillingStatDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public IActionResult GetAnalysis(int clusterId)
|
public IActionResult GetStat(int idCluster)
|
||||||
{
|
{
|
||||||
int? idCompany = User.GetCompanyId();
|
int? idCompany = User.GetCompanyId();
|
||||||
|
|
||||||
if (idCompany is null)
|
if (idCompany is null)
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var result = clusterService.GetStat((int)idCompany, clusterId);
|
var result = clusterService.GetStat((int)idCompany, idCluster);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
|
@ -59,7 +59,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
bool isCompanyOwnsWell = wellService.CheckWellOwnership((int)idCompany, wellId);
|
bool isCompanyOwnsWell = wellService.CheckWellOwnership((int)idCompany, wellId);
|
||||||
|
|
||||||
if (!isCompanyOwnsWell)
|
if (!isCompanyOwnsWell)
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
using System;
|
using AsbCloudApp.Data;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.IO;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using AsbCloudApp.Data;
|
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudWebApi.SignalR;
|
using AsbCloudWebApi.SignalR;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
@ -29,16 +29,18 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
this.reportsHubContext = reportsHubContext;
|
this.reportsHubContext = reportsHubContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleReportProgressAsync (float progress, string operation, int id) =>
|
private void HandleReportProgressAsync(float progress, string operation, int id) =>
|
||||||
Task.Run(()=> {
|
Task.Run(() =>
|
||||||
|
{
|
||||||
reportsHubContext.Clients.Group($"Report_{id}").SendAsync(
|
reportsHubContext.Clients.Group($"Report_{id}").SendAsync(
|
||||||
nameof(IReportHubClient.GetReportProgress),
|
nameof(IReportHubClient.GetReportProgress),
|
||||||
new { Progress = progress, Operation = operation, ReportName = "" }
|
new { Progress = progress, Operation = operation, ReportName = "" }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
private void HandleReportNameAsync (string reportName, int groupId) =>
|
private void HandleReportNameAsync(string reportName, int groupId) =>
|
||||||
Task.Run(() => {
|
Task.Run(() =>
|
||||||
|
{
|
||||||
reportsHubContext.Clients.All.SendAsync(
|
reportsHubContext.Clients.All.SendAsync(
|
||||||
nameof(IReportHubClient.GetReportProgress),
|
nameof(IReportHubClient.GetReportProgress),
|
||||||
new { Progress = 100, Operation = "Отчет успешно создан", ReportName = reportName }
|
new { Progress = 100, Operation = "Отчет успешно создан", ReportName = reportName }
|
||||||
@ -58,9 +60,9 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("{wellId}/report")]
|
[Route("{wellId}/report")]
|
||||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public IActionResult CreateReport(int wellId, int stepSeconds, int format,
|
public IActionResult CreateReport(int wellId, int stepSeconds, int format,
|
||||||
DateTime begin = default, DateTime end = default)
|
DateTime begin = default, DateTime end = default)
|
||||||
{
|
{
|
||||||
int? idCompany = User.GetCompanyId();
|
int? idCompany = User.GetCompanyId();
|
||||||
|
|
||||||
if (idCompany is null)
|
if (idCompany is null)
|
||||||
|
@ -41,7 +41,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
this.telemetryHubContext = telemetryHubContext;
|
this.telemetryHubContext = telemetryHubContext;
|
||||||
this.telemetryTracker = telemetryTracker;
|
this.telemetryTracker = telemetryTracker;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Принимает общую информацию по скважине
|
/// Принимает общую информацию по скважине
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -44,18 +44,18 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
{
|
{
|
||||||
var idCompany = User.GetCompanyId();
|
var idCompany = User.GetCompanyId();
|
||||||
|
|
||||||
if(idCompany is null)
|
if (idCompany is null)
|
||||||
{
|
{
|
||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
var transmittingWells = wellService.GetTransmittingWells((int)idCompany);
|
var transmittingWells = wellService.GetTransmittingWells((int)idCompany);
|
||||||
|
|
||||||
if (transmittingWells is null || !transmittingWells.Any())
|
if (transmittingWells is null || !transmittingWells.Any())
|
||||||
return NoContent();
|
return NoContent();
|
||||||
|
|
||||||
return Ok(transmittingWells);
|
return Ok(transmittingWells);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using AsbCloudInfrastructure.Services;
|
using AsbCloudInfrastructure.Services;
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System.Threading.Tasks;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace AsbCloudWebApi.SignalR
|
namespace AsbCloudWebApi.SignalR
|
||||||
{
|
{
|
||||||
|
@ -1,20 +1,17 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ConsoleApp1
|
namespace ConsoleApp1
|
||||||
{
|
{
|
||||||
public enum WellDepthState {Idle, Increase }
|
public enum WellDepthState { Idle, Increase }
|
||||||
public enum BitDepthState {Idle, Increase, Decrease, OnSurface}
|
public enum BitDepthState { Idle, Increase, Decrease, OnSurface }
|
||||||
public enum BlockState {Idle, Increase, Decrease}
|
public enum BlockState { Idle, Increase, Decrease }
|
||||||
public enum RotorState {Inactive, Active}
|
public enum RotorState { Inactive, Active }
|
||||||
public enum PressureState { Inactive, Active }
|
public enum PressureState { Inactive, Active }
|
||||||
public enum HookWeightState { Idle, None }
|
public enum HookWeightState { Idle, None }
|
||||||
public enum DrillingOperation {
|
public enum DrillingOperation
|
||||||
Unknown,
|
{
|
||||||
RotorDrilling,
|
Unknown,
|
||||||
|
RotorDrilling,
|
||||||
SlideDrilling,
|
SlideDrilling,
|
||||||
TrippingOutReaming,
|
TrippingOutReaming,
|
||||||
TrippingInReaming,
|
TrippingInReaming,
|
||||||
|
@ -29,7 +29,8 @@ namespace ConsoleApp1
|
|||||||
.UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True")
|
.UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True")
|
||||||
.Options;
|
.Options;
|
||||||
|
|
||||||
var acfg = new MapperConfiguration(cfg => {
|
var acfg = new MapperConfiguration(cfg =>
|
||||||
|
{
|
||||||
cfg.CreateMap<DataSaubBase, DataSaubBaseDto>();
|
cfg.CreateMap<DataSaubBase, DataSaubBaseDto>();
|
||||||
cfg.CreateMap<DataSaubBaseDto, DataSaubBase>();
|
cfg.CreateMap<DataSaubBaseDto, DataSaubBase>();
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ namespace ConsoleApp1
|
|||||||
var telemetryService = new TelemetryService(context, cachedDb, acfg);
|
var telemetryService = new TelemetryService(context, cachedDb, acfg);
|
||||||
var telemetryUserService = new TelemetryUserService(context, cachedDb, telemetryService);
|
var telemetryUserService = new TelemetryUserService(context, cachedDb, telemetryService);
|
||||||
|
|
||||||
var tusers = new List<TelemetryUserDto> {
|
var tusers = new List<TelemetryUserDto> {
|
||||||
new TelemetryUserDto{
|
new TelemetryUserDto{
|
||||||
Id=1,
|
Id=1,
|
||||||
Level=0,
|
Level=0,
|
||||||
|
@ -1,12 +1,4 @@
|
|||||||
using System;
|
namespace DataTable
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using System.Runtime.Serialization.Formatters.Binary;
|
|
||||||
using System.Text.Json;
|
|
||||||
|
|
||||||
namespace DataTable
|
|
||||||
{
|
{
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
@ -60,7 +52,7 @@ namespace DataTable
|
|||||||
// });
|
// });
|
||||||
|
|
||||||
//var tMapper = new TableMapper<TestDto>();
|
//var tMapper = new TableMapper<TestDto>();
|
||||||
|
|
||||||
//var tab = tMapper.MakeTable(listDtos);
|
//var tab = tMapper.MakeTable(listDtos);
|
||||||
|
|
||||||
//var e = tMapper.AsEnumerable(tab);
|
//var e = tMapper.AsEnumerable(tab);
|
||||||
@ -76,12 +68,12 @@ namespace DataTable
|
|||||||
//formatter.Serialize(mem, tab);
|
//formatter.Serialize(mem, tab);
|
||||||
//var tabBinBytes = new byte[mem.Length];
|
//var tabBinBytes = new byte[mem.Length];
|
||||||
//Array.Copy(mem.GetBuffer(), tabBinBytes, mem.Length);
|
//Array.Copy(mem.GetBuffer(), tabBinBytes, mem.Length);
|
||||||
|
|
||||||
//mem = new MemoryStream();
|
//mem = new MemoryStream();
|
||||||
//formatter.Serialize(mem, listDtos);
|
//formatter.Serialize(mem, listDtos);
|
||||||
//var listBinBytes = new byte[mem.Length];
|
//var listBinBytes = new byte[mem.Length];
|
||||||
//Array.Copy(mem.GetBuffer(), listBinBytes, mem.Length);
|
//Array.Copy(mem.GetBuffer(), listBinBytes, mem.Length);
|
||||||
|
|
||||||
//Console.WriteLine($"tabJsonBytes:{tabJsonBytes.Length}");
|
//Console.WriteLine($"tabJsonBytes:{tabJsonBytes.Length}");
|
||||||
//Console.WriteLine($"listJsonBytes:{listJsonBytes.Length}");
|
//Console.WriteLine($"listJsonBytes:{listJsonBytes.Length}");
|
||||||
//Console.WriteLine($"tabBinBytes:{tabBinBytes.Length}");
|
//Console.WriteLine($"tabBinBytes:{tabBinBytes.Length}");
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.ComponentModel;
|
|
||||||
|
|
||||||
namespace DataTable
|
namespace DataTable
|
||||||
{
|
{
|
||||||
@ -43,7 +43,7 @@ namespace DataTable
|
|||||||
|
|
||||||
private string GetDescription(PropertyInfo property)
|
private string GetDescription(PropertyInfo property)
|
||||||
{
|
{
|
||||||
var descriptionAttr = property.GetCustomAttribute<DescriptionAttribute>();
|
var descriptionAttr = property.GetCustomAttribute<DescriptionAttribute>();
|
||||||
return descriptionAttr?.Description ?? string.Empty;
|
return descriptionAttr?.Description ?? string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ namespace DataTable
|
|||||||
public object Get(object instance)
|
public object Get(object instance)
|
||||||
=> Getter(instance);
|
=> Getter(instance);
|
||||||
|
|
||||||
public static string MakeIdentity(string propertyTypeName, string propertyName)
|
public static string MakeIdentity(string propertyTypeName, string propertyName)
|
||||||
=> $"{propertyTypeName}_{propertyName}".ToLower();
|
=> $"{propertyTypeName}_{propertyName}".ToLower();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
namespace DataTable
|
namespace DataTable
|
||||||
{
|
{
|
||||||
public class TableMapper<T>
|
public class TableMapper<T>
|
||||||
where T: new()
|
where T : new()
|
||||||
{
|
{
|
||||||
private readonly Dictionary<string, PropertyHelper> props;
|
private readonly Dictionary<string, PropertyHelper> props;
|
||||||
|
|
||||||
@ -23,14 +23,14 @@ namespace DataTable
|
|||||||
{
|
{
|
||||||
if ((table?.Headers is null) ||
|
if ((table?.Headers is null) ||
|
||||||
(table?.Rows is null) ||
|
(table?.Rows is null) ||
|
||||||
(!table.Headers.Any()) ||
|
(!table.Headers.Any()) ||
|
||||||
(!table.Rows.Any()) ||
|
(!table.Rows.Any()) ||
|
||||||
(!props.Any()) )
|
(!props.Any()))
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
var headerIdToProp = new Dictionary<int, PropertyHelper>(props.Count);
|
var headerIdToProp = new Dictionary<int, PropertyHelper>(props.Count);
|
||||||
foreach(var (_, propHelper) in props)
|
foreach (var (_, propHelper) in props)
|
||||||
for(var i = 0; i < table.Headers.Count(); i++)
|
for (var i = 0; i < table.Headers.Count(); i++)
|
||||||
{
|
{
|
||||||
var header = table.Headers.ElementAt(i);
|
var header = table.Headers.ElementAt(i);
|
||||||
var columnType = System.Type.GetType(header.ColumnType);
|
var columnType = System.Type.GetType(header.ColumnType);
|
||||||
@ -64,7 +64,7 @@ namespace DataTable
|
|||||||
}).ToArray();
|
}).ToArray();
|
||||||
|
|
||||||
var rows = new List<List<object>>(data.Count());
|
var rows = new List<List<object>>(data.Count());
|
||||||
foreach(var dataItem in data)
|
foreach (var dataItem in data)
|
||||||
rows.Add(MakeRow(dataItem));
|
rows.Add(MakeRow(dataItem));
|
||||||
|
|
||||||
table.Rows = rows;
|
table.Rows = rows;
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataTable
|
namespace DataTable
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user