forked from ddrilling/AsbCloudServer
merge net6_migrate
This commit is contained in:
commit
fed253d0f6
@ -8,6 +8,7 @@ namespace AsbCloudApp.Data
|
||||
public string Caption { get; set; }
|
||||
public double? Latitude { get; set; }
|
||||
public double? Longitude { get; set; }
|
||||
public SimpleTimezoneDto Timezone { get; set; }
|
||||
public int? IdDeposit { get; set; }
|
||||
public DepositBaseDto Deposit { get; set; }
|
||||
public IEnumerable<WellDto> Wells { get; set; }
|
||||
|
@ -8,6 +8,7 @@ namespace AsbCloudApp.Data
|
||||
public string Caption { get; set; }
|
||||
public double? Latitude { get; set; }
|
||||
public double? Longitude { get; set; }
|
||||
public SimpleTimezoneDto Timezone { get; set; }
|
||||
}
|
||||
|
||||
public class DepositDto : DepositBaseDto
|
||||
|
@ -3,7 +3,7 @@ using System;
|
||||
namespace AsbCloudApp.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Параметры корридоров бурения (диапазоны параметров бурения)
|
||||
/// Параметры коридоров бурения (диапазоны параметров бурения)
|
||||
/// </summary>
|
||||
public class DrillFlowChartDto : IId
|
||||
{
|
||||
|
@ -4,5 +4,6 @@
|
||||
{
|
||||
double? Latitude { get; set; }
|
||||
double? Longitude { get; set; }
|
||||
SimpleTimezoneDto Timezone { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ namespace AsbCloudApp.Data
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Кол-во записей пропущеных с начала таблицы в запросе от api
|
||||
/// Кол-во записей пропущенных с начала таблицы в запросе от api
|
||||
/// </summary>
|
||||
public int Skip { get; set; }
|
||||
|
||||
|
@ -9,8 +9,8 @@ namespace AsbCloudApp.Data
|
||||
public FileInfoDto File { get; set; }
|
||||
public int IdWell { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public DateTimeOffset Begin { get; set; }
|
||||
public DateTimeOffset End { get; set; }
|
||||
public DateTime Begin { get; set; }
|
||||
public DateTime End { get; set; }
|
||||
public int Step { get; set; }
|
||||
public string Format { get; set; }
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
namespace AsbCloudApp.Data
|
||||
{
|
||||
public class TelemetryTimeZoneDto
|
||||
public class SimpleTimezoneDto
|
||||
{
|
||||
public double Hours { get; set; }
|
||||
public string TimeZoneId { get; set; }
|
||||
public string TimezoneId { get; set; }
|
||||
public bool IsOverride { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if(obj is TelemetryTimeZoneDto tTimeZone
|
||||
if(obj is SimpleTimezoneDto tTimeZone
|
||||
&& tTimeZone.Hours == Hours
|
||||
&& tTimeZone.TimeZoneId == TimeZoneId
|
||||
&& tTimeZone.TimezoneId == TimezoneId
|
||||
&& tTimeZone.IsOverride == IsOverride)
|
||||
return true;
|
||||
return false;
|
||||
@ -18,7 +18,7 @@ namespace AsbCloudApp.Data
|
||||
|
||||
public override int GetHashCode()
|
||||
=> Hours.GetHashCode()
|
||||
| TimeZoneId.GetHashCode()
|
||||
| TimezoneId.GetHashCode()
|
||||
| IsOverride.GetHashCode();
|
||||
}
|
||||
}
|
@ -38,7 +38,7 @@ namespace AsbCloudApp.Data
|
||||
public float? WellDepth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Глубина долта
|
||||
/// Глубина долота
|
||||
/// </summary>
|
||||
public float? BitDepth { get; set; }
|
||||
|
||||
@ -83,12 +83,12 @@ namespace AsbCloudApp.Data
|
||||
public float? BlockSpeedSpDevelop { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Давтение
|
||||
/// Давление
|
||||
/// </summary>
|
||||
public float? Pressure { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Давтение при холостом ходе.
|
||||
/// Давление при холостом ходе.
|
||||
/// </summary>
|
||||
public float? PressureIdle { get; set; }
|
||||
|
||||
|
@ -5,7 +5,7 @@ namespace AsbCloudApp.Data
|
||||
{
|
||||
public class TelemetryOperationInfoDto
|
||||
{
|
||||
public DateTimeOffset IntervalBegin { get; set; }
|
||||
public DateTime IntervalBegin { get; set; }
|
||||
public IList<TelemetryOperationDetailsDto> Operations { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -8,12 +8,13 @@ namespace AsbCloudApp.Data
|
||||
public int Id { get; set; }
|
||||
public double? Latitude { get; set; }
|
||||
public double? Longitude { get; set; }
|
||||
public SimpleTimezoneDto Timezone { get; set; }
|
||||
public string WellType { get; set; }
|
||||
public int IdWellType { get; set; }
|
||||
public int? IdWellType { get; set; }
|
||||
public int? IdCluster { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 0 - незвестно,
|
||||
/// 0 - неизвестно,
|
||||
/// 1 - в работе,
|
||||
/// 2 - завершена
|
||||
/// </summary>
|
||||
|
@ -11,10 +11,9 @@ namespace AsbCloudApp.Services
|
||||
Task<PaginationContainer<MessageDto>> GetMessagesAsync(int idWell,
|
||||
IEnumerable<int> categoryids = default, DateTime begin = default,
|
||||
DateTime end = default, string searchString = default,
|
||||
int skip = 0, int take = 32, bool isUtc = true,
|
||||
CancellationToken token = default);
|
||||
Task<DatesRangeDto> GetMessagesDatesRangeAsync(int idWell, bool isUtc,
|
||||
int skip = 0, int take = 32,
|
||||
CancellationToken token = default);
|
||||
|
||||
Task InsertAsync(string uid, IEnumerable<TelemetryMessageDto> dtos,
|
||||
CancellationToken token);
|
||||
}
|
||||
|
@ -14,8 +14,7 @@ namespace AsbCloudApp.Services
|
||||
Action<object, int> handleReportProgress);
|
||||
int GetReportPagesCount(int idWell, DateTime begin, DateTime end,
|
||||
int stepSeconds, int format);
|
||||
Task<DatesRangeDto> GetReportsDatesRangeAsync(int idWell, bool isUtc,
|
||||
CancellationToken token = default);
|
||||
Task<List<ReportPropertiesDto>> GetAllReportsByWellAsync(int idWell, CancellationToken token);
|
||||
DatesRangeDto GetDatesRangeOrDefault(int idWell);
|
||||
Task<IEnumerable<ReportPropertiesDto>> GetAllReportsByWellAsync(int idWell, CancellationToken token);
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ namespace AsbCloudApp.Services
|
||||
int intervalHoursTimestamp, int workBeginTimestamp,
|
||||
CancellationToken token = default);
|
||||
Task AnalyzeAndSaveTelemetriesAsync(CancellationToken token = default);
|
||||
Task<DatesRangeDto> GetOperationsDateRangeAsync(int idWell, bool isUtc,
|
||||
Task<DatesRangeDto> GetOperationsDateRangeAsync(int idWell,
|
||||
CancellationToken token = default);
|
||||
}
|
||||
}
|
||||
|
@ -10,9 +10,8 @@ namespace AsbCloudApp.Services
|
||||
{
|
||||
Task<IEnumerable<TDto>> GetAsync(int idWell,
|
||||
DateTime dateBegin = default, double intervalSec = 600d,
|
||||
int approxPointsCount = 1024, bool isUtc = false, CancellationToken token = default);
|
||||
Task<DatesRangeDto> GetDataDatesRangeAsync(int idWell, bool isUtc = false,
|
||||
CancellationToken token = default);
|
||||
int approxPointsCount = 1024, CancellationToken token = default);
|
||||
|
||||
Task<int> UpdateDataAsync(string uid, IEnumerable<TDto> dtos, CancellationToken token = default);
|
||||
}
|
||||
}
|
@ -8,23 +8,17 @@ namespace AsbCloudApp.Services
|
||||
{
|
||||
public interface ITelemetryService
|
||||
{
|
||||
ITimeZoneService TimeZoneService { get; }
|
||||
ITimezoneService TimeZoneService { get; }
|
||||
ITelemetryTracker TelemetryTracker { get; }
|
||||
|
||||
int? GetIdWellByTelemetryUid(string uid);
|
||||
int GetOrCreateTelemetryIdByUid(string uid);
|
||||
double GetTimezoneOffsetByTelemetryId(int idTelemetry);
|
||||
Task<double?> GetTelemetryTimeZoneOffsetAsync(int idTelemetry, CancellationToken token);
|
||||
SimpleTimezoneDto GetTimezone(int idTelemetry);
|
||||
IEnumerable<TelemetryDto> GetTransmittingTelemetries();
|
||||
DateTime GetLastTelemetryDate(string telemetryUid);
|
||||
DateTime GetLastTelemetryDate(int telemetryId);
|
||||
DateTime GetLastTelemetryDate(int idTelemetry, bool useUtc = false);
|
||||
int? GetIdTelemetryByIdWell(int idWell);
|
||||
|
||||
DatesRangeDto GetDatesRange(int idTelemetry);
|
||||
Task UpdateInfoAsync(string uid, TelemetryInfoDto info, CancellationToken token);
|
||||
Task<DatesRangeDto> DatesRangeToTelemetryTimeZoneAsync(int telemetryId, DatesRangeDto result,
|
||||
CancellationToken token);
|
||||
|
||||
Task UpdateTimeZoneAsync(string uid, TelemetryTimeZoneDto telemetryTimeZoneInfo, CancellationToken token);
|
||||
Task UpdateTimezoneAsync(string uid, SimpleTimezoneDto telemetryTimeZoneInfo, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Слить данные телеметрии в одну
|
||||
@ -33,8 +27,6 @@ namespace AsbCloudApp.Services
|
||||
/// <param name="to">новая</param>
|
||||
/// <returns></returns>
|
||||
Task<int> MergeAsync(int from, int to, CancellationToken token);
|
||||
|
||||
void SaveRequestDate(string uid, DateTime remoteDate);
|
||||
Task<DatesRangeDto> GetDatesRangeAsync(int idWell, bool isUtc, CancellationToken token = default);
|
||||
void SaveRequestDate(string uid, DateTimeOffset remoteDate);
|
||||
}
|
||||
}
|
@ -6,9 +6,9 @@ namespace AsbCloudApp.Services
|
||||
{
|
||||
public interface ITelemetryTracker
|
||||
{
|
||||
DateTime GetLastTelemetryDateByUid(string uid);
|
||||
DateTimeOffset GetLastTelemetryDateByUid(string uid);
|
||||
DatesRangeDto GetTelemetryDateRangeByUid(string uid);
|
||||
IEnumerable<string> GetTransmittingTelemetriesUids();
|
||||
void SaveRequestDate(string uid, DateTime remoteDate);
|
||||
void SaveRequestDate(string uid, DateTimeOffset remoteDate);
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
using System;
|
||||
using AsbCloudApp.Data;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudApp.Services
|
||||
{
|
||||
public interface ITimeZoneService
|
||||
public interface ITimezoneService
|
||||
{
|
||||
DateTime DateToUtc(DateTime date, double remoteTimezoneOffsetHours);
|
||||
DateTime DateToTimeZone(DateTime date, double remoteTimezoneOffsetHours);
|
||||
Task<Data.TelemetryTimeZoneDto> GetByCoordinatesAsync(double latitude, double longitude, CancellationToken token);
|
||||
SimpleTimezoneDto GetByCoordinates(double latitude, double longitude);
|
||||
Task<Data.SimpleTimezoneDto> GetByCoordinatesAsync(double latitude, double longitude, CancellationToken token);
|
||||
}
|
||||
}
|
@ -8,6 +8,8 @@ namespace AsbCloudApp.Services
|
||||
{
|
||||
public interface IWellService: ICrudService<WellDto>
|
||||
{
|
||||
ITelemetryService TelemetryService { get; }
|
||||
|
||||
Task<IEnumerable<WellDto>> GetWellsByCompanyAsync(int idCompany, CancellationToken token);
|
||||
Task<bool> IsCompanyInvolvedInWellAsync(int idCompany, int idWell, CancellationToken token);
|
||||
Task<string> GetWellCaptionByIdAsync(int idWell, CancellationToken token);
|
||||
@ -15,7 +17,10 @@ namespace AsbCloudApp.Services
|
||||
Task<IEnumerable<CompanyDto>> GetCompaniesAsync(int idWell, CancellationToken token);
|
||||
bool IsCompanyInvolvedInWell(int idCompany, int idWell);
|
||||
string GetStateText(int state);
|
||||
DateTime GetLastTelemetryDate(int idWell);
|
||||
DateTimeOffset GetLastTelemetryDate(int idWell);
|
||||
Task<IEnumerable<int>> GetClusterWellsIdsAsync(int idWell, CancellationToken token);
|
||||
SimpleTimezoneDto GetTimezone(int idWell);
|
||||
DatesRangeDto GetDatesRange(int idWell);
|
||||
void EnshureTimezonesIsSet();
|
||||
}
|
||||
}
|
||||
|
@ -125,6 +125,7 @@ namespace AsbCloudDb
|
||||
{
|
||||
string vStr => $"'{vStr}'",
|
||||
DateTime vDate => $"'{FormatDateValue(vDate)}'",
|
||||
DateTimeOffset vDate => $"'{FormatDateValue(vDate.UtcDateTime)}'",
|
||||
IFormattable vFormattable=> FormatFormattableValue(vFormattable),
|
||||
_ => System.Text.Json.JsonSerializer.Serialize(v),
|
||||
};
|
||||
|
@ -770,7 +770,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("remote_uid")
|
||||
.HasComment("Идентификатор передающего устройства. Может повторяться в списке, так как комплекты оборудования переезжают от скв. к скв.");
|
||||
|
||||
b.Property<TelemetryTimeZone>("TelemetryTimeZone")
|
||||
b.Property<SimpleTimezone>("TelemetryTimeZone")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("timezone")
|
||||
.HasComment("Смещение часового пояса от UTC");
|
||||
|
@ -7,7 +7,7 @@ namespace AsbCloudDb.Migrations
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<TelemetryTimeZone>(
|
||||
migrationBuilder.AddColumn<SimpleTimezone>(
|
||||
name: "timezone",
|
||||
table: "t_telemetry",
|
||||
type: "jsonb",
|
||||
|
@ -853,7 +853,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("remote_uid")
|
||||
.HasComment("Идентификатор передающего устройства. Может повторяться в списке, так как комплекты оборудования переезжают от скв. к скв.");
|
||||
|
||||
b.Property<TelemetryTimeZone>("TelemetryTimeZone")
|
||||
b.Property<SimpleTimezone>("TelemetryTimeZone")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("timezone")
|
||||
.HasComment("Смещение часового пояса от UTC");
|
||||
|
@ -824,7 +824,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("remote_uid")
|
||||
.HasComment("Идентификатор передающего устройства. Может повторяться в списке, так как комплекты оборудования переезжают от скв. к скв.");
|
||||
|
||||
b.Property<TelemetryTimeZone>("TelemetryTimeZone")
|
||||
b.Property<SimpleTimezone>("TelemetryTimeZone")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("timezone")
|
||||
.HasComment("Смещение часового пояса от UTC");
|
||||
|
@ -854,7 +854,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("remote_uid")
|
||||
.HasComment("Идентификатор передающего устройства. Может повторяться в списке, так как комплекты оборудования переезжают от скв. к скв.");
|
||||
|
||||
b.Property<TelemetryTimeZone>("TelemetryTimeZone")
|
||||
b.Property<SimpleTimezone>("TelemetryTimeZone")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("timezone")
|
||||
.HasComment("Смещение часового пояса от UTC");
|
||||
|
@ -854,7 +854,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("remote_uid")
|
||||
.HasComment("Идентификатор передающего устройства. Может повторяться в списке, так как комплекты оборудования переезжают от скв. к скв.");
|
||||
|
||||
b.Property<TelemetryTimeZone>("TelemetryTimeZone")
|
||||
b.Property<SimpleTimezone>("TelemetryTimeZone")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("timezone")
|
||||
.HasComment("Смещение часового пояса от UTC");
|
||||
|
@ -854,7 +854,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("remote_uid")
|
||||
.HasComment("Идентификатор передающего устройства. Может повторяться в списке, так как комплекты оборудования переезжают от скв. к скв.");
|
||||
|
||||
b.Property<TelemetryTimeZone>("TelemetryTimeZone")
|
||||
b.Property<SimpleTimezone>("TelemetryTimeZone")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("timezone")
|
||||
.HasComment("Смещение часового пояса от UTC");
|
||||
|
@ -854,7 +854,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("remote_uid")
|
||||
.HasComment("Идентификатор передающего устройства. Может повторяться в списке, так как комплекты оборудования переезжают от скв. к скв.");
|
||||
|
||||
b.Property<TelemetryTimeZone>("TelemetryTimeZone")
|
||||
b.Property<SimpleTimezone>("TelemetryTimeZone")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("timezone")
|
||||
.HasComment("Смещение часового пояса от UTC");
|
||||
|
@ -824,7 +824,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("remote_uid")
|
||||
.HasComment("Идентификатор передающего устройства. Может повторяться в списке, так как комплекты оборудования переезжают от скв. к скв.");
|
||||
|
||||
b.Property<TelemetryTimeZone>("TelemetryTimeZone")
|
||||
b.Property<SimpleTimezone>("TelemetryTimeZone")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("timezone")
|
||||
.HasComment("Смещение часового пояса от UTC");
|
||||
|
@ -908,7 +908,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("remote_uid")
|
||||
.HasComment("Идентификатор передающего устройства. Может повторяться в списке, так как комплекты оборудования переезжают от скв. к скв.");
|
||||
|
||||
b.Property<TelemetryTimeZone>("TelemetryTimeZone")
|
||||
b.Property<SimpleTimezone>("TelemetryTimeZone")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("timezone")
|
||||
.HasComment("Смещение часового пояса от UTC");
|
||||
|
@ -908,7 +908,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("remote_uid")
|
||||
.HasComment("Идентификатор передающего устройства. Может повторяться в списке, так как комплекты оборудования переезжают от скв. к скв.");
|
||||
|
||||
b.Property<TelemetryTimeZone>("TelemetryTimeZone")
|
||||
b.Property<SimpleTimezone>("TelemetryTimeZone")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("timezone")
|
||||
.HasComment("Смещение часового пояса от UTC");
|
||||
|
@ -908,7 +908,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("remote_uid")
|
||||
.HasComment("Идентификатор передающего устройства. Может повторяться в списке, так как комплекты оборудования переезжают от скв. к скв.");
|
||||
|
||||
b.Property<TelemetryTimeZone>("TelemetryTimeZone")
|
||||
b.Property<SimpleTimezone>("TelemetryTimeZone")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("timezone")
|
||||
.HasComment("Смещение часового пояса от UTC");
|
||||
|
@ -899,7 +899,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("remote_uid")
|
||||
.HasComment("Идентификатор передающего устройства. Может повторяться в списке, так как комплекты оборудования переезжают от скв. к скв.");
|
||||
|
||||
b.Property<TelemetryTimeZone>("TelemetryTimeZone")
|
||||
b.Property<SimpleTimezone>("TelemetryTimeZone")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("timezone")
|
||||
.HasComment("Смещение часового пояса от UTC");
|
||||
|
@ -902,7 +902,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("remote_uid")
|
||||
.HasComment("Идентификатор передающего устройства. Может повторяться в списке, так как комплекты оборудования переезжают от скв. к скв.");
|
||||
|
||||
b.Property<TelemetryTimeZone>("TelemetryTimeZone")
|
||||
b.Property<SimpleTimezone>("TelemetryTimeZone")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("timezone")
|
||||
.HasComment("Смещение часового пояса от UTC");
|
||||
|
@ -893,7 +893,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("remote_uid")
|
||||
.HasComment("Идентификатор передающего устройства. Может повторяться в списке, так как комплекты оборудования переезжают от скв. к скв.");
|
||||
|
||||
b.Property<TelemetryTimeZone>("TelemetryTimeZone")
|
||||
b.Property<SimpleTimezone>("TelemetryTimeZone")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("timezone")
|
||||
.HasComment("Смещение часового пояса от UTC");
|
||||
|
@ -893,7 +893,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("remote_uid")
|
||||
.HasComment("Идентификатор передающего устройства. Может повторяться в списке, так как комплекты оборудования переезжают от скв. к скв.");
|
||||
|
||||
b.Property<TelemetryTimeZone>("TelemetryTimeZone")
|
||||
b.Property<SimpleTimezone>("TelemetryTimeZone")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("timezone")
|
||||
.HasComment("Смещение часового пояса от UTC");
|
||||
|
@ -893,7 +893,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("remote_uid")
|
||||
.HasComment("Идентификатор передающего устройства. Может повторяться в списке, так как комплекты оборудования переезжают от скв. к скв.");
|
||||
|
||||
b.Property<TelemetryTimeZone>("TelemetryTimeZone")
|
||||
b.Property<SimpleTimezone>("TelemetryTimeZone")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("timezone")
|
||||
.HasComment("Смещение часового пояса от UTC");
|
||||
|
3080
AsbCloudDb/Migrations/20211230054224_Fix_spelling_of_defaults.Designer.cs
generated
Normal file
3080
AsbCloudDb/Migrations/20211230054224_Fix_spelling_of_defaults.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
113
AsbCloudDb/Migrations/20211230054224_Fix_spelling_of_defaults.cs
Normal file
113
AsbCloudDb/Migrations/20211230054224_Fix_spelling_of_defaults.cs
Normal file
@ -0,0 +1,113 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
public partial class Fix_spelling_of_defaults : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.UpdateData(
|
||||
table: "t_well_operation_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 1014,
|
||||
column: "name",
|
||||
value: "Опрессовка Ц.К.");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "t_well_section_type",
|
||||
keyColumn: "id",
|
||||
keyValue: 1,
|
||||
column: "caption",
|
||||
value: "Пилотный ствол");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "t_well_section_type",
|
||||
keyColumn: "id",
|
||||
keyValue: 2,
|
||||
column: "caption",
|
||||
value: "Направление");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "t_well_section_type",
|
||||
keyColumn: "id",
|
||||
keyValue: 3,
|
||||
column: "caption",
|
||||
value: "Кондуктор");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "t_well_section_type",
|
||||
keyColumn: "id",
|
||||
keyValue: 4,
|
||||
column: "caption",
|
||||
value: "Эксплуатационная колонна");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "t_well_section_type",
|
||||
keyColumn: "id",
|
||||
keyValue: 5,
|
||||
column: "caption",
|
||||
value: "Транспортный ствол");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "t_well_section_type",
|
||||
keyColumn: "id",
|
||||
keyValue: 6,
|
||||
column: "caption",
|
||||
value: "Хвостовик");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.UpdateData(
|
||||
table: "t_well_operation_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 1014,
|
||||
column: "name",
|
||||
value: "Опресовка Ц.К.");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "t_well_section_type",
|
||||
keyColumn: "id",
|
||||
keyValue: 1,
|
||||
column: "caption",
|
||||
value: "Пилотный ствол 1");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "t_well_section_type",
|
||||
keyColumn: "id",
|
||||
keyValue: 2,
|
||||
column: "caption",
|
||||
value: "Направление 1");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "t_well_section_type",
|
||||
keyColumn: "id",
|
||||
keyValue: 3,
|
||||
column: "caption",
|
||||
value: "Кондуктор 1");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "t_well_section_type",
|
||||
keyColumn: "id",
|
||||
keyValue: 4,
|
||||
column: "caption",
|
||||
value: "Эксплуатационная колонна 1");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "t_well_section_type",
|
||||
keyColumn: "id",
|
||||
keyValue: 5,
|
||||
column: "caption",
|
||||
value: "Транспортный ствол 1");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "t_well_section_type",
|
||||
keyColumn: "id",
|
||||
keyValue: 6,
|
||||
column: "caption",
|
||||
value: "Хвостовик 1");
|
||||
}
|
||||
}
|
||||
}
|
3095
AsbCloudDb/Migrations/20220102073023_Add_timeZone_to_IMapPoint.Designer.cs
generated
Normal file
3095
AsbCloudDb/Migrations/20220102073023_Add_timeZone_to_IMapPoint.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,49 @@
|
||||
using AsbCloudDb.Model;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
public partial class Add_timeZone_to_IMapPoint : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<SimpleTimezone>(
|
||||
name: "timezone",
|
||||
table: "t_well",
|
||||
type: "jsonb",
|
||||
nullable: true,
|
||||
comment: "Смещение часового пояса от UTC");
|
||||
|
||||
migrationBuilder.AddColumn<SimpleTimezone>(
|
||||
name: "timezone",
|
||||
table: "t_deposit",
|
||||
type: "jsonb",
|
||||
nullable: true,
|
||||
comment: "Смещение часового пояса от UTC");
|
||||
|
||||
migrationBuilder.AddColumn<SimpleTimezone>(
|
||||
name: "timezone",
|
||||
table: "t_cluster",
|
||||
type: "jsonb",
|
||||
nullable: true,
|
||||
comment: "Смещение часового пояса от UTC");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "timezone",
|
||||
table: "t_well");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "timezone",
|
||||
table: "t_deposit");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "timezone",
|
||||
table: "t_cluster");
|
||||
}
|
||||
}
|
||||
}
|
3095
AsbCloudDb/Migrations/20220105123412_Fix_Spelling.Designer.cs
generated
Normal file
3095
AsbCloudDb/Migrations/20220105123412_Fix_Spelling.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
177
AsbCloudDb/Migrations/20220105123412_Fix_Spelling.cs
Normal file
177
AsbCloudDb/Migrations/20220105123412_Fix_Spelling.cs
Normal file
@ -0,0 +1,177 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
public partial class Fix_Spelling : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterTable(
|
||||
name: "t_drill_flow_chart",
|
||||
comment: "Параметры коридоров бурения (диапазоны параметров бурения)",
|
||||
oldComment: "Параметры корридоров бурения (диапазоны параметров бурения)");
|
||||
|
||||
migrationBuilder.AlterColumn<float>(
|
||||
name: "torque_starting",
|
||||
table: "t_telemetry_data_spin",
|
||||
type: "real",
|
||||
nullable: true,
|
||||
comment: "Страгивающий момент",
|
||||
oldClrType: typeof(float),
|
||||
oldType: "real",
|
||||
oldNullable: true,
|
||||
oldComment: " Страгивающий момент");
|
||||
|
||||
migrationBuilder.AlterColumn<float>(
|
||||
name: "rotor_torque_avg",
|
||||
table: "t_telemetry_data_spin",
|
||||
type: "real",
|
||||
nullable: true,
|
||||
comment: "Момент в роторе средний",
|
||||
oldClrType: typeof(float),
|
||||
oldType: "real",
|
||||
oldNullable: true,
|
||||
oldComment: " Момент в роторе средний");
|
||||
|
||||
migrationBuilder.AlterColumn<float>(
|
||||
name: "ratio",
|
||||
table: "t_telemetry_data_spin",
|
||||
type: "real",
|
||||
nullable: true,
|
||||
comment: " Коэффициент редукции редуктора",
|
||||
oldClrType: typeof(float),
|
||||
oldType: "real",
|
||||
oldNullable: true,
|
||||
oldComment: " Коэффициент редукции редектора");
|
||||
|
||||
migrationBuilder.AlterColumn<float>(
|
||||
name: "position_zero",
|
||||
table: "t_telemetry_data_spin",
|
||||
type: "real",
|
||||
nullable: true,
|
||||
comment: "Нулевая позиция осцилляции",
|
||||
oldClrType: typeof(float),
|
||||
oldType: "real",
|
||||
oldNullable: true,
|
||||
oldComment: "Нулевая позиция осциляции");
|
||||
|
||||
migrationBuilder.AlterColumn<float>(
|
||||
name: "position_right",
|
||||
table: "t_telemetry_data_spin",
|
||||
type: "real",
|
||||
nullable: true,
|
||||
comment: "Крайний правый угол осцилляции",
|
||||
oldClrType: typeof(float),
|
||||
oldType: "real",
|
||||
oldNullable: true,
|
||||
oldComment: "Крайний правый угол осциляции");
|
||||
|
||||
migrationBuilder.AlterColumn<float>(
|
||||
name: "encoder_resolution",
|
||||
table: "t_telemetry_data_spin",
|
||||
type: "real",
|
||||
nullable: true,
|
||||
comment: "Разрешение энкодера",
|
||||
oldClrType: typeof(float),
|
||||
oldType: "real",
|
||||
oldNullable: true,
|
||||
oldComment: " Разрешение энкодера");
|
||||
|
||||
migrationBuilder.AlterColumn<bool>(
|
||||
name: "is_pressure_gt_20",
|
||||
table: "t_telemetry_analysis",
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
comment: "Давление более 20",
|
||||
oldClrType: typeof(bool),
|
||||
oldType: "boolean",
|
||||
oldComment: "Давоение более 20");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterTable(
|
||||
name: "t_drill_flow_chart",
|
||||
comment: "Параметры корридоров бурения (диапазоны параметров бурения)",
|
||||
oldComment: "Параметры коридоров бурения (диапазоны параметров бурения)");
|
||||
|
||||
migrationBuilder.AlterColumn<float>(
|
||||
name: "torque_starting",
|
||||
table: "t_telemetry_data_spin",
|
||||
type: "real",
|
||||
nullable: true,
|
||||
comment: " Страгивающий момент",
|
||||
oldClrType: typeof(float),
|
||||
oldType: "real",
|
||||
oldNullable: true,
|
||||
oldComment: "Страгивающий момент");
|
||||
|
||||
migrationBuilder.AlterColumn<float>(
|
||||
name: "rotor_torque_avg",
|
||||
table: "t_telemetry_data_spin",
|
||||
type: "real",
|
||||
nullable: true,
|
||||
comment: " Момент в роторе средний",
|
||||
oldClrType: typeof(float),
|
||||
oldType: "real",
|
||||
oldNullable: true,
|
||||
oldComment: "Момент в роторе средний");
|
||||
|
||||
migrationBuilder.AlterColumn<float>(
|
||||
name: "ratio",
|
||||
table: "t_telemetry_data_spin",
|
||||
type: "real",
|
||||
nullable: true,
|
||||
comment: " Коэффициент редукции редектора",
|
||||
oldClrType: typeof(float),
|
||||
oldType: "real",
|
||||
oldNullable: true,
|
||||
oldComment: " Коэффициент редукции редуктора");
|
||||
|
||||
migrationBuilder.AlterColumn<float>(
|
||||
name: "position_zero",
|
||||
table: "t_telemetry_data_spin",
|
||||
type: "real",
|
||||
nullable: true,
|
||||
comment: "Нулевая позиция осциляции",
|
||||
oldClrType: typeof(float),
|
||||
oldType: "real",
|
||||
oldNullable: true,
|
||||
oldComment: "Нулевая позиция осцилляции");
|
||||
|
||||
migrationBuilder.AlterColumn<float>(
|
||||
name: "position_right",
|
||||
table: "t_telemetry_data_spin",
|
||||
type: "real",
|
||||
nullable: true,
|
||||
comment: "Крайний правый угол осциляции",
|
||||
oldClrType: typeof(float),
|
||||
oldType: "real",
|
||||
oldNullable: true,
|
||||
oldComment: "Крайний правый угол осцилляции");
|
||||
|
||||
migrationBuilder.AlterColumn<float>(
|
||||
name: "encoder_resolution",
|
||||
table: "t_telemetry_data_spin",
|
||||
type: "real",
|
||||
nullable: true,
|
||||
comment: " Разрешение энкодера",
|
||||
oldClrType: typeof(float),
|
||||
oldType: "real",
|
||||
oldNullable: true,
|
||||
oldComment: "Разрешение энкодера");
|
||||
|
||||
migrationBuilder.AlterColumn<bool>(
|
||||
name: "is_pressure_gt_20",
|
||||
table: "t_telemetry_analysis",
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
comment: "Давоение более 20",
|
||||
oldClrType: typeof(bool),
|
||||
oldType: "boolean",
|
||||
oldComment: "Давление более 20");
|
||||
}
|
||||
}
|
||||
}
|
@ -7,6 +7,8 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
[DbContext(typeof(AsbCloudDbContext))]
|
||||
@ -16,19 +18,21 @@ namespace AsbCloudDb.Migrations
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasPostgresExtension("adminpack")
|
||||
.HasAnnotation("Relational:Collation", "Russian_Russia.1251")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63)
|
||||
.HasAnnotation("ProductVersion", "5.0.10")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.UseCollation("Russian_Russia.1251")
|
||||
.HasAnnotation("ProductVersion", "6.0.1")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "adminpack");
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.Cluster", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Caption")
|
||||
.HasMaxLength(255)
|
||||
@ -48,14 +52,18 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("longitude");
|
||||
|
||||
b.Property<SimpleTimezone>("Timezone")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("timezone")
|
||||
.HasComment("Смещение часового пояса от UTC");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IdDeposit");
|
||||
|
||||
b.ToTable("t_cluster");
|
||||
|
||||
b
|
||||
.HasComment("Кусты");
|
||||
b.HasComment("Кусты");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.Company", b =>
|
||||
@ -63,8 +71,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Caption")
|
||||
.HasMaxLength(255)
|
||||
@ -97,8 +106,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Caption")
|
||||
.HasMaxLength(255)
|
||||
@ -132,8 +142,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Caption")
|
||||
.HasMaxLength(255)
|
||||
@ -148,12 +159,16 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("longitude");
|
||||
|
||||
b.Property<SimpleTimezone>("Timezone")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("timezone")
|
||||
.HasComment("Смещение часового пояса от UTC");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("t_deposit");
|
||||
|
||||
b
|
||||
.HasComment("Месторождение");
|
||||
b.HasComment("Месторождение");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.DrillFlowChart", b =>
|
||||
@ -161,8 +176,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("AxialLoadMax")
|
||||
.HasColumnType("double precision")
|
||||
@ -204,7 +220,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("id_operation_category")
|
||||
.HasComment("Id типа операции");
|
||||
|
||||
b.Property<DateTime>("LastUpdate")
|
||||
b.Property<DateTimeOffset>("LastUpdate")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("last_update")
|
||||
.HasComment("Дата последнего изменения");
|
||||
@ -247,8 +263,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_drill_flow_chart");
|
||||
|
||||
b
|
||||
.HasComment("Параметры корридоров бурения (диапазоны параметров бурения)");
|
||||
b.HasComment("Параметры коридоров бурения (диапазоны параметров бурения)");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.DrillParams", b =>
|
||||
@ -256,8 +271,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("AxialLoadAvg")
|
||||
.HasColumnType("double precision")
|
||||
@ -362,8 +378,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_drill_params");
|
||||
|
||||
b
|
||||
.HasComment("Режим бурения в секции (диапазоны параметров бурения)");
|
||||
b.HasComment("Режим бурения в секции (диапазоны параметров бурения)");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.FileCategory", b =>
|
||||
@ -371,8 +386,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("text")
|
||||
@ -388,8 +404,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_file_category");
|
||||
|
||||
b
|
||||
.HasComment("Категории файлов");
|
||||
b.HasComment("Категории файлов");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
@ -477,8 +492,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int?>("IdAuthor")
|
||||
.HasColumnType("integer")
|
||||
@ -515,7 +531,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("file_size")
|
||||
.HasComment("Размер файла");
|
||||
|
||||
b.Property<DateTime>("UploadDate")
|
||||
b.Property<DateTimeOffset>("UploadDate")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("date");
|
||||
|
||||
@ -529,8 +545,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_file_info");
|
||||
|
||||
b
|
||||
.HasComment("Файлы всех категорий");
|
||||
b.HasComment("Файлы всех категорий");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.FileMark", b =>
|
||||
@ -538,8 +553,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Comment")
|
||||
.HasMaxLength(255)
|
||||
@ -547,7 +563,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("comment")
|
||||
.HasComment("Комментарий");
|
||||
|
||||
b.Property<DateTime>("DateCreated")
|
||||
b.Property<DateTimeOffset>("DateCreated")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("date_created")
|
||||
.HasComment("Дата совершенного действия");
|
||||
@ -580,8 +596,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_file_mark");
|
||||
|
||||
b
|
||||
.HasComment("Действия с файлами.");
|
||||
b.HasComment("Действия с файлами.");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.Measure", b =>
|
||||
@ -589,10 +604,11 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id");
|
||||
|
||||
b.Property<Dictionary<string, object>>("Data")
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<RawData>("Data")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("data")
|
||||
.HasComment("Данные таблицы последних данных");
|
||||
@ -612,7 +628,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("is_deleted")
|
||||
.HasComment("Пометка удаленным");
|
||||
|
||||
b.Property<DateTime>("Timestamp")
|
||||
b.Property<DateTimeOffset>("Timestamp")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("timestamp")
|
||||
.HasComment("время добавления");
|
||||
@ -625,8 +641,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_measure");
|
||||
|
||||
b
|
||||
.HasComment("Таблица c данными для вкладки 'Последние данные'");
|
||||
b.HasComment("Таблица c данными для вкладки 'Последние данные'");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.MeasureCategory", b =>
|
||||
@ -634,8 +649,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("text")
|
||||
@ -651,8 +667,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_measure_category");
|
||||
|
||||
b
|
||||
.HasComment("Категория последних данных");
|
||||
b.HasComment("Категория последних данных");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
@ -680,8 +695,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasMaxLength(255)
|
||||
@ -699,8 +715,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_permission");
|
||||
|
||||
b
|
||||
.HasComment("Разрешения на доступ к данным");
|
||||
b.HasComment("Разрешения на доступ к данным");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.RelationCompanyWell", b =>
|
||||
@ -719,8 +734,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_relation_company_well");
|
||||
|
||||
b
|
||||
.HasComment("отношение скважин и компаний");
|
||||
b.HasComment("отношение скважин и компаний");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.RelationUserRolePermission", b =>
|
||||
@ -739,8 +753,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_relation_user_role_permission");
|
||||
|
||||
b
|
||||
.HasComment("Отношение ролей пользователей и разрешений доступа");
|
||||
b.HasComment("Отношение ролей пользователей и разрешений доступа");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.RelationUserUserRole", b =>
|
||||
@ -759,8 +772,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_relation_user_user_role");
|
||||
|
||||
b
|
||||
.HasComment("Отношение пользователей и ролей");
|
||||
b.HasComment("Отношение пользователей и ролей");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
@ -775,8 +787,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTimeOffset>("Begin")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
@ -815,8 +828,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_report_property");
|
||||
|
||||
b
|
||||
.HasComment("Отчеты с данными по буровым");
|
||||
b.HasComment("Отчеты с данными по буровым");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.SetpointsRequest", b =>
|
||||
@ -824,8 +836,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Comment")
|
||||
.HasColumnType("text")
|
||||
@ -857,7 +870,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("setpoint_set")
|
||||
.HasComment("Набор уставок");
|
||||
|
||||
b.Property<DateTime>("UploadDate")
|
||||
b.Property<DateTimeOffset>("UploadDate")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("date");
|
||||
|
||||
@ -869,8 +882,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_setpoints_rquest");
|
||||
|
||||
b
|
||||
.HasComment("Запросы на изменение уставок панели оператора");
|
||||
b.HasComment("Запросы на изменение уставок панели оператора");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.Telemetry", b =>
|
||||
@ -878,8 +890,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<TelemetryInfo>("Info")
|
||||
.HasColumnType("jsonb")
|
||||
@ -891,7 +904,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("remote_uid")
|
||||
.HasComment("Идентификатор передающего устройства. Может повторяться в списке, так как комплекты оборудования переезжают от скв. к скв.");
|
||||
|
||||
b.Property<TelemetryTimeZone>("TelemetryTimeZone")
|
||||
b.Property<SimpleTimezone>("TimeZone")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("timezone")
|
||||
.HasComment("Смещение часового пояса от UTC");
|
||||
@ -902,8 +915,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_telemetry");
|
||||
|
||||
b
|
||||
.HasComment("таблица привязки телеметрии от комплектов к конкретной скважине.");
|
||||
b.HasComment("таблица привязки телеметрии от комплектов к конкретной скважине.");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.TelemetryAnalysis", b =>
|
||||
@ -911,8 +923,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("DurationSec")
|
||||
.HasColumnType("integer")
|
||||
@ -965,7 +978,7 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<bool>("IsPressureGt20")
|
||||
.HasColumnType("boolean")
|
||||
.HasColumnName("is_pressure_gt_20")
|
||||
.HasComment("Давоение более 20");
|
||||
.HasComment("Давление более 20");
|
||||
|
||||
b.Property<bool>("IsPressureLt20")
|
||||
.HasColumnType("boolean")
|
||||
@ -1015,8 +1028,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_telemetry_analysis");
|
||||
|
||||
b
|
||||
.HasComment("События на скважине");
|
||||
b.HasComment("События на скважине");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.TelemetryDataSaub", b =>
|
||||
@ -1025,7 +1037,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_telemetry");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
b.Property<DateTimeOffset>("Date")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("date")
|
||||
.HasComment("'2021-10-19 18:23:54+05'");
|
||||
@ -1214,8 +1226,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_telemetry_data_saub");
|
||||
|
||||
b
|
||||
.HasComment("набор основных данных по SAUB");
|
||||
b.HasComment("набор основных данных по SAUB");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.TelemetryDataSpin", b =>
|
||||
@ -1224,7 +1235,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_telemetry");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
b.Property<DateTimeOffset>("Date")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("date")
|
||||
.HasComment("'2021-10-19 18:23:54+05'");
|
||||
@ -1242,7 +1253,7 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<float?>("EncoderResolution")
|
||||
.HasColumnType("real")
|
||||
.HasColumnName("encoder_resolution")
|
||||
.HasComment(" Разрешение энкодера");
|
||||
.HasComment("Разрешение энкодера");
|
||||
|
||||
b.Property<short?>("Mode")
|
||||
.HasColumnType("smallint")
|
||||
@ -1257,17 +1268,17 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<float?>("PositionRight")
|
||||
.HasColumnType("real")
|
||||
.HasColumnName("position_right")
|
||||
.HasComment("Крайний правый угол осциляции");
|
||||
.HasComment("Крайний правый угол осцилляции");
|
||||
|
||||
b.Property<float?>("PositionZero")
|
||||
.HasColumnType("real")
|
||||
.HasColumnName("position_zero")
|
||||
.HasComment("Нулевая позиция осциляции");
|
||||
.HasComment("Нулевая позиция осцилляции");
|
||||
|
||||
b.Property<float?>("Ratio")
|
||||
.HasColumnType("real")
|
||||
.HasColumnName("ratio")
|
||||
.HasComment(" Коэффициент редукции редектора");
|
||||
.HasComment(" Коэффициент редукции редуктора");
|
||||
|
||||
b.Property<float?>("ReverseKTorque")
|
||||
.HasColumnType("real")
|
||||
@ -1302,7 +1313,7 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<float?>("RotorTorqueAvg")
|
||||
.HasColumnType("real")
|
||||
.HasColumnName("rotor_torque_avg")
|
||||
.HasComment(" Момент в роторе средний");
|
||||
.HasComment("Момент в роторе средний");
|
||||
|
||||
b.Property<float?>("SpeedLeftSp")
|
||||
.HasColumnType("real")
|
||||
@ -1466,7 +1477,7 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<float?>("TorqueStarting")
|
||||
.HasColumnType("real")
|
||||
.HasColumnName("torque_starting")
|
||||
.HasComment(" Страгивающий момент");
|
||||
.HasComment("Страгивающий момент");
|
||||
|
||||
b.Property<float?>("TurnLeftOnceByAngle")
|
||||
.HasColumnType("real")
|
||||
@ -1527,8 +1538,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_telemetry_data_spin");
|
||||
|
||||
b
|
||||
.HasComment("набор основных данных по SpinMaster");
|
||||
b.HasComment("набор основных данных по SpinMaster");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.TelemetryEvent", b =>
|
||||
@ -1553,8 +1563,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_telemetry_event");
|
||||
|
||||
b
|
||||
.HasComment("Справочник событий. События формируют сообщения. Разделено по версиям посылок от телеметрии.");
|
||||
b.HasComment("Справочник событий. События формируют сообщения. Разделено по версиям посылок от телеметрии.");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.TelemetryMessage", b =>
|
||||
@ -1562,8 +1571,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Arg0")
|
||||
.HasMaxLength(255)
|
||||
@ -1586,7 +1596,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnType("character varying(255)")
|
||||
.HasColumnName("arg3");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
b.Property<DateTimeOffset>("Date")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("date");
|
||||
|
||||
@ -1613,8 +1623,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_telemetry_message");
|
||||
|
||||
b
|
||||
.HasComment("Сообщения на буровых");
|
||||
b.HasComment("Сообщения на буровых");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.TelemetryUser", b =>
|
||||
@ -1650,8 +1659,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_telemetry_user");
|
||||
|
||||
b
|
||||
.HasComment("Пользователи панели САУБ. Для сообщений.");
|
||||
b.HasComment("Пользователи панели САУБ. Для сообщений.");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.User", b =>
|
||||
@ -1659,8 +1667,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasMaxLength(255)
|
||||
@ -1727,8 +1736,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_user");
|
||||
|
||||
b
|
||||
.HasComment("Пользователи облака");
|
||||
b.HasComment("Пользователи облака");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
@ -1746,8 +1754,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Caption")
|
||||
.HasMaxLength(255)
|
||||
@ -1769,8 +1778,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_user_role");
|
||||
|
||||
b
|
||||
.HasComment("Роли пользователей в системе");
|
||||
b.HasComment("Роли пользователей в системе");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
@ -1792,8 +1800,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Caption")
|
||||
.HasMaxLength(255)
|
||||
@ -1825,6 +1834,11 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("longitude");
|
||||
|
||||
b.Property<SimpleTimezone>("Timezone")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("timezone")
|
||||
.HasComment("Смещение часового пояса от UTC");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IdCluster");
|
||||
@ -1836,8 +1850,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_well");
|
||||
|
||||
b
|
||||
.HasComment("скважины");
|
||||
b.HasComment("скважины");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.WellComposite", b =>
|
||||
@ -1865,8 +1878,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_well_composite");
|
||||
|
||||
b
|
||||
.HasComment("Композитная скважина");
|
||||
b.HasComment("Композитная скважина");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.WellOperation", b =>
|
||||
@ -1874,8 +1886,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("CategoryInfo")
|
||||
.HasColumnType("text")
|
||||
@ -1887,7 +1900,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("comment")
|
||||
.HasComment("Комментарий");
|
||||
|
||||
b.Property<DateTime>("DateStart")
|
||||
b.Property<DateTimeOffset>("DateStart")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("date_start")
|
||||
.HasComment("Дата начала операции");
|
||||
@ -1941,8 +1954,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_well_operation");
|
||||
|
||||
b
|
||||
.HasComment("Данные по операциям на скважине");
|
||||
b.HasComment("Данные по операциям на скважине");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.WellOperationCategory", b =>
|
||||
@ -1950,8 +1962,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Code")
|
||||
.HasColumnType("integer")
|
||||
@ -1967,8 +1980,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_well_operation_category");
|
||||
|
||||
b
|
||||
.HasComment("Справочник операций на скважине");
|
||||
b.HasComment("Справочник операций на скважине");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
@ -2143,7 +2155,7 @@ namespace AsbCloudDb.Migrations
|
||||
{
|
||||
Id = 1014,
|
||||
Code = 0,
|
||||
Name = "Опресовка Ц.К."
|
||||
Name = "Опрессовка Ц.К."
|
||||
},
|
||||
new
|
||||
{
|
||||
@ -2386,8 +2398,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Caption")
|
||||
.HasMaxLength(255)
|
||||
@ -2399,39 +2412,38 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_well_section_type");
|
||||
|
||||
b
|
||||
.HasComment("конструкция секции скважины");
|
||||
b.HasComment("конструкция секции скважины");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
Id = 1,
|
||||
Caption = "Пилотный ствол 1"
|
||||
Caption = "Пилотный ствол"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 2,
|
||||
Caption = "Направление 1"
|
||||
Caption = "Направление"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 3,
|
||||
Caption = "Кондуктор 1"
|
||||
Caption = "Кондуктор"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 4,
|
||||
Caption = "Эксплуатационная колонна 1"
|
||||
Caption = "Эксплуатационная колонна"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 5,
|
||||
Caption = "Транспортный ствол 1"
|
||||
Caption = "Транспортный ствол"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 6,
|
||||
Caption = "Хвостовик 1"
|
||||
Caption = "Хвостовик"
|
||||
},
|
||||
new
|
||||
{
|
||||
@ -2560,8 +2572,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Caption")
|
||||
.HasMaxLength(255)
|
||||
@ -2573,8 +2586,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.ToTable("t_well_type");
|
||||
|
||||
b
|
||||
.HasComment("конструкция скважины");
|
||||
b.HasComment("конструкция скважины");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
@ -2632,9 +2644,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.HasOne("AsbCloudDb.Model.WellSectionType", "WellSectionType")
|
||||
.WithMany("DrillParamsCollection")
|
||||
.HasForeignKey("IdWellSectionType")
|
||||
.HasConstraintName("t_drill_params_t_well_section_type_id_fk")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.IsRequired()
|
||||
.HasConstraintName("t_drill_params_t_well_section_type_id_fk");
|
||||
|
||||
b.Navigation("Well");
|
||||
|
||||
@ -2671,16 +2683,16 @@ namespace AsbCloudDb.Migrations
|
||||
b.HasOne("AsbCloudDb.Model.FileInfo", "FileInfo")
|
||||
.WithMany("FileMarks")
|
||||
.HasForeignKey("IdFile")
|
||||
.HasConstraintName("t_file_mark_t_file_info_fk")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.IsRequired()
|
||||
.HasConstraintName("t_file_mark_t_file_info_fk");
|
||||
|
||||
b.HasOne("AsbCloudDb.Model.User", "User")
|
||||
.WithMany("FileMarks")
|
||||
.HasForeignKey("IdUser")
|
||||
.HasConstraintName("t_user_t_file_mark_fk")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.IsRequired()
|
||||
.HasConstraintName("t_user_t_file_mark_fk");
|
||||
|
||||
b.Navigation("FileInfo");
|
||||
|
||||
@ -2711,16 +2723,16 @@ namespace AsbCloudDb.Migrations
|
||||
b.HasOne("AsbCloudDb.Model.Company", "Company")
|
||||
.WithMany("RelationCompaniesWells")
|
||||
.HasForeignKey("IdCompany")
|
||||
.HasConstraintName("t_relation_company_well_t_company_id_fk")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.IsRequired()
|
||||
.HasConstraintName("t_relation_company_well_t_company_id_fk");
|
||||
|
||||
b.HasOne("AsbCloudDb.Model.Well", "Well")
|
||||
.WithMany("RelationCompaniesWells")
|
||||
.HasForeignKey("IdWell")
|
||||
.HasConstraintName("t_relation_company_well_t_well_id_fk")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.IsRequired()
|
||||
.HasConstraintName("t_relation_company_well_t_well_id_fk");
|
||||
|
||||
b.Navigation("Company");
|
||||
|
||||
@ -2808,16 +2820,16 @@ namespace AsbCloudDb.Migrations
|
||||
b.HasOne("AsbCloudDb.Model.WellOperationCategory", "Operation")
|
||||
.WithMany("Analysis")
|
||||
.HasForeignKey("IdOperation")
|
||||
.HasConstraintName("t_analysis_t_operation_id_fk")
|
||||
.OnDelete(DeleteBehavior.SetNull)
|
||||
.IsRequired();
|
||||
.IsRequired()
|
||||
.HasConstraintName("t_analysis_t_operation_id_fk");
|
||||
|
||||
b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry")
|
||||
.WithMany("Analysis")
|
||||
.HasForeignKey("IdTelemetry")
|
||||
.HasConstraintName("t_analysis_t_telemetry_id_fk")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.IsRequired()
|
||||
.HasConstraintName("t_analysis_t_telemetry_id_fk");
|
||||
|
||||
b.Navigation("Operation");
|
||||
|
||||
@ -2829,9 +2841,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry")
|
||||
.WithMany("DataSaub")
|
||||
.HasForeignKey("IdTelemetry")
|
||||
.HasConstraintName("t_telemetry_data_saub_t_telemetry_id_fk")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.IsRequired()
|
||||
.HasConstraintName("t_telemetry_data_saub_t_telemetry_id_fk");
|
||||
|
||||
b.Navigation("Telemetry");
|
||||
});
|
||||
@ -2841,9 +2853,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry")
|
||||
.WithMany("DataSpin")
|
||||
.HasForeignKey("IdTelemetry")
|
||||
.HasConstraintName("t_telemetry_data_spin_t_telemetry_id_fk")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.IsRequired()
|
||||
.HasConstraintName("t_telemetry_data_spin_t_telemetry_id_fk");
|
||||
|
||||
b.Navigation("Telemetry");
|
||||
});
|
||||
@ -2853,9 +2865,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry")
|
||||
.WithMany("Events")
|
||||
.HasForeignKey("IdTelemetry")
|
||||
.HasConstraintName("t_event_t_telemetry_id_fk")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.IsRequired()
|
||||
.HasConstraintName("t_event_t_telemetry_id_fk");
|
||||
|
||||
b.Navigation("Telemetry");
|
||||
});
|
||||
@ -2865,9 +2877,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry")
|
||||
.WithMany("Messages")
|
||||
.HasForeignKey("IdTelemetry")
|
||||
.HasConstraintName("t_messages_t_telemetry_id_fk")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.IsRequired()
|
||||
.HasConstraintName("t_messages_t_telemetry_id_fk");
|
||||
|
||||
b.Navigation("Telemetry");
|
||||
});
|
||||
@ -2877,9 +2889,9 @@ namespace AsbCloudDb.Migrations
|
||||
b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry")
|
||||
.WithMany("Users")
|
||||
.HasForeignKey("IdTelemetry")
|
||||
.HasConstraintName("t_telemetry_user_t_telemetry_id_fk")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.IsRequired()
|
||||
.HasConstraintName("t_telemetry_user_t_telemetry_id_fk");
|
||||
|
||||
b.Navigation("Telemetry");
|
||||
});
|
||||
@ -2889,8 +2901,8 @@ namespace AsbCloudDb.Migrations
|
||||
b.HasOne("AsbCloudDb.Model.Company", "Company")
|
||||
.WithMany("Users")
|
||||
.HasForeignKey("IdCompany")
|
||||
.HasConstraintName("t_user_t_company_id_fk")
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
.OnDelete(DeleteBehavior.SetNull)
|
||||
.HasConstraintName("t_user_t_company_id_fk");
|
||||
|
||||
b.Navigation("Company");
|
||||
});
|
||||
@ -2905,8 +2917,8 @@ namespace AsbCloudDb.Migrations
|
||||
b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry")
|
||||
.WithOne("Well")
|
||||
.HasForeignKey("AsbCloudDb.Model.Well", "IdTelemetry")
|
||||
.HasConstraintName("t_well_t_telemetry_id_fk")
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
.OnDelete(DeleteBehavior.SetNull)
|
||||
.HasConstraintName("t_well_t_telemetry_id_fk");
|
||||
|
||||
b.HasOne("AsbCloudDb.Model.WellType", "WellType")
|
||||
.WithMany("Wells")
|
||||
@ -2924,23 +2936,23 @@ namespace AsbCloudDb.Migrations
|
||||
b.HasOne("AsbCloudDb.Model.Well", "Well")
|
||||
.WithMany("WellComposites")
|
||||
.HasForeignKey("IdWell")
|
||||
.HasConstraintName("t_well_сomposite_t_well_id_fk")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.IsRequired()
|
||||
.HasConstraintName("t_well_сomposite_t_well_id_fk");
|
||||
|
||||
b.HasOne("AsbCloudDb.Model.WellSectionType", "WellSectionType")
|
||||
.WithMany("WellComposites")
|
||||
.HasForeignKey("IdWellSectionType")
|
||||
.HasConstraintName("t_well_сomposite_t_well_section_type_id_fk")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.IsRequired()
|
||||
.HasConstraintName("t_well_сomposite_t_well_section_type_id_fk");
|
||||
|
||||
b.HasOne("AsbCloudDb.Model.Well", "WellSrc")
|
||||
.WithMany("WellCompositeSrcs")
|
||||
.HasForeignKey("IdWellSrc")
|
||||
.HasConstraintName("t_well_сomposite_src_t_well_id_fk")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.IsRequired()
|
||||
.HasConstraintName("t_well_сomposite_src_t_well_id_fk");
|
||||
|
||||
b.Navigation("Well");
|
||||
|
||||
@ -3050,10 +3062,10 @@ namespace AsbCloudDb.Migrations
|
||||
{
|
||||
b.Navigation("RelationCompaniesWells");
|
||||
|
||||
b.Navigation("WellComposites");
|
||||
|
||||
b.Navigation("WellCompositeSrcs");
|
||||
|
||||
b.Navigation("WellComposites");
|
||||
|
||||
b.Navigation("WellOperations");
|
||||
});
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
#nullable disable
|
||||
|
||||
@ -281,7 +277,7 @@ namespace AsbCloudDb.Model
|
||||
Id = 1,
|
||||
IdCompany = 1,
|
||||
Login = "dev",
|
||||
PasswordHash = "Vlcj|4fa529103dde7ff72cfe76185f344d4aa87931f8e1b2044e8a7739947c3d18923464eaad93843e4f809c5e126d013072", // dev
|
||||
PasswordHash = "Vlcj|4fa529103dde7ff72cfe76185f344d4aa87931f8e1b2044e8a7739947c3d18923464eaad93843e4f809c5e126d013072",
|
||||
Name = "Разработчик",
|
||||
},
|
||||
});
|
||||
@ -304,7 +300,7 @@ namespace AsbCloudDb.Model
|
||||
modelBuilder.Entity<WellOperationCategory>(entity =>
|
||||
{
|
||||
entity.HasData(new List<WellOperationCategory> {
|
||||
// Автоматически опеределяемые операции
|
||||
// Автоматически определяемые операции
|
||||
new WellOperationCategory {Id = 1, Name = "Невозможно определить операцию", Code = 0},
|
||||
new WellOperationCategory {Id = 2, Name = "Роторное бурение", Code = 0 },
|
||||
new WellOperationCategory {Id = 3, Name = "Слайдирование", Code = 0 },
|
||||
@ -334,7 +330,7 @@ namespace AsbCloudDb.Model
|
||||
new WellOperationCategory {Id = 1011, Name = "Начало цикла строительства скважины", Code = 0 },
|
||||
new WellOperationCategory {Id = 1012, Name = "Окончание цикла строительства скважины", Code = 0 },
|
||||
new WellOperationCategory {Id = 1013, Name = "Опрессовка ПВО", Code = 0 },
|
||||
new WellOperationCategory {Id = 1014, Name = "Опресовка Ц.К.", Code = 0 },
|
||||
new WellOperationCategory {Id = 1014, Name = "Опрессовка Ц.К.", Code = 0 },
|
||||
new WellOperationCategory {Id = 1015, Name = "Опрессовка ВЗД", Code = 0 },
|
||||
new WellOperationCategory {Id = 1016, Name = "Перевод скв на другой тип промывочной жидкости", Code = 0 },
|
||||
new WellOperationCategory {Id = 1017, Name = "Перезапись каротажа", Code = 0 },
|
||||
@ -402,12 +398,12 @@ namespace AsbCloudDb.Model
|
||||
modelBuilder.Entity<WellSectionType>(entity =>
|
||||
{
|
||||
entity.HasData(new List<WellSectionType>{
|
||||
new WellSectionType{ Id = 1, Caption = "Пилотный ствол 1"},
|
||||
new WellSectionType{ Id = 2, Caption = "Направление 1"},
|
||||
new WellSectionType{ Id = 3, Caption = "Кондуктор 1"},
|
||||
new WellSectionType{ Id = 4, Caption = "Эксплуатационная колонна 1"},
|
||||
new WellSectionType{ Id = 5, Caption = "Транспортный ствол 1"},
|
||||
new WellSectionType{ Id = 6, Caption = "Хвостовик 1"},
|
||||
new WellSectionType{ Id = 1, Caption = "Пилотный ствол"},
|
||||
new WellSectionType{ Id = 2, Caption = "Направление"},
|
||||
new WellSectionType{ Id = 3, Caption = "Кондуктор"},
|
||||
new WellSectionType{ Id = 4, Caption = "Эксплуатационная колонна"},
|
||||
new WellSectionType{ Id = 5, Caption = "Транспортный ствол"},
|
||||
new WellSectionType{ Id = 6, Caption = "Хвостовик"},
|
||||
|
||||
new WellSectionType{ Id = 7, Caption = "Пилотный ствол 2"},
|
||||
new WellSectionType{ Id = 8, Caption = "Направление 2"},
|
||||
|
@ -38,5 +38,8 @@ namespace AsbCloudDb.Model
|
||||
|
||||
[Column("longitude")]
|
||||
public double? Longitude { get; set; }
|
||||
|
||||
[Column("timezone", TypeName = "jsonb"), Comment("Смещение часового пояса от UTC")]
|
||||
public SimpleTimezone Timezone { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -31,5 +31,8 @@ namespace AsbCloudDb.Model
|
||||
|
||||
[Column("longitude")]
|
||||
public double? Longitude { get; set; }
|
||||
|
||||
[Column("timezone", TypeName = "jsonb"), Comment("Смещение часового пояса от UTC")]
|
||||
public SimpleTimezone Timezone { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ using System.Text.Json.Serialization;
|
||||
|
||||
namespace AsbCloudDb.Model
|
||||
{
|
||||
[Table("t_drill_flow_chart"), Comment("Параметры корридоров бурения (диапазоны параметров бурения)")]
|
||||
[Table("t_drill_flow_chart"), Comment("Параметры коридоров бурения (диапазоны параметров бурения)")]
|
||||
public class DrillFlowChart : IId
|
||||
{
|
||||
[Key]
|
||||
@ -20,7 +20,7 @@ namespace AsbCloudDb.Model
|
||||
public int IdWellOperationCategory { get; set; }
|
||||
|
||||
[Column("last_update", TypeName = "timestamp with time zone"), Comment("Дата последнего изменения")]
|
||||
public DateTime LastUpdate { get; set; }
|
||||
public DateTimeOffset LastUpdate { get; set; }
|
||||
|
||||
[Column("depth_start"), Comment("Стартовая глубина")]
|
||||
public double DepthStart { get; set; }
|
||||
|
@ -27,7 +27,7 @@ namespace AsbCloudDb.Model
|
||||
public string Name { get; set; }
|
||||
|
||||
[Column("date", TypeName = "timestamp with time zone")]
|
||||
public DateTime UploadDate { get; set; }
|
||||
public DateTimeOffset UploadDate { get; set; }
|
||||
|
||||
[Column("file_size"), Comment("Размер файла")]
|
||||
public long Size { get; set; }
|
||||
|
@ -20,7 +20,7 @@ namespace AsbCloudDb.Model
|
||||
public int IdMarkType { get; set; }
|
||||
|
||||
[Column("date_created", TypeName = "timestamp with time zone"), Comment("Дата совершенного действия")]
|
||||
public DateTime DateCreated { get; set; }
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
|
||||
[Column("id_user"), Comment("id пользователя")]
|
||||
public int IdUser { get; set; }
|
||||
|
@ -5,7 +5,7 @@ namespace AsbCloudDb.Model
|
||||
public class FilePublishInfo
|
||||
{
|
||||
public int IdPublisher { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public DateTimeOffset Date { get; set; }
|
||||
public string WebStorageFileUrl { get; set; }
|
||||
}
|
||||
}
|
@ -5,5 +5,7 @@
|
||||
double? Latitude { get; set; }
|
||||
|
||||
double? Longitude { get; set; }
|
||||
|
||||
SimpleTimezone Timezone { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,6 @@ namespace AsbCloudDb.Model
|
||||
public interface ITelemetryData
|
||||
{
|
||||
int IdTelemetry { get; set; }
|
||||
DateTime Date { get; set; }
|
||||
DateTimeOffset Date { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ namespace AsbCloudDb.Model
|
||||
public int IdCategory { get; set; }
|
||||
|
||||
[Column("timestamp", TypeName = "timestamp with time zone"), Comment("время добавления")]
|
||||
public DateTime Timestamp { get; set; }
|
||||
public DateTimeOffset Timestamp { get; set; }
|
||||
|
||||
[Column("data", TypeName = "jsonb"), Comment("Данные таблицы последних данных")]
|
||||
public RawData Data { get; set; }
|
||||
|
@ -23,7 +23,7 @@ namespace AsbCloudDb.Model
|
||||
public int IdState { get; set; }
|
||||
|
||||
[Column("date", TypeName = "timestamp with time zone")]
|
||||
public DateTime UploadDate { get; set; }
|
||||
public DateTimeOffset UploadDate { get; set; }
|
||||
|
||||
[Column("obsolescence"), Comment("сек. до устаревания")]
|
||||
public int ObsolescenceSec { get; set; }
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace AsbCloudDb.Model
|
||||
{
|
||||
public class TelemetryTimeZone
|
||||
public class SimpleTimezone
|
||||
{
|
||||
public double Hours { get; set; }
|
||||
public string TimeZoneId { get; set; }
|
@ -28,7 +28,7 @@ namespace AsbCloudDb.Model
|
||||
public TelemetryInfo Info { get; set; }
|
||||
|
||||
[Column("timezone", TypeName = "jsonb"), Comment("Смещение часового пояса от UTC")]
|
||||
public TelemetryTimeZone TelemetryTimeZone { get; set; }
|
||||
public SimpleTimezone TimeZone { get; set; }
|
||||
|
||||
[InverseProperty(nameof(Model.Well.Telemetry))]
|
||||
public virtual Well Well { get; set; }
|
||||
|
@ -71,7 +71,7 @@ namespace AsbCloudDb.Model
|
||||
[Column("is_pressure_lt_20"), Comment("Давление менее 20")]
|
||||
public bool IsPressureLt20 { get; set; }
|
||||
|
||||
[Column("is_pressure_gt_20"), Comment("Давоение более 20")]
|
||||
[Column("is_pressure_gt_20"), Comment("Давление более 20")]
|
||||
public bool IsPressureGt20 { get; set; }
|
||||
|
||||
[Column("is_hook_weight_not_changes"), Comment("Вес на крюке не меняется")]
|
||||
|
@ -18,7 +18,7 @@ namespace AsbCloudDb.Model
|
||||
public int? IdUser { get; set; }
|
||||
|
||||
[Column("date", TypeName = "timestamp with time zone"), Comment("'2021-10-19 18:23:54+05'")]
|
||||
public DateTime Date { get; set; }
|
||||
public DateTimeOffset Date { get; set; }
|
||||
|
||||
[Column("mode"), Comment("Режим САУБ")]
|
||||
public short? Mode { get; set; }
|
||||
|
@ -12,7 +12,7 @@ namespace AsbCloudDb.Model
|
||||
[Column("id_telemetry")]
|
||||
public int IdTelemetry { get; set; }
|
||||
[Column("date", TypeName = "timestamp with time zone"), Comment("'2021-10-19 18:23:54+05'")]
|
||||
public DateTime Date { get; set; }
|
||||
public DateTimeOffset Date { get; set; }
|
||||
|
||||
[Column("top_drive_speed"), Comment("Скорость СВП")]
|
||||
public float? TopDriveSpeed { get; set; }
|
||||
@ -62,13 +62,13 @@ namespace AsbCloudDb.Model
|
||||
public float? TopDriveTorqueSpToMax { get; set; }
|
||||
[Column("top_drive_torque_sp_to_offset")]
|
||||
public float? TopDriveTorqueSpToOffset { get; set; }
|
||||
[Column("torque_starting"), Comment(" Страгивающий момент")]
|
||||
[Column("torque_starting"), Comment("Страгивающий момент")]
|
||||
public float? TorqueStarting { get; set; }
|
||||
[Column("rotor_torque_avg"), Comment(" Момент в роторе средний")]
|
||||
[Column("rotor_torque_avg"), Comment("Момент в роторе средний")]
|
||||
public float? RotorTorqueAvg { get; set; }
|
||||
[Column("encoder_resolution"), Comment(" Разрешение энкодера")]
|
||||
[Column("encoder_resolution"), Comment("Разрешение энкодера")]
|
||||
public float? EncoderResolution { get; set; }
|
||||
[Column("ratio"), Comment(" Коэффициент редукции редектора")]
|
||||
[Column("ratio"), Comment(" Коэффициент редукции редуктора")]
|
||||
public float? Ratio { get; set; }
|
||||
[Column("torque_right_limit"), Comment("Ограничение крутящего момента вправо")]
|
||||
public float? TorqueRightLimit { get; set; }
|
||||
@ -102,9 +102,9 @@ namespace AsbCloudDb.Model
|
||||
public float? BreakAngleK { get; set; }
|
||||
[Column("reverse_k_torque"), Comment("Коэффициент на который умножается момент, для того чтобы система поняла что мы движемся в обратную сторону")]
|
||||
public float? ReverseKTorque { get; set; }
|
||||
[Column("position_zero"), Comment("Нулевая позиция осциляции")]
|
||||
[Column("position_zero"), Comment("Нулевая позиция осцилляции")]
|
||||
public float? PositionZero { get; set; }
|
||||
[Column("position_right"), Comment("Крайний правый угол осциляции")]
|
||||
[Column("position_right"), Comment("Крайний правый угол осцилляции")]
|
||||
public float? PositionRight { get; set; }
|
||||
[Column("torque_ramp_time"), Comment("Время нарастания момента")]
|
||||
public float? TorqueRampTime { get; set; }
|
||||
|
@ -4,7 +4,7 @@ namespace AsbCloudDb.Model
|
||||
{
|
||||
public class TelemetryInfo
|
||||
{
|
||||
public DateTime DrillingStartDate { get; set; }
|
||||
public DateTimeOffset DrillingStartDate { get; set; }
|
||||
public string TimeZoneId { get; set; }
|
||||
public double TimeZoneOffsetTotalHours { get; set; }
|
||||
public string Well { get; set; }
|
||||
|
@ -24,7 +24,7 @@ namespace AsbCloudDb.Model
|
||||
public int? IdTelemetryUser { get; set; }
|
||||
|
||||
[Column("date", TypeName = "timestamp with time zone")]
|
||||
public DateTime Date { get; set; }
|
||||
public DateTimeOffset Date { get; set; }
|
||||
|
||||
[Column("well_depth")]
|
||||
public double WellDepth { get; set; }
|
||||
|
@ -37,6 +37,9 @@ namespace AsbCloudDb.Model
|
||||
[Column("longitude")]
|
||||
public double? Longitude { get; set; }
|
||||
|
||||
[Column("timezone", TypeName = "jsonb"), Comment("Смещение часового пояса от UTC")]
|
||||
public SimpleTimezone Timezone { get; set; }
|
||||
|
||||
[ForeignKey(nameof(IdWellType))]
|
||||
[InverseProperty(nameof(Model.WellType.Wells))]
|
||||
public virtual WellType WellType { get; set; }
|
||||
|
@ -32,7 +32,7 @@ namespace AsbCloudDb.Model
|
||||
public double DepthEnd { get; set; }
|
||||
|
||||
[Column("date_start", TypeName = "timestamp with time zone"), Comment("Дата начала операции")]
|
||||
public DateTime DateStart { get; set; }
|
||||
public DateTimeOffset DateStart { get; set; }
|
||||
|
||||
[Column("duration_hours"), Comment("Продолжительность, часы")]
|
||||
public double DurationHours { get; set; }
|
||||
|
@ -17,10 +17,10 @@ dotnet ef migrations add <MigrationName> --project AsbCloudDb
|
||||
```
|
||||
## Откатить миграцию
|
||||
```
|
||||
dotnet ef migrations remvoe <MigrationName> --project AsbCloudDb
|
||||
dotnet ef migrations remove <MigrationName> --project AsbCloudDb
|
||||
```
|
||||
\<MigrationName> - Name of migration class.
|
||||
После создания миграции обязательно прочитать сгенерированый код.
|
||||
После создания миграции обязательно прочитать генерированный код.
|
||||
|
||||
## Применить миграции
|
||||
При старте проекта применяются автоматически
|
||||
@ -45,7 +45,7 @@ CREATE DATABASE postgres;
|
||||
create schema public;
|
||||
```
|
||||
|
||||
### Step 2. Innit timescaledb and prepare DB to restore
|
||||
### Step 2. Init timescaledb and prepare DB to restore
|
||||
```
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb;
|
||||
SELECT timescaledb_pre_restore();
|
||||
@ -55,12 +55,14 @@ SELECT timescaledb_pre_restore();
|
||||
Terminal:
|
||||
```
|
||||
sudo -u postgres psql -p 5499 -U postgres postgres -W < dump_2021-11-26.bak
|
||||
or
|
||||
sudo pg_restore -Fc -d postgres dump_2021-11-26.bak
|
||||
```
|
||||
OR psql:
|
||||
```
|
||||
\! pg_restore -Fc -d postgres dump_2021-11-26.bak
|
||||
```
|
||||
Then 'exit resore mode' psql:
|
||||
Then 'exit restore mode' psql:
|
||||
```
|
||||
SELECT timescaledb_post_restore();
|
||||
```
|
@ -5,7 +5,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<NoWarn>1701;1702;IDE0090;IDE0063;IDE0066</NoWarn>
|
||||
<NoWarn>1701;1702;IDE0090;IDE0063;IDE0066;IDE0054</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -1,11 +1,11 @@
|
||||
{
|
||||
"runtimeTarget": {
|
||||
"name": ".NETCoreApp,Version=v5.0",
|
||||
"name": ".NETCoreApp,Version=v6.0",
|
||||
"signature": ""
|
||||
},
|
||||
"compilationOptions": {},
|
||||
"targets": {
|
||||
".NETCoreApp,Version=v5.0": {
|
||||
".NETCoreApp,Version=v6.0": {
|
||||
"AsbSaubReport/1.0.0": {
|
||||
"runtime": {
|
||||
"AsbSaubReport.dll": {}
|
||||
|
Binary file not shown.
@ -1,11 +1,11 @@
|
||||
{
|
||||
"runtimeTarget": {
|
||||
"name": ".NETCoreApp,Version=v5.0",
|
||||
"name": ".NETCoreApp,Version=v6.0",
|
||||
"signature": ""
|
||||
},
|
||||
"compilationOptions": {},
|
||||
"targets": {
|
||||
".NETCoreApp,Version=v5.0": {
|
||||
".NETCoreApp,Version=v6.0": {
|
||||
"AsbSaubReportLas/1.0.0": {
|
||||
"dependencies": {
|
||||
"AsbSaubReport": "1.0.0"
|
||||
|
Binary file not shown.
@ -1,53 +1,25 @@
|
||||
{
|
||||
"runtimeTarget": {
|
||||
"name": ".NETCoreApp,Version=v5.0",
|
||||
"name": ".NETCoreApp,Version=v6.0",
|
||||
"signature": ""
|
||||
},
|
||||
"compilationOptions": {},
|
||||
"targets": {
|
||||
".NETCoreApp,Version=v5.0": {
|
||||
".NETCoreApp,Version=v6.0": {
|
||||
"AsbSaubReportPdf/1.0.0": {
|
||||
"dependencies": {
|
||||
"AsbSaubReport": "1.0.0",
|
||||
"itext7": "7.1.15"
|
||||
"itext7": "7.2.0"
|
||||
},
|
||||
"runtime": {
|
||||
"AsbSaubReportPdf.dll": {}
|
||||
}
|
||||
},
|
||||
"Common.Logging/3.4.1": {
|
||||
"itext7/7.2.0": {
|
||||
"dependencies": {
|
||||
"Common.Logging.Core": "3.4.1",
|
||||
"Microsoft.CSharp": "4.0.1",
|
||||
"System.Collections": "4.3.0",
|
||||
"System.Diagnostics.Debug": "4.3.0",
|
||||
"System.Globalization": "4.3.0",
|
||||
"System.Reflection.TypeExtensions": "4.1.0",
|
||||
"System.Runtime.Extensions": "4.3.0",
|
||||
"System.Threading": "4.3.0"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/netstandard1.3/Common.Logging.dll": {
|
||||
"assemblyVersion": "3.4.1.0",
|
||||
"fileVersion": "3.4.0.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Common.Logging.Core/3.4.1": {
|
||||
"dependencies": {
|
||||
"Microsoft.CSharp": "4.0.1"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/netstandard1.0/Common.Logging.Core.dll": {
|
||||
"assemblyVersion": "3.4.1.0",
|
||||
"fileVersion": "3.4.0.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"itext7/7.1.15": {
|
||||
"dependencies": {
|
||||
"Common.Logging": "3.4.1",
|
||||
"Microsoft.DotNet.PlatformAbstractions": "1.1.0",
|
||||
"Microsoft.Extensions.DependencyModel": "1.1.0",
|
||||
"Microsoft.Extensions.Logging": "5.0.0",
|
||||
"Portable.BouncyCastle": "1.8.9",
|
||||
"System.Collections.NonGeneric": "4.3.0",
|
||||
"System.Diagnostics.Process": "4.3.0",
|
||||
@ -58,44 +30,56 @@
|
||||
"System.Text.Encoding.CodePages": "4.3.0",
|
||||
"System.Threading.Thread": "4.3.0",
|
||||
"System.Threading.ThreadPool": "4.3.0",
|
||||
"System.Xml.XmlDocument": "4.3.0"
|
||||
"System.Xml.XmlDocument": "4.3.0",
|
||||
"itext7.commons": "7.2.0"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/netstandard2.0/itext.barcodes.dll": {
|
||||
"assemblyVersion": "7.1.15.0",
|
||||
"fileVersion": "7.1.15.0"
|
||||
"assemblyVersion": "7.2.0.0",
|
||||
"fileVersion": "7.2.0.0"
|
||||
},
|
||||
"lib/netstandard2.0/itext.forms.dll": {
|
||||
"assemblyVersion": "7.1.15.0",
|
||||
"fileVersion": "7.1.15.0"
|
||||
"assemblyVersion": "7.2.0.0",
|
||||
"fileVersion": "7.2.0.0"
|
||||
},
|
||||
"lib/netstandard2.0/itext.io.dll": {
|
||||
"assemblyVersion": "7.1.15.0",
|
||||
"fileVersion": "7.1.15.0"
|
||||
"assemblyVersion": "7.2.0.0",
|
||||
"fileVersion": "7.2.0.0"
|
||||
},
|
||||
"lib/netstandard2.0/itext.kernel.dll": {
|
||||
"assemblyVersion": "7.1.15.0",
|
||||
"fileVersion": "7.1.15.0"
|
||||
"assemblyVersion": "7.2.0.0",
|
||||
"fileVersion": "7.2.0.0"
|
||||
},
|
||||
"lib/netstandard2.0/itext.layout.dll": {
|
||||
"assemblyVersion": "7.1.15.0",
|
||||
"fileVersion": "7.1.15.0"
|
||||
"assemblyVersion": "7.2.0.0",
|
||||
"fileVersion": "7.2.0.0"
|
||||
},
|
||||
"lib/netstandard2.0/itext.pdfa.dll": {
|
||||
"assemblyVersion": "7.1.15.0",
|
||||
"fileVersion": "7.1.15.0"
|
||||
"assemblyVersion": "7.2.0.0",
|
||||
"fileVersion": "7.2.0.0"
|
||||
},
|
||||
"lib/netstandard2.0/itext.sign.dll": {
|
||||
"assemblyVersion": "7.1.15.0",
|
||||
"fileVersion": "7.1.15.0"
|
||||
"assemblyVersion": "7.2.0.0",
|
||||
"fileVersion": "7.2.0.0"
|
||||
},
|
||||
"lib/netstandard2.0/itext.styledxmlparser.dll": {
|
||||
"assemblyVersion": "7.1.15.0",
|
||||
"fileVersion": "7.1.15.0"
|
||||
"assemblyVersion": "7.2.0.0",
|
||||
"fileVersion": "7.2.0.0"
|
||||
},
|
||||
"lib/netstandard2.0/itext.svg.dll": {
|
||||
"assemblyVersion": "7.1.15.0",
|
||||
"fileVersion": "7.1.15.0"
|
||||
"assemblyVersion": "7.2.0.0",
|
||||
"fileVersion": "7.2.0.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"itext7.commons/7.2.0": {
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.Logging": "5.0.0"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/netstandard2.0/itext.commons.dll": {
|
||||
"assemblyVersion": "7.2.0.0",
|
||||
"fileVersion": "7.2.0.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -137,6 +121,25 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.DependencyInjection/5.0.0": {
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.DependencyInjection.Abstractions": "5.0.0"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net5.0/Microsoft.Extensions.DependencyInjection.dll": {
|
||||
"assemblyVersion": "5.0.0.0",
|
||||
"fileVersion": "5.0.20.51904"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.DependencyInjection.Abstractions/5.0.0": {
|
||||
"runtime": {
|
||||
"lib/netstandard2.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll": {
|
||||
"assemblyVersion": "5.0.0.0",
|
||||
"fileVersion": "5.0.20.51904"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.DependencyModel/1.1.0": {
|
||||
"dependencies": {
|
||||
"Microsoft.DotNet.PlatformAbstractions": "1.1.0",
|
||||
@ -152,6 +155,48 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Logging/5.0.0": {
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.DependencyInjection": "5.0.0",
|
||||
"Microsoft.Extensions.DependencyInjection.Abstractions": "5.0.0",
|
||||
"Microsoft.Extensions.Logging.Abstractions": "5.0.0",
|
||||
"Microsoft.Extensions.Options": "5.0.0"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/netstandard2.1/Microsoft.Extensions.Logging.dll": {
|
||||
"assemblyVersion": "5.0.0.0",
|
||||
"fileVersion": "5.0.20.51904"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Logging.Abstractions/5.0.0": {
|
||||
"runtime": {
|
||||
"lib/netstandard2.0/Microsoft.Extensions.Logging.Abstractions.dll": {
|
||||
"assemblyVersion": "5.0.0.0",
|
||||
"fileVersion": "5.0.20.51904"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Options/5.0.0": {
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.DependencyInjection.Abstractions": "5.0.0",
|
||||
"Microsoft.Extensions.Primitives": "5.0.0"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net5.0/Microsoft.Extensions.Options.dll": {
|
||||
"assemblyVersion": "5.0.0.0",
|
||||
"fileVersion": "5.0.20.51904"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Primitives/5.0.0": {
|
||||
"runtime": {
|
||||
"lib/netcoreapp3.0/Microsoft.Extensions.Primitives.dll": {
|
||||
"assemblyVersion": "5.0.0.0",
|
||||
"fileVersion": "5.0.20.51904"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.NETCore.Platforms/1.1.0": {},
|
||||
"Microsoft.NETCore.Targets/1.1.0": {},
|
||||
"Microsoft.Win32.Primitives/4.3.0": {
|
||||
@ -757,26 +802,19 @@
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
},
|
||||
"Common.Logging/3.4.1": {
|
||||
"itext7/7.2.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-5eZ/vgEOqzLg4PypZqnJ+wMhhgHyckicbZY4iDxqQ4FtOz0CpdYZ0xQ78aszMzeAJZiLLb5VdR9tPfunVQLz6g==",
|
||||
"path": "common.logging/3.4.1",
|
||||
"hashPath": "common.logging.3.4.1.nupkg.sha512"
|
||||
"sha512": "sha512-1MkQiUY0pCevnKWrY/le7BiW/oV/9CLwB2jGD6xfs0tepE5eU5BTSlabgYq7oWZP8OB7KXoGySMqP+Ugj6MeOA==",
|
||||
"path": "itext7/7.2.0",
|
||||
"hashPath": "itext7.7.2.0.nupkg.sha512"
|
||||
},
|
||||
"Common.Logging.Core/3.4.1": {
|
||||
"itext7.commons/7.2.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-wLHldZHvxsSD6Ahonfj00/SkfHfKqO+YT6jsUwVm8Rch1REL9IArHAcSLXxYxYfu5/4ydGtmXvOtaH3AkVPu0A==",
|
||||
"path": "common.logging.core/3.4.1",
|
||||
"hashPath": "common.logging.core.3.4.1.nupkg.sha512"
|
||||
},
|
||||
"itext7/7.1.15": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-BJKdScf6C7LlHB5pV5fr0qHGbrPLX1yl+1R1qHroRZxtyTVFMeZ9gPV6IOsmgTRLr2ee9hUXHbb8/ZqKB4pqiA==",
|
||||
"path": "itext7/7.1.15",
|
||||
"hashPath": "itext7.7.1.15.nupkg.sha512"
|
||||
"sha512": "sha512-bfysIirFpBOTc/mSfElJMOy9D/I2LTLeL0uae7xNgV4Vv7P2HF2n2/CJRTe9iZFsL3r8JdH0hd+eusnt0BjA8w==",
|
||||
"path": "itext7.commons/7.2.0",
|
||||
"hashPath": "itext7.commons.7.2.0.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.CSharp/4.0.1": {
|
||||
"type": "package",
|
||||
@ -792,6 +830,20 @@
|
||||
"path": "microsoft.dotnet.platformabstractions/1.1.0",
|
||||
"hashPath": "microsoft.dotnet.platformabstractions.1.1.0.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.DependencyInjection/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-Rc2kb/p3Ze6cP6rhFC3PJRdWGbLvSHZc0ev7YlyeU6FmHciDMLrhoVoTUEzKPhN5ZjFgKF1Cf5fOz8mCMIkvpA==",
|
||||
"path": "microsoft.extensions.dependencyinjection/5.0.0",
|
||||
"hashPath": "microsoft.extensions.dependencyinjection.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.DependencyInjection.Abstractions/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-ORj7Zh81gC69TyvmcUm9tSzytcy8AVousi+IVRAI8nLieQjOFryRusSFh7+aLk16FN9pQNqJAiMd7BTKINK0kA==",
|
||||
"path": "microsoft.extensions.dependencyinjection.abstractions/5.0.0",
|
||||
"hashPath": "microsoft.extensions.dependencyinjection.abstractions.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.DependencyModel/1.1.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
@ -799,6 +851,34 @@
|
||||
"path": "microsoft.extensions.dependencymodel/1.1.0",
|
||||
"hashPath": "microsoft.extensions.dependencymodel.1.1.0.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.Logging/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-MgOwK6tPzB6YNH21wssJcw/2MKwee8b2gI7SllYfn6rvTpIrVvVS5HAjSU2vqSku1fwqRvWP0MdIi14qjd93Aw==",
|
||||
"path": "microsoft.extensions.logging/5.0.0",
|
||||
"hashPath": "microsoft.extensions.logging.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.Logging.Abstractions/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-NxP6ahFcBnnSfwNBi2KH2Oz8Xl5Sm2krjId/jRR3I7teFphwiUoUeZPwTNA21EX+5PtjqmyAvKaOeBXcJjcH/w==",
|
||||
"path": "microsoft.extensions.logging.abstractions/5.0.0",
|
||||
"hashPath": "microsoft.extensions.logging.abstractions.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.Options/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-CBvR92TCJ5uBIdd9/HzDSrxYak+0W/3+yxrNg8Qm6Bmrkh5L+nu6m3WeazQehcZ5q1/6dDA7J5YdQjim0165zg==",
|
||||
"path": "microsoft.extensions.options/5.0.0",
|
||||
"hashPath": "microsoft.extensions.options.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.Primitives/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-cI/VWn9G1fghXrNDagX9nYaaB/nokkZn0HYAawGaELQrl8InSezfe9OnfPZLcJq3esXxygh3hkq2c3qoV3SDyQ==",
|
||||
"path": "microsoft.extensions.primitives/5.0.0",
|
||||
"hashPath": "microsoft.extensions.primitives.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.NETCore.Platforms/1.1.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
@ -830,7 +910,7 @@
|
||||
"Newtonsoft.Json/9.0.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-U82mHQSKaIk+lpSVCbWYKNavmNH1i5xrExDEquU1i6I5pV6UMOqRnJRSlKO3cMPfcpp0RgDY+8jUXHdQ4IfXvw==",
|
||||
"sha512": "sha512-2okXpTRwUcgQb06put5LwwCjtgoFo74zkPksjcvOpnIjx7TagGW5IoBCAA4luZx1+tfiIhoNqoiI7Y7zwWGyKA==",
|
||||
"path": "newtonsoft.json/9.0.1",
|
||||
"hashPath": "newtonsoft.json.9.0.1.nupkg.sha512"
|
||||
},
|
||||
@ -1145,7 +1225,7 @@
|
||||
"System.Runtime.InteropServices.RuntimeInformation/4.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-hWPhJxc453RCa8Z29O91EmfGeZIHX1ZH2A8L6lYQVSaKzku2DfArSfMEb1/MYYzPQRJZeu0c9dmYeJKxW5Fgng==",
|
||||
"sha512": "sha512-Ri015my90h3AB/BsbvEpq1foEPoPBBa9L8b7fu1VE4eA1NMeMe5iZ6guLjoWB+XGQr1u/rEwtXobqofjFBsAgA==",
|
||||
"path": "system.runtime.interopservices.runtimeinformation/4.0.0",
|
||||
"hashPath": "system.runtime.interopservices.runtimeinformation.4.0.0.nupkg.sha512"
|
||||
},
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
29
AsbCloudInfrastructure/DateTimeExtentions.cs
Normal file
29
AsbCloudInfrastructure/DateTimeExtentions.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
|
||||
namespace AsbCloudInfrastructure
|
||||
{
|
||||
public static class DateTimeExtentions
|
||||
{
|
||||
public static DateTimeOffset ToUtcDateTimeOffset(this DateTime date, double remoteTimezoneOffsetHours)
|
||||
{
|
||||
if (date == default)
|
||||
return new DateTimeOffset();
|
||||
|
||||
var dateUtc = date.Kind switch
|
||||
{
|
||||
DateTimeKind.Local => date.ToUniversalTime(),
|
||||
DateTimeKind.Unspecified => DateTime.SpecifyKind(date.AddHours(-remoteTimezoneOffsetHours), DateTimeKind.Utc),
|
||||
_ => date,
|
||||
};
|
||||
return new DateTimeOffset( dateUtc);
|
||||
}
|
||||
|
||||
public static DateTime ToRemoteDateTime(this DateTimeOffset date, double remoteTimezoneOffsetHours)
|
||||
{
|
||||
if (date == default)
|
||||
return new DateTime(0, DateTimeKind.Unspecified);
|
||||
var dateTz = date.ToOffset(TimeSpan.FromHours(remoteTimezoneOffsetHours));
|
||||
return dateTz.DateTime;
|
||||
}
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ using AsbCloudInfrastructure.Services.Analysis;
|
||||
using AsbCloudInfrastructure.Services.Cache;
|
||||
using AsbCloudInfrastructure.Services.WellOperationService;
|
||||
using AsbCloudInfrastructure.Validators;
|
||||
using Mapster;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@ -26,8 +27,20 @@ namespace AsbCloudInfrastructure
|
||||
return context;
|
||||
}
|
||||
|
||||
public static void MapsterSetup()
|
||||
{
|
||||
TypeAdapterConfig.GlobalSettings.Default.Config
|
||||
.ForType<DateTimeOffset, DateTime>()
|
||||
.MapWith((source) => source.DateTime);
|
||||
TypeAdapterConfig.GlobalSettings.Default.Config
|
||||
.ForType<DateTime, DateTimeOffset>()
|
||||
.MapWith((source) => source == default ? new DateTime(0, DateTimeKind.Utc) : source);
|
||||
|
||||
}
|
||||
|
||||
public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
MapsterSetup();
|
||||
services.AddDbContext<AsbCloudDbContext>(options =>
|
||||
options.UseNpgsql(configuration.GetConnectionString("DefaultConnection")));
|
||||
|
||||
@ -59,7 +72,7 @@ namespace AsbCloudInfrastructure
|
||||
services.AddTransient<ITelemetryAnalyticsService, TelemetryAnalyticsService>();
|
||||
services.AddTransient<ITelemetryService, TelemetryService>();
|
||||
services.AddTransient<ITelemetryUserService, TelemetryUserService>();
|
||||
services.AddTransient<ITimeZoneService, TimeZoneService>();
|
||||
services.AddTransient<ITimezoneService, TimezoneService>();
|
||||
services.AddTransient<IUserService, UserService>();
|
||||
services.AddTransient<IUserRoleService, UserRoleService>();
|
||||
services.AddTransient<IWellService, WellService>();
|
||||
|
@ -16,6 +16,7 @@ namespace AsbCloudInfrastructure
|
||||
|
||||
private readonly Dictionary<int, TelemetryEvent> events;
|
||||
private readonly Dictionary<int, TelemetryUser> users;
|
||||
private readonly double timezoneOffset;
|
||||
private readonly Dictionary<int, string> categories = new Dictionary<int, string>
|
||||
{
|
||||
{1, "Авария"},
|
||||
@ -26,6 +27,7 @@ namespace AsbCloudInfrastructure
|
||||
public ReportDataSourcePgCloud(AsbCloudDbContext context, int idWell)
|
||||
{
|
||||
this.context = context;
|
||||
|
||||
var well = context.Wells
|
||||
.Include(w => w.Cluster)
|
||||
.ThenInclude(c => c.Deposit)
|
||||
@ -46,15 +48,17 @@ namespace AsbCloudInfrastructure
|
||||
.Where(u => u.IdTelemetry == idTelemetry)
|
||||
.ToDictionary(u => u.IdUser, u => u);
|
||||
|
||||
timezoneOffset = well?.Telemetry?.Info?.TimeZoneOffsetTotalHours ?? well.Timezone?.Hours ?? 5.0;
|
||||
|
||||
info = new WellInfoReport
|
||||
{
|
||||
Deposit = well?.Cluster?.Deposit?.Caption,
|
||||
Cluster = well?.Cluster?.Caption,
|
||||
Well = well?.Caption,
|
||||
Customer = well?.RelationCompaniesWells.FirstOrDefault(c => c.Company.IdCompanyType == 1)?.Company.Caption,
|
||||
DrillingStartDate = well?.Telemetry?.Info?.DrillingStartDate ?? default,
|
||||
TimeZoneId = well?.Telemetry?.Info?.TimeZoneId ?? default,
|
||||
TimeZoneOffsetTotalHours = well?.Telemetry?.Info?.TimeZoneOffsetTotalHours ?? default,
|
||||
Deposit = well.Cluster?.Deposit?.Caption,
|
||||
Cluster = well.Cluster?.Caption,
|
||||
Well = well.Caption,
|
||||
Customer = well.RelationCompaniesWells.FirstOrDefault(c => c.Company.IdCompanyType == 1)?.Company.Caption,
|
||||
DrillingStartDate = well.Telemetry?.Info?.DrillingStartDate.ToRemoteDateTime(timezoneOffset) ?? default,
|
||||
TimeZoneId = well.Telemetry?.Info?.TimeZoneId ?? well.Timezone?.TimeZoneId ?? default,
|
||||
TimeZoneOffsetTotalHours = timezoneOffset,
|
||||
};
|
||||
}
|
||||
|
||||
@ -74,8 +78,8 @@ namespace AsbCloudInfrastructure
|
||||
|
||||
var result = new AnalyzeResult
|
||||
{
|
||||
MinDate = dataStat?.min ?? messagesStat?.min ?? default,
|
||||
MaxDate = dataStat?.max ?? messagesStat?.max ?? default,
|
||||
MinDate = dataStat?.min.UtcDateTime ?? messagesStat?.min.UtcDateTime ?? default,
|
||||
MaxDate = dataStat?.max.UtcDateTime ?? messagesStat?.max.UtcDateTime ?? default,
|
||||
MessagesCount = messagesStat?.count ?? 0,
|
||||
};
|
||||
|
||||
@ -83,57 +87,67 @@ namespace AsbCloudInfrastructure
|
||||
}
|
||||
|
||||
public IQueryable<DataSaubReport> GetDataSaubItems(DateTime begin, DateTime end)
|
||||
=> from item in context.TelemetryDataSaub
|
||||
where item.IdTelemetry == idTelemetry
|
||||
&& item.Date >= begin
|
||||
&& item.Date <= end
|
||||
orderby item.Date
|
||||
select new DataSaubReport
|
||||
{
|
||||
//Id = item.Id,
|
||||
Date = item.Date,
|
||||
Mode = item.Mode,
|
||||
WellDepth = item.WellDepth,
|
||||
BitDepth = item.BitDepth,
|
||||
BlockPosition = item.BlockPosition,
|
||||
BlockSpeed = item.BlockSpeed,
|
||||
BlockSpeedSp = item.BlockSpeedSp,
|
||||
BlockSpeedSpDevelop = item.BlockSpeedSpDevelop,
|
||||
Pressure = item.Pressure,
|
||||
PressureSp = item.PressureSp,
|
||||
AxialLoad = item.AxialLoad,
|
||||
AxialLoadSp = item.AxialLoadSp,
|
||||
AxialLoadLimitMax = item.AxialLoadLimitMax,
|
||||
HookWeight = item.HookWeight,
|
||||
RotorTorque = item.RotorTorque,
|
||||
RotorTorqueSp = item.RotorTorqueSp,
|
||||
RotorSpeed = item.RotorSpeed,
|
||||
Flow = item.Flow,
|
||||
PressureSpDevelop = item.PressureSpDevelop,
|
||||
};
|
||||
{
|
||||
var beginUtc = begin.ToUtcDateTimeOffset(timezoneOffset);
|
||||
var endUtc = end.ToUtcDateTimeOffset(timezoneOffset);
|
||||
|
||||
var query = context.TelemetryDataSaub
|
||||
.Where(d => d.IdTelemetry == idTelemetry
|
||||
&& d.Date >= beginUtc
|
||||
&& d.Date <= endUtc)
|
||||
.OrderBy(d => d.Date)
|
||||
.Select(d => new DataSaubReport {
|
||||
Date = d.Date.DateTime.AddHours(timezoneOffset),
|
||||
Mode = d.Mode,
|
||||
WellDepth = d.WellDepth,
|
||||
BitDepth = d.BitDepth,
|
||||
BlockPosition = d.BlockPosition,
|
||||
BlockSpeed = d.BlockSpeed,
|
||||
BlockSpeedSp = d.BlockSpeedSp,
|
||||
BlockSpeedSpDevelop = d.BlockSpeedSpDevelop,
|
||||
Pressure = d.Pressure,
|
||||
PressureSp = d.PressureSp,
|
||||
AxialLoad = d.AxialLoad,
|
||||
AxialLoadSp = d.AxialLoadSp,
|
||||
AxialLoadLimitMax = d.AxialLoadLimitMax,
|
||||
HookWeight = d.HookWeight,
|
||||
RotorTorque = d.RotorTorque,
|
||||
RotorTorqueSp = d.RotorTorqueSp,
|
||||
RotorSpeed = d.RotorSpeed,
|
||||
Flow = d.Flow,
|
||||
PressureSpDevelop = d.PressureSpDevelop,
|
||||
});
|
||||
return query;
|
||||
}
|
||||
|
||||
public IQueryable<MessageReport> GetMessages(DateTime begin, DateTime end)
|
||||
=> from item in context.TelemetryMessages
|
||||
where item.IdTelemetry == idTelemetry
|
||||
&& item.Date >= begin
|
||||
&& item.Date <= end
|
||||
orderby item.Date
|
||||
select new MessageReport
|
||||
{
|
||||
Id = item.Id,
|
||||
Date = item.Date,
|
||||
Category = events.GetValueOrDefault(item.IdEvent) == null
|
||||
? $""
|
||||
: categories[events[item.IdEvent].IdCategory],
|
||||
User = item.IdTelemetryUser == null
|
||||
? ""
|
||||
: users.GetValueOrDefault((int)item.IdTelemetryUser) == null
|
||||
? $"User id{item.IdTelemetryUser}"
|
||||
: users[(int)item.IdTelemetryUser].MakeDisplayName(),
|
||||
Text = events.GetValueOrDefault(item.IdEvent) == null
|
||||
? $"Стбытие {item.IdEvent} {item.Arg0} {item.Arg1} {item.Arg2} {item.Arg3}"
|
||||
: events[item.IdEvent].MakeMessageText(item)
|
||||
};
|
||||
{
|
||||
var beginUtc = begin.ToUtcDateTimeOffset(timezoneOffset);
|
||||
var endUtc = end.ToUtcDateTimeOffset(timezoneOffset);
|
||||
|
||||
var query = from item in context.TelemetryMessages
|
||||
where item.IdTelemetry == idTelemetry
|
||||
&& item.Date >= beginUtc
|
||||
&& item.Date <= endUtc
|
||||
orderby item.Date
|
||||
select new MessageReport
|
||||
{
|
||||
Id = item.Id,
|
||||
Date = item.Date.DateTime,
|
||||
Category = events.GetValueOrDefault(item.IdEvent) == null
|
||||
? $""
|
||||
: categories[events[item.IdEvent].IdCategory],
|
||||
User = item.IdTelemetryUser == null
|
||||
? ""
|
||||
: users.GetValueOrDefault((int)item.IdTelemetryUser) == null
|
||||
? $"User id{item.IdTelemetryUser}"
|
||||
: users[(int)item.IdTelemetryUser].MakeDisplayName(),
|
||||
Text = events.GetValueOrDefault(item.IdEvent) == null
|
||||
? $"Событие {item.IdEvent} {item.Arg0} {item.Arg1} {item.Arg2} {item.Arg3}"
|
||||
: events[item.IdEvent].MakeMessageText(item)
|
||||
};
|
||||
return query;
|
||||
}
|
||||
|
||||
public WellInfoReport GetWellInfo()
|
||||
=> info;
|
||||
|
@ -5,7 +5,7 @@ namespace AsbCloudInfrastructure.Services.Analysis
|
||||
class DataSaubAnalyse
|
||||
{
|
||||
public int IdTelemetry { get; internal set; }
|
||||
public DateTime Date { get; internal set; }
|
||||
public DateTimeOffset Date { get; internal set; }
|
||||
public double WellDepth { get; internal set; }
|
||||
public double BitDepth { get; internal set; }
|
||||
public double BlockPosition { get; internal set; }
|
||||
|
@ -40,8 +40,8 @@ namespace AsbCloudInfrastructure.Services.Analysis
|
||||
try
|
||||
{
|
||||
using var context = new AsbCloudDbContext(options);
|
||||
var timeZoneService = new TimeZoneService();
|
||||
var telemetryService = new TelemetryService(context, telemetryTracker, timeZoneService, cacheDb);
|
||||
var timezoneService = new TimezoneService();
|
||||
var telemetryService = new TelemetryService(context, telemetryTracker, timezoneService, cacheDb);
|
||||
var analyticsService = new TelemetryAnalyticsService(context,
|
||||
telemetryService, cacheDb);
|
||||
|
||||
|
@ -33,13 +33,14 @@ namespace AsbCloudInfrastructure.Services.Analysis
|
||||
|
||||
public async Task<IEnumerable<WellDepthToDayDto>> GetWellDepthToDayAsync(int idWell, CancellationToken token = default)
|
||||
{
|
||||
var telemetryId = telemetryService.GetIdTelemetryByIdWell(idWell);
|
||||
var idTelemetry = telemetryService.GetIdTelemetryByIdWell(idWell);
|
||||
|
||||
if (telemetryId is null)
|
||||
if (idTelemetry is null)
|
||||
return null;
|
||||
|
||||
var timezone = telemetryService.GetTimezone((int)idTelemetry);
|
||||
var depthToTimeData = (from d in db.TelemetryDataSaub
|
||||
where d.IdTelemetry == telemetryId
|
||||
where d.IdTelemetry == idTelemetry
|
||||
select new
|
||||
{
|
||||
d.WellDepth,
|
||||
@ -56,7 +57,7 @@ namespace AsbCloudInfrastructure.Services.Analysis
|
||||
{
|
||||
WellDepth = d.WellDepth ?? 0.0,
|
||||
BitDepth = d.BitDepth ?? 0.0,
|
||||
Date = d.Date
|
||||
Date = d.Date.ToRemoteDateTime(timezone.Hours),
|
||||
}).AsNoTracking().ToListAsync(token).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@ -70,11 +71,11 @@ namespace AsbCloudInfrastructure.Services.Analysis
|
||||
if (telemetryId is null)
|
||||
return null;
|
||||
|
||||
var timezoneOffset = telemetryService.GetTimezoneOffsetByTelemetryId((int)telemetryId);
|
||||
var timezone = telemetryService.GetTimezone((int)telemetryId);
|
||||
|
||||
var drillingPeriodsInfo = await db.TelemetryDataSaub
|
||||
.Where(t => t.IdTelemetry == telemetryId)
|
||||
.GroupBy(t => Math.Floor((((t.Date.DayOfYear * 24 + t.Date.Hour) * 60 + t.Date.Minute) * 60 + t.Date.Second + timezoneOffset - shiftStartSec) / intervalSeconds))
|
||||
.GroupBy(t => Math.Floor((((t.Date.DayOfYear * 24 + t.Date.Hour) * 60 + t.Date.Minute) * 60 + t.Date.Second + timezone.Hours - shiftStartSec) / intervalSeconds))
|
||||
.Select(g => new {
|
||||
WellDepthMin = g.Min(t => t.WellDepth),
|
||||
WellDepthMax = g.Max(t => t.WellDepth),
|
||||
@ -86,7 +87,7 @@ namespace AsbCloudInfrastructure.Services.Analysis
|
||||
|
||||
var wellDepthToIntervalData = drillingPeriodsInfo.Select(d => new WellDepthToIntervalDto
|
||||
{
|
||||
IntervalStartDate = d.DateMin,
|
||||
IntervalStartDate = d.DateMin.ToRemoteDateTime(timezone.Hours),
|
||||
IntervalDepthProgress = (d.WellDepthMax - d.WellDepthMin) ?? 0.0
|
||||
// / (d.DateMax - d.DateMin).TotalHours,
|
||||
}).OrderBy(d => d.IntervalStartDate).ToList();
|
||||
@ -201,7 +202,7 @@ namespace AsbCloudInfrastructure.Services.Analysis
|
||||
if (telemetryId is null)
|
||||
return null;
|
||||
|
||||
var timezoneOffset = telemetryService.GetTimezoneOffsetByTelemetryId((int)telemetryId);
|
||||
var timezone = telemetryService.GetTimezone((int)telemetryId);
|
||||
|
||||
// Get'n'Group all operations only by start date and by name (if there were several operations in interval).
|
||||
// Without dividing these operations duration by given interval
|
||||
@ -210,7 +211,7 @@ namespace AsbCloudInfrastructure.Services.Analysis
|
||||
join o in db.WellOperationCategories on a.IdOperation equals o.Id
|
||||
group a by new
|
||||
{
|
||||
Interval = Math.Floor((a.UnixDate - workBeginSeconds + timezoneOffset) / intervalSeconds),
|
||||
Interval = Math.Floor((a.UnixDate - workBeginSeconds + timezone.Hours) / intervalSeconds),
|
||||
o.Name
|
||||
} into g
|
||||
select new
|
||||
@ -223,17 +224,15 @@ namespace AsbCloudInfrastructure.Services.Analysis
|
||||
.ToListAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
|
||||
var groupedOperationsList = new List<TelemetryOperationInfoDto>();
|
||||
|
||||
|
||||
if (operations is not null && operations.Any())
|
||||
{
|
||||
var operations = ops.Select(o => (o.IntervalStart, o.OperationName, o.OperationDuration));
|
||||
|
||||
var splittedOperationsByInterval = DivideOperationsByIntervalLength(operations, intervalSeconds); // divides good
|
||||
|
||||
groupedOperationsList = UniteOperationsInDto(splittedOperationsByInterval, intervalSeconds).ToList(); // unites not good
|
||||
groupedOperationsList = UniteOperationsInDto(splittedOperationsByInterval, intervalSeconds, timezone.Hours).ToList(); // unites not good
|
||||
}
|
||||
|
||||
return groupedOperationsList;
|
||||
@ -251,7 +250,7 @@ namespace AsbCloudInfrastructure.Services.Analysis
|
||||
}
|
||||
}
|
||||
|
||||
private async Task AnalyseAndSaveTelemetryAsync(int idTelemetry, DateTime analyzeStartDate, CancellationToken token = default)
|
||||
private async Task AnalyseAndSaveTelemetryAsync(int idTelemetry, DateTimeOffset analyzeStartDate, CancellationToken token = default)
|
||||
{
|
||||
const int step = 10;
|
||||
const int take = step * 2;
|
||||
@ -300,16 +299,17 @@ namespace AsbCloudInfrastructure.Services.Analysis
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<DatesRangeDto> GetOperationsDateRangeAsync(int idWell, bool isUtc,
|
||||
CancellationToken token = default)
|
||||
public async Task<DatesRangeDto> GetOperationsDateRangeAsync(int idWell, CancellationToken token = default)
|
||||
{
|
||||
var telemetryId = telemetryService.GetIdTelemetryByIdWell(idWell);
|
||||
var idTelemetry = telemetryService.GetIdTelemetryByIdWell(idWell);
|
||||
|
||||
if (telemetryId is null)
|
||||
if (idTelemetry is null)
|
||||
return null;
|
||||
|
||||
var timezone = telemetryService.GetTimezone((int)idTelemetry);
|
||||
|
||||
var datesRange = await (from d in db.TelemetryAnalysis
|
||||
where d.IdTelemetry == telemetryId
|
||||
where d.IdTelemetry == idTelemetry
|
||||
select d.UnixDate).DefaultIfEmpty()
|
||||
.GroupBy(g => true)
|
||||
.AsNoTracking()
|
||||
@ -323,18 +323,12 @@ namespace AsbCloudInfrastructure.Services.Analysis
|
||||
|
||||
var result = new DatesRangeDto
|
||||
{
|
||||
From = DateTimeOffset.FromUnixTimeSeconds(datesRange.From).DateTime,
|
||||
To = datesRange.To == default
|
||||
From = DateTimeOffset.FromUnixTimeSeconds(datesRange.From).ToRemoteDateTime(timezone.Hours),
|
||||
To = (datesRange.To == default
|
||||
? DateTime.MaxValue
|
||||
: DateTimeOffset.FromUnixTimeSeconds(datesRange.To).DateTime
|
||||
: DateTimeOffset.FromUnixTimeSeconds(datesRange.To)).ToRemoteDateTime(timezone.Hours),
|
||||
};
|
||||
|
||||
if (isUtc)
|
||||
return result;
|
||||
|
||||
result = await telemetryService.DatesRangeToTelemetryTimeZoneAsync((int)telemetryId, result, token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -347,7 +341,7 @@ namespace AsbCloudInfrastructure.Services.Analysis
|
||||
.LastOrDefaultAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
DateTime lastAnalysisDate = default;
|
||||
DateTime lastAnalysisDate = new DateTime(0, DateTimeKind.Utc);
|
||||
|
||||
if(lastAnalysisInDb is not null)
|
||||
lastAnalysisDate = DateTime.UnixEpoch.AddSeconds(lastAnalysisInDb.DurationSec + lastAnalysisInDb.UnixDate);
|
||||
@ -355,7 +349,7 @@ namespace AsbCloudInfrastructure.Services.Analysis
|
||||
return lastAnalysisDate;
|
||||
}
|
||||
|
||||
private Task<List<DataSaubAnalyse>> GetDataSaubPartOrDefaultAsync(int idTelemetry, DateTime analyzeStartDate, CancellationToken token) =>
|
||||
private Task<List<DataSaubAnalyse>> GetDataSaubPartOrDefaultAsync(int idTelemetry, DateTimeOffset analyzeStartDate, CancellationToken token) =>
|
||||
db.TelemetryDataSaub
|
||||
.Where(d =>
|
||||
d.IdTelemetry == idTelemetry &&
|
||||
@ -396,7 +390,7 @@ namespace AsbCloudInfrastructure.Services.Analysis
|
||||
operationDurationTimeCounter += OperationDuration;
|
||||
}
|
||||
else
|
||||
{ // if operation duration overflows current interval it shoud be divided into 2 or more parts for this and next intervals
|
||||
{ // if operation duration overflows current interval it should be divided into 2 or more parts for this and next intervals
|
||||
var remainingIntervalTime = intervalSeconds - operationDurationTimeCounter;
|
||||
splittedOperationsByInterval.Add((IntervalStart, OperationName, remainingIntervalTime)); // first part of long operation
|
||||
|
||||
@ -432,13 +426,14 @@ namespace AsbCloudInfrastructure.Services.Analysis
|
||||
}
|
||||
|
||||
private static IEnumerable<TelemetryOperationInfoDto> UniteOperationsInDto(
|
||||
IEnumerable<(long IntervalStart, string OperationName, int OperationDuration)> operations, int intervalSeconds)
|
||||
IEnumerable<(long IntervalStart, string OperationName, int OperationDuration)> operations, int intervalSeconds, double timezoneOffset)
|
||||
{
|
||||
var groupedOperationsList = new List<TelemetryOperationInfoDto>();
|
||||
|
||||
var groupedOperationsObj = new TelemetryOperationInfoDto
|
||||
{
|
||||
IntervalBegin = DateTimeOffset.FromUnixTimeSeconds(operations.First().IntervalStart),
|
||||
IntervalBegin = DateTimeOffset.FromUnixTimeSeconds(operations.First().IntervalStart)
|
||||
.ToRemoteDateTime(timezoneOffset),
|
||||
Operations = new List<TelemetryOperationDetailsDto>()
|
||||
};
|
||||
|
||||
@ -461,7 +456,8 @@ namespace AsbCloudInfrastructure.Services.Analysis
|
||||
intervalEndDate = IntervalStart + intervalSeconds;
|
||||
groupedOperationsObj = new TelemetryOperationInfoDto
|
||||
{
|
||||
IntervalBegin = DateTimeOffset.FromUnixTimeSeconds(IntervalStart),
|
||||
IntervalBegin = DateTimeOffset.FromUnixTimeSeconds(IntervalStart)
|
||||
.ToRemoteDateTime(timezoneOffset),
|
||||
Operations = new List<TelemetryOperationDetailsDto>()
|
||||
};
|
||||
|
||||
|
@ -5,15 +5,14 @@ using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AsbCloudInfrastructure.Services.Cache;
|
||||
using Mapster;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
|
||||
namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
|
@ -309,7 +309,7 @@ namespace AsbCloudInfrastructure.Services.Cache
|
||||
{
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
if (dbSet.Contains(entity)) // TODO: это очень ммедленно
|
||||
if (dbSet.Contains(entity)) // TODO: это очень медленно
|
||||
dbSet.Update(entity);
|
||||
else
|
||||
dbSet.Add(entity);
|
||||
|
@ -148,7 +148,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
Wells = gCluster.Select(well => {
|
||||
var dto = well.Adapt<WellDto>();
|
||||
dto.WellType = well.WellType?.Caption;
|
||||
dto.LastTelemetryDate = wellService.GetLastTelemetryDate(well.Id);
|
||||
dto.LastTelemetryDate = wellService.GetLastTelemetryDate(well.Id).DateTime;
|
||||
dto.Cluster = gCluster.Key.Caption;
|
||||
dto.Deposit = gDeposit.Key.Caption;
|
||||
return dto;
|
||||
|
@ -15,36 +15,42 @@ namespace AsbCloudInfrastructure.Services
|
||||
IDrillFlowChartService
|
||||
{
|
||||
private readonly IAsbCloudDbContext db;
|
||||
private readonly IWellService wellService;
|
||||
|
||||
public DrillFlowChartService(IAsbCloudDbContext context)
|
||||
public DrillFlowChartService(IAsbCloudDbContext context, IWellService wellService)
|
||||
: base(context)
|
||||
{
|
||||
this.db = context;
|
||||
this.wellService = wellService;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<DrillFlowChartDto>> GetAllAsync(int idWell,
|
||||
DateTime updateFrom, CancellationToken token = default)
|
||||
{
|
||||
var timezone = wellService.GetTimezone(idWell);
|
||||
var updateFromUtc = updateFrom.ToUtcDateTimeOffset(timezone.Hours);
|
||||
var entities = await (from p in db.DrillFlowChart
|
||||
where p.IdWell == idWell &&
|
||||
p.LastUpdate > updateFrom
|
||||
p.LastUpdate > updateFromUtc
|
||||
orderby p.DepthStart, p.Id
|
||||
select p)
|
||||
.ToListAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var dto = entities.Adapt<DrillFlowChartDto>();
|
||||
return dto;
|
||||
var dtos = entities.Select(entity => {
|
||||
var dto = entity.Adapt<DrillFlowChartDto>();
|
||||
dto.LastUpdate = entity.LastUpdate.ToRemoteDateTime(timezone.Hours);
|
||||
return dto;
|
||||
});
|
||||
return dtos;
|
||||
}
|
||||
|
||||
public async Task<int> InsertAsync(int idWell, DrillFlowChartDto dto,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
dto.IdWell = idWell;
|
||||
dto.LastUpdate = DateTime.Now;
|
||||
|
||||
dto.LastUpdate = DateTime.UtcNow;
|
||||
var result = await base.InsertAsync(dto, token).ConfigureAwait(false);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -54,7 +60,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
foreach (var dto in dtos)
|
||||
{
|
||||
dto.IdWell = idWell;
|
||||
dto.LastUpdate = DateTime.Now;
|
||||
dto.LastUpdate = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
var result = await base.InsertRangeAsync(dtos, token).ConfigureAwait(false);
|
||||
|
@ -164,7 +164,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
newSheetName = sheetSrc.Name;
|
||||
suffix = $"_{index++}";
|
||||
if (newSheetName.Length + suffix.Length >= 31)
|
||||
newSheetName = newSheetName.Substring(0, (31 - suffix.Length));
|
||||
newSheetName = newSheetName[..(31 - suffix.Length)];
|
||||
newSheetName += suffix;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,8 @@ namespace AsbCloudInfrastructure.Services
|
||||
.ThenInclude(u => u.Company)
|
||||
.ThenInclude(c => c.CompanyType)
|
||||
.Include(f => f.FileMarks)
|
||||
.ThenInclude(m => m.User);
|
||||
.ThenInclude(m => m.User)
|
||||
.Include(f=>f.Well);
|
||||
}
|
||||
|
||||
public async Task<string> GetSharedUrlAsync(int idFileInfo, int idUser, IFileShareService fileShareService,
|
||||
@ -75,7 +76,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
IdAuthor = idUser,
|
||||
IdCategory = idCategory,
|
||||
Name = destinationFileName,
|
||||
UploadDate = DateTime.Now,
|
||||
UploadDate = DateTime.UtcNow,
|
||||
IsDeleted = false,
|
||||
Size = sysFileInfo.Length,
|
||||
};
|
||||
@ -87,8 +88,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(filePath));
|
||||
File.Move(srcFilePath, filePath);
|
||||
|
||||
var dto = entry.Entity.Adapt<FileInfoDto>();
|
||||
return dto;
|
||||
return await GetInfoAsync(entry.Entity.Id, token);
|
||||
}
|
||||
|
||||
public async Task<FileInfoDto> SaveAsync(int idWell, int? idUser, int idCategory,
|
||||
@ -101,7 +101,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
IdAuthor = idUser,
|
||||
IdCategory = idCategory,
|
||||
Name = Path.GetFileName(fileFullName),
|
||||
UploadDate = DateTime.Now,
|
||||
UploadDate = DateTime.UtcNow,
|
||||
IsDeleted = false,
|
||||
Size = fileStream?.Length ?? 0
|
||||
};
|
||||
@ -116,9 +116,8 @@ namespace AsbCloudInfrastructure.Services
|
||||
|
||||
using var newfileStream = new FileStream(filePath, FileMode.Create);
|
||||
await fileStream.CopyToAsync(newfileStream, token).ConfigureAwait(false);
|
||||
|
||||
var dto = entry.Entity.Adapt<FileInfoDto>();
|
||||
return dto;
|
||||
|
||||
return await GetInfoAsync(entry.Entity.Id, token);
|
||||
}
|
||||
|
||||
private string MakeFilePath(int idWell, int idCategory, string fileFullName, int fileId)
|
||||
@ -136,7 +135,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
.ToListAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var dtos = entities.Adapt<FileInfoDto>();
|
||||
var dtos = entities.Select(e => Convert(e));
|
||||
return dtos;
|
||||
}
|
||||
|
||||
@ -157,11 +156,28 @@ namespace AsbCloudInfrastructure.Services
|
||||
if (!string.IsNullOrEmpty(fileName))
|
||||
query = query.Where(e => e.Name.ToLower().Contains(fileName.ToLower()));
|
||||
|
||||
var firstFile = await query.FirstOrDefaultAsync(token);
|
||||
if (firstFile is null)
|
||||
return new PaginationContainer<FileInfoDto>()
|
||||
{
|
||||
Skip = skip,
|
||||
Take = take,
|
||||
Count = 0,
|
||||
};
|
||||
|
||||
var timezoneOffset = firstFile.Well.Timezone?.Hours ?? 5;
|
||||
|
||||
if (begin != default)
|
||||
query = query.Where(e => e.UploadDate >= begin);
|
||||
{
|
||||
var beginUtc = begin.ToUtcDateTimeOffset(timezoneOffset);
|
||||
query = query.Where(e => e.UploadDate >= beginUtc);
|
||||
}
|
||||
|
||||
if (end != default)
|
||||
query = query.Where(e => e.UploadDate <= end);
|
||||
{
|
||||
var endUtc = end.ToUtcDateTimeOffset(timezoneOffset);
|
||||
query = query.Where(e => e.UploadDate <= endUtc);
|
||||
}
|
||||
|
||||
var count = await query.CountAsync(token).ConfigureAwait(false);
|
||||
|
||||
@ -185,8 +201,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
.Take(take).AsNoTracking().ToListAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var dtos = entities.Adapt<FileInfoDto>();
|
||||
|
||||
var dtos = entities.Select(e => Convert(e, timezoneOffset));
|
||||
result.Items.AddRange(dtos);
|
||||
return result;
|
||||
}
|
||||
@ -202,7 +217,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
if (entity is null)
|
||||
return null;
|
||||
|
||||
var dto = entity.Adapt<FileInfoDto>();
|
||||
var dto = Convert(entity);
|
||||
return dto;
|
||||
}
|
||||
|
||||
@ -259,10 +274,29 @@ namespace AsbCloudInfrastructure.Services
|
||||
var entity = await dbSetConfigured
|
||||
.FirstOrDefaultAsync(f => f.FileMarks.Any(m => m.Id == idMark), token)
|
||||
.ConfigureAwait(false);
|
||||
var dto = entity.Adapt<FileInfoDto>();
|
||||
|
||||
FileInfoDto dto = Convert(entity);
|
||||
return dto;
|
||||
}
|
||||
|
||||
private static FileInfoDto Convert(AsbCloudDb.Model.FileInfo entity)
|
||||
{
|
||||
var timezoneOffset = entity.Well.Timezone?.Hours ?? 5;
|
||||
return Convert(entity, timezoneOffset);
|
||||
}
|
||||
|
||||
private static FileInfoDto Convert(AsbCloudDb.Model.FileInfo entity, double timezoneOffset)
|
||||
{
|
||||
var dto = entity.Adapt<FileInfoDto>();
|
||||
dto.UploadDate = entity.UploadDate.ToRemoteDateTime(timezoneOffset);
|
||||
dto.FileMarks = entity.FileMarks.Select(m =>
|
||||
{
|
||||
var mark = m.Adapt<FileMarkDto>();
|
||||
mark.DateCreated = m.DateCreated.ToRemoteDateTime(timezoneOffset);
|
||||
return mark;
|
||||
});
|
||||
return dto;
|
||||
}
|
||||
public async Task<int> CreateFileMarkAsync(FileMarkDto fileMarkDto, int idUser, CancellationToken token)
|
||||
{
|
||||
var fileMark = await db.FileMarks
|
||||
@ -278,7 +312,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
|
||||
var newFileMark = fileMarkDto.Adapt<FileMark>();
|
||||
newFileMark.Id = default;
|
||||
newFileMark.DateCreated = DateTime.Now;
|
||||
newFileMark.DateCreated = DateTime.UtcNow;
|
||||
newFileMark.IdUser = idUser;
|
||||
|
||||
db.FileMarks.Add(newFileMark);
|
||||
@ -303,7 +337,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
fileInfo.PublishInfo = new FilePublishInfo()
|
||||
{
|
||||
IdPublisher = idUser,
|
||||
Date = DateTime.Now,
|
||||
Date = DateTime.UtcNow,
|
||||
WebStorageFileUrl = weblink
|
||||
};
|
||||
|
||||
|
@ -15,11 +15,13 @@ namespace AsbCloudInfrastructure.Services
|
||||
public class MeasureService : IMeasureService
|
||||
{
|
||||
private readonly IAsbCloudDbContext db;
|
||||
private readonly IWellService wellService;
|
||||
private readonly CacheTable<MeasureCategory> cacheCategories;
|
||||
|
||||
public MeasureService(IAsbCloudDbContext db, Cache.CacheDb cacheDb)
|
||||
public MeasureService(IAsbCloudDbContext db, Cache.CacheDb cacheDb, IWellService wellService)
|
||||
{
|
||||
this.db = db;
|
||||
this.wellService = wellService;
|
||||
cacheCategories = cacheDb.GetCachedTable<MeasureCategory>((DbContext)db);
|
||||
}
|
||||
|
||||
@ -43,8 +45,12 @@ namespace AsbCloudInfrastructure.Services
|
||||
.FirstOrDefaultAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var dtos = entity?.Adapt<MeasureDto, Measure>((d, s) => d.CategoryName = s.Category?.Name);
|
||||
return dtos;
|
||||
var timezone = wellService.GetTimezone(idWell);
|
||||
var dto = entity?.Adapt<MeasureDto, Measure>((d, s) => {
|
||||
d.CategoryName = s.Category?.Name;
|
||||
d.Timestamp = s.Timestamp.ToRemoteDateTime(timezone.Hours);
|
||||
});
|
||||
return dto;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<MeasureDto>> GetHisoryAsync(int idWell, int? idCategory = null, CancellationToken token = default)
|
||||
@ -61,41 +67,50 @@ namespace AsbCloudInfrastructure.Services
|
||||
.ToListAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var dtos = entities.Adapt<MeasureDto, Measure>((d, s) => d.CategoryName = s.Category?.Name);
|
||||
var timezone = wellService.GetTimezone(idWell);
|
||||
var dtos = entities.Adapt<MeasureDto, Measure>((d, s) => {
|
||||
d.CategoryName = s.Category?.Name;
|
||||
d.Timestamp = s.Timestamp.ToRemoteDateTime(timezone.Hours);
|
||||
});
|
||||
return dtos;
|
||||
}
|
||||
|
||||
public Task<int> InsertAsync(int idWell, MeasureDto data, CancellationToken token)
|
||||
public Task<int> InsertAsync(int idWell, MeasureDto dto, CancellationToken token)
|
||||
{
|
||||
if (data.IdCategory < 1)
|
||||
throw new ArgumentException("wrong idCategory", nameof(data));
|
||||
if (data.Data is null)
|
||||
throw new ArgumentException("data.data is not optional", nameof(data));
|
||||
var entity = data.Adapt<Measure>();
|
||||
if (dto.IdCategory < 1)
|
||||
throw new ArgumentException("wrong idCategory", nameof(dto));
|
||||
if (dto.Data is null)
|
||||
throw new ArgumentException("data.data is not optional", nameof(dto));
|
||||
var timezone = wellService.GetTimezone(idWell);
|
||||
var entity = dto.Adapt<Measure>();
|
||||
entity.IdWell = idWell;
|
||||
entity.Timestamp = dto.Timestamp.ToUtcDateTimeOffset(timezone.Hours);
|
||||
db.Measures.Add(entity);
|
||||
return db.SaveChangesAsync(token);
|
||||
}
|
||||
|
||||
public async Task<int> UpdateAsync(int idWell, MeasureDto data, CancellationToken token)
|
||||
public async Task<int> UpdateAsync(int idWell, MeasureDto dto, CancellationToken token)
|
||||
{
|
||||
if (data.Id < 1)
|
||||
throw new ArgumentException("wrong id", nameof(data));
|
||||
if (data.IdCategory < 1)
|
||||
throw new ArgumentException("wrong idCategory", nameof(data));
|
||||
if (data.Data is null)
|
||||
throw new ArgumentException("data.data is not optional", nameof(data));
|
||||
if (dto.Id < 1)
|
||||
throw new ArgumentException("wrong id", nameof(dto));
|
||||
if (dto.IdCategory < 1)
|
||||
throw new ArgumentException("wrong idCategory", nameof(dto));
|
||||
if (dto.Data is null)
|
||||
throw new ArgumentException("data.data is not optional", nameof(dto));
|
||||
|
||||
var entity = await db.Measures
|
||||
.Where(m => m.Id == data.Id && !m.IsDeleted)
|
||||
.Where(m => m.Id == dto.Id && !m.IsDeleted)
|
||||
.FirstOrDefaultAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (entity is null)
|
||||
throw new ArgumentException("id doesn't exist", nameof(data));
|
||||
throw new ArgumentException("id doesn't exist", nameof(dto));
|
||||
|
||||
var timezone = wellService.GetTimezone(idWell);
|
||||
|
||||
entity.IdWell = idWell;
|
||||
entity.Timestamp = data.Timestamp;
|
||||
entity.Data = data.Data;
|
||||
entity.Timestamp = dto.Timestamp.ToUtcDateTimeOffset(timezone.Hours);
|
||||
entity.Data = (RawData)dto.Data;
|
||||
|
||||
return await db.SaveChangesAsync(token).ConfigureAwait(false);
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ namespace AsbCloudInfrastructure.Services
|
||||
string searchString = default,
|
||||
int skip = 0,
|
||||
int take = 32,
|
||||
bool isUtc = true,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
var idTelemetry = telemetryService.GetIdTelemetryByIdWell(idWell);
|
||||
@ -68,21 +67,19 @@ namespace AsbCloudInfrastructure.Services
|
||||
|
||||
query = query.OrderByDescending(m => m.Date);
|
||||
|
||||
|
||||
var timeOffset = await telemetryService.GetTelemetryTimeZoneOffsetAsync(idTelemetry??default, token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (timeOffset is not null)
|
||||
{
|
||||
begin = telemetryService.TimeZoneService.DateToUtc(begin, timeOffset ?? default);
|
||||
end = telemetryService.TimeZoneService.DateToUtc(end, timeOffset ?? default);
|
||||
}
|
||||
var timezone = telemetryService.GetTimezone(idTelemetry??default);
|
||||
|
||||
if (begin != default)
|
||||
query = query.Where(m => m.Date >= begin);
|
||||
{
|
||||
var beginUtc = begin.ToUtcDateTimeOffset(timezone.Hours);
|
||||
query = query.Where(m => m.Date >= beginUtc);
|
||||
}
|
||||
|
||||
if (end != default)
|
||||
query = query.Where(m => m.Date <= end);
|
||||
{
|
||||
var endUtc = end.ToUtcDateTimeOffset(timezone.Hours);
|
||||
query = query.Where(m => m.Date <= endUtc);
|
||||
}
|
||||
|
||||
var result = new PaginationContainer<MessageDto>
|
||||
{
|
||||
@ -106,11 +103,12 @@ namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
var messageDto = new MessageDto
|
||||
{
|
||||
Date = message.Date,
|
||||
Id = message.Id,
|
||||
WellDepth = message.WellDepth
|
||||
};
|
||||
|
||||
messageDto.Date = message.Date.ToRemoteDateTime(timezone.Hours);
|
||||
|
||||
if (message.IdTelemetryUser is not null)
|
||||
{
|
||||
if (users.Any())
|
||||
@ -131,24 +129,10 @@ namespace AsbCloudInfrastructure.Services
|
||||
|
||||
result.Items.Add(messageDto);
|
||||
}
|
||||
|
||||
if (isUtc && timeOffset is not null)
|
||||
return result;
|
||||
|
||||
result.Items = result.Items.Select(m =>
|
||||
{
|
||||
m.Date = telemetryService.TimeZoneService.DateToTimeZone( m.Date, timeOffset ?? default);
|
||||
return m;
|
||||
}).ToList();
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
[Obsolete("Use telemetryService.GetDatesRangeAsync instead", false)]
|
||||
public Task<DatesRangeDto> GetMessagesDatesRangeAsync(int idWell, bool isUtc,
|
||||
CancellationToken token = default)
|
||||
=> telemetryService.GetDatesRangeAsync(idWell, isUtc, token);
|
||||
|
||||
public Task InsertAsync(string uid, IEnumerable<TelemetryMessageDto> dtos,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
@ -156,15 +140,18 @@ namespace AsbCloudInfrastructure.Services
|
||||
return null;
|
||||
|
||||
var telemetryId = telemetryService.GetOrCreateTelemetryIdByUid(uid);
|
||||
var timezone = telemetryService.GetTimezone(telemetryId);
|
||||
|
||||
var maxDateDto = dtos.Max(m => m.Date);
|
||||
var maxDateDto = dtos.Max(m => m.Date);
|
||||
var maxDateUtc = maxDateDto.ToUtcDateTimeOffset(timezone.Hours);
|
||||
telemetryService.SaveRequestDate(uid, maxDateDto);
|
||||
|
||||
foreach (var dto in dtos)
|
||||
{
|
||||
var entity = dto.Adapt<TelemetryMessage>();
|
||||
var entity = dto.Adapt<TelemetryMessage>();
|
||||
entity.Id = 0;
|
||||
entity.IdTelemetry = telemetryId;
|
||||
entity.Date = dto.Date.ToUtcDateTimeOffset(timezone.Hours);
|
||||
db.TelemetryMessages.Add(entity);
|
||||
}
|
||||
|
||||
|
@ -19,17 +19,17 @@ namespace AsbCloudInfrastructure.Services
|
||||
private readonly IAsbCloudDbContext db;
|
||||
private readonly string connectionString;
|
||||
private readonly ITelemetryService telemetryService;
|
||||
//private readonly IFileService fileService;
|
||||
private readonly IReportsBackgroundQueue queue;
|
||||
private readonly IWellService wellService;
|
||||
|
||||
public ReportService(IAsbCloudDbContext db, IConfiguration configuration,
|
||||
ITelemetryService telemetryService,
|
||||
IReportsBackgroundQueue queue)
|
||||
IReportsBackgroundQueue queue, IWellService wellService)
|
||||
{
|
||||
this.db = db;
|
||||
this.connectionString = configuration.GetConnectionString("DefaultConnection");
|
||||
this.wellService = wellService;
|
||||
this.telemetryService = telemetryService;
|
||||
//this.fileService = fileService;
|
||||
this.queue = queue;
|
||||
ReportCategoryId = db.FileCategories.AsNoTracking()
|
||||
.FirstOrDefault(c =>
|
||||
@ -41,6 +41,12 @@ namespace AsbCloudInfrastructure.Services
|
||||
public int CreateReport(int idWell, int idUser, int stepSeconds, int format, DateTime begin,
|
||||
DateTime end, Action<object, int> progressHandler)
|
||||
{
|
||||
var timezoneOffset = wellService.GetTimezone(idWell).Hours;
|
||||
var beginUtc = begin.ToUtcDateTimeOffset(timezoneOffset);
|
||||
var endUtc = end.ToUtcDateTimeOffset(timezoneOffset);
|
||||
var beginRemote = begin.ToTimeZoneOffsetHours(timezoneOffset);
|
||||
var endRemote = end.ToTimeZoneOffsetHours(timezoneOffset);
|
||||
|
||||
var newReportId = queue.EnqueueTask((id) =>
|
||||
{
|
||||
var optionsBuilder = new DbContextOptionsBuilder<AsbCloudDbContext>();
|
||||
@ -49,7 +55,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
|
||||
using var context = new AsbCloudDbContext(optionsBuilder.Options);
|
||||
|
||||
var generator = GetReportGenerator(idWell, begin, end, stepSeconds, format, context);
|
||||
var generator = GetReportGenerator(idWell, beginRemote, endRemote, stepSeconds, format, context);
|
||||
var reportFileName = Path.Combine(tempDir, generator.GetReportDefaultFileName());
|
||||
var totalPages = generator.GetPagesCount();
|
||||
|
||||
@ -58,7 +64,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
progressHandler.Invoke(e.Adapt<ReportProgressDto>(), id);
|
||||
};
|
||||
generator.Make(reportFileName);
|
||||
|
||||
|
||||
var fileService = new FileService(context);
|
||||
var fileInfo = fileService.MoveAsync(idWell, idUser, ReportCategoryId, reportFileName, reportFileName).Result;
|
||||
|
||||
@ -75,8 +81,8 @@ namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
IdWell = idWell,
|
||||
IdFile = fileInfo.Id,
|
||||
Begin = begin,
|
||||
End = end,
|
||||
Begin = beginUtc,
|
||||
End = endUtc,
|
||||
Step = stepSeconds,
|
||||
Format = format
|
||||
};
|
||||
@ -93,77 +99,56 @@ namespace AsbCloudInfrastructure.Services
|
||||
|
||||
public int GetReportPagesCount(int idWell, DateTime begin, DateTime end, int stepSeconds, int format)
|
||||
{
|
||||
var generator = GetReportGenerator(idWell, begin, end, stepSeconds, format, (AsbCloudDbContext)db);
|
||||
return generator.GetPagesCount();
|
||||
var timezoneOffset = wellService.GetTimezone(idWell).Hours;
|
||||
var beginRemote = begin.ToTimeZoneOffsetHours(timezoneOffset);
|
||||
var endRemote = end.ToTimeZoneOffsetHours(timezoneOffset);
|
||||
|
||||
var generator = GetReportGenerator(idWell, beginRemote, endRemote, stepSeconds, format, (AsbCloudDbContext)db);
|
||||
var pagesCount = generator.GetPagesCount();
|
||||
return pagesCount;
|
||||
}
|
||||
|
||||
public async Task<DatesRangeDto> GetReportsDatesRangeAsync(int idWell, bool isUtc,
|
||||
CancellationToken token = default)
|
||||
public DatesRangeDto GetDatesRangeOrDefault(int idWell)
|
||||
{
|
||||
var telemetryId = telemetryService.GetIdTelemetryByIdWell(idWell);
|
||||
|
||||
if (telemetryId is null)
|
||||
var idTelemetry = telemetryService.GetIdTelemetryByIdWell(idWell);
|
||||
if(idTelemetry is null)
|
||||
return null;
|
||||
|
||||
var datesRange = await (from d in db.TelemetryDataSaub
|
||||
where d.IdTelemetry == telemetryId
|
||||
select d.Date).Union(
|
||||
from m in db.TelemetryMessages
|
||||
where m.IdTelemetry == telemetryId
|
||||
select m.Date).DefaultIfEmpty()
|
||||
.GroupBy(g => true)
|
||||
.AsNoTracking()
|
||||
.Select(g => new
|
||||
{
|
||||
From = g.Min(),
|
||||
To = g.Max()
|
||||
}).OrderBy(gr => gr.From)
|
||||
.FirstOrDefaultAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var result = new DatesRangeDto
|
||||
{
|
||||
From = datesRange.From,
|
||||
To = datesRange.To.Year == 1 ? DateTime.MaxValue : datesRange.To
|
||||
};
|
||||
|
||||
if (isUtc)
|
||||
return result;
|
||||
|
||||
result = await telemetryService.DatesRangeToTelemetryTimeZoneAsync((int)telemetryId, result, token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return result;
|
||||
var range = telemetryService.GetDatesRange((int)idTelemetry);
|
||||
return range;
|
||||
}
|
||||
|
||||
public Task<List<ReportPropertiesDto>> GetAllReportsByWellAsync(int idWell, CancellationToken token) =>
|
||||
(from r in db.ReportProperties.Include(r => r.File)
|
||||
where r.IdWell == idWell
|
||||
select new ReportPropertiesDto
|
||||
{
|
||||
Id = r.Id,
|
||||
Name = r.File.Name,
|
||||
File = new FileInfoDto
|
||||
{
|
||||
Id = r.File.Id,
|
||||
Author = null,
|
||||
IdAuthor = r.File.IdAuthor ?? 0,
|
||||
IdCategory = r.File.IdCategory,
|
||||
IdWell = r.File.IdWell,
|
||||
Name = r.File.Name,
|
||||
Size = r.File.Size,
|
||||
UploadDate = r.File.UploadDate,
|
||||
},
|
||||
IdWell = r.IdWell,
|
||||
Date = r.File.UploadDate,
|
||||
Begin = r.Begin,
|
||||
End = r.End,
|
||||
Step = r.Step,
|
||||
Format = r.Format == 0 ? ".pdf" : ".las"
|
||||
})
|
||||
.OrderBy(o => o.Date)
|
||||
public async Task<IEnumerable<ReportPropertiesDto>> GetAllReportsByWellAsync(int idWell, CancellationToken token)
|
||||
{
|
||||
var timezoneOffset = wellService.GetTimezone(idWell).Hours;
|
||||
var propertiesQuery = db.ReportProperties.Include(r => r.File)
|
||||
.Where(p => p.IdWell == idWell)
|
||||
.OrderBy(o => o.File.UploadDate)
|
||||
.AsNoTracking()
|
||||
.Take(1024).ToListAsync(token);
|
||||
.Take(1024);
|
||||
var properties = await propertiesQuery.ToListAsync(token);
|
||||
return properties.Select(p => new ReportPropertiesDto
|
||||
{
|
||||
Id = p.Id,
|
||||
Name = p.File.Name,
|
||||
File = new FileInfoDto
|
||||
{
|
||||
Id = p.File.Id,
|
||||
Author = null,
|
||||
IdAuthor = p.File.IdAuthor ?? 0,
|
||||
IdCategory = p.File.IdCategory,
|
||||
IdWell = p.File.IdWell,
|
||||
Name = p.File.Name,
|
||||
Size = p.File.Size,
|
||||
UploadDate = p.File.UploadDate.ToRemoteDateTime(timezoneOffset),
|
||||
},
|
||||
IdWell = p.IdWell,
|
||||
Date = p.File.UploadDate.ToRemoteDateTime(timezoneOffset),
|
||||
Begin = p.Begin.ToRemoteDateTime(timezoneOffset),
|
||||
End = p.End.ToRemoteDateTime(timezoneOffset),
|
||||
Step = p.Step,
|
||||
Format = p.Format == 0 ? ".pdf" : ".las"
|
||||
});
|
||||
}
|
||||
|
||||
private static IReportGenerator GetReportGenerator(int idWell, DateTime begin,
|
||||
DateTime end, int stepSeconds, int format, AsbCloudDbContext context)
|
||||
|
@ -13,7 +13,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
public abstract class TelemetryDataBaseService<TDto, TModel> : ITelemetryDataService<TDto>, IConverter<TDto, TModel>
|
||||
public abstract class TelemetryDataBaseService<TDto, TModel> : ITelemetryDataService<TDto>
|
||||
where TDto : AsbCloudApp.Data.ITelemetryData
|
||||
where TModel : class, AsbCloudDb.Model.ITelemetryData
|
||||
{
|
||||
@ -40,8 +40,6 @@ namespace AsbCloudInfrastructure.Services
|
||||
if (dtos == default || !dtos.Any())
|
||||
return 0;
|
||||
|
||||
var idTelemetry = telemetryService.GetOrCreateTelemetryIdByUid(uid);
|
||||
var lastTelemetryDate = telemetryService.GetLastTelemetryDate(uid);
|
||||
var dtosList = dtos.OrderBy(d => d.Date).ToList();
|
||||
|
||||
var dtoMinDate = dtosList.First().Date;
|
||||
@ -56,15 +54,14 @@ namespace AsbCloudInfrastructure.Services
|
||||
foreach (var duplicate in duplicates)
|
||||
dtosList.Remove(duplicate);
|
||||
}
|
||||
|
||||
var offsetHours = await telemetryService.GetTelemetryTimeZoneOffsetAsync(idTelemetry, token);
|
||||
|
||||
var entities = dtosList.Select(d => {
|
||||
var e = Convert(d);
|
||||
e.IdTelemetry = idTelemetry;
|
||||
if(offsetHours is not null)
|
||||
e.Date = telemetryService.TimeZoneService.DateToUtc(d.Date, (double)offsetHours);
|
||||
return e;
|
||||
var idTelemetry = telemetryService.GetOrCreateTelemetryIdByUid(uid);
|
||||
var timezone = telemetryService.GetTimezone(idTelemetry);
|
||||
|
||||
var entities = dtosList.Select(dto => {
|
||||
var entity = Convert(dto, timezone.Hours);
|
||||
entity.IdTelemetry = idTelemetry;
|
||||
return entity;
|
||||
});
|
||||
|
||||
var entityMaxDate = entities.Max(e => e.Date);
|
||||
@ -79,7 +76,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
catch(Exception ex)
|
||||
{
|
||||
stopwatch.Stop();
|
||||
Trace.WriteLine($"Fail to save data telemerty " +
|
||||
Trace.WriteLine($"Fail to save data telemetry " +
|
||||
$"uid: {uid}, " +
|
||||
$"idTelemetry {idTelemetry}, " +
|
||||
$"count: {entities.Count()}, " +
|
||||
@ -92,7 +89,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
|
||||
public virtual async Task<IEnumerable<TDto>> GetAsync(int idWell,
|
||||
DateTime dateBegin = default, double intervalSec = 600d,
|
||||
int approxPointsCount = 1024, bool isUtc = false, CancellationToken token = default)
|
||||
int approxPointsCount = 1024, CancellationToken token = default)
|
||||
{
|
||||
var well = cacheWells.FirstOrDefault(w => w.Id == idWell);
|
||||
if (well?.IdTelemetry is null)
|
||||
@ -100,35 +97,33 @@ namespace AsbCloudInfrastructure.Services
|
||||
|
||||
var idTelemetry = well?.IdTelemetry ?? default;
|
||||
|
||||
var timezone = telemetryService.GetTimezone(idTelemetry);
|
||||
|
||||
var filterByDateEnd = dateBegin != default;
|
||||
DateTimeOffset dateBeginUtc;
|
||||
if (dateBegin == default)
|
||||
{
|
||||
dateBegin = telemetryService.GetLastTelemetryDate(idTelemetry);
|
||||
if (dateBegin != default)
|
||||
dateBegin = dateBegin.AddSeconds(-intervalSec);
|
||||
}
|
||||
dateBeginUtc = telemetryService.GetLastTelemetryDate(idTelemetry, true);
|
||||
if (dateBeginUtc != default)
|
||||
dateBeginUtc = dateBeginUtc.AddSeconds(-intervalSec);
|
||||
}
|
||||
else
|
||||
{
|
||||
dateBeginUtc = dateBegin.ToUtcDateTimeOffset(timezone.Hours);
|
||||
}
|
||||
|
||||
if (dateBegin == default)
|
||||
dateBegin = DateTime.Now.AddSeconds(-intervalSec);
|
||||
if (dateBeginUtc == default)
|
||||
dateBeginUtc = DateTime.UtcNow.AddSeconds(-intervalSec);
|
||||
|
||||
if (dateBegin.Kind == DateTimeKind.Unspecified)
|
||||
dateBegin = DateTime.SpecifyKind(dateBegin, DateTimeKind.Utc);
|
||||
|
||||
var timeOffset = await telemetryService.GetTelemetryTimeZoneOffsetAsync(idTelemetry, token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if(timeOffset is not null)
|
||||
dateBegin = telemetryService.TimeZoneService.DateToUtc(dateBegin, timeOffset?? default);
|
||||
|
||||
var dateEnd = dateBegin.AddSeconds(intervalSec);
|
||||
var dateEnd = dateBeginUtc.AddSeconds(intervalSec);
|
||||
var dbSet = db.Set<TModel>();
|
||||
|
||||
var query = dbSet
|
||||
.Where(d => d.IdTelemetry == idTelemetry
|
||||
&& d.Date >= dateBegin);
|
||||
&& d.Date >= dateBeginUtc);
|
||||
|
||||
if (filterByDateEnd)
|
||||
query = query.Where(d => d.Date < dateEnd);
|
||||
query = query.Where(d => d.Date <= dateEnd);
|
||||
|
||||
var fullDataCount = await query.CountAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
@ -168,30 +163,31 @@ namespace AsbCloudInfrastructure.Services
|
||||
.ToListAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var dtos = entities.Select(e => Convert(e));
|
||||
|
||||
if (isUtc)
|
||||
return dtos;
|
||||
|
||||
if (timeOffset is null)
|
||||
return dtos;
|
||||
|
||||
dtos = dtos.Select(d =>
|
||||
{
|
||||
d.Date = telemetryService.TimeZoneService.DateToTimeZone(d.Date, timeOffset ?? default);
|
||||
return d;
|
||||
});
|
||||
|
||||
var dtos = entities.Select(e => Convert(e, timezone.Hours));
|
||||
|
||||
return dtos;
|
||||
}
|
||||
|
||||
[Obsolete("Use telemetryService.GetDatesRangeAsync instead", false)]
|
||||
public virtual Task<DatesRangeDto> GetDataDatesRangeAsync(int idWell, bool isUtc,
|
||||
CancellationToken token = default)
|
||||
=> telemetryService.GetDatesRangeAsync(idWell, isUtc, token);
|
||||
public abstract TDto Convert(TModel src, double timezoneOffset);
|
||||
|
||||
public abstract TDto Convert(TModel src);
|
||||
public abstract TModel Convert(TDto src, double timezoneOffset);
|
||||
|
||||
public abstract TModel Convert(TDto src);
|
||||
private static double AssumeTimezoneOffset(DateTime nearToCurrentDate)
|
||||
{
|
||||
var offset = 5d;
|
||||
if (nearToCurrentDate.Kind == DateTimeKind.Unspecified)
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
var minutes = 60 * (now.Hour - nearToCurrentDate.Hour) + now.Minute - nearToCurrentDate.Minute;
|
||||
var minutesPositive = (1440_0000 + minutes) % 1440; //60*24
|
||||
var halfsHours = Math.Round(1d * minutesPositive / 30d); // quarters are ignored
|
||||
var hours = halfsHours / 2;
|
||||
offset = hours < 12 ? hours : 24 - hours;
|
||||
}
|
||||
if (nearToCurrentDate.Kind == DateTimeKind.Local)
|
||||
offset = TimeZoneInfo.Local.BaseUtcOffset.TotalHours;
|
||||
|
||||
return offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,21 +15,23 @@ namespace AsbCloudInfrastructure.Services
|
||||
:base(db, telemetryService, cacheDb)
|
||||
{}
|
||||
|
||||
public override TelemetryDataSaub Convert(TelemetryDataSaubDto src)
|
||||
public override TelemetryDataSaub Convert(TelemetryDataSaubDto src, double timezoneOffset)
|
||||
{
|
||||
var entity = src.Adapt<TelemetryDataSaub>();
|
||||
var telemetryUser = cacheTelemetryUsers?
|
||||
.FirstOrDefault(u => u.IdTelemetry == src.IdTelemetry && (u.Name == src.User || u.Surname == src.User));
|
||||
entity.IdUser = telemetryUser?.IdUser;
|
||||
entity.Date = src.Date.ToUtcDateTimeOffset(timezoneOffset);
|
||||
return entity;
|
||||
}
|
||||
|
||||
public override TelemetryDataSaubDto Convert(TelemetryDataSaub src)
|
||||
public override TelemetryDataSaubDto Convert(TelemetryDataSaub src, double timezoneOffset)
|
||||
{
|
||||
var dto = src.Adapt<TelemetryDataSaubDto>();
|
||||
var telemetryUser = cacheTelemetryUsers?
|
||||
.FirstOrDefault(u => u.IdTelemetry == src.IdTelemetry && u.IdUser == src.IdUser);
|
||||
dto.User = telemetryUser?.MakeDisplayName();
|
||||
dto.Date = src.Date.ToRemoteDateTime(timezoneOffset);
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
|
@ -15,15 +15,17 @@ namespace AsbCloudInfrastructure.Services
|
||||
: base(db, telemetryService, cacheDb)
|
||||
{ }
|
||||
|
||||
public override TelemetryDataSpin Convert(TelemetryDataSpinDto src)
|
||||
public override TelemetryDataSpin Convert(TelemetryDataSpinDto src, double timezoneOffset)
|
||||
{
|
||||
var entity = src.Adapt<TelemetryDataSpin>();
|
||||
entity.Date = src.Date.ToUtcDateTimeOffset(timezoneOffset);
|
||||
return entity;
|
||||
}
|
||||
|
||||
public override TelemetryDataSpinDto Convert(TelemetryDataSpin src)
|
||||
public override TelemetryDataSpinDto Convert(TelemetryDataSpin src, double timezoneOffset)
|
||||
{
|
||||
var dto = src.Adapt<TelemetryDataSpinDto>();
|
||||
dto.Date = src.Date.ToRemoteDateTime(timezoneOffset);
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
|
@ -16,18 +16,18 @@ namespace AsbCloudInfrastructure.Services
|
||||
public class TelemetryService : ITelemetryService
|
||||
{
|
||||
private readonly CacheTable<Telemetry> cacheTelemetry;
|
||||
private readonly CacheTable<Well> cacheWells;//TODO: use wellService insad of this
|
||||
private readonly CacheTable<Well> cacheWells;//TODO: use wellService instead of this
|
||||
private readonly IAsbCloudDbContext db;
|
||||
private readonly ITelemetryTracker telemetryTracker;
|
||||
private readonly ITimeZoneService timeZoneService;
|
||||
private readonly ITimezoneService timezoneService;
|
||||
|
||||
public ITimeZoneService TimeZoneService => timeZoneService;
|
||||
public ITimezoneService TimeZoneService => timezoneService;
|
||||
public ITelemetryTracker TelemetryTracker => telemetryTracker;
|
||||
|
||||
public TelemetryService(
|
||||
IAsbCloudDbContext db,
|
||||
ITelemetryTracker telemetryTracker,
|
||||
ITimeZoneService timeZoneService,
|
||||
ITimezoneService timezoneService,
|
||||
CacheDb cacheDb)
|
||||
{
|
||||
cacheTelemetry = cacheDb.GetCachedTable<Telemetry>((AsbCloudDbContext)db);
|
||||
@ -39,7 +39,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
nameof(Well.WellType));
|
||||
this.db = db;
|
||||
this.telemetryTracker = telemetryTracker;
|
||||
this.timeZoneService = timeZoneService;
|
||||
this.timezoneService = timezoneService;
|
||||
}
|
||||
|
||||
public IEnumerable<TelemetryDto> GetTransmittingTelemetries()
|
||||
@ -55,48 +55,43 @@ namespace AsbCloudInfrastructure.Services
|
||||
return telemetryDtos;
|
||||
}
|
||||
|
||||
public void SaveRequestDate(string uid, DateTime remoteDate) =>
|
||||
public void SaveRequestDate(string uid, DateTimeOffset remoteDate) =>
|
||||
telemetryTracker.SaveRequestDate(uid, remoteDate);
|
||||
|
||||
public DateTime GetLastTelemetryDate(string telemetryUid) =>
|
||||
telemetryTracker.GetLastTelemetryDateByUid(telemetryUid);
|
||||
|
||||
public DateTime GetLastTelemetryDate(int telemetryId)
|
||||
public DateTime GetLastTelemetryDate(int idTelemetry, bool useUtc = false)
|
||||
{
|
||||
var lastTelemetryDate = DateTime.MinValue;
|
||||
var telemetry = cacheTelemetry.FirstOrDefault(t => t.Id == telemetryId);
|
||||
var lastTelemetryDate = DateTimeOffset.MinValue;
|
||||
var telemetry = cacheTelemetry.FirstOrDefault(t => t.Id == idTelemetry);
|
||||
|
||||
if (telemetry is null)
|
||||
return lastTelemetryDate;
|
||||
throw new Exception($"Telemetry id:{idTelemetry} does not exist");
|
||||
|
||||
var uid = telemetry.RemoteUid;
|
||||
var timzone = GetTimezone(idTelemetry);
|
||||
|
||||
lastTelemetryDate = GetLastTelemetryDate(uid);
|
||||
return lastTelemetryDate;
|
||||
lastTelemetryDate = telemetryTracker.GetLastTelemetryDateByUid(uid);
|
||||
|
||||
if (useUtc)
|
||||
return lastTelemetryDate.UtcDateTime;
|
||||
|
||||
return lastTelemetryDate.ToRemoteDateTime(timzone.Hours);
|
||||
}
|
||||
|
||||
public virtual async Task<DatesRangeDto> GetDatesRangeAsync(
|
||||
int idWell,
|
||||
bool isUtc,
|
||||
CancellationToken token = default)
|
||||
public DatesRangeDto GetDatesRange(int idTelemetry)
|
||||
{
|
||||
var telemetryId = GetIdTelemetryByIdWell(idWell);
|
||||
if (telemetryId is null)
|
||||
return null;
|
||||
|
||||
var telemetry = await cacheTelemetry.FirstOrDefaultAsync(t => t.Id == telemetryId, token)
|
||||
.ConfigureAwait(false);
|
||||
var telemetry = cacheTelemetry.FirstOrDefault(t => t.Id == idTelemetry);
|
||||
if (telemetry is null)
|
||||
throw new Exception($"Telemetry id:{idTelemetry} does not exist");
|
||||
|
||||
var dto = TelemetryTracker.GetTelemetryDateRangeByUid(telemetry.RemoteUid);
|
||||
if (dto is null)
|
||||
throw new Exception($"Telemetry id:{idTelemetry} has no data");
|
||||
|
||||
if (isUtc)
|
||||
return dto;
|
||||
|
||||
dto = await DatesRangeToTelemetryTimeZoneAsync((int)telemetryId, dto, token)
|
||||
.ConfigureAwait(false);
|
||||
var timezone = GetTimezone((int)idTelemetry);
|
||||
dto.From = dto.From.ToTimeZoneOffsetHours(timezone.Hours);
|
||||
dto.To = dto.To.ToTimeZoneOffsetHours(timezone.Hours);
|
||||
|
||||
return dto;
|
||||
|
||||
}
|
||||
|
||||
public int GetOrCreateTelemetryIdByUid(string uid)
|
||||
@ -105,9 +100,6 @@ namespace AsbCloudInfrastructure.Services
|
||||
public int? GetIdWellByTelemetryUid(string uid)
|
||||
=> GetWellByTelemetryUid(uid)?.Id;
|
||||
|
||||
public double GetTimezoneOffsetByTelemetryId(int idTelemetry) =>
|
||||
cacheTelemetry.FirstOrDefault(t => t.Id == idTelemetry).Info?.TimeZoneOffsetTotalHours ?? 0d;
|
||||
|
||||
public async Task UpdateInfoAsync(string uid, TelemetryInfoDto info,
|
||||
CancellationToken token)
|
||||
{
|
||||
@ -115,8 +107,8 @@ namespace AsbCloudInfrastructure.Services
|
||||
telemetry.Info = info.Adapt<TelemetryInfo>();
|
||||
|
||||
if (!string.IsNullOrEmpty(info.TimeZoneId) &&
|
||||
telemetry.TelemetryTimeZone?.IsOverride != true)
|
||||
telemetry.TelemetryTimeZone = new TelemetryTimeZone()
|
||||
telemetry.TimeZone?.IsOverride != true)
|
||||
telemetry.TimeZone = new SimpleTimezone()
|
||||
{
|
||||
Hours = info.TimeZoneOffsetTotalHours,
|
||||
TimeZoneId = info.TimeZoneId
|
||||
@ -126,71 +118,44 @@ namespace AsbCloudInfrastructure.Services
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<double?> GetTelemetryTimeZoneOffsetAsync(int idTelemetry, CancellationToken token)
|
||||
public SimpleTimezoneDto GetTimezone(int idTelemetry)
|
||||
{
|
||||
var telemetry =
|
||||
await cacheTelemetry.FirstOrDefaultAsync(t => t.Id == idTelemetry, token);
|
||||
var telemetry = cacheTelemetry.FirstOrDefault(t => t.Id == idTelemetry);
|
||||
|
||||
if (!string.IsNullOrEmpty(telemetry.TelemetryTimeZone?.TimeZoneId))
|
||||
return telemetry.TelemetryTimeZone.Hours;
|
||||
if (telemetry is null)
|
||||
throw new Exception($"Telemetry id: {idTelemetry} does not exist.");
|
||||
|
||||
if (!string.IsNullOrEmpty(telemetry.Info?.TimeZoneId))
|
||||
if (telemetry.TimeZone is not null)
|
||||
return telemetry.TimeZone.Adapt<SimpleTimezoneDto>();
|
||||
|
||||
if (telemetry.Info is not null)
|
||||
{
|
||||
telemetry.TelemetryTimeZone = new TelemetryTimeZone
|
||||
telemetry.TimeZone = new SimpleTimezone
|
||||
{
|
||||
Hours = telemetry.Info.TimeZoneOffsetTotalHours,
|
||||
IsOverride = false,
|
||||
TimeZoneId = telemetry.Info.TimeZoneId,
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
var well = await cacheWells.FirstOrDefaultAsync(t => t.IdTelemetry == telemetry.Id, token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (well is null)
|
||||
return null;
|
||||
|
||||
var coordinates = await GetWellCoordinatesAsync(well.Id, token);
|
||||
|
||||
if (coordinates is null)
|
||||
return null;
|
||||
|
||||
var requestedTimeZone = await timeZoneService.GetByCoordinatesAsync(coordinates.Value.latitude, coordinates.Value.longitude, token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (requestedTimeZone is null)
|
||||
return null;
|
||||
|
||||
telemetry.TelemetryTimeZone = requestedTimeZone.Adapt<TelemetryTimeZone>();
|
||||
cacheTelemetry.Upsert(telemetry);
|
||||
return telemetry.TimeZone.Adapt<SimpleTimezoneDto>();
|
||||
}
|
||||
|
||||
await cacheTelemetry.UpsertAsync(telemetry, token).ConfigureAwait(false);
|
||||
|
||||
return telemetry.TelemetryTimeZone.Hours;
|
||||
}
|
||||
|
||||
public async Task<DatesRangeDto> DatesRangeToTelemetryTimeZoneAsync(int idTelemetry, DatesRangeDto range,
|
||||
CancellationToken token)
|
||||
{
|
||||
var offset = await GetTelemetryTimeZoneOffsetAsync(idTelemetry, token);
|
||||
|
||||
if (offset is null)
|
||||
return range;
|
||||
|
||||
return new DatesRangeDto()
|
||||
if (telemetry.Well?.Timezone is not null)
|
||||
{
|
||||
From = timeZoneService.DateToTimeZone(range.From, offset ?? default),
|
||||
To = timeZoneService.DateToTimeZone(range.To, offset ?? default),
|
||||
};
|
||||
telemetry.TimeZone = telemetry.Well.Timezone;
|
||||
cacheTelemetry.Upsert(telemetry);
|
||||
return telemetry.TimeZone.Adapt<SimpleTimezoneDto>();
|
||||
}
|
||||
|
||||
throw new Exception($"Telemetry id: {idTelemetry} can't find timezone.");
|
||||
}
|
||||
|
||||
public async Task UpdateTimeZoneAsync(string uid, TelemetryTimeZoneDto timeZoneInfo,
|
||||
public async Task UpdateTimezoneAsync(string uid, SimpleTimezoneDto timeone,
|
||||
CancellationToken token)
|
||||
{
|
||||
var telemetry = GetOrCreateTelemetryByUid(uid);
|
||||
var newTelemetryTimeZone = timeZoneInfo.Adapt<TelemetryTimeZone>();
|
||||
if (newTelemetryTimeZone?.Equals(telemetry.TelemetryTimeZone) == true)
|
||||
var newTelemetryTimeZone = timeone.Adapt<SimpleTimezone>();
|
||||
if (newTelemetryTimeZone?.Equals(telemetry.TimeZone) == true)
|
||||
return;
|
||||
await cacheTelemetry.UpsertAsync(telemetry, token)
|
||||
.ConfigureAwait(false);
|
||||
@ -202,40 +167,27 @@ namespace AsbCloudInfrastructure.Services
|
||||
return well?.IdTelemetry;
|
||||
}
|
||||
|
||||
private async Task<(double latitude, double longitude)?> GetWellCoordinatesAsync(int idWell,
|
||||
CancellationToken token)
|
||||
{
|
||||
var well = await cacheWells.FirstOrDefaultAsync(w => w.Id == idWell, token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (well is null)
|
||||
return null;
|
||||
|
||||
var latitude = well.Latitude ??
|
||||
well.Cluster?.Latitude ??
|
||||
well.Cluster?.Deposit?.Latitude;
|
||||
|
||||
var longitude = well.Longitude ??
|
||||
well.Cluster?.Longitude ??
|
||||
well.Cluster?.Deposit?.Longitude;
|
||||
|
||||
if (latitude is not null && longitude is not null)
|
||||
return ((double)latitude, (double)longitude);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private Well GetWellByTelemetryUid(string uid)
|
||||
{
|
||||
var tele = cacheTelemetry.FirstOrDefault(t => t.RemoteUid == uid);
|
||||
if (tele is null)
|
||||
return null;
|
||||
|
||||
return cacheWells.FirstOrDefault(w => w?.IdTelemetry == tele.Id);
|
||||
var well = cacheWells.FirstOrDefault(w => w?.IdTelemetry == tele.Id);
|
||||
return well;
|
||||
}
|
||||
|
||||
private Telemetry GetOrCreateTelemetryByUid(string uid)
|
||||
=> cacheTelemetry.GetOrCreate(t => t.RemoteUid == uid, () => new Telemetry { RemoteUid = uid });
|
||||
=> cacheTelemetry.GetOrCreate(t => t.RemoteUid == uid, () => new Telemetry
|
||||
{
|
||||
RemoteUid = uid,
|
||||
TimeZone = new SimpleTimezone
|
||||
{
|
||||
Hours = 5,
|
||||
IsOverride = false,
|
||||
TimeZoneId = "default",
|
||||
}
|
||||
});
|
||||
|
||||
public async Task<int> MergeAsync(int from, int to, CancellationToken token)
|
||||
{
|
||||
@ -275,7 +227,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
await transaction.CommitAsync(token).ConfigureAwait(false);
|
||||
|
||||
stopwath.Stop();
|
||||
Console.WriteLine($"Successfully commited in {1d * stopwath.ElapsedMilliseconds / 1000d: #0.00} sec. Affected {affected} rows.");
|
||||
Console.WriteLine($"Successfully committed in {1d * stopwath.ElapsedMilliseconds / 1000d: #0.00} sec. Affected {affected} rows.");
|
||||
return affected;
|
||||
}
|
||||
catch(Exception ex)
|
||||
|
@ -23,17 +23,17 @@ namespace AsbCloudInfrastructure.Services
|
||||
/// <summary>
|
||||
/// Время последнего запроса (по времени сервера)
|
||||
/// </summary>
|
||||
public DateTime LastTimeServer { get; set; }
|
||||
public DateTimeOffset LastTimeServer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дата первых данных в БД
|
||||
/// </summary>
|
||||
public DateTime TelemetryDateMin { get; set; }
|
||||
public DateTimeOffset TelemetryDateUtcMin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дата последних данных в БД
|
||||
/// </summary>
|
||||
public DateTime TelemetryDateMax { get; set; }
|
||||
public DateTimeOffset TelemetryDateUtcMax { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@ -56,8 +56,8 @@ namespace AsbCloudInfrastructure.Services
|
||||
keyValuePairs[telemetry.RemoteUid] = new TrackerStat
|
||||
{
|
||||
RemoteUid = telemetry.RemoteUid,
|
||||
TelemetryDateMin = date,
|
||||
TelemetryDateMax = date,
|
||||
TelemetryDateUtcMin = date,
|
||||
TelemetryDateUtcMax = date,
|
||||
LastTimeServer = date,
|
||||
};
|
||||
}
|
||||
@ -88,15 +88,9 @@ namespace AsbCloudInfrastructure.Services
|
||||
foreach (var oldReq in oldRequests)
|
||||
{
|
||||
var telemetryStat = telemetriesStats.GetOrAdd(oldReq.Uid, (uid) => new TrackerStat { RemoteUid = uid });
|
||||
var dateMin = oldReq.DateMin.Kind == DateTimeKind.Local
|
||||
? oldReq.DateMin.ToUniversalTime()
|
||||
: oldReq.DateMin;
|
||||
var dateMax = oldReq.DateMax.Kind == DateTimeKind.Local
|
||||
? oldReq.DateMax.ToUniversalTime()
|
||||
: oldReq.DateMax;
|
||||
telemetryStat.TelemetryDateMin = dateMin;
|
||||
telemetryStat.TelemetryDateMax = dateMax;
|
||||
telemetryStat.LastTimeServer = dateMax;
|
||||
telemetryStat.TelemetryDateUtcMin = oldReq.DateMin;
|
||||
telemetryStat.TelemetryDateUtcMax = oldReq.DateMax;
|
||||
telemetryStat.LastTimeServer = oldReq.DateMax;
|
||||
}
|
||||
}).ContinueWith((t) =>
|
||||
{
|
||||
@ -105,9 +99,9 @@ namespace AsbCloudInfrastructure.Services
|
||||
});
|
||||
}
|
||||
|
||||
private static DateTime ParseDateFromUidOrDefault(string remoteUid, DateTime defaultValue = default)
|
||||
private static DateTimeOffset ParseDateFromUidOrDefault(string remoteUid, DateTime defaultValue = default)
|
||||
{
|
||||
//eg: uid = 20211102_173407926
|
||||
//example: uid = 20211102_173407926
|
||||
if (string.IsNullOrEmpty(remoteUid) || (remoteUid.Length != 18))
|
||||
return defaultValue;
|
||||
|
||||
@ -120,30 +114,29 @@ namespace AsbCloudInfrastructure.Services
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public void SaveRequestDate(string uid, DateTime remoteDate)
|
||||
public void SaveRequestDate(string uid, DateTimeOffset remoteDate)
|
||||
{
|
||||
var stat = telemetriesStats.GetOrAdd(uid, _ => new TrackerStat {
|
||||
RemoteUid = uid,
|
||||
TelemetryDateMin = remoteDate}
|
||||
TelemetryDateUtcMin = remoteDate}
|
||||
);
|
||||
|
||||
stat.LastTimeServer = DateTime.Now;
|
||||
|
||||
if(stat.TelemetryDateMax.ToUniversalTime() < remoteDate.ToUniversalTime())
|
||||
stat.TelemetryDateMax = remoteDate;
|
||||
if(stat.TelemetryDateUtcMax.ToUniversalTime() < remoteDate.ToUniversalTime())
|
||||
stat.TelemetryDateUtcMax = remoteDate;
|
||||
}
|
||||
|
||||
public DateTime GetLastTelemetryDateByUid(string uid) =>
|
||||
telemetriesStats.GetValueOrDefault(uid)?.TelemetryDateMax ?? default;
|
||||
|
||||
public DateTimeOffset GetLastTelemetryDateByUid(string uid) =>
|
||||
telemetriesStats.GetValueOrDefault(uid)?.TelemetryDateUtcMax ?? default;
|
||||
|
||||
public DatesRangeDto GetTelemetryDateRangeByUid(string uid)
|
||||
{
|
||||
var stat = telemetriesStats.GetValueOrDefault(uid);
|
||||
var range = new DatesRangeDto
|
||||
{
|
||||
From = stat?.TelemetryDateMin ?? default,
|
||||
To = stat?.TelemetryDateMax ?? default,
|
||||
From = stat?.TelemetryDateUtcMin.UtcDateTime ?? default,
|
||||
To = stat?.TelemetryDateUtcMax.UtcDateTime ?? default,
|
||||
};
|
||||
return range;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ using System;
|
||||
|
||||
namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
public class TimeZoneService : ITimeZoneService
|
||||
public class TimezoneService : ITimezoneService
|
||||
{
|
||||
private class TimeZoneInfo
|
||||
{
|
||||
@ -25,16 +25,19 @@ namespace AsbCloudInfrastructure.Services
|
||||
public string Time { get; set; }
|
||||
}
|
||||
|
||||
private const string timeZoneApiUrl = "http://api.geonames.org/timezoneJSON";
|
||||
private const string timezoneApiUrl = "http://api.geonames.org/timezoneJSON";
|
||||
private const string timezoneApiUserName = "asbautodrilling";
|
||||
|
||||
public async Task<TelemetryTimeZoneDto> GetByCoordinatesAsync(double latitude, double longitude, CancellationToken token)
|
||||
public SimpleTimezoneDto GetByCoordinates(double latitude, double longitude)
|
||||
=> GetByCoordinatesAsync(latitude, longitude, default).Result;
|
||||
|
||||
public async Task<SimpleTimezoneDto> GetByCoordinatesAsync(double latitude, double longitude, CancellationToken token)
|
||||
{
|
||||
var lat = latitude.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
var lng = longitude.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
|
||||
var url =
|
||||
$"{timeZoneApiUrl}?lat={lat}&lng={lng}&username={timezoneApiUserName}";
|
||||
$"{timezoneApiUrl}?lat={lat}&lng={lng}&username={timezoneApiUserName}";
|
||||
|
||||
using var client = new HttpClient();
|
||||
|
||||
@ -51,42 +54,16 @@ namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
var timeZoneInfo = JsonSerializer.Deserialize<TimeZoneInfo>(responseJson, options);
|
||||
var timezoneInfo = JsonSerializer.Deserialize<TimeZoneInfo>(responseJson, options);
|
||||
|
||||
return new TelemetryTimeZoneDto
|
||||
return new SimpleTimezoneDto
|
||||
{
|
||||
Hours = timeZoneInfo.DstOffset,
|
||||
Hours = timezoneInfo.DstOffset,
|
||||
IsOverride = false,
|
||||
TimeZoneId = timeZoneInfo.TimezoneId,
|
||||
TimezoneId = timezoneInfo.TimezoneId,
|
||||
};
|
||||
}
|
||||
|
||||
public DateTime DateToUtc(DateTime date, double remoteTimezoneOffsetHours)
|
||||
{
|
||||
if (date == default)
|
||||
return new DateTime(0, DateTimeKind.Utc);
|
||||
|
||||
var newDate = date.Kind switch
|
||||
{
|
||||
DateTimeKind.Local => date.ToUniversalTime(),
|
||||
DateTimeKind.Unspecified => date.AddHours(-remoteTimezoneOffsetHours),
|
||||
_ => date,
|
||||
};
|
||||
return DateTime.SpecifyKind(newDate, DateTimeKind.Utc);
|
||||
}
|
||||
|
||||
public DateTime DateToTimeZone(DateTime date, double remoteTimezoneOffsetHours)
|
||||
{
|
||||
if (date == default)
|
||||
return new DateTime(0, DateTimeKind.Unspecified);
|
||||
|
||||
var newDate = date.Kind switch
|
||||
{
|
||||
DateTimeKind.Local => date.ToUniversalTime().AddHours(remoteTimezoneOffsetHours),
|
||||
DateTimeKind.Utc => date.AddHours(remoteTimezoneOffsetHours),
|
||||
_ => date,
|
||||
};
|
||||
return DateTime.SpecifyKind(newDate, DateTimeKind.Unspecified);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +143,8 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
var statsList = clusterWellsIds.Select(clusterWellId =>
|
||||
{
|
||||
var currentWellOps = operations.Where(o => o.IdWell == clusterWellId);
|
||||
var stat = CalcStat(currentWellOps);
|
||||
var timezoneOffsetH = wellService.GetTimezone(clusterWellId).Hours;
|
||||
var stat = CalcStat(currentWellOps, timezoneOffsetH);
|
||||
return stat;
|
||||
}).Where(c => c is not null);
|
||||
|
||||
@ -161,8 +162,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
|
||||
private async Task<StatWellDto> CalcStatWellAsync(Well well, CancellationToken token = default)
|
||||
{
|
||||
var wellType = await cacheWellType.FirstOrDefaultAsync(t => t.Id == well.IdWellType, token);
|
||||
|
||||
var wellType = await cacheWellType.FirstOrDefaultAsync(t => t.Id == well.IdWellType, token);
|
||||
var statWellDto = new StatWellDto()
|
||||
{
|
||||
Id = well.Id,
|
||||
@ -170,7 +170,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
WellType = wellType?.Caption ?? "",
|
||||
IdState = well.IdState,
|
||||
State = wellService.GetStateText(well.IdState),
|
||||
LastTelemetryDate = wellService.GetLastTelemetryDate(well.Id),
|
||||
LastTelemetryDate = wellService.GetLastTelemetryDate(well.Id).DateTime,
|
||||
};
|
||||
|
||||
statWellDto.Companies = await wellService.GetCompaniesAsync(well.Id, token);
|
||||
@ -185,13 +185,14 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
if (!wellOperations.Any())
|
||||
return statWellDto;
|
||||
|
||||
statWellDto.Sections = CalcSectionsStats(wellOperations);
|
||||
statWellDto.Total = GetStatTotal(wellOperations, well.IdState);
|
||||
var timezoneOffsetH = wellService.GetTimezone(well.Id).Hours;
|
||||
statWellDto.Sections = CalcSectionsStats(wellOperations, timezoneOffsetH);
|
||||
statWellDto.Total = GetStatTotal(wellOperations, well.IdState, timezoneOffsetH);
|
||||
|
||||
return statWellDto;
|
||||
}
|
||||
|
||||
private IEnumerable<StatSectionDto> CalcSectionsStats(IEnumerable<WellOperation> operations)
|
||||
private IEnumerable<StatSectionDto> CalcSectionsStats(IEnumerable<WellOperation> operations, double timezoneOffsetH)
|
||||
{
|
||||
var sectionTypeIds = operations
|
||||
.Select(o => o.IdWellSectionType)
|
||||
@ -211,8 +212,8 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
{
|
||||
Id = id,
|
||||
Caption = sectionType.Caption,
|
||||
Plan = CalcSectionStat(operationsPlan, id),
|
||||
Fact = CalcSectionStat(operationsFact, id),
|
||||
Plan = CalcSectionStat(operationsPlan, id, timezoneOffsetH),
|
||||
Fact = CalcSectionStat(operationsFact, id, timezoneOffsetH),
|
||||
};
|
||||
sections.Add(section);
|
||||
}
|
||||
@ -220,42 +221,42 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
}
|
||||
|
||||
private static PlanFactBase<StatOperationsDto> GetStatTotal(IEnumerable<WellOperation> operations,
|
||||
int idWellState)
|
||||
int idWellState, double timezoneOffsetH)
|
||||
{
|
||||
var operationsPlan = operations.Where(o => o.IdType == idOperationTypePlan);
|
||||
var operationsFact = operations.Where(o => o.IdType == idOperationTypeFact);
|
||||
var factEnd = CalcStat(operationsFact);
|
||||
var factEnd = CalcStat(operationsFact, timezoneOffsetH);
|
||||
if (idWellState != 2)
|
||||
factEnd.End = null;
|
||||
var section = new PlanFactBase<StatOperationsDto>
|
||||
{
|
||||
Plan = CalcStat(operationsPlan),
|
||||
Plan = CalcStat(operationsPlan, timezoneOffsetH),
|
||||
Fact = factEnd,
|
||||
};
|
||||
return section;
|
||||
}
|
||||
|
||||
private static StatOperationsDto CalcSectionStat(IEnumerable<WellOperation> operations, int idSectionType)
|
||||
private static StatOperationsDto CalcSectionStat(IEnumerable<WellOperation> operations, int idSectionType, double timezoneOffsetH)
|
||||
{
|
||||
var sectionOperations = operations
|
||||
.Where(o => o.IdWellSectionType == idSectionType)
|
||||
.OrderBy(o => o.DateStart)
|
||||
.ThenBy(o => o.DepthStart);
|
||||
|
||||
return CalcStat(sectionOperations);
|
||||
return CalcStat(sectionOperations, timezoneOffsetH);
|
||||
}
|
||||
|
||||
private static StatOperationsDto CalcStat(IEnumerable<WellOperation> operations)
|
||||
private static StatOperationsDto CalcStat(IEnumerable<WellOperation> operations, double timezoneOffsetH)
|
||||
{
|
||||
if (!operations.Any())
|
||||
return null;
|
||||
|
||||
var races = GetCompleteRaces(operations);
|
||||
var races = GetCompleteRaces(operations, timezoneOffsetH);
|
||||
|
||||
var section = new StatOperationsDto
|
||||
{
|
||||
Start = operations.FirstOrDefault()?.DateStart,
|
||||
End = operations.Max(o => o.DateStart.AddHours(o.DurationHours)),
|
||||
Start = operations.FirstOrDefault()?.DateStart.ToRemoteDateTime(timezoneOffsetH),
|
||||
End = operations.Max(o => o.DateStart.ToRemoteDateTime(timezoneOffsetH).AddHours(o.DurationHours)),
|
||||
WellDepthStart = operations.Min(o => o.DepthStart),
|
||||
WellDepthEnd = operations.Max(o => o.DepthStart),
|
||||
Rop = CalcROP(operations),
|
||||
@ -297,7 +298,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
return depth / (dHours + double.Epsilon);
|
||||
}
|
||||
|
||||
private static IEnumerable<Race> GetCompleteRaces(IEnumerable<WellOperation> operations)
|
||||
private static IEnumerable<Race> GetCompleteRaces(IEnumerable<WellOperation> operations, double timezoneOffsetH)
|
||||
{
|
||||
var races = new List<Race>();
|
||||
var iterator = operations
|
||||
@ -309,7 +310,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
{
|
||||
var race = new Race
|
||||
{
|
||||
StartDate = iterator.Current.DateStart.AddHours(iterator.Current.DurationHours),
|
||||
StartDate = iterator.Current.DateStart.ToRemoteDateTime(timezoneOffsetH).AddHours(iterator.Current.DurationHours),
|
||||
StartWellDepth = iterator.Current.DepthStart,
|
||||
Operations = new List<WellOperation>(10),
|
||||
};
|
||||
@ -321,7 +322,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
}
|
||||
if (iterator.Current.IdCategory == idOperationBhaDisassembly)
|
||||
{
|
||||
race.EndDate = iterator.Current.DateStart;
|
||||
race.EndDate = iterator.Current.DateStart.ToRemoteDateTime(timezoneOffsetH);
|
||||
race.EndWellDepth = iterator.Current.DepthStart;
|
||||
races.Add(race);
|
||||
break;
|
||||
|
@ -35,7 +35,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
private static readonly TimeSpan drillingDurationLimitMax = TimeSpan.FromDays(366);
|
||||
|
||||
private readonly IAsbCloudDbContext db;
|
||||
|
||||
private readonly IWellService wellService;
|
||||
private List<WellOperationCategory> categories = null;
|
||||
public List<WellOperationCategory> Categories
|
||||
{
|
||||
@ -65,9 +65,10 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
}
|
||||
}
|
||||
|
||||
public WellOperationImportService(IAsbCloudDbContext db)
|
||||
public WellOperationImportService(IAsbCloudDbContext db, IWellService wellService)
|
||||
{
|
||||
this.db = db;
|
||||
this.wellService = wellService;
|
||||
}
|
||||
|
||||
public void Import(int idWell, Stream stream, bool deleteWellOperationsBeforeImport = false)
|
||||
@ -93,7 +94,9 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
if (!operations.Any())
|
||||
return null;
|
||||
|
||||
return MakeExelFileStream(operations);
|
||||
var timezone = wellService.GetTimezone(idWell);
|
||||
|
||||
return MakeExelFileStream(operations, timezone.Hours);
|
||||
}
|
||||
|
||||
public Stream GetExcelTemplateStream() {
|
||||
@ -102,12 +105,12 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
return stream;
|
||||
}
|
||||
|
||||
private Stream MakeExelFileStream(IEnumerable<WellOperation> operations)
|
||||
private Stream MakeExelFileStream(IEnumerable<WellOperation> operations, double timezoneOffset)
|
||||
{
|
||||
using Stream ecxelTemplateStream = GetExcelTemplateStream();
|
||||
|
||||
using var workbook = new XLWorkbook(ecxelTemplateStream, XLEventTracking.Disabled);
|
||||
AddOperationsToWorkbook(workbook, operations);
|
||||
AddOperationsToWorkbook(workbook, operations, timezoneOffset);
|
||||
|
||||
MemoryStream memoryStream = new MemoryStream();
|
||||
workbook.SaveAs(memoryStream, new SaveOptions { });
|
||||
@ -115,53 +118,61 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
return memoryStream;
|
||||
}
|
||||
|
||||
private static void AddOperationsToWorkbook(XLWorkbook workbook, IEnumerable<WellOperation> operations)
|
||||
private static void AddOperationsToWorkbook(XLWorkbook workbook, IEnumerable<WellOperation> operations, double timezoneOffset)
|
||||
{
|
||||
var planOperations = operations.Where(o => o.IdType == 0);
|
||||
if (planOperations.Any())
|
||||
{
|
||||
var sheetPlan = workbook.Worksheets.FirstOrDefault(ws => ws.Name == sheetNamePlan);
|
||||
AddOperationsToSheet(sheetPlan, planOperations);
|
||||
AddOperationsToSheet(sheetPlan, planOperations, timezoneOffset);
|
||||
}
|
||||
|
||||
var factOperations = operations.Where(o => o.IdType == 1);
|
||||
if (factOperations.Any())
|
||||
{
|
||||
var sheetFact = workbook.Worksheets.FirstOrDefault(ws => ws.Name == sheetNameFact);
|
||||
AddOperationsToSheet(sheetFact, factOperations);
|
||||
AddOperationsToSheet(sheetFact, factOperations, timezoneOffset);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddOperationsToSheet(IXLWorksheet sheet, IEnumerable<WellOperation> operations)
|
||||
private static void AddOperationsToSheet(IXLWorksheet sheet, IEnumerable<WellOperation> operations, double timezoneOffset)
|
||||
{
|
||||
var operationsList = operations.ToList();
|
||||
for (int i = 0; i < operationsList.Count; i++)
|
||||
{
|
||||
var row = sheet.Row(1 + i + headerRowsCount);
|
||||
AddOperationToRow(row, operationsList[i]);
|
||||
AddOperationToRow(row, operationsList[i], timezoneOffset);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddOperationToRow(IXLRow row, WellOperation operation)
|
||||
private static void AddOperationToRow(IXLRow row, WellOperation operation, double timezoneOffset)
|
||||
{
|
||||
row.Cell(columnSection).Value = operation.WellSectionType?.Caption;
|
||||
row.Cell(columnCategory).Value = operation.OperationCategory?.Name;
|
||||
row.Cell(columnCategoryInfo).Value = operation.CategoryInfo;
|
||||
row.Cell(columnDepthStart).Value = operation.DepthStart;
|
||||
row.Cell(columnDepthEnd).Value = operation.DepthEnd;
|
||||
row.Cell(columnDate).Value = operation.DateStart;
|
||||
row.Cell(columnDate).Value = operation.DateStart.ToRemoteDateTime(timezoneOffset);
|
||||
row.Cell(columnDuration).Value = operation.DurationHours;
|
||||
row.Cell(columnComment).Value = operation.Comment;
|
||||
}
|
||||
|
||||
private void SaveOperations(int idWell, IEnumerable<WellOperationDto> operations, bool deleteWellOperationsBeforeImport = false)
|
||||
{
|
||||
var timezone = wellService.GetTimezone(idWell);
|
||||
|
||||
var transaction = db.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
if (deleteWellOperationsBeforeImport)
|
||||
db.WellOperations.RemoveRange(db.WellOperations.Where(o => o.IdWell == idWell));
|
||||
db.WellOperations.AddRange(operations.Adapt<WellOperation>());
|
||||
var entities = operations.Select(o => {
|
||||
var entity = o.Adapt<WellOperation>();
|
||||
entity.IdWell = idWell;
|
||||
entity.DateStart = o.DateStart.ToUtcDateTimeOffset(timezone.Hours);
|
||||
return entity;
|
||||
});
|
||||
db.WellOperations.AddRange(entities);
|
||||
db.SaveChanges();
|
||||
transaction.Commit();
|
||||
}
|
||||
@ -204,7 +215,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
{
|
||||
|
||||
if (sheet.RangeUsed().RangeAddress.LastAddress.ColumnNumber < 7)
|
||||
throw new FileFormatException($"Лист {sheet.Name} содержит меньшее количество столбцев.");
|
||||
throw new FileFormatException($"Лист {sheet.Name} содержит меньшее количество столбцов.");
|
||||
|
||||
var count = sheet.RowsUsed().Count() - headerRowsCount;
|
||||
|
||||
|
Binary file not shown.
@ -15,12 +15,14 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
public class WellOperationService : IWellOperationService
|
||||
{
|
||||
private readonly IAsbCloudDbContext db;
|
||||
private readonly IWellService wellService;
|
||||
private readonly CacheTable<WellOperationCategory> cachedOperationCategories;
|
||||
private readonly CacheTable<WellSectionType> cachedSectionTypes;
|
||||
|
||||
public WellOperationService(IAsbCloudDbContext db, CacheDb cache)
|
||||
public WellOperationService(IAsbCloudDbContext db, CacheDb cache, IWellService wellService)
|
||||
{
|
||||
this.db = db;
|
||||
this.wellService = wellService;
|
||||
cachedOperationCategories = cache.GetCachedTable<WellOperationCategory>((DbContext)db);
|
||||
cachedSectionTypes = cache.GetCachedTable<WellSectionType>((DbContext)db);
|
||||
}
|
||||
@ -31,7 +33,6 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
public IEnumerable<WellOperationCategoryDto> GetCategories()
|
||||
{
|
||||
var operationTypes = cachedOperationCategories
|
||||
//.Where(oc => oc.Code > 999)
|
||||
.Distinct().OrderBy(o => o.Name);
|
||||
var result = operationTypes.Adapt<WellOperationCategoryDto>();
|
||||
|
||||
@ -51,6 +52,8 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
int take = 32,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
var timezone = wellService.GetTimezone(idWell);
|
||||
|
||||
var query = db.WellOperations
|
||||
.Include(s => s.WellSectionType)
|
||||
.Include(s => s.OperationCategory)
|
||||
@ -72,10 +75,17 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
query = query.Where(e => e.DepthEnd <= maxDepth);
|
||||
|
||||
if (begin != default)
|
||||
query = query.Where(e => e.DateStart >= begin);
|
||||
{
|
||||
var beginOffset = begin.ToUtcDateTimeOffset(timezone.Hours);
|
||||
query = query.Where(e => e.DateStart >= beginOffset);
|
||||
}
|
||||
|
||||
if (end != default)
|
||||
query = query.Where(e => e.DateStart <= end);
|
||||
{
|
||||
|
||||
var endOffset = end.ToUtcDateTimeOffset(timezone.Hours);
|
||||
query = query.Where(e => e.DateStart <= endOffset);
|
||||
}
|
||||
|
||||
var result = new PaginationContainer<WellOperationDto>
|
||||
{
|
||||
@ -95,11 +105,12 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
var entities = await query.Take(take).AsNoTracking()
|
||||
.ToListAsync(token).ConfigureAwait(false);
|
||||
|
||||
foreach (var item in entities)
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
var dto = item.Adapt<WellOperationDto>();
|
||||
dto.WellSectionTypeName = item.WellSectionType.Caption;
|
||||
dto.CategoryName = item.OperationCategory.Name;
|
||||
var dto = entity.Adapt<WellOperationDto>();
|
||||
dto.WellSectionTypeName = entity.WellSectionType.Caption;
|
||||
dto.DateStart = entity.DateStart.ToRemoteDateTime(timezone.Hours);
|
||||
dto.CategoryName = entity.OperationCategory.Name;
|
||||
result.Items.Add(dto);
|
||||
}
|
||||
|
||||
@ -109,6 +120,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
public async Task<WellOperationDto> GetAsync(int id,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
|
||||
var entity = await db.WellOperations
|
||||
.Include(s => s.WellSectionType)
|
||||
.Include(s => s.OperationCategory)
|
||||
@ -118,8 +130,11 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
if (entity is null)
|
||||
return null;
|
||||
|
||||
var timezone = wellService.GetTimezone(entity.IdWell);
|
||||
|
||||
var dto = entity.Adapt<WellOperationDto>();
|
||||
dto.WellSectionTypeName = entity.WellSectionType.Caption;
|
||||
dto.DateStart = entity.DateStart.ToRemoteDateTime(timezone.Hours);
|
||||
dto.CategoryName = entity.OperationCategory.Name;
|
||||
return dto;
|
||||
}
|
||||
@ -128,10 +143,12 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
IEnumerable<WellOperationDto> wellOperationDtos,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
foreach (var operationDto in wellOperationDtos)
|
||||
var timezone = wellService.GetTimezone(idWell);
|
||||
foreach (var dto in wellOperationDtos)
|
||||
{
|
||||
var entity = operationDto.Adapt<WellOperation>();
|
||||
var entity = dto.Adapt<WellOperation>();
|
||||
entity.Id = default;
|
||||
entity.DateStart = dto.DateStart.ToUtcDateTimeOffset(timezone.Hours);
|
||||
entity.IdWell = idWell;
|
||||
db.WellOperations.Add(entity);
|
||||
}
|
||||
@ -141,11 +158,12 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||
}
|
||||
|
||||
public async Task<int> UpdateAsync(int idWell, int idOperation,
|
||||
WellOperationDto item, CancellationToken token = default)
|
||||
WellOperationDto dto, CancellationToken token = default)
|
||||
{
|
||||
var entity = item.Adapt<WellOperation>();
|
||||
var timezone = wellService.GetTimezone(idWell);
|
||||
var entity = dto.Adapt<WellOperation>();
|
||||
entity.Id = idOperation;
|
||||
entity.IdWell = idWell;
|
||||
entity.DateStart = dto.DateStart.ToUtcDateTimeOffset(timezone.Hours);
|
||||
db.WellOperations.Update(entity);
|
||||
return await db.SaveChangesAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
@ -27,11 +27,15 @@ namespace AsbCloudInfrastructure.Services
|
||||
private readonly ITelemetryService telemetryService;
|
||||
private readonly CacheTable<RelationCompanyWell> cacheRelationCompaniesWells;
|
||||
private readonly CacheTable<CompanyType> cacheCompanyWellTypes;
|
||||
private readonly ITimezoneService timezoneService;
|
||||
|
||||
public WellService(IAsbCloudDbContext db, CacheDb cacheDb, ITelemetryService telemetryService)
|
||||
public ITelemetryService TelemetryService => telemetryService;
|
||||
|
||||
public WellService(IAsbCloudDbContext db, CacheDb cacheDb, ITelemetryService telemetryService, ITimezoneService timezoneService)
|
||||
:base(db, cacheDb)
|
||||
{
|
||||
this.telemetryService = telemetryService;
|
||||
this.timezoneService = timezoneService;
|
||||
cacheRelationCompaniesWells = cacheDb.GetCachedTable<RelationCompanyWell>((AsbCloudDbContext)db, nameof(RelationCompanyWell.Company), nameof(RelationCompanyWell.Well));
|
||||
cacheCompanyWellTypes = cacheDb.GetCachedTable<CompanyType>((AsbCloudDbContext)db);
|
||||
Includes.Add($"{nameof(Well.Cluster)}.{nameof(Cluster.Deposit)}");
|
||||
@ -40,12 +44,12 @@ namespace AsbCloudInfrastructure.Services
|
||||
Includes.Add(nameof(Well.WellType));
|
||||
}
|
||||
|
||||
public DateTime GetLastTelemetryDate(int idWell)
|
||||
public DateTimeOffset GetLastTelemetryDate(int idWell)
|
||||
{
|
||||
var well = Cache.FirstOrDefault(w => w.Id == idWell);
|
||||
|
||||
if (well?.IdTelemetry is null)
|
||||
return DateTime.MinValue;
|
||||
return DateTimeOffset.MinValue;
|
||||
|
||||
var lastTelemetryDate = telemetryService.GetLastTelemetryDate((int)well.IdTelemetry);
|
||||
return lastTelemetryDate;
|
||||
@ -57,7 +61,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
.WhereAsync(r => r.IdCompany == idCompany, token);
|
||||
|
||||
var wellsIds = relations.Select(r => r.IdWell);
|
||||
var wells = await Cache.WhereAsync(w => wellsIds.Contains(w.Id));
|
||||
var wells = await Cache.WhereAsync(w => wellsIds.Contains(w.Id), token);
|
||||
|
||||
var dtos = wells.Select(Convert);
|
||||
return dtos;
|
||||
@ -155,7 +159,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
1 => "В работе",
|
||||
2 => "Завершена",
|
||||
_ => "Незвестно",
|
||||
_ => "Неизвестно",
|
||||
};
|
||||
}
|
||||
|
||||
@ -176,21 +180,31 @@ namespace AsbCloudInfrastructure.Services
|
||||
protected override Well Convert(WellDto dto)
|
||||
{
|
||||
var entity = dto.Adapt<Well>(typeAdapterConfig);
|
||||
//dto.WellType = entity.WellType?.Caption;
|
||||
//dto.Cluster = entity.Cluster?.Caption;
|
||||
//dto.Deposit = entity.Cluster?.Deposit?.Caption;
|
||||
//dto.LastTelemetryDate = GetLastTelemetryDate(entity.Id);
|
||||
//dto.Companies = GetCompanies(entity.Id);
|
||||
|
||||
entity.IdTelemetry = entity.IdTelemetry ?? dto.IdTelemetry ?? dto.Telemetry?.Id;
|
||||
|
||||
if (dto.Timezone is null)
|
||||
if (TryGetTimezone(dto.Id, out var timezoneDto))
|
||||
entity.Timezone = timezoneDto.Adapt<SimpleTimezone>();
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
protected override WellDto Convert(Well entity)
|
||||
{
|
||||
if (entity is null)
|
||||
return null;
|
||||
|
||||
var dto = base.Convert(entity);
|
||||
|
||||
if (entity.Timezone is null)
|
||||
if(TryGetTimezone(entity, out var timezone))
|
||||
dto.Timezone = timezone;
|
||||
|
||||
dto.WellType = entity.WellType?.Caption;
|
||||
dto.Cluster = entity.Cluster?.Caption;
|
||||
dto.Deposit = entity.Cluster?.Deposit?.Caption;
|
||||
dto.LastTelemetryDate = GetLastTelemetryDate(entity.Id);
|
||||
dto.LastTelemetryDate = GetLastTelemetryDate(entity.Id).DateTime;
|
||||
dto.Companies = GetCompanies(entity.Id);
|
||||
return dto;
|
||||
}
|
||||
@ -202,5 +216,145 @@ namespace AsbCloudInfrastructure.Services
|
||||
?? cacheCompanyWellTypes.FirstOrDefault(c => c.Id == entity.IdCompanyType).Caption;
|
||||
return dto;
|
||||
}
|
||||
|
||||
public void EnshureTimezonesIsSet()
|
||||
{
|
||||
var wells = Cache.Where(w => w.Timezone is null).ToList();
|
||||
foreach (var well in wells)
|
||||
{
|
||||
if (TryGetTimezone(well, out var timezone))
|
||||
well.Timezone = timezone.Adapt<SimpleTimezone>();
|
||||
else
|
||||
well.Timezone = new SimpleTimezone
|
||||
{
|
||||
Hours = 5,
|
||||
IsOverride = false,
|
||||
TimeZoneId = "Assumed",
|
||||
};
|
||||
}
|
||||
|
||||
var wellsWithTz = wells.Where(w => w.Timezone is not null);
|
||||
if (wellsWithTz.Any())
|
||||
{
|
||||
var adaptedWells = wellsWithTz.Adapt<WellDto>().Select(Convert);
|
||||
Cache.Upsert(adaptedWells);
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryGetTimezone(int idWell, out SimpleTimezoneDto timezone)
|
||||
{
|
||||
timezone = null;
|
||||
try
|
||||
{
|
||||
timezone = GetTimezone(idWell);
|
||||
return timezone is not null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public SimpleTimezoneDto GetTimezone(int idWell)
|
||||
{
|
||||
var well = Cache.FirstOrDefault(c => c.Id == idWell);
|
||||
if (well == null)
|
||||
throw new ArgumentException($"idWell: {idWell} does not exist.", nameof(idWell));
|
||||
return GetTimezone(well);
|
||||
}
|
||||
|
||||
private bool TryGetTimezone(Well well, out SimpleTimezoneDto timezone)
|
||||
{
|
||||
timezone = null;
|
||||
try
|
||||
{
|
||||
timezone = GetTimezone(well);
|
||||
return timezone is not null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private SimpleTimezoneDto GetTimezone(Well well)
|
||||
{
|
||||
if (well == null)
|
||||
throw new ArgumentNullException(nameof(well));
|
||||
|
||||
if (well.Timezone is not null)
|
||||
return well.Timezone.Adapt<SimpleTimezoneDto>();
|
||||
|
||||
if (well.Telemetry is not null)
|
||||
{
|
||||
var timezone = telemetryService.GetTimezone(well.Telemetry.Id);
|
||||
if (timezone is not null)
|
||||
{
|
||||
well.Timezone = timezone.Adapt<SimpleTimezone>();
|
||||
return timezone;
|
||||
}
|
||||
}
|
||||
|
||||
var point = GetCoordinates(well);
|
||||
if (point is not null)
|
||||
{
|
||||
if (point.Timezone is not null)
|
||||
{
|
||||
well.Timezone = point.Timezone;
|
||||
return point.Timezone.Adapt<SimpleTimezoneDto>();
|
||||
}
|
||||
|
||||
if (point.Latitude is not null & point.Longitude is not null)
|
||||
{
|
||||
var timezone = timezoneService.GetByCoordinates((double)point.Latitude, (double)point.Longitude);
|
||||
if (timezone is not null)
|
||||
{
|
||||
well.Timezone = timezone.Adapt<SimpleTimezone>();
|
||||
return timezone;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception($"Can't find timezone for well {well.Caption} id: {well.Id}");
|
||||
}
|
||||
|
||||
private static AsbCloudDb.Model.IMapPoint GetCoordinates(Well well)
|
||||
{
|
||||
if(well is null)
|
||||
throw new ArgumentNullException(nameof(well));
|
||||
|
||||
if (well.Latitude is not null & well.Longitude is not null)
|
||||
return well;
|
||||
|
||||
if (well.Cluster is null)
|
||||
throw new Exception($"Can't find coordinates of well {well.Caption} id: {well.Id}");
|
||||
|
||||
var cluster = well.Cluster;
|
||||
|
||||
if (cluster.Latitude is not null & cluster.Longitude is not null)
|
||||
return cluster;
|
||||
|
||||
if (cluster.Deposit is null)
|
||||
throw new Exception($"Can't find coordinates of well by cluster {cluster.Caption} id: {cluster.Id}");
|
||||
|
||||
var deposit = cluster.Deposit;
|
||||
|
||||
if (deposit.Latitude is not null & deposit.Longitude is not null)
|
||||
return deposit;
|
||||
|
||||
throw new Exception($"Can't find coordinates of well by deposit {deposit.Caption} id: {deposit.Id}");
|
||||
}
|
||||
|
||||
public DatesRangeDto GetDatesRange(int idWell)
|
||||
{
|
||||
var well = Cache.FirstOrDefault(w => w.Id == idWell);
|
||||
if (well is null)
|
||||
throw new Exception($"Well id: {idWell} does not exist.");
|
||||
|
||||
if (well.IdTelemetry is null)
|
||||
throw new Exception($"Well id: {idWell} does not contain telemetry.");
|
||||
|
||||
return telemetryService.GetDatesRange((int)well.IdTelemetry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Claims;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace AsbCloudWebApi.Tests.ControllersTests
|
||||
@ -38,18 +39,13 @@ namespace AsbCloudWebApi.Tests.ControllersTests
|
||||
wellService.Setup(s => s.IsCompanyInvolvedInWell(It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Returns(true);
|
||||
|
||||
wellService.Setup(s => s.IsCompanyInvolvedInWellAsync(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<CancellationToken>()))
|
||||
.Returns(Task.FromResult(true));
|
||||
|
||||
controller = new TelemetryAnalyticsController(analyticsService.Object,
|
||||
wellService.Object);
|
||||
|
||||
var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
|
||||
{
|
||||
new Claim("idCompany", "1"),
|
||||
}, "mock"));
|
||||
|
||||
controller.ControllerContext = new ControllerContext()
|
||||
{
|
||||
HttpContext = new DefaultHttpContext() { User = user }
|
||||
};
|
||||
controller.AddUser();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -149,8 +145,8 @@ namespace AsbCloudWebApi.Tests.ControllersTests
|
||||
{
|
||||
var emptyAnalyticsService = new Mock<ITelemetryAnalyticsService>();
|
||||
|
||||
emptyAnalyticsService.Setup(s => s.GetWellDepthToDayAsync(It.IsAny<int>(), CancellationToken.None).Result)
|
||||
.Returns(value: null);
|
||||
emptyAnalyticsService.Setup(s => s.GetWellDepthToDayAsync(It.IsAny<int>(), CancellationToken.None))
|
||||
.Returns(Task.FromResult<IEnumerable<WellDepthToDayDto>>(null));
|
||||
|
||||
var newControllerInstance = new TelemetryAnalyticsController(emptyAnalyticsService.Object,
|
||||
wellService.Object);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user