diff --git a/AsbCloudApp/Data/DailyReport/DailyReportDto.cs b/AsbCloudApp/Data/DailyReport/DailyReportDto.cs
index d8d9d4c8..c31dd73c 100644
--- a/AsbCloudApp/Data/DailyReport/DailyReportDto.cs
+++ b/AsbCloudApp/Data/DailyReport/DailyReportDto.cs
@@ -74,7 +74,7 @@ public class DailyReportDto : IId,
///
/// Дата последнего обновления
///
- public DateTime? DateLastUpdate { get; set; }
+ public DateTimeOffset? DateLastUpdate { get; set; }
///
/// Блок фактической траектории
diff --git a/AsbCloudApp/Data/DataSaubStatDto.cs b/AsbCloudApp/Data/DataSaubStatDto.cs
index a3b80a5d..ceae4f9d 100644
--- a/AsbCloudApp/Data/DataSaubStatDto.cs
+++ b/AsbCloudApp/Data/DataSaubStatDto.cs
@@ -1,4 +1,5 @@
using System;
+using AsbCloudApp.Data.WellOperation;
namespace AsbCloudApp.Data
{
diff --git a/AsbCloudApp/Data/DatesRangeDto.cs b/AsbCloudApp/Data/DatesRangeDto.cs
index 3f12acb7..a61034b6 100644
--- a/AsbCloudApp/Data/DatesRangeDto.cs
+++ b/AsbCloudApp/Data/DatesRangeDto.cs
@@ -12,12 +12,12 @@ namespace AsbCloudApp.Data
/// Дата начала диапазона
///
[Required]
- public DateTime From { get; set; }
+ public DateTimeOffset From { get; set; }
///
/// Дата окончания диапазона
///
[Required]
- public DateTime To { get; set; }
+ public DateTimeOffset To { get; set; }
}
}
diff --git a/AsbCloudApp/Data/DetectedOperation/DetectedOperationDto.cs b/AsbCloudApp/Data/DetectedOperation/DetectedOperationDto.cs
index e81a45fb..c8b1e15a 100644
--- a/AsbCloudApp/Data/DetectedOperation/DetectedOperationDto.cs
+++ b/AsbCloudApp/Data/DetectedOperation/DetectedOperationDto.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
+using AsbCloudApp.Data.WellOperation;
namespace AsbCloudApp.Data.DetectedOperation;
diff --git a/AsbCloudApp/Data/DrillTestReport/DrillTestReportDataDto.cs b/AsbCloudApp/Data/DrillTestReport/DrillTestReportDataDto.cs
index ee63bf9b..b45783e6 100644
--- a/AsbCloudApp/Data/DrillTestReport/DrillTestReportDataDto.cs
+++ b/AsbCloudApp/Data/DrillTestReport/DrillTestReportDataDto.cs
@@ -21,6 +21,6 @@ namespace AsbCloudApp.Data.DrillTestReport
///
/// Дата отчета
///
- public DateTime Date { get; set; } = DateTime.Now;
+ public DateTimeOffset Date { get; set; } = DateTimeOffset.Now;
}
}
diff --git a/AsbCloudApp/Data/DrillTestReport/DrillTestReportInfoDto.cs b/AsbCloudApp/Data/DrillTestReport/DrillTestReportInfoDto.cs
index 39d37a11..a178e6fe 100644
--- a/AsbCloudApp/Data/DrillTestReport/DrillTestReportInfoDto.cs
+++ b/AsbCloudApp/Data/DrillTestReport/DrillTestReportInfoDto.cs
@@ -24,6 +24,6 @@ namespace AsbCloudApp.Data.DrillTestReport
/// Дата и время
///
[Required]
- public DateTime DateTime { get; set; }
+ public DateTimeOffset DateTime { get; set; }
}
}
diff --git a/AsbCloudApp/Data/FileInfoDto.cs b/AsbCloudApp/Data/FileInfoDto.cs
index 8e006661..ab44b317 100644
--- a/AsbCloudApp/Data/FileInfoDto.cs
+++ b/AsbCloudApp/Data/FileInfoDto.cs
@@ -43,7 +43,7 @@ namespace AsbCloudApp.Data
/// дата загрузки
///
[Required]
- public DateTime UploadDate { get; set; }
+ public DateTimeOffset UploadDate { get; set; }
///
/// размер в байтах
diff --git a/AsbCloudApp/Data/FileMarkDto.cs b/AsbCloudApp/Data/FileMarkDto.cs
index 7329821b..305fad5c 100644
--- a/AsbCloudApp/Data/FileMarkDto.cs
+++ b/AsbCloudApp/Data/FileMarkDto.cs
@@ -33,7 +33,7 @@ namespace AsbCloudApp.Data
/// .
///
[Required]
- public DateTime DateCreated { get; set; }
+ public DateTimeOffset DateCreated { get; set; }
///
///
diff --git a/AsbCloudApp/Data/LimitingParameterDataDto.cs b/AsbCloudApp/Data/LimitingParameterDataDto.cs
index 1bf982dc..c5692729 100644
--- a/AsbCloudApp/Data/LimitingParameterDataDto.cs
+++ b/AsbCloudApp/Data/LimitingParameterDataDto.cs
@@ -20,12 +20,12 @@ namespace AsbCloudApp.Data
///
/// Дата начала ограничения
///
- public DateTime DateStart { get; set; }
+ public DateTimeOffset DateStart { get; set; }
///
/// Дата окончания ограничения
///
- public DateTime DateEnd { get; set; }
+ public DateTimeOffset DateEnd { get; set; }
///
/// Глубина начала ограничения
diff --git a/AsbCloudApp/Data/Manuals/ManualDto.cs b/AsbCloudApp/Data/Manuals/ManualDto.cs
index bb89dfbe..c5aa92c4 100644
--- a/AsbCloudApp/Data/Manuals/ManualDto.cs
+++ b/AsbCloudApp/Data/Manuals/ManualDto.cs
@@ -18,7 +18,7 @@ public class ManualDto : IId
///
/// Дата загрузки
///
- public DateTime DateDownload { get; set; }
+ public DateTimeOffset DateDownload { get; set; }
///
/// Id автора
diff --git a/AsbCloudApp/Data/MeasureDto.cs b/AsbCloudApp/Data/MeasureDto.cs
index 9f823a91..4eddd78f 100644
--- a/AsbCloudApp/Data/MeasureDto.cs
+++ b/AsbCloudApp/Data/MeasureDto.cs
@@ -36,7 +36,7 @@ namespace AsbCloudApp.Data
/// отметка времени замера
///
[Required]
- public DateTime Timestamp { get; set; }
+ public DateTimeOffset Timestamp { get; set; }
///
/// данные замера
diff --git a/AsbCloudApp/Data/MessageDto.cs b/AsbCloudApp/Data/MessageDto.cs
index 071967d9..7234db7a 100644
--- a/AsbCloudApp/Data/MessageDto.cs
+++ b/AsbCloudApp/Data/MessageDto.cs
@@ -16,7 +16,7 @@ namespace AsbCloudApp.Data
/// дата появления события
///
[Required]
- public DateTime DateTime { get; set; }
+ public DateTimeOffset DateTime { get; set; }
///
/// категория события
diff --git a/AsbCloudApp/Data/NotificationDto.cs b/AsbCloudApp/Data/NotificationDto.cs
index ee42f8d7..0fd8b673 100644
--- a/AsbCloudApp/Data/NotificationDto.cs
+++ b/AsbCloudApp/Data/NotificationDto.cs
@@ -42,17 +42,17 @@ public class NotificationDto : IId
/// Дата регистрации уведомления
///
[Required]
- public DateTime RegistrationDate { get; set; }
+ public DateTimeOffset RegistrationDate { get; set; }
///
/// Дата отправки уведомления
///
- public DateTime? SentDate { get; set; }
+ public DateTimeOffset? SentDate { get; set; }
///
/// Дата прочтения уведомления
///
- public DateTime? ReadDate { get; set; }
+ public DateTimeOffset? ReadDate { get; set; }
///
/// Состояние уведомления
@@ -82,12 +82,12 @@ public class NotificationDto : IId
ReadDate = null;
break;
case 1:
- SentDate = DateTime.UtcNow;
+ SentDate = DateTimeOffset.UtcNow;
ReadDate = null;
break;
case 2:
- SentDate = DateTime.UtcNow;
- ReadDate = DateTime.UtcNow;
+ SentDate = DateTimeOffset.UtcNow;
+ ReadDate = DateTimeOffset.UtcNow;
break;
}
}
diff --git a/AsbCloudApp/Data/ParserResultDto.cs b/AsbCloudApp/Data/ParserResultDto.cs
index 5b6eca8d..ffb24d50 100644
--- a/AsbCloudApp/Data/ParserResultDto.cs
+++ b/AsbCloudApp/Data/ParserResultDto.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Linq;
namespace AsbCloudApp.Data;
@@ -9,4 +10,8 @@ namespace AsbCloudApp.Data;
public class ParserResultDto : ValidationResultDto>>
where TDto : class, IId
{
+ ///
+ /// Объекты полученные из файла
+ ///
+ public override IEnumerable> Item { get; set; } = Enumerable.Empty>();
}
\ No newline at end of file
diff --git a/AsbCloudApp/Data/ProcessMaps/Report/ProcessMapReportDataSaubStatDto.cs b/AsbCloudApp/Data/ProcessMaps/Report/ProcessMapReportDataSaubStatDto.cs
index 6255726f..4bf221de 100644
--- a/AsbCloudApp/Data/ProcessMaps/Report/ProcessMapReportDataSaubStatDto.cs
+++ b/AsbCloudApp/Data/ProcessMaps/Report/ProcessMapReportDataSaubStatDto.cs
@@ -44,7 +44,7 @@ public class ProcessMapReportDataSaubStatDto
/// на начало интервала
///
///
- public DateTime DateStart { get; set; }
+ public DateTimeOffset DateStart { get; set; }
///
/// Режим бурения (Ротор/слайд/ручной)
diff --git a/AsbCloudApp/Data/ProcessMaps/Report/ProcessMapReportWellDrillingDto.cs b/AsbCloudApp/Data/ProcessMaps/Report/ProcessMapReportWellDrillingDto.cs
index 16a9749c..cee53050 100644
--- a/AsbCloudApp/Data/ProcessMaps/Report/ProcessMapReportWellDrillingDto.cs
+++ b/AsbCloudApp/Data/ProcessMaps/Report/ProcessMapReportWellDrillingDto.cs
@@ -44,7 +44,7 @@ public class ProcessMapReportWellDrillingDto
/// на начало интервала
///
///
- public DateTime DateStart { get; set; }
+ public DateTimeOffset DateStart { get; set; }
///
/// Время мех бурения, ч
diff --git a/AsbCloudApp/Data/ReportPropertiesDto.cs b/AsbCloudApp/Data/ReportPropertiesDto.cs
index 82caa77e..f802a7e0 100644
--- a/AsbCloudApp/Data/ReportPropertiesDto.cs
+++ b/AsbCloudApp/Data/ReportPropertiesDto.cs
@@ -29,17 +29,17 @@ namespace AsbCloudApp.Data
///
/// Дата формирования
///
- public DateTime Date { get; set; }
+ public DateTimeOffset Date { get; set; }
///
/// Дата начала рапорта
///
- public DateTime Begin { get; set; }
+ public DateTimeOffset Begin { get; set; }
///
/// Дата окончания рапорта
///
- public DateTime End { get; set; }
+ public DateTimeOffset End { get; set; }
///
/// шаг между точками диаграммы
diff --git a/AsbCloudApp/Data/SAUB/SetpointsRequestDto.cs b/AsbCloudApp/Data/SAUB/SetpointsRequestDto.cs
index ed81c0ef..192805a6 100644
--- a/AsbCloudApp/Data/SAUB/SetpointsRequestDto.cs
+++ b/AsbCloudApp/Data/SAUB/SetpointsRequestDto.cs
@@ -33,7 +33,7 @@ namespace AsbCloudApp.Data.SAUB
///
/// отметка времени создания запроса
///
- public DateTime UploadDate { get; set; } = DateTime.Now;
+ public DateTimeOffset UploadDate { get; set; } = DateTimeOffset.Now;
///
/// время в секундах актуальности этого запроса
diff --git a/AsbCloudApp/Data/SAUB/TelemetryMessageDto.cs b/AsbCloudApp/Data/SAUB/TelemetryMessageDto.cs
index 6c246f16..ee86fc46 100644
--- a/AsbCloudApp/Data/SAUB/TelemetryMessageDto.cs
+++ b/AsbCloudApp/Data/SAUB/TelemetryMessageDto.cs
@@ -15,7 +15,7 @@ namespace AsbCloudApp.Data.SAUB
///
/// отметка времени
///
- public DateTime Date { get; set; }
+ public DateTimeOffset Date { get; set; }
///
/// глубина забоя
diff --git a/AsbCloudApp/Data/SAUB/TelemetryWirelineRunOutDto.cs b/AsbCloudApp/Data/SAUB/TelemetryWirelineRunOutDto.cs
index 69ac6929..213b67ec 100644
--- a/AsbCloudApp/Data/SAUB/TelemetryWirelineRunOutDto.cs
+++ b/AsbCloudApp/Data/SAUB/TelemetryWirelineRunOutDto.cs
@@ -10,7 +10,7 @@ namespace AsbCloudApp.Data.SAUB
///
/// отметка времени
///
- public DateTime DateTime { get; set; }
+ public DateTimeOffset DateTime { get; set; }
///
/// Наработка талевого каната с момента перетяжки каната, т*км
diff --git a/AsbCloudApp/Data/ScheduleDto.cs b/AsbCloudApp/Data/ScheduleDto.cs
index 84cbe515..a8c8d652 100644
--- a/AsbCloudApp/Data/ScheduleDto.cs
+++ b/AsbCloudApp/Data/ScheduleDto.cs
@@ -39,13 +39,13 @@ namespace AsbCloudApp.Data
/// Начало бурения
///
[Required]
- public DateTime DrillStart { get; set; }
+ public DateTimeOffset DrillStart { get; set; }
///
/// Конец бурения
///
[Required]
- public DateTime DrillEnd { get; set; }
+ public DateTimeOffset DrillEnd { get; set; }
///
/// Бурильщик
diff --git a/AsbCloudApp/Data/StatOperationsDto.cs b/AsbCloudApp/Data/StatOperationsDto.cs
index 7d082648..ec59eae0 100644
--- a/AsbCloudApp/Data/StatOperationsDto.cs
+++ b/AsbCloudApp/Data/StatOperationsDto.cs
@@ -11,12 +11,12 @@ namespace AsbCloudApp.Data
///
/// Дата и время начала
///
- public DateTime? Start { get; set; }
+ public DateTimeOffset? Start { get; set; }
///
/// Дата и время окончания
///
- public DateTime? End { get; set; }
+ public DateTimeOffset? End { get; set; }
///
/// Глубина, м
diff --git a/AsbCloudApp/Data/StatWellDto.cs b/AsbCloudApp/Data/StatWellDto.cs
index ece9756c..9cf27fe4 100644
--- a/AsbCloudApp/Data/StatWellDto.cs
+++ b/AsbCloudApp/Data/StatWellDto.cs
@@ -42,7 +42,7 @@ namespace AsbCloudApp.Data
/// дата прихода последней телеметрии
///
[Required]
- public DateTime LastTelemetryDate { get; set; }
+ public DateTimeOffset LastTelemetryDate { get; set; }
///
/// Статистика по секциям
diff --git a/AsbCloudApp/Data/Trajectory/TrajectoryGeoDto.cs b/AsbCloudApp/Data/Trajectory/TrajectoryGeoDto.cs
index 237c20b2..11b88141 100644
--- a/AsbCloudApp/Data/Trajectory/TrajectoryGeoDto.cs
+++ b/AsbCloudApp/Data/Trajectory/TrajectoryGeoDto.cs
@@ -46,7 +46,7 @@ namespace AsbCloudApp.Data.Trajectory
///
/// Дата загрузки
///
- public DateTime UpdateDate { get; set; }
+ public DateTimeOffset UpdateDate { get; set; }
///
/// ИД пользователя
diff --git a/AsbCloudApp/Data/ValidationResultDto.cs b/AsbCloudApp/Data/ValidationResultDto.cs
index 0116fe0a..1fe0f918 100644
--- a/AsbCloudApp/Data/ValidationResultDto.cs
+++ b/AsbCloudApp/Data/ValidationResultDto.cs
@@ -18,7 +18,7 @@ public class ValidationResultDto
///
/// Объект валидации
///
- public T Item { get; set; } = null!;
+ public virtual T Item { get; set; } = null!;
///
/// Предупреждения
diff --git a/AsbCloudApp/Data/WellDto.cs b/AsbCloudApp/Data/WellDto.cs
index 30f524c2..368e58c9 100644
--- a/AsbCloudApp/Data/WellDto.cs
+++ b/AsbCloudApp/Data/WellDto.cs
@@ -67,12 +67,12 @@ namespace AsbCloudApp.Data
///
/// Дата/время первой операции
///
- public DateTime? StartDate { get; set; }
+ public DateTimeOffset? StartDate { get; set; }
///
/// Дата/время кода приходили данные последний раз
///
- public DateTime LastTelemetryDate { get; set; }
+ public DateTimeOffset LastTelemetryDate { get; set; }
///
/// ID телеметрии
diff --git a/AsbCloudApp/Data/WellMapInfoDto.cs b/AsbCloudApp/Data/WellMapInfoDto.cs
index a677a1e3..55098f4b 100644
--- a/AsbCloudApp/Data/WellMapInfoDto.cs
+++ b/AsbCloudApp/Data/WellMapInfoDto.cs
@@ -82,14 +82,14 @@ namespace AsbCloudApp.Data
/// Дата начала первой фактической операции
/// Используется как дата начала бурения
///
- public DateTime? FirstFactOperationDateStart { get; set; }
+ public DateTimeOffset? FirstFactOperationDateStart { get; set; }
///
/// Дата окончания последней прогнозируемой операции
/// Если скважина завершена, то дата окончания последней фактической операции
/// Используется как прогноз окончания бурения
///
- public DateTime? LastPredictOperationDateEnd { get; set; }
+ public DateTimeOffset? LastPredictOperationDateEnd { get; set; }
///
/// Рейсовая скорость проходки, последнего рейса
diff --git a/AsbCloudApp/Data/WellGroupOpertionDto.cs b/AsbCloudApp/Data/WellOperation/WellGroupOpertionDto.cs
similarity index 100%
rename from AsbCloudApp/Data/WellGroupOpertionDto.cs
rename to AsbCloudApp/Data/WellOperation/WellGroupOpertionDto.cs
diff --git a/AsbCloudApp/Data/WellOperationCategoryDto.cs b/AsbCloudApp/Data/WellOperation/WellOperationCategoryDto.cs
similarity index 96%
rename from AsbCloudApp/Data/WellOperationCategoryDto.cs
rename to AsbCloudApp/Data/WellOperation/WellOperationCategoryDto.cs
index 108a31f0..2fe0b177 100644
--- a/AsbCloudApp/Data/WellOperationCategoryDto.cs
+++ b/AsbCloudApp/Data/WellOperation/WellOperationCategoryDto.cs
@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;
-namespace AsbCloudApp.Data
+namespace AsbCloudApp.Data.WellOperation
{
///
/// DTO категория операции
diff --git a/AsbCloudApp/Data/WellOperation/WellOperationDto.cs b/AsbCloudApp/Data/WellOperation/WellOperationDto.cs
new file mode 100644
index 00000000..17015451
--- /dev/null
+++ b/AsbCloudApp/Data/WellOperation/WellOperationDto.cs
@@ -0,0 +1,116 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+
+namespace AsbCloudApp.Data.WellOperation;
+
+public class WellOperationDto : ItemInfoDto,
+ IId,
+ IWellRelated,
+ IValidatableObject
+{
+ ///
+ [Required]
+ public int Id { get; set; }
+
+ ///
+ [Required]
+ public int IdWell { get; set; }
+
+ ///
+ /// Id секции скважины
+ ///
+ public int IdWellSectionType { get; set; }
+
+ ///
+ /// 0 = план или 1 = факт или прогноз = 2
+ ///
+ [Required]
+ public int IdType { get; set; }
+
+ ///
+ /// id категории операции
+ ///
+ public int IdCategory { get; set; }
+
+ ///
+ /// Глубина на начало операции, м
+ ///
+ public double DepthStart { get; set; }
+
+ ///
+ /// Глубина после завершения операции, м
+ ///
+ [Required]
+ [Range(0, 50_000)]
+ public double DepthEnd { get; set; }
+
+ ///
+ /// Дата начала операции
+ ///
+ [Required]
+ public DateTimeOffset DateStart { get; set; }
+
+ ///
+ /// Продолжительность, часы
+ ///
+ public double DurationHours { get; set; }
+
+ ///
+ /// Наименование секции
+ ///
+ public string? WellSectionTypeCaption { get; set; }
+
+ ///
+ /// Наименование категории
+ ///
+ public string? OperationCategoryName { get; set; }
+
+ ///
+ /// id плановой операции для сопоставления
+ ///
+ public int? IdPlan { get; set; }
+
+ ///
+ /// Ключ родителя у категории
+ ///
+ public int? IdParentCategory { get; set; }
+
+ ///
+ /// дополнительная информация по операции
+ ///
+ [StringLength(8192)]
+ public string? CategoryInfo { get; set; }
+
+ ///
+ /// Кол-во дней от даты начала первой плановой (а если её нет, то фактической) операции
+ ///
+ [Required]
+ public double Day { get; set; }
+
+ ///
+ /// Кол-во часов НПВ от даты начала первой плановой (а если её нет, то фактической) операции
+ ///
+ [Required]
+ public double NptHours { get; set; }
+
+ ///
+ /// Полезный комментарий
+ ///
+ [StringLength(4096, ErrorMessage = "Комментарий не может быть длиннее 4096 символов")]
+ public string? Comment { get; set; }
+
+ ///
+ /// Валидация даты
+ ///
+ ///
+ ///
+ public IEnumerable Validate(ValidationContext validationContext)
+ {
+ var gtDate = new DateTimeOffset(2010, 1, 1, 0, 0, 0, TimeSpan.Zero);
+ if (DateStart <= gtDate)
+ yield return new ValidationResult(
+ $"{nameof(DateStart)}: DateStart не может быть меньше {gtDate}",
+ new[] { nameof(DateStart) });
+ }
+}
\ No newline at end of file
diff --git a/AsbCloudApp/Data/WellOperationDataDto.cs b/AsbCloudApp/Data/WellOperationDataDto.cs
deleted file mode 100644
index 874bd65c..00000000
--- a/AsbCloudApp/Data/WellOperationDataDto.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace AsbCloudApp.Data
-{
- /// Операция на скважине
- public class WellOperationDataDto : IWellRelated
- {
- ///
- public int IdWell { get; set; }
-
- ///
- /// id секции скважины
- ///
- public int IdWellSectionType { get; set; }
-
- ///
- /// id категории операции
- ///
- public int IdCategory { get; set; }
-
- ///
- /// Глубина на начало операции, м
- ///
- public double DepthStart { get; set; }
-
- ///
- /// Продолжительность, часы
- ///
- public double DurationHours { get; set; }
-
- ///
- /// Наименование секции
- ///
- public string WellSectionTypeCaption { get; set; } = string.Empty;
-
- ///
- /// Наименование категории
- ///
- public string OperationCategoryName { get; set; } = string.Empty;
- }
-}
diff --git a/AsbCloudApp/Data/WellOperationDto.cs b/AsbCloudApp/Data/WellOperationDto.cs
deleted file mode 100644
index 725debfd..00000000
--- a/AsbCloudApp/Data/WellOperationDto.cs
+++ /dev/null
@@ -1,124 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-
-namespace AsbCloudApp.Data
-{
- ///
- /// Операции на скважине (заведенные пользователем)
- ///
- public class WellOperationDto : ItemInfoDto, IId, IWellRelated, IValidatableObject
- {
- ///
- [Required]
- public int Id { get; set; }
-
- ///
- [Required]
- public int IdWell { get; set; }
-
- ///
- /// id секции скважины
- ///
- [Required]
- public int IdWellSectionType { get; set; }
-
- ///
- /// название секции скважины
- ///
- public string? WellSectionTypeName { get; set; }
-
- ///
- /// id категории операции
- ///
- [Required]
- [Range(5000, int.MaxValue)]
- public int IdCategory { get; set; }
-
- ///
- /// id плановой операции для сопоставления
- ///
- public int? IdPlan { get; set; }
-
- ///
- /// название категории операции
- ///
- public string? CategoryName { get; set; }
-
- ///
- /// ключ родителя у категории
- ///
- public int? IdParentCategory { get; set; }
-
- ///
- /// дополнительная информация по операции
- ///
- [StringLength(8192)]
- public string? CategoryInfo { get; set; }
-
- ///
- /// 0 = план или 1 = факт или прогноз = 2
- ///
- [Required]
- public int IdType { get; set; }
-
- ///
- /// Глубина на начало операции, м
- ///
- [Required]
- [Range(0, 50_000)]
- public double DepthStart { get; set; }
-
- ///
- /// Глубина после завершения операции, м
- ///
- [Required]
- [Range(0, 50_000)]
- public double DepthEnd { get; set; }
-
- ///
- /// Кол-во дней от даты начала первой плановой (а если её нет, то фактической) операции
- ///
- [Required]
- public double Day { get; set; }
-
- ///
- /// Кол-во часов НПВ от даты начала первой плановой (а если её нет, то фактической) операции
- ///
- [Required]
- public double NptHours { get; set; }
-
- ///
- /// Дата начала операции
- ///
- [Required]
- public DateTimeOffset DateStart { get; set; }
-
- ///
- /// Продолжительность, часы
- ///
- [Required]
- [Range(0, 50)]
- public double DurationHours { get; set; }
-
- ///
- /// Полезный комментарий
- ///
- [StringLength(4096, ErrorMessage = "Комментарий не может быть длиннее 4096 символов")]
- public string? Comment { get; set; }
-
- ///
- /// Валидация даты
- ///
- ///
- ///
- public IEnumerable Validate(ValidationContext validationContext)
- {
- var gtDate = new DateTimeOffset(2010, 1, 1, 0, 0, 0, TimeSpan.Zero);
- if (DateStart <= gtDate)
- yield return new ValidationResult(
- $"{nameof(DateStart)}: DateStart не может быть меньше {gtDate}",
- new[] { nameof(DateStart) });
- }
- }
-}
diff --git a/AsbCloudApp/Data/WellOperationPlanDto.cs b/AsbCloudApp/Data/WellOperationPlanDto.cs
deleted file mode 100644
index 5c1bac9f..00000000
--- a/AsbCloudApp/Data/WellOperationPlanDto.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.Linq;
-
-namespace AsbCloudApp.Data
-{
- ///
- /// класс, который хранит список плановых операций для сопоставления
- /// и даты последней сопоставленной плановой операции
- ///
-#nullable enable
- public class WellOperationPlanDto
- {
- ///
- /// коллекция плановых операций
- ///
- [Required]
- public IEnumerable WellOperationsPlan { get; set; } = Enumerable.Empty();
-
- ///
- /// дата последней сопоставленной плановой операции
- ///
- public DateTime? DateLastAssosiatedPlanOperation { get; set; }
-
- }
-
-}
diff --git a/AsbCloudApp/Repositories/IWellOperationCategoryRepository.cs b/AsbCloudApp/Repositories/IWellOperationCategoryRepository.cs
index 4e18c231..ecf915cd 100644
--- a/AsbCloudApp/Repositories/IWellOperationCategoryRepository.cs
+++ b/AsbCloudApp/Repositories/IWellOperationCategoryRepository.cs
@@ -1,5 +1,5 @@
-using AsbCloudApp.Data;
-using System.Collections.Generic;
+using System.Collections.Generic;
+using AsbCloudApp.Data.WellOperation;
namespace AsbCloudApp.Repositories
{
diff --git a/AsbCloudApp/Repositories/IWellOperationRepository.cs b/AsbCloudApp/Repositories/IWellOperationRepository.cs
index dd39ce52..0409969e 100644
--- a/AsbCloudApp/Repositories/IWellOperationRepository.cs
+++ b/AsbCloudApp/Repositories/IWellOperationRepository.cs
@@ -1,9 +1,9 @@
using AsbCloudApp.Data;
-using AsbCloudApp.Requests;
-using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
+using AsbCloudApp.Data.WellOperation;
+using AsbCloudApp.Requests;
namespace AsbCloudApp.Repositories
{
@@ -17,24 +17,8 @@ namespace AsbCloudApp.Repositories
///
///
IEnumerable GetSectionTypes();
-
- ///
- /// список плановых операций для сопоставления
- ///
- ///
- ///
- ///
- ///
- Task GetOperationsPlanAsync(int idWell, DateTime? currentDate, CancellationToken token);
-
- ///
- /// дата/время первой операции по скважине
- ///
- ///
- ///
- DateTimeOffset? FirstOperationDate(int idWell);
-
- ///
+
+ ///
/// Получить страницу списка операций
///
///
@@ -42,15 +26,7 @@ namespace AsbCloudApp.Repositories
///
Task> GetAsync(WellOperationRequest request, CancellationToken token);
- ///
- /// Получить список операций по запросу
- ///
- ///
- ///
- ///
- Task> GetAsync(WellsOperationRequest request, CancellationToken token);
-
- ///
+ ///
/// Получить страницу списка операций
///
///
@@ -58,31 +34,22 @@ namespace AsbCloudApp.Repositories
///
Task> GetPageAsync(WellOperationRequest request, CancellationToken token);
- ///
- /// Получить операцию по id
- ///
- ///
- ///
- ///
- Task GetOrDefaultAsync(int id, CancellationToken token);
-
- ///
+ ///
/// Получить статистику операции по скважине с группировкой по категориям
///
///
///
///
- Task> GetGroupOperationsStatAsync(
- WellOperationRequest request,
- CancellationToken token);
+ Task> GetGroupOperationsStatAsync(WellOperationRequest request, CancellationToken token);
- ///
- /// Добавить несколько операций за один раз
- ///
- ///
- ///
- ///
- Task InsertRangeAsync(IEnumerable wellOperationDtos, CancellationToken token);
+ ///
+ /// Добавить несколько операций
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task InsertRangeAsync(IEnumerable dtos, bool deleteBeforeInsert, CancellationToken token);
///
/// Обновить существующую операцию
@@ -90,7 +57,7 @@ namespace AsbCloudApp.Repositories
///
///
///
- Task UpdateAsync(WellOperationDto dto, CancellationToken token);
+ Task UpdateRangeAsync(IEnumerable dtos, CancellationToken token);
///
/// Удалить операции по id
@@ -98,7 +65,7 @@ namespace AsbCloudApp.Repositories
///
///
///
- Task DeleteAsync(IEnumerable ids, CancellationToken token);
+ Task DeleteRangeAsync(IEnumerable ids, CancellationToken token);
///
/// Получить секции скважин из операций ГГД. Секцие поделены на плановые и фактические.
@@ -115,24 +82,6 @@ namespace AsbCloudApp.Repositories
///
///
///
- Task GetDatesRangeAsync(int idWell, int idType, CancellationToken cancellationToken);
-
- ///
- /// Удаление полных дубликатов операций по всем скважинам
- ///
- ///
- ///
- ///
- Task RemoveDuplicates(Action onProgressCallback, CancellationToken token);
-
- ///
- /// Усечение пересекающейся последующей операции по дате и глубине забоя
- ///
- /// Фильтр по дате. Если хоть одна операция попадет в в фильтр, то будет обработана вся скважина, а не только эта операция
- /// Фильтр по дате. Если хоть одна операция попадет в в фильтр, то будет обработана вся скважина, а не только эта операция
- ///
- ///
- ///
- Task TrimOverlapping(DateTimeOffset? geDate, DateTimeOffset leDate, Action onProgressCallback, CancellationToken token);
- }
+ Task GetDatesRangeAsync(int idWell, int idType, CancellationToken cancellationToken);
+ }
}
\ No newline at end of file
diff --git a/AsbCloudApp/Requests/ExportOptions/WellOperationExportRequest.cs b/AsbCloudApp/Requests/ExportOptions/WellOperationExportRequest.cs
new file mode 100644
index 00000000..facbba72
--- /dev/null
+++ b/AsbCloudApp/Requests/ExportOptions/WellOperationExportRequest.cs
@@ -0,0 +1,20 @@
+namespace AsbCloudApp.Requests.ExportOptions;
+
+///
+/// Параметры экспорта ГГД
+///
+public class WellOperationExportRequest : WellRelatedExportRequest
+{
+ ///
+ public WellOperationExportRequest(int idWell,
+ int idType)
+ : base(idWell)
+ {
+ IdType = idType;
+ }
+
+ ///
+ /// Тип операций
+ ///
+ public int IdType { get; }
+}
\ No newline at end of file
diff --git a/AsbCloudApp/Requests/FileRequest.cs b/AsbCloudApp/Requests/FileRequest.cs
index 7ea84c7e..403c0655 100644
--- a/AsbCloudApp/Requests/FileRequest.cs
+++ b/AsbCloudApp/Requests/FileRequest.cs
@@ -33,12 +33,12 @@ namespace AsbCloudApp.Requests
///
/// Дата начала периода
///
- public DateTime? Begin { get; set; }
+ public DateTimeOffset? Begin { get; set; }
///
/// Дата окончания периода
///
- public DateTime? End { get; set; }
+ public DateTimeOffset? End { get; set; }
///
/// Признак удаления
diff --git a/AsbCloudApp/Requests/LimitingParameterRequest.cs b/AsbCloudApp/Requests/LimitingParameterRequest.cs
index 31fb02f0..4e1b5d98 100644
--- a/AsbCloudApp/Requests/LimitingParameterRequest.cs
+++ b/AsbCloudApp/Requests/LimitingParameterRequest.cs
@@ -17,12 +17,12 @@ namespace AsbCloudApp.Requests
///
/// Больше или равно дате
///
- public DateTime? GtDate { get; set; }
+ public DateTimeOffset? GtDate { get; set; }
///
/// Меньше или равно дате
///
- public DateTime? LtDate { get; set; }
+ public DateTimeOffset? LtDate { get; set; }
///
/// Больше или равно глубины забоя
diff --git a/AsbCloudApp/Requests/MessageRequest.cs b/AsbCloudApp/Requests/MessageRequest.cs
index 1bfba1a2..a474c7b9 100644
--- a/AsbCloudApp/Requests/MessageRequest.cs
+++ b/AsbCloudApp/Requests/MessageRequest.cs
@@ -17,12 +17,12 @@ namespace AsbCloudApp.Requests
///
/// начальная дата
///
- public DateTime? Begin { get; set; }
+ public DateTimeOffset? Begin { get; set; }
///
/// конечная дата
///
- public DateTime? End { get; set; }
+ public DateTimeOffset? End { get; set; }
///
/// строка поиска
diff --git a/AsbCloudApp/Requests/NotificationDeleteRequest.cs b/AsbCloudApp/Requests/NotificationDeleteRequest.cs
index ec2026f3..56921d70 100644
--- a/AsbCloudApp/Requests/NotificationDeleteRequest.cs
+++ b/AsbCloudApp/Requests/NotificationDeleteRequest.cs
@@ -15,10 +15,10 @@ public class NotificationDeleteRequest
///
/// Меньше или равно дате отправки
///
- public DateTime? LtSentDate { get; set; }
+ public DateTimeOffset? LtSentDate { get; set; }
///
/// Меньше или равно дате прочтения
///
- public DateTime? LtReadDate { get; set; }
+ public DateTimeOffset? LtReadDate { get; set; }
}
\ No newline at end of file
diff --git a/AsbCloudApp/Requests/ParserOptions/WellOperationParserRequest.cs b/AsbCloudApp/Requests/ParserOptions/WellOperationParserRequest.cs
new file mode 100644
index 00000000..efb9aad2
--- /dev/null
+++ b/AsbCloudApp/Requests/ParserOptions/WellOperationParserRequest.cs
@@ -0,0 +1,29 @@
+using AsbCloudApp.Data;
+
+namespace AsbCloudApp.Requests.ParserOptions;
+
+///
+/// Параметры парсинга ГГД
+///
+public class WellOperationParserRequest : WellRelatedParserRequest
+{
+ ///
+ public WellOperationParserRequest(int idWell,
+ int idType,
+ SimpleTimezoneDto wellTimezone)
+ : base(idWell)
+ {
+ IdType = idType;
+ WellTimezone = wellTimezone;
+ }
+
+ ///
+ /// Тип операции
+ ///
+ public int IdType { get; }
+
+ ///
+ /// Часовой пояс в котором находится скважина
+ ///
+ public SimpleTimezoneDto WellTimezone { get; }
+}
\ No newline at end of file
diff --git a/AsbCloudApp/Requests/ProcessMapPlanRequest.cs b/AsbCloudApp/Requests/ProcessMapPlanRequest.cs
index b614b8c3..b3247ce2 100644
--- a/AsbCloudApp/Requests/ProcessMapPlanRequest.cs
+++ b/AsbCloudApp/Requests/ProcessMapPlanRequest.cs
@@ -20,5 +20,5 @@ public class ProcessMapPlanRequest
///
/// Дата обновления
///
- public DateTime? UpdateFrom { get; set; }
+ public DateTimeOffset? UpdateFrom { get; set; }
}
\ No newline at end of file
diff --git a/AsbCloudApp/Requests/ReportParametersRequest.cs b/AsbCloudApp/Requests/ReportParametersRequest.cs
index 57b83e4d..74bc358a 100644
--- a/AsbCloudApp/Requests/ReportParametersRequest.cs
+++ b/AsbCloudApp/Requests/ReportParametersRequest.cs
@@ -24,12 +24,12 @@ public class ReportParametersRequest: IValidatableObject
///
/// Дата начала интервала
///
- public DateTime Begin { get; set; } = default;
+ public DateTimeOffset Begin { get; set; } = default;
///
/// Дата окончания интервала
///
- public DateTime End { get; set; } = default;
+ public DateTimeOffset End { get; set; } = default;
///
public IEnumerable Validate(ValidationContext validationContext)
@@ -37,7 +37,7 @@ public class ReportParametersRequest: IValidatableObject
if (End < Begin)
yield return new("End mast be less then begin");
- if (Begin < new DateTime(2000, 1, 1))
+ if (Begin < new DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.Zero))
yield return new("Begin mast be > 2000-1-1");
}
}
\ No newline at end of file
diff --git a/AsbCloudApp/Requests/SubsystemRequest.cs b/AsbCloudApp/Requests/SubsystemRequest.cs
index 23a7e70a..08b980ab 100644
--- a/AsbCloudApp/Requests/SubsystemRequest.cs
+++ b/AsbCloudApp/Requests/SubsystemRequest.cs
@@ -9,7 +9,7 @@ namespace AsbCloudApp.Requests
///
public class SubsystemRequest: RequestBase, IValidatableObject
{
- private static readonly DateTime validationMinDate = new DateTime(2020,01,01,0,0,0,DateTimeKind.Utc);
+ private static readonly DateTimeOffset validationMinDate = new DateTimeOffset(2020,01,01,0,0,0, TimeSpan.Zero);
///
/// идентификатор скважины
diff --git a/AsbCloudApp/Requests/TrajectoryRequest.cs b/AsbCloudApp/Requests/TrajectoryRequest.cs
index 954879bc..35eca8c3 100644
--- a/AsbCloudApp/Requests/TrajectoryRequest.cs
+++ b/AsbCloudApp/Requests/TrajectoryRequest.cs
@@ -15,10 +15,10 @@ public class TrajectoryRequest : RequestBase
///
/// Больше или равно дате
///
- public DateTime? GeDate { get; set; }
+ public DateTimeOffset? GeDate { get; set; }
///
/// Меньше или равно дате
///
- public DateTime? LeDate { get; set; }
+ public DateTimeOffset? LeDate { get; set; }
}
\ No newline at end of file
diff --git a/AsbCloudApp/Requests/WellOperationRequest.cs b/AsbCloudApp/Requests/WellOperationRequest.cs
index 1d190018..356ef52d 100644
--- a/AsbCloudApp/Requests/WellOperationRequest.cs
+++ b/AsbCloudApp/Requests/WellOperationRequest.cs
@@ -1,112 +1,84 @@
using System;
using System.Collections.Generic;
-namespace AsbCloudApp.Requests
+namespace AsbCloudApp.Requests;
+
+///
+/// Запрос получения ГГД
+///
+public class WellOperationRequestBase : RequestBase
{
- ///
- /// параметры для запроса списка операций
- ///
- public class WellOperationRequestBase : RequestBase
- {
- ///
- /// фильтр по дате начала операции
- ///
- public DateTime? GeDate { get; set; }
+ ///
+ /// Больше или равно дате начала операции
+ ///
+ public DateTimeOffset? GeDate { get; set; }
- ///
- /// фильтр по дате окончания операции
- ///
- public DateTime? LtDate { get; set; }
+ ///
+ /// Меньше или равно дате окончания операции
+ ///
+ public DateTimeOffset? LeDate { get; set; }
- ///
- /// фильтр. Больше или равно глубины скважины на начало операции.
- ///
- public double? GeDepth { get; set; }
+ ///
+ /// Больше или равно глубины скважины на начало операции.
+ ///
+ public double? GeDepth { get; set; }
- ///
- /// фильтр. Меньше или равно глубины скважины на конец операции.
- ///
- public double? LeDepth { get; set; }
+ ///
+ /// Меньше или равно глубины скважины на конец операции.
+ ///
+ public double? LeDepth { get; set; }
- ///
- /// фильтр по списку id категорий операции
- ///
- public IEnumerable? OperationCategoryIds { get; set; }
+ ///
+ /// Идентификаторы категорий операции
+ ///
+ public IEnumerable? OperationCategoryIds { get; set; }
- ///
- /// фильтр по план = 0, факт = 1
- ///
- public int? OperationType { get; set; }
+ ///
+ /// Тип операций
+ ///
+ /// - 0 - плановая операция
+ /// - 1 - фактическая операция
+ ///
+ ///
+ public int? OperationType { get; set; }
- ///
- /// фильтр по списку id конструкций секции
- ///
- public IEnumerable? SectionTypeIds { get; set; }
-
- ///
- /// Параметры для запроса списка операций.
- /// Базовый конструктор
- ///
- public WellOperationRequestBase()
- { }
-
- ///
- /// Параметры для запроса списка операций.
- /// Копирующий конструктор
- ///
- ///
- public WellOperationRequestBase(WellOperationRequestBase request)
- {
- GeDepth = request.GeDepth;
- LeDepth = request.LeDepth;
- GeDate = request.GeDate;
- LtDate = request.LtDate;
-
- OperationCategoryIds = request.OperationCategoryIds;
- OperationType = request.OperationType;
- SectionTypeIds = request.SectionTypeIds;
-
- Skip = request.Skip;
- Take = request.Take;
- SortFields = request.SortFields;
- }
- }
-
- ///
- /// Параметры для запроса списка операций (с id скважины)
- ///
- public class WellOperationRequest : WellOperationRequestBase
- {
- ///
- /// id скважины
- ///
- public int IdWell { get; set; }
-
- ///
- /// ctor
- ///
- public WellOperationRequest() { }
-
- ///
- /// копирующий конструктор
- ///
- ///
- ///
- public WellOperationRequest(WellOperationRequestBase request, int idWell)
- :base(request)
- {
- IdWell = idWell;
- }
- }
-
- ///
- /// Параметры для запроса списка операций (с массивом id скважин)
- ///
- public class WellsOperationRequest : WellOperationRequestBase
- {
- ///
- /// ids скважин
- ///
- public IEnumerable IdsWell { get; set; } = null!;
- }
+ ///
+ /// Идентификаторы конструкций секции
+ ///
+ public IEnumerable? SectionTypeIds { get; set; }
}
+
+///
+/// Запрос получения ГГД с идентификаторами скважин
+///
+public class WellOperationRequest : WellOperationRequestBase
+{
+ ///
+ public WellOperationRequest(IEnumerable idsWell)
+ {
+ IdsWell = idsWell;
+ }
+
+ ///
+ public WellOperationRequest(WellOperationRequestBase request, IEnumerable idsWell)
+ : this(idsWell)
+ {
+ GeDepth = request.GeDepth;
+ LeDepth = request.LeDepth;
+ GeDate = request.GeDate;
+ LeDate = request.LeDate;
+
+ OperationCategoryIds = request.OperationCategoryIds;
+ OperationType = request.OperationType;
+ SectionTypeIds = request.SectionTypeIds;
+
+ Skip = request.Skip;
+ Take = request.Take;
+ SortFields = request.SortFields;
+ }
+
+ ///
+ /// Идентификаторы скважин
+ ///
+ public IEnumerable? IdsWell { get; }
+}
\ No newline at end of file
diff --git a/AsbCloudApp/Services/DailyReport/IDailyReportService.cs b/AsbCloudApp/Services/DailyReport/IDailyReportService.cs
index f0318025..b39375a6 100644
--- a/AsbCloudApp/Services/DailyReport/IDailyReportService.cs
+++ b/AsbCloudApp/Services/DailyReport/IDailyReportService.cs
@@ -42,12 +42,4 @@ public interface IDailyReportService
///
///
Task> GetAsync(int idWell, FileReportRequest request, CancellationToken cancellationToken);
-
- ///
- /// Получить диапазон дат по которым возможно сформировать суточный отчёты
- ///
- ///
- ///
- ///
- Task GetDatesRangeAsync(int idWell, CancellationToken cancellationToken);
}
\ No newline at end of file
diff --git a/AsbCloudApp/Services/IExportService.cs b/AsbCloudApp/Services/Export/IExportService.cs
similarity index 70%
rename from AsbCloudApp/Services/IExportService.cs
rename to AsbCloudApp/Services/Export/IExportService.cs
index b921fec5..ddfd50f9 100644
--- a/AsbCloudApp/Services/IExportService.cs
+++ b/AsbCloudApp/Services/Export/IExportService.cs
@@ -3,12 +3,12 @@ using System.Threading;
using System.Threading.Tasks;
using AsbCloudApp.Requests.ExportOptions;
-namespace AsbCloudApp.Services;
+namespace AsbCloudApp.Services.Export;
///
/// Экспорт данных
///
-public interface IExportService
+public interface IExportService : IExportService
where TOptions : IExportOptionsRequest
{
///
@@ -18,4 +18,12 @@ public interface IExportService
///
///
Task<(string FileName, Stream File)> ExportAsync(TOptions options, CancellationToken token);
+}
+
+///
+/// Экспорт данных
+///
+public interface IExportService
+{
+
}
\ No newline at end of file
diff --git a/AsbCloudApp/Services/Export/IExportServiceFactory.cs b/AsbCloudApp/Services/Export/IExportServiceFactory.cs
new file mode 100644
index 00000000..fb6b5fc9
--- /dev/null
+++ b/AsbCloudApp/Services/Export/IExportServiceFactory.cs
@@ -0,0 +1,20 @@
+using AsbCloudApp.Requests.ExportOptions;
+
+namespace AsbCloudApp.Services.Export;
+
+///
+/// Фабрика создания сервисов для экспорта
+///
+///
+public interface IExportServiceFactory
+ where TId : struct
+{
+ ///
+ /// Создать сервис экспорта
+ ///
+ ///
+ ///
+ ///
+ IExportService CreateExportService(TId id)
+ where TOptions : IExportOptionsRequest;
+}
\ No newline at end of file
diff --git a/AsbCloudApp/Services/IDetectedOperationService.cs b/AsbCloudApp/Services/IDetectedOperationService.cs
index 998032ba..208706f7 100644
--- a/AsbCloudApp/Services/IDetectedOperationService.cs
+++ b/AsbCloudApp/Services/IDetectedOperationService.cs
@@ -1,10 +1,10 @@
using System;
-using AsbCloudApp.Data;
using AsbCloudApp.Data.DetectedOperation;
using AsbCloudApp.Requests;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
+using AsbCloudApp.Data.WellOperation;
namespace AsbCloudApp.Services
{
diff --git a/AsbCloudApp/Services/IOperationsStatService.cs b/AsbCloudApp/Services/IOperationsStatService.cs
index a92d0553..f5ec7c7c 100644
--- a/AsbCloudApp/Services/IOperationsStatService.cs
+++ b/AsbCloudApp/Services/IOperationsStatService.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
+using AsbCloudApp.Data.WellOperation;
namespace AsbCloudApp.Services
{
diff --git a/AsbCloudApp/Services/IReportService.cs b/AsbCloudApp/Services/IReportService.cs
index 5f992a20..4b259240 100644
--- a/AsbCloudApp/Services/IReportService.cs
+++ b/AsbCloudApp/Services/IReportService.cs
@@ -46,7 +46,7 @@ namespace AsbCloudApp.Services
///
///
///
- int GetReportPagesCount(int idWell, DateTime begin, DateTime end,
+ int GetReportPagesCount(int idWell, DateTimeOffset begin, DateTimeOffset end,
int stepSeconds, int format);
///
diff --git a/AsbCloudApp/Services/IScheduleService.cs b/AsbCloudApp/Services/IScheduleService.cs
index 5a28b4c2..81c0d385 100644
--- a/AsbCloudApp/Services/IScheduleService.cs
+++ b/AsbCloudApp/Services/IScheduleService.cs
@@ -19,7 +19,7 @@ namespace AsbCloudApp.Services
///
///
///
- Task> GetAsync(int idWell, DateTime workTime, CancellationToken token);
+ Task> GetAsync(int idWell, DateTimeOffset workTime, CancellationToken token);
///
/// получить бурильщика по idWell и времени
@@ -28,7 +28,7 @@ namespace AsbCloudApp.Services
///
///
///
- Task GetOrDefaultDrillerAsync(int idWell, DateTime workTime, CancellationToken token);
+ Task GetOrDefaultDrillerAsync(int idWell, DateTimeOffset workTime, CancellationToken token);
///
/// Получить расписание смен
diff --git a/AsbCloudApp/Services/IWellCompositeOperationService.cs b/AsbCloudApp/Services/IWellCompositeOperationService.cs
index 94ba1f93..96dbcf2b 100644
--- a/AsbCloudApp/Services/IWellCompositeOperationService.cs
+++ b/AsbCloudApp/Services/IWellCompositeOperationService.cs
@@ -1,7 +1,7 @@
-using AsbCloudApp.Data;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
+using AsbCloudApp.Data.WellOperation;
namespace AsbCloudApp.Services
{
@@ -16,6 +16,6 @@ namespace AsbCloudApp.Services
///
///
///
- Task>> GetAsync(IEnumerable idsWells, CancellationToken token);
+ Task>> GetAsync(IEnumerable idsWells, CancellationToken token);
}
}
diff --git a/AsbCloudApp/Services/IWellService.cs b/AsbCloudApp/Services/IWellService.cs
index edea98ae..4279f587 100644
--- a/AsbCloudApp/Services/IWellService.cs
+++ b/AsbCloudApp/Services/IWellService.cs
@@ -72,7 +72,7 @@ namespace AsbCloudApp.Services
///
///
///
- DateTime GetLastTelemetryDate(int idWell);
+ DateTimeOffset GetLastTelemetryDate(int idWell);
//TODO: выяснить и удалить отсюда
///
diff --git a/AsbCloudApp/Services/Notifications/NotificationService.cs b/AsbCloudApp/Services/Notifications/NotificationService.cs
index d703ffb4..97b8bfb5 100644
--- a/AsbCloudApp/Services/Notifications/NotificationService.cs
+++ b/AsbCloudApp/Services/Notifications/NotificationService.cs
@@ -49,7 +49,7 @@ public class NotificationService
var notification = new NotificationDto
{
IdUser = request.IdUser,
- RegistrationDate = DateTime.UtcNow,
+ RegistrationDate = DateTimeOffset.UtcNow,
IdNotificationCategory = notificationCategory.Id,
Title = request.Title,
Message = request.Message,
@@ -71,7 +71,7 @@ public class NotificationService
Console.WriteLine(ex.Message);
}
- notification.SentDate = DateTime.UtcNow;
+ notification.SentDate = DateTimeOffset.UtcNow;
await notificationRepository.UpdateAsync(notification, cancellationToken);
}
@@ -92,7 +92,7 @@ public class NotificationService
if(isRead && !notification.SentDate.HasValue)
throw new ArgumentInvalidException(nameof(isRead), "Уведомление не может быть прочитано");
- notification.ReadDate = isRead ? DateTime.UtcNow : null;
+ notification.ReadDate = isRead ? DateTimeOffset.UtcNow : null;
await notificationRepository.UpdateAsync(notification,
cancellationToken);
@@ -119,7 +119,7 @@ public class NotificationService
var tasks = notifications.Select(notification =>
{
- notification.SentDate = DateTime.UtcNow;
+ notification.SentDate = DateTimeOffset.UtcNow;
return notificationRepository.UpdateAsync(notification, cancellationToken);
});
diff --git a/AsbCloudApp/Services/Parsers/IParserFactory.cs b/AsbCloudApp/Services/Parsers/IParserFactory.cs
new file mode 100644
index 00000000..e0fc1aa2
--- /dev/null
+++ b/AsbCloudApp/Services/Parsers/IParserFactory.cs
@@ -0,0 +1,23 @@
+using AsbCloudApp.Data;
+using AsbCloudApp.Requests.ParserOptions;
+
+namespace AsbCloudApp.Services.Parsers;
+
+///
+/// Фабрика для создания сервиса парсинга
+///
+///
+///
+public interface IParserFactory
+ where TId : struct
+ where TDto : class, IId
+{
+ ///
+ /// Создать парсер
+ ///
+ ///
+ ///
+ ///
+ IParserService CreateParser(TId id)
+ where TOptions : IParserOptionsRequest;
+}
\ No newline at end of file
diff --git a/AsbCloudApp/Services/IParserService.cs b/AsbCloudApp/Services/Parsers/IParserService.cs
similarity index 76%
rename from AsbCloudApp/Services/IParserService.cs
rename to AsbCloudApp/Services/Parsers/IParserService.cs
index 89212ba7..672c9e2b 100644
--- a/AsbCloudApp/Services/IParserService.cs
+++ b/AsbCloudApp/Services/Parsers/IParserService.cs
@@ -2,14 +2,14 @@ using System.IO;
using AsbCloudApp.Data;
using AsbCloudApp.Requests.ParserOptions;
-namespace AsbCloudApp.Services;
+namespace AsbCloudApp.Services.Parsers;
///
/// Сервис парсинга
///
///
///
-public interface IParserService
+public interface IParserService : IParserService
where TDto : class, IId
where TOptions : IParserOptionsRequest
{
@@ -26,4 +26,11 @@ public interface IParserService
///
///
Stream GetTemplateFile();
+}
+
+///
+/// Сервис парсинга
+///
+public interface IParserService
+{
}
\ No newline at end of file
diff --git a/AsbCloudApp/Services/WellOperationImport/IWellOperationExcelParser.cs b/AsbCloudApp/Services/WellOperationImport/IWellOperationExcelParser.cs
deleted file mode 100644
index 7a695beb..00000000
--- a/AsbCloudApp/Services/WellOperationImport/IWellOperationExcelParser.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System.IO;
-using AsbCloudApp.Data.WellOperationImport;
-using AsbCloudApp.Data.WellOperationImport.Options;
-
-namespace AsbCloudApp.Services.WellOperationImport;
-
-///
-/// Парсинг операций из excel файла
-///
-public interface IWellOperationExcelParser
- where TOptions : IWellOperationImportOptions
-{
- ///
- /// Метод парсинга документа
- ///
- ///
- ///
- ///
- SheetDto Parse(Stream stream, TOptions options);
-}
\ No newline at end of file
diff --git a/AsbCloudApp/Services/WellOperationImport/IWellOperationExportService.cs b/AsbCloudApp/Services/WellOperationImport/IWellOperationExportService.cs
deleted file mode 100644
index 9b0a96ac..00000000
--- a/AsbCloudApp/Services/WellOperationImport/IWellOperationExportService.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System.IO;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace AsbCloudApp.Services.WellOperationImport;
-
-///
-/// Экспорт ГГД
-///
-public interface IWellOperationExportService
-{
- ///
- /// Скачать в excel
- ///
- ///
- ///
- ///
- Task ExportAsync(int idWell, CancellationToken cancellationToken);
-}
\ No newline at end of file
diff --git a/AsbCloudApp/Services/WellOperationImport/IWellOperationImportService.cs b/AsbCloudApp/Services/WellOperationImport/IWellOperationImportService.cs
deleted file mode 100644
index f65d8888..00000000
--- a/AsbCloudApp/Services/WellOperationImport/IWellOperationImportService.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System.Collections.Generic;
-using AsbCloudApp.Data;
-using AsbCloudApp.Data.WellOperationImport;
-
-namespace AsbCloudApp.Services.WellOperationImport;
-
-///
-/// Импорт ГГД
-///
-public interface IWellOperationImportService
-{
- ///
- /// Загрузить из excel список операций
- ///
- ///
- ///
- ///
- ///
- IEnumerable Import(int idWell, int idUser, int idType, SheetDto sheet);
-}
\ No newline at end of file
diff --git a/AsbCloudApp/Services/WellOperationImport/IWellOperationImportTemplateService.cs b/AsbCloudApp/Services/WellOperationImport/IWellOperationImportTemplateService.cs
deleted file mode 100644
index 817f3ae5..00000000
--- a/AsbCloudApp/Services/WellOperationImport/IWellOperationImportTemplateService.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System.IO;
-
-namespace AsbCloudApp.Services.WellOperationImport;
-
-///
-/// Сервис для получения шаблонов ГГД
-///
-public interface IWellOperationImportTemplateService
-{
- ///
- /// Скачать шаблон для заполнения
- ///
- ///
- Stream GetExcelTemplateStream();
-}
\ No newline at end of file
diff --git a/AsbCloudDb/Migrations/AsbCloudDbContextModelSnapshot.cs b/AsbCloudDb/Migrations/AsbCloudDbContextModelSnapshot.cs
index 9957e235..b572b8da 100644
--- a/AsbCloudDb/Migrations/AsbCloudDbContextModelSnapshot.cs
+++ b/AsbCloudDb/Migrations/AsbCloudDbContextModelSnapshot.cs
@@ -63,9 +63,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdDeposit");
- b.ToTable("t_cluster");
-
- b.HasComment("Кусты");
+ b.ToTable("t_cluster", t =>
+ {
+ t.HasComment("Кусты");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.Company", b =>
@@ -264,9 +265,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
- b.ToTable("t_contact");
-
- b.HasComment("Контакты");
+ b.ToTable("t_contact", t =>
+ {
+ t.HasComment("Контакты");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.DailyReports.DailyReport", b =>
@@ -312,9 +314,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell", "Date")
.IsUnique();
- b.ToTable("t_daily_report");
-
- b.HasComment("Ежедневные отчёты");
+ b.ToTable("t_daily_report", t =>
+ {
+ t.HasComment("Ежедневные отчёты");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.DataSaubStat", b =>
@@ -442,9 +445,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdTelemetry");
- b.ToTable("t_data_saub_stat");
-
- b.HasComment("Кеш-таблица для хранения данных для РТК-отчета");
+ b.ToTable("t_data_saub_stat", t =>
+ {
+ t.HasComment("Кеш-таблица для хранения данных для РТК-отчета");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.Deposit", b =>
@@ -478,9 +482,10 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
- b.ToTable("t_deposit");
-
- b.HasComment("Месторождение");
+ b.ToTable("t_deposit", null, t =>
+ {
+ t.HasComment("Месторождение");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.DetectedOperation", b =>
@@ -548,75 +553,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdTelemetry");
- b.ToTable("t_detected_operation");
-
- b.HasComment("автоматически определенные операции по телеметрии");
- });
-
- modelBuilder.Entity("AsbCloudDb.Model.Driller", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer")
- .HasColumnName("id")
- .HasComment("Идентификатор");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
-
- b.Property("Name")
- .IsRequired()
- .HasMaxLength(255)
- .HasColumnType("character varying(255)")
- .HasColumnName("name")
- .HasComment("Имя");
-
- b.Property("Patronymic")
- .HasMaxLength(255)
- .HasColumnType("character varying(255)")
- .HasColumnName("patronymic")
- .HasComment("Отчество");
-
- b.Property("Surname")
- .IsRequired()
- .HasMaxLength(255)
- .HasColumnType("character varying(255)")
- .HasColumnName("surname")
- .HasComment("Фамилия");
-
- b.HasKey("Id");
-
- b.ToTable("t_driller");
-
- b.HasComment("Бурильщик");
- });
-
- modelBuilder.Entity("AsbCloudDb.Model.DrillingProgramPart", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer")
- .HasColumnName("id");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
-
- b.Property("IdFileCategory")
- .HasColumnType("integer")
- .HasColumnName("id_file_category");
-
- b.Property("IdWell")
- .HasColumnType("integer")
- .HasColumnName("id_well");
-
- b.HasKey("Id");
-
- b.HasIndex("IdFileCategory");
-
- b.HasIndex("IdWell", "IdFileCategory")
- .IsUnique();
-
- b.ToTable("t_drilling_program_part");
-
- b.HasComment("части программ бурения");
+ b.ToTable("t_detected_operation", null, t =>
+ {
+ t.HasComment("автоматически определенные операции по телеметрии");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.DrillTest", b =>
@@ -651,9 +591,78 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdTelemetry");
- b.ToTable("t_drill_test");
+ b.ToTable("t_drill_test", null, t =>
+ {
+ t.HasComment("Drill_test");
+ });
+ });
- b.HasComment("Drill_test");
+ modelBuilder.Entity("AsbCloudDb.Model.Driller", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer")
+ .HasColumnName("id")
+ .HasComment("Идентификатор");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)")
+ .HasColumnName("name")
+ .HasComment("Имя");
+
+ b.Property("Patronymic")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)")
+ .HasColumnName("patronymic")
+ .HasComment("Отчество");
+
+ b.Property("Surname")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)")
+ .HasColumnName("surname")
+ .HasComment("Фамилия");
+
+ b.HasKey("Id");
+
+ b.ToTable("t_driller", null, t =>
+ {
+ t.HasComment("Бурильщик");
+ });
+ });
+
+ modelBuilder.Entity("AsbCloudDb.Model.DrillingProgramPart", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer")
+ .HasColumnName("id");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("IdFileCategory")
+ .HasColumnType("integer")
+ .HasColumnName("id_file_category");
+
+ b.Property("IdWell")
+ .HasColumnType("integer")
+ .HasColumnName("id_well");
+
+ b.HasKey("Id");
+
+ b.HasIndex("IdFileCategory");
+
+ b.HasIndex("IdWell", "IdFileCategory")
+ .IsUnique();
+
+ b.ToTable("t_drilling_program_part", null, t =>
+ {
+ t.HasComment("части программ бурения");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.Faq", b =>
@@ -728,9 +737,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdAuthorQuestion");
- b.ToTable("t_faq");
-
- b.HasComment("вопросы пользователей");
+ b.ToTable("t_faq", null, t =>
+ {
+ t.HasComment("вопросы пользователей");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.FileCategory", b =>
@@ -755,9 +765,10 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
- b.ToTable("t_file_category");
-
- b.HasComment("Категории файлов");
+ b.ToTable("t_file_category", null, t =>
+ {
+ t.HasComment("Категории файлов");
+ });
b.HasData(
new
@@ -1155,9 +1166,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
- b.ToTable("t_file_info");
-
- b.HasComment("Файлы всех категорий");
+ b.ToTable("t_file_info", null, t =>
+ {
+ t.HasComment("Файлы всех категорий");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.FileMark", b =>
@@ -1206,9 +1218,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdUser");
- b.ToTable("t_file_mark");
-
- b.HasComment("Действия с файлами.");
+ b.ToTable("t_file_mark", null, t =>
+ {
+ t.HasComment("Действия с файлами.");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsItemFloat", b =>
@@ -1235,9 +1248,10 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdTelemetry", "IdRecord", "IdItem", "DateTime");
- b.ToTable("t_wits_float");
-
- b.HasComment("таблица данных ГТИ с типом значения float");
+ b.ToTable("t_wits_float", null, t =>
+ {
+ t.HasComment("таблица данных ГТИ с типом значения float");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsItemInt", b =>
@@ -1264,9 +1278,10 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdTelemetry", "IdRecord", "IdItem", "DateTime");
- b.ToTable("t_wits_int");
-
- b.HasComment("таблица данных ГТИ с типом значения int");
+ b.ToTable("t_wits_int", null, t =>
+ {
+ t.HasComment("таблица данных ГТИ с типом значения int");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsItemString", b =>
@@ -1294,9 +1309,10 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdTelemetry", "IdRecord", "IdItem", "DateTime");
- b.ToTable("t_wits_string");
-
- b.HasComment("таблица данных ГТИ с типом значения string");
+ b.ToTable("t_wits_string", null, t =>
+ {
+ t.HasComment("таблица данных ГТИ с типом значения string");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.HelpPage", b =>
@@ -1334,9 +1350,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdCategory");
- b.ToTable("t_help_page");
-
- b.HasComment("Справки");
+ b.ToTable("t_help_page", null, t =>
+ {
+ t.HasComment("Справки");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.LimitingParameter", b =>
@@ -1376,9 +1393,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdTelemetry");
- b.ToTable("t_limiting_parameter");
-
- b.HasComment("Ограничения по параметрам телеметрии");
+ b.ToTable("t_limiting_parameter", null, t =>
+ {
+ t.HasComment("Ограничения по параметрам телеметрии");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.Manuals.Manual", b =>
@@ -1424,9 +1442,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdDirectory");
- b.ToTable("t_manual");
-
- b.HasComment("Инструкции");
+ b.ToTable("t_manual", null, t =>
+ {
+ t.HasComment("Инструкции");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.Manuals.ManualDirectory", b =>
@@ -1453,9 +1472,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdParent");
- b.ToTable("t_manual_directory");
-
- b.HasComment("Директория для инструкций");
+ b.ToTable("t_manual_directory", null, t =>
+ {
+ t.HasComment("Директория для инструкций");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.Measure", b =>
@@ -1499,9 +1519,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
- b.ToTable("t_measure");
-
- b.HasComment("Таблица c данными для вкладки 'Последние данные'");
+ b.ToTable("t_measure", null, t =>
+ {
+ t.HasComment("Таблица c данными для вкладки 'Последние данные'");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.MeasureCategory", b =>
@@ -1526,9 +1547,10 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
- b.ToTable("t_measure_category");
-
- b.HasComment("Категория последних данных");
+ b.ToTable("t_measure_category", null, t =>
+ {
+ t.HasComment("Категория последних данных");
+ });
b.HasData(
new
@@ -1608,9 +1630,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdUser");
- b.ToTable("t_notification");
-
- b.HasComment("Уведомления");
+ b.ToTable("t_notification", null, t =>
+ {
+ t.HasComment("Уведомления");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.NotificationCategory", b =>
@@ -1629,9 +1652,10 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
- b.ToTable("t_notification_category");
-
- b.HasComment("Категории уведомлений");
+ b.ToTable("t_notification_category", null, t =>
+ {
+ t.HasComment("Категории уведомлений");
+ });
b.HasData(
new
@@ -1687,9 +1711,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
- b.ToTable("t_operationvalue");
-
- b.HasComment("Целевые/нормативные показатели операции");
+ b.ToTable("t_operationvalue", null, t =>
+ {
+ t.HasComment("Целевые/нормативные показатели операции");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.Permission", b =>
@@ -1716,9 +1741,10 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
- b.ToTable("t_permission");
-
- b.HasComment("Разрешения на доступ к данным");
+ b.ToTable("t_permission", null, t =>
+ {
+ t.HasComment("Разрешения на доступ к данным");
+ });
b.HasData(
new
@@ -2742,9 +2768,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWellSectionType");
- b.ToTable("t_process_map_plan_drilling");
-
- b.HasComment("РТК план бурение");
+ b.ToTable("t_process_map_plan_drilling", null, t =>
+ {
+ t.HasComment("РТК план бурение");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.ProcessMaps.ProcessMapPlanReam", b =>
@@ -2862,9 +2889,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWellSectionType");
- b.ToTable("t_process_map_plan_ream");
-
- b.HasComment("РТК проработка скважины");
+ b.ToTable("t_process_map_plan_ream", null, t =>
+ {
+ t.HasComment("РТК проработка скважины");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.RelationCompanyWell", b =>
@@ -2881,9 +2909,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
- b.ToTable("t_relation_company_well");
-
- b.HasComment("отношение скважин и компаний");
+ b.ToTable("t_relation_company_well", null, t =>
+ {
+ t.HasComment("отношение скважин и компаний");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.RelationContactWell", b =>
@@ -2900,7 +2929,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdUser");
- b.ToTable("t_relation_contact_well");
+ b.ToTable("t_relation_contact_well", (string)null);
});
modelBuilder.Entity("AsbCloudDb.Model.RelationUserDrillingProgramPart", b =>
@@ -2923,9 +2952,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdDrillingProgramPart");
- b.ToTable("t_relation_user_drilling_program_part");
-
- b.HasComment("Отношение пользователей и частей ПБ");
+ b.ToTable("t_relation_user_drilling_program_part", null, t =>
+ {
+ t.HasComment("Отношение пользователей и частей ПБ");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.RelationUserRolePermission", b =>
@@ -2942,9 +2972,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdPermission");
- b.ToTable("t_relation_user_role_permission");
-
- b.HasComment("Отношение ролей пользователей и разрешений доступа");
+ b.ToTable("t_relation_user_role_permission", null, t =>
+ {
+ t.HasComment("Отношение ролей пользователей и разрешений доступа");
+ });
b.HasData(
new
@@ -4259,9 +4290,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdInclude");
- b.ToTable("t_relation_user_role_user_role");
-
- b.HasComment("Отношение ролей к ролям");
+ b.ToTable("t_relation_user_role_user_role", null, t =>
+ {
+ t.HasComment("Отношение ролей к ролям");
+ });
b.HasData(
new
@@ -4550,9 +4582,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdUserRole");
- b.ToTable("t_relation_user_user_role");
-
- b.HasComment("Отношение пользователей и ролей");
+ b.ToTable("t_relation_user_user_role", null, t =>
+ {
+ t.HasComment("Отношение пользователей и ролей");
+ });
b.HasData(
new
@@ -4606,9 +4639,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
- b.ToTable("t_report_property");
-
- b.HasComment("Отчеты с данными по буровым");
+ b.ToTable("t_report_property", null, t =>
+ {
+ t.HasComment("Отчеты с данными по буровым");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.Schedule", b =>
@@ -4657,9 +4691,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
- b.ToTable("t_schedule");
-
- b.HasComment("График работы бурильщика");
+ b.ToTable("t_schedule", null, t =>
+ {
+ t.HasComment("График работы бурильщика");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.SetpointsRequest", b =>
@@ -4712,9 +4747,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
- b.ToTable("t_setpoints_rquest");
-
- b.HasComment("Запросы на изменение уставок панели оператора");
+ b.ToTable("t_setpoints_rquest", null, t =>
+ {
+ t.HasComment("Запросы на изменение уставок панели оператора");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.Subsystem", b =>
@@ -4739,9 +4775,10 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
- b.ToTable("t_subsystem");
-
- b.HasComment("Описание подсистем");
+ b.ToTable("t_subsystem", null, t =>
+ {
+ t.HasComment("Описание подсистем");
+ });
b.HasData(
new
@@ -4807,9 +4844,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex(new[] { "RemoteUid" }, "t_telemetry_remote_uid_index");
- b.ToTable("t_telemetry");
-
- b.HasComment("таблица привязки телеметрии от комплектов к конкретной скважине.");
+ b.ToTable("t_telemetry", null, t =>
+ {
+ t.HasComment("таблица привязки телеметрии от комплектов к конкретной скважине.");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.TelemetryDataSaub", b =>
@@ -5025,9 +5063,10 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdTelemetry", "DateTime");
- b.ToTable("t_telemetry_data_saub");
-
- b.HasComment("набор основных данных по SAUB");
+ b.ToTable("t_telemetry_data_saub", null, t =>
+ {
+ t.HasComment("набор основных данных по SAUB");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.TelemetryDataSaubStat", b =>
@@ -5056,7 +5095,9 @@ namespace AsbCloudDb.Migrations
.HasColumnType("integer")
.HasColumnName("id_telemetry");
- b.ToView("mw_telemetry_datas_saub_stat");
+ b.ToTable((string)null);
+
+ b.ToView("mw_telemetry_datas_saub_stat", (string)null);
});
modelBuilder.Entity("AsbCloudDb.Model.TelemetryDataSpin", b =>
@@ -5122,9 +5163,10 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdTelemetry", "DateTime");
- b.ToTable("t_telemetry_data_spin");
-
- b.HasComment("набор основных данных по SpinMaster");
+ b.ToTable("t_telemetry_data_spin", null, t =>
+ {
+ t.HasComment("набор основных данных по SpinMaster");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.TelemetryEvent", b =>
@@ -5148,9 +5190,10 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdTelemetry", "IdEvent");
- b.ToTable("t_telemetry_event");
-
- b.HasComment("Справочник событий. События формируют сообщения. Разделено по версиям посылок от телеметрии.");
+ b.ToTable("t_telemetry_event", null, t =>
+ {
+ t.HasComment("Справочник событий. События формируют сообщения. Разделено по версиям посылок от телеметрии.");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.TelemetryMessage", b =>
@@ -5208,9 +5251,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdTelemetry");
- b.ToTable("t_telemetry_message");
-
- b.HasComment("Сообщения на буровых");
+ b.ToTable("t_telemetry_message", null, t =>
+ {
+ t.HasComment("Сообщения на буровых");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.TelemetryUser", b =>
@@ -5245,9 +5289,10 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdTelemetry", "IdUser");
- b.ToTable("t_telemetry_user");
-
- b.HasComment("Пользователи панели САУБ. Для сообщений.");
+ b.ToTable("t_telemetry_user", null, t =>
+ {
+ t.HasComment("Пользователи панели САУБ. Для сообщений.");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.TelemetryWirelineRunOut", b =>
@@ -5287,9 +5332,10 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdTelemetry");
- b.ToTable("t_telemetry_wireline_run_out");
-
- b.HasComment("Наработка талевого каната");
+ b.ToTable("t_telemetry_wireline_run_out", null, t =>
+ {
+ t.HasComment("Наработка талевого каната");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.Trajectory.TrajectoryFact", b =>
@@ -5352,9 +5398,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
- b.ToTable("t_trajectory_fact");
-
- b.HasComment("Загрузка фактической траектории");
+ b.ToTable("t_trajectory_fact", null, t =>
+ {
+ t.HasComment("Загрузка фактической траектории");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.Trajectory.TrajectoryPlan", b =>
@@ -5422,9 +5469,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
- b.ToTable("t_trajectory_plan");
-
- b.HasComment("Загрузка плановой траектории");
+ b.ToTable("t_trajectory_plan", null, t =>
+ {
+ t.HasComment("Загрузка плановой траектории");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.User", b =>
@@ -5502,9 +5550,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("Login")
.IsUnique();
- b.ToTable("t_user");
-
- b.HasComment("Пользователи облака");
+ b.ToTable("t_user", null, t =>
+ {
+ t.HasComment("Пользователи облака");
+ });
b.HasData(
new
@@ -5542,9 +5591,10 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
- b.ToTable("t_user_role");
-
- b.HasComment("Роли пользователей в системе");
+ b.ToTable("t_user_role", null, t =>
+ {
+ t.HasComment("Роли пользователей в системе");
+ });
b.HasData(
new
@@ -5880,9 +5930,53 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdUser", "Key");
- b.ToTable("t_user_settings");
+ b.ToTable("t_user_settings", null, t =>
+ {
+ t.HasComment("настройки интерфейса пользователя");
+ });
+ });
- b.HasComment("настройки интерфейса пользователя");
+ modelBuilder.Entity("AsbCloudDb.Model.WITS.RecordBase", b =>
+ {
+ b.Property("IdTelemetry")
+ .HasColumnType("integer")
+ .HasColumnName("id_telemetry");
+
+ b.Property("DateTime")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("date");
+
+ b.Property("Actcod")
+ .HasColumnType("smallint")
+ .HasColumnName("ACTCOD");
+
+ b.Property("Date")
+ .HasColumnType("integer")
+ .HasColumnName("DATE");
+
+ b.Property("Recid")
+ .HasColumnType("smallint")
+ .HasColumnName("RECID");
+
+ b.Property("Seqid")
+ .HasColumnType("integer")
+ .HasColumnName("SEQID");
+
+ b.Property("Stknum")
+ .HasColumnType("smallint")
+ .HasColumnName("STKNUM");
+
+ b.Property("Time")
+ .HasColumnType("integer")
+ .HasColumnName("TIME");
+
+ b.Property("Wellid")
+ .HasColumnType("text")
+ .HasColumnName("WELLID");
+
+ b.HasKey("IdTelemetry", "DateTime");
+
+ b.ToTable("t_telemetry_wits_base", (string)null);
});
modelBuilder.Entity("AsbCloudDb.Model.Well", b =>
@@ -5940,9 +6034,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWellType");
- b.ToTable("t_well");
-
- b.HasComment("скважины");
+ b.ToTable("t_well", null, t =>
+ {
+ t.HasComment("скважины");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.WellComposite", b =>
@@ -5968,9 +6063,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWellSrc");
- b.ToTable("t_well_composite");
-
- b.HasComment("Композитная скважина");
+ b.ToTable("t_well_composite", null, t =>
+ {
+ t.HasComment("Композитная скважина");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.WellFinalDocument", b =>
@@ -5994,9 +6090,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdUser");
- b.ToTable("t_well_final_documents");
-
- b.HasComment("Дело скважины");
+ b.ToTable("t_well_final_documents", null, t =>
+ {
+ t.HasComment("Дело скважины");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.WellOperation", b =>
@@ -6083,9 +6180,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWellSectionType");
- b.ToTable("t_well_operation");
-
- b.HasComment("Данные по операциям на скважине");
+ b.ToTable("t_well_operation", null, t =>
+ {
+ t.HasComment("Данные по операциям на скважине");
+ });
});
modelBuilder.Entity("AsbCloudDb.Model.WellOperationCategory", b =>
@@ -6124,9 +6222,10 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdParent");
- b.ToTable("t_well_operation_category");
-
- b.HasComment("Справочник операций на скважине");
+ b.ToTable("t_well_operation_category", null, t =>
+ {
+ t.HasComment("Справочник операций на скважине");
+ });
b.HasData(
new
@@ -7213,65 +7312,6 @@ namespace AsbCloudDb.Migrations
});
});
- modelBuilder.Entity("AsbCloudDb.Model.WellSections.WellSectionPlan", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer")
- .HasColumnName("id");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
-
- b.Property("DepthEnd")
- .HasColumnType("double precision")
- .HasColumnName("depth_end")
- .HasComment("Конечная глубина бурения, м");
-
- b.Property("DepthStart")
- .HasColumnType("double precision")
- .HasColumnName("depth_start")
- .HasComment("Начальная глубина бурения, м");
-
- b.Property("IdSectionType")
- .HasColumnType("integer")
- .HasColumnName("id_section_type")
- .HasComment("Тип секции");
-
- b.Property("IdUser")
- .HasColumnType("integer")
- .HasColumnName("id_user")
- .HasComment("Id пользователя");
-
- b.Property("IdWell")
- .HasColumnType("integer")
- .HasColumnName("id_well")
- .HasComment("Id скважины");
-
- b.Property("InnerDiameter")
- .HasColumnType("double precision")
- .HasColumnName("inner_diameter")
- .HasComment("Внутренний диаметр");
-
- b.Property("LastUpdateDate")
- .HasColumnType("timestamp with time zone")
- .HasColumnName("date_last_update")
- .HasComment("Дата последнего обновления");
-
- b.Property("OuterDiameter")
- .HasColumnType("double precision")
- .HasColumnName("outer_diameter")
- .HasComment("Внешний диаметр");
-
- b.HasKey("Id");
-
- b.HasIndex("IdSectionType");
-
- b.HasIndex("IdWell", "IdSectionType")
- .IsUnique();
-
- b.ToTable("t_well_section_plan");
- });
-
modelBuilder.Entity("AsbCloudDb.Model.WellSectionType", b =>
{
b.Property("Id")
@@ -7295,9 +7335,10 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
- b.ToTable("t_well_section_type");
-
- b.HasComment("конструкция секции скважины");
+ b.ToTable("t_well_section_type", null, t =>
+ {
+ t.HasComment("конструкция секции скважины");
+ });
b.HasData(
new
@@ -7530,6 +7571,65 @@ namespace AsbCloudDb.Migrations
});
});
+ modelBuilder.Entity("AsbCloudDb.Model.WellSections.WellSectionPlan", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer")
+ .HasColumnName("id");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("DepthEnd")
+ .HasColumnType("double precision")
+ .HasColumnName("depth_end")
+ .HasComment("Конечная глубина бурения, м");
+
+ b.Property("DepthStart")
+ .HasColumnType("double precision")
+ .HasColumnName("depth_start")
+ .HasComment("Начальная глубина бурения, м");
+
+ b.Property("IdSectionType")
+ .HasColumnType("integer")
+ .HasColumnName("id_section_type")
+ .HasComment("Тип секции");
+
+ b.Property("IdUser")
+ .HasColumnType("integer")
+ .HasColumnName("id_user")
+ .HasComment("Id пользователя");
+
+ b.Property("IdWell")
+ .HasColumnType("integer")
+ .HasColumnName("id_well")
+ .HasComment("Id скважины");
+
+ b.Property("InnerDiameter")
+ .HasColumnType("double precision")
+ .HasColumnName("inner_diameter")
+ .HasComment("Внутренний диаметр");
+
+ b.Property("LastUpdateDate")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("date_last_update")
+ .HasComment("Дата последнего обновления");
+
+ b.Property("OuterDiameter")
+ .HasColumnType("double precision")
+ .HasColumnName("outer_diameter")
+ .HasComment("Внешний диаметр");
+
+ b.HasKey("Id");
+
+ b.HasIndex("IdSectionType");
+
+ b.HasIndex("IdWell", "IdSectionType")
+ .IsUnique();
+
+ b.ToTable("t_well_section_plan", (string)null);
+ });
+
modelBuilder.Entity("AsbCloudDb.Model.WellType", b =>
{
b.Property("Id")
@@ -7548,9 +7648,10 @@ namespace AsbCloudDb.Migrations
b.HasKey("Id");
- b.ToTable("t_well_type");
-
- b.HasComment("конструкция скважины");
+ b.ToTable("t_well_type", null, t =>
+ {
+ t.HasComment("конструкция скважины");
+ });
b.HasData(
new
@@ -7565,49 +7666,6 @@ namespace AsbCloudDb.Migrations
});
});
- modelBuilder.Entity("AsbCloudDb.Model.WITS.RecordBase", b =>
- {
- b.Property("IdTelemetry")
- .HasColumnType("integer")
- .HasColumnName("id_telemetry");
-
- b.Property("DateTime")
- .HasColumnType("timestamp with time zone")
- .HasColumnName("date");
-
- b.Property("Actcod")
- .HasColumnType("smallint")
- .HasColumnName("ACTCOD");
-
- b.Property("Date")
- .HasColumnType("integer")
- .HasColumnName("DATE");
-
- b.Property("Recid")
- .HasColumnType("smallint")
- .HasColumnName("RECID");
-
- b.Property("Seqid")
- .HasColumnType("integer")
- .HasColumnName("SEQID");
-
- b.Property("Stknum")
- .HasColumnType("smallint")
- .HasColumnName("STKNUM");
-
- b.Property("Time")
- .HasColumnType("integer")
- .HasColumnName("TIME");
-
- b.Property("Wellid")
- .HasColumnType("text")
- .HasColumnName("WELLID");
-
- b.HasKey("IdTelemetry", "DateTime");
-
- b.ToTable("t_telemetry_wits_base");
- });
-
modelBuilder.Entity("AsbCloudDb.Model.WITS.Record1", b =>
{
b.HasBaseType("AsbCloudDb.Model.WITS.RecordBase");
@@ -7769,7 +7827,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("TelemetryId");
- b.ToTable("t_telemetry_wits_1");
+ b.ToTable("t_telemetry_wits_1", (string)null);
});
modelBuilder.Entity("AsbCloudDb.Model.WITS.Record50", b =>
@@ -7857,7 +7915,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("TelemetryId");
- b.ToTable("t_telemetry_wits_50");
+ b.ToTable("t_telemetry_wits_50", (string)null);
});
modelBuilder.Entity("AsbCloudDb.Model.WITS.Record60", b =>
@@ -7909,7 +7967,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("TelemetryId");
- b.ToTable("t_telemetry_wits_60");
+ b.ToTable("t_telemetry_wits_60", (string)null);
});
modelBuilder.Entity("AsbCloudDb.Model.WITS.Record61", b =>
@@ -7965,7 +8023,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("TelemetryId");
- b.ToTable("t_telemetry_wits_61");
+ b.ToTable("t_telemetry_wits_61", (string)null);
});
modelBuilder.Entity("AsbCloudDb.Model.WITS.Record7", b =>
@@ -8053,7 +8111,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("TelemetryId");
- b.ToTable("t_telemetry_wits_7");
+ b.ToTable("t_telemetry_wits_7", (string)null);
});
modelBuilder.Entity("AsbCloudDb.Model.WITS.Record8", b =>
@@ -8257,7 +8315,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("TelemetryId");
- b.ToTable("t_telemetry_wits_8");
+ b.ToTable("t_telemetry_wits_8", (string)null);
});
modelBuilder.Entity("AsbCloudDb.Model.Cluster", b =>
@@ -8351,6 +8409,17 @@ namespace AsbCloudDb.Migrations
b.Navigation("Telemetry");
});
+ modelBuilder.Entity("AsbCloudDb.Model.DrillTest", b =>
+ {
+ b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry")
+ .WithMany()
+ .HasForeignKey("IdTelemetry")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Telemetry");
+ });
+
modelBuilder.Entity("AsbCloudDb.Model.DrillingProgramPart", b =>
{
b.HasOne("AsbCloudDb.Model.FileCategory", "FileCategory")
@@ -8370,17 +8439,6 @@ namespace AsbCloudDb.Migrations
b.Navigation("Well");
});
- modelBuilder.Entity("AsbCloudDb.Model.DrillTest", b =>
- {
- b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry")
- .WithMany()
- .HasForeignKey("IdTelemetry")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Telemetry");
- });
-
modelBuilder.Entity("AsbCloudDb.Model.Faq", b =>
{
b.HasOne("AsbCloudDb.Model.User", "AuthorAnswer")
diff --git a/AsbCloudDb/Model/DailyReports/DailyReport.cs b/AsbCloudDb/Model/DailyReports/DailyReport.cs
index c521ca54..8bc99470 100644
--- a/AsbCloudDb/Model/DailyReports/DailyReport.cs
+++ b/AsbCloudDb/Model/DailyReports/DailyReport.cs
@@ -18,7 +18,7 @@ public class DailyReport : IId
public int IdWell { get; set; }
[Column("date_last_update", TypeName = "timestamp with time zone"), Comment("Дата последнего обновления")]
- public DateTime? DateLastUpdate { get; set; }
+ public DateTimeOffset? DateLastUpdate { get; set; }
[Column("date", TypeName = "date"), Comment("Дата формирования отчёта")]
public DateOnly Date { get; set; }
diff --git a/AsbCloudDb/Model/ItemInfo.cs b/AsbCloudDb/Model/ItemInfo.cs
index 3d7e6793..c93a74bf 100644
--- a/AsbCloudDb/Model/ItemInfo.cs
+++ b/AsbCloudDb/Model/ItemInfo.cs
@@ -12,6 +12,6 @@ namespace AsbCloudDb.Model
///
/// дата последнего обновления блока
///
- public DateTimeOffset LastUpdateDate { get; set; } = DateTimeOffset.Now;
+ public DateTimeOffset LastUpdateDate { get; set; } = DateTimeOffset.UtcNow;
}
}
diff --git a/AsbCloudDb/Model/Manuals/Manual.cs b/AsbCloudDb/Model/Manuals/Manual.cs
index 35b091b5..8ab64735 100644
--- a/AsbCloudDb/Model/Manuals/Manual.cs
+++ b/AsbCloudDb/Model/Manuals/Manual.cs
@@ -15,8 +15,8 @@ public class Manual : IId
[Column("name"), Comment("Название")]
public string Name { get; set; } = null!;
- [Column("date_download"), Comment("Дата загрузки")]
- public DateTime DateDownload { get; set; }
+ [Column("date_download", TypeName = "timestamp with time zone"), Comment("Дата загрузки")]
+ public DateTimeOffset DateDownload { get; set; }
[Column("id_directory"), Comment("Id директории")]
public int IdDirectory { get; set; }
diff --git a/AsbCloudDb/Model/Notification.cs b/AsbCloudDb/Model/Notification.cs
index 09f718b1..bed84a2b 100644
--- a/AsbCloudDb/Model/Notification.cs
+++ b/AsbCloudDb/Model/Notification.cs
@@ -25,13 +25,13 @@ public class Notification : IId
public string Message { get; set; } = null!;
[Column("registration_date"), Comment("Дата регистрации уведомления")]
- public DateTime RegistrationDate { get; set; }
+ public DateTimeOffset RegistrationDate { get; set; }
[Column("sent_date"), Comment("Дата отправки уведомления")]
- public DateTime? SentDate { get; set; }
+ public DateTimeOffset? SentDate { get; set; }
[Column("read_date"), Comment("Дата прочтения уведомления")]
- public DateTime? ReadDate { get; set; }
+ public DateTimeOffset? ReadDate { get; set; }
[Column("id_transport_type"), Comment("Id типа доставки уведомления")]
public int IdTransportType { get; set; }
diff --git a/AsbCloudDb/Model/WellOperation.cs b/AsbCloudDb/Model/WellOperation.cs
index dda4e3e4..9926f0b1 100644
--- a/AsbCloudDb/Model/WellOperation.cs
+++ b/AsbCloudDb/Model/WellOperation.cs
@@ -67,23 +67,6 @@ namespace AsbCloudDb.Model
[JsonIgnore]
[ForeignKey(nameof(IdPlan))]
public virtual WellOperation? OperationPlan { get; set; } = null!;
-
- public bool IsSame(WellOperation other)
- {
- var isSame = IdWell == other.IdWell &&
- IdWellSectionType == other.IdWellSectionType &&
- IdCategory == other.IdCategory &&
- IdType == other.IdType &&
- IdPlan == other.IdPlan &&
- DepthStart == other.DepthStart &&
- DepthEnd == other.DepthEnd &&
- DateStart == other.DateStart &&
- DurationHours == other.DurationHours &&
- CategoryInfo == other.CategoryInfo &&
- Comment == other.Comment;
-
- return isSame;
- }
}
}
diff --git a/AsbCloudInfrastructure/AsbCloudInfrastructure.csproj b/AsbCloudInfrastructure/AsbCloudInfrastructure.csproj
index 0d56b6bd..6bdaf411 100644
--- a/AsbCloudInfrastructure/AsbCloudInfrastructure.csproj
+++ b/AsbCloudInfrastructure/AsbCloudInfrastructure.csproj
@@ -45,11 +45,9 @@
-
-
-
-
+
+
@@ -77,4 +75,5 @@
CommonLibs\AsbWitsInfo.dll
+
diff --git a/AsbCloudInfrastructure/Background/WorkToSendEmail.cs b/AsbCloudInfrastructure/Background/WorkToSendEmail.cs
index 57605438..ef8048e9 100644
--- a/AsbCloudInfrastructure/Background/WorkToSendEmail.cs
+++ b/AsbCloudInfrastructure/Background/WorkToSendEmail.cs
@@ -27,7 +27,7 @@ namespace AsbCloudInfrastructure.Background
await notificationService.SendAsync(notification, token);
- notification.SentDate = DateTime.UtcNow;
+ notification.SentDate = DateTimeOffset.UtcNow;
await notificationRepository.UpdateAsync(notification, token);
}
diff --git a/AsbCloudInfrastructure/DependencyInjection.cs b/AsbCloudInfrastructure/DependencyInjection.cs
index d07de418..1139dd3a 100644
--- a/AsbCloudInfrastructure/DependencyInjection.cs
+++ b/AsbCloudInfrastructure/DependencyInjection.cs
@@ -14,7 +14,6 @@ using AsbCloudApp.Services.DailyReport;
using AsbCloudApp.Services.Notifications;
using AsbCloudApp.Services.ProcessMaps;
using AsbCloudApp.Services.ProcessMaps.WellDrilling;
-using AsbCloudApp.Services.WellOperationImport;
using AsbCloudDb.Model;
using AsbCloudDb.Model.DailyReports.Blocks.TimeBalance;
using AsbCloudDb.Model.Manuals;
@@ -36,8 +35,6 @@ using AsbCloudInfrastructure.Services.Subsystems;
using AsbCloudInfrastructure.Services.Trajectory;
using AsbCloudInfrastructure.Services.Trajectory.Export;
using AsbCloudInfrastructure.Services.Trajectory.Parser;
-using AsbCloudInfrastructure.Services.WellOperationImport;
-using AsbCloudInfrastructure.Services.WellOperationImport.FileParser;
using AsbCloudInfrastructure.Services.WellOperationService;
using Mapster;
using Microsoft.EntityFrameworkCore;
@@ -46,6 +43,7 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using AsbCloudInfrastructure.Services.ProcessMapPlan.Export;
+using AsbCloudInfrastructure.Services.WellOperations.Factories;
namespace AsbCloudInfrastructure
{
@@ -160,7 +158,6 @@ namespace AsbCloudInfrastructure
services.AddTransient();
services.AddTransient();
services.AddScoped();
- services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
@@ -270,13 +267,6 @@ namespace AsbCloudInfrastructure
services.AddTransient();
- services.AddTransient();
- services.AddTransient();
- services.AddTransient();
-
- services.AddTransient, WellOperationDefaultExcelParser>();
- services.AddTransient, WellOperationGazpromKhantosExcelParser>();
-
services.AddTransient();
services.AddTransient();
@@ -300,6 +290,9 @@ namespace AsbCloudInfrastructure
services.AddTransient();
services.AddTransient();
+
+ services.AddTransient();
+ services.AddTransient();
return services;
}
diff --git a/AsbCloudInfrastructure/Repository/CrudRepositoryBase.cs b/AsbCloudInfrastructure/Repository/CrudRepositoryBase.cs
index f21dd487..f5d11f38 100644
--- a/AsbCloudInfrastructure/Repository/CrudRepositoryBase.cs
+++ b/AsbCloudInfrastructure/Repository/CrudRepositoryBase.cs
@@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.ChangeTracking;
namespace AsbCloudInfrastructure.Repository
{
@@ -86,7 +87,7 @@ namespace AsbCloudInfrastructure.Repository
entity.Id = 0;
return entity;
});
- var entries = new List(items.Count());
+ var entries = new List(items.Count());
foreach (var entity in entities)
{
var entry = dbSet.Add(entity);
@@ -114,6 +115,27 @@ namespace AsbCloudInfrastructure.Repository
entry.State = EntityState.Detached;
return entry.Entity.Id;
}
+
+ public virtual async Task UpdateRangeAsync(IEnumerable dtos, CancellationToken token)
+ {
+ if (!dtos.Any())
+ return 0;
+
+ var ids = dtos.Select(d => d.Id);
+
+ var countExistingEntities = await dbSet
+ .Where(d => ids.Contains(d.Id))
+ .CountAsync(token);
+
+ if (ids.Count() > countExistingEntities)
+ return ICrudRepository.ErrorIdNotFound;
+
+ var entities = dtos.Select(Convert);
+ var entries = entities.Select(entity => dbSet.Update(entity)).Cast().ToList();
+ var affected = await dbContext.SaveChangesAsync(token);
+ entries.ForEach(e => e.State = EntityState.Detached);
+ return affected;
+ }
///
public virtual Task DeleteAsync(int id, CancellationToken token)
@@ -129,6 +151,25 @@ namespace AsbCloudInfrastructure.Repository
return affected;
}
+ public virtual async Task DeleteRangeAsync(IEnumerable ids, CancellationToken token)
+ {
+ if (!ids.Any())
+ return 0;
+
+ var countExistingEntities = await dbSet
+ .Where(d => ids.Contains(d.Id))
+ .CountAsync(token);
+
+ if (ids.Count() > countExistingEntities)
+ return ICrudRepository.ErrorIdNotFound;
+
+ var entities = dbContext.Set().Where(e => ids.Contains(e.Id));
+ var entries = entities.Select(entity => dbSet.Remove(entity)).Cast().ToList();
+ var affected = await dbContext.SaveChangesAsync(token);
+ entries.ForEach(e => e.State = EntityState.Detached);
+ return affected;
+ }
+
protected virtual TDto Convert(TEntity src) => src.Adapt();
protected virtual TEntity Convert(TDto src) => src.Adapt();
diff --git a/AsbCloudInfrastructure/Repository/DailyReportRepository.cs b/AsbCloudInfrastructure/Repository/DailyReportRepository.cs
index b82b0ce1..f7f582fa 100644
--- a/AsbCloudInfrastructure/Repository/DailyReportRepository.cs
+++ b/AsbCloudInfrastructure/Repository/DailyReportRepository.cs
@@ -1,80 +1,85 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
using AsbCloudApp.Data.DailyReport;
using AsbCloudApp.Data.DailyReport.Blocks.Sign;
using AsbCloudApp.Data.DailyReport.Blocks.Subsystems;
using AsbCloudApp.Data.DailyReport.Blocks.TimeBalance;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
+using AsbCloudApp.Services;
using AsbCloudDb;
using AsbCloudDb.Model;
using AsbCloudDb.Model.DailyReports;
using Mapster;
using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Repository;
public class DailyReportRepository : CrudRepositoryBase,
- IDailyReportRepository
+ IDailyReportRepository
{
- public DailyReportRepository(IAsbCloudDbContext dbContext)
- : base(dbContext)
- {
- }
+ private IWellService wellService;
- public async Task> GetAsync(int idWell, FileReportRequest request, CancellationToken cancellationToken)
- {
- var skip = request.Skip ?? 0;
- var take = request.Take ?? 10;
+ public DailyReportRepository(IAsbCloudDbContext dbContext, IWellService wellService)
+ : base(dbContext)
+ {
+ this.wellService = wellService;
+ }
- var query = GetQuery().Where(d => d.IdWell == idWell);
+ public async Task> GetAsync(int idWell, FileReportRequest request, CancellationToken cancellationToken)
+ {
+ var skip = request.Skip ?? 0;
+ var take = request.Take ?? 10;
- if (request.GeDate.HasValue)
- query = query.Where(d => d.Date >= request.GeDate.Value);
-
- if (request.LeDate.HasValue)
- query = query.Where(d => d.Date <= request.LeDate.Value);
+ var query = GetQuery().Where(d => d.IdWell == idWell);
- query = request.SortFields?.Any() == true ?
- query.SortBy(request.SortFields) :
- query.OrderBy(d => d.Date);
+ if (request.GeDate.HasValue)
+ query = query.Where(d => d.Date >= request.GeDate.Value);
- var entities = await query
- .Skip(skip)
- .Take(take)
- .AsNoTracking()
- .ToArrayAsync(cancellationToken);
+ if (request.LeDate.HasValue)
+ query = query.Where(d => d.Date <= request.LeDate.Value);
- var dtos = entities.Select(Convert);
+ query = request.SortFields?.Any() == true ?
+ query.SortBy(request.SortFields) :
+ query.OrderBy(d => d.Date);
- return dtos;
- }
+ var entities = await query
+ .Skip(skip)
+ .Take(take)
+ .AsNoTracking()
+ .ToArrayAsync(cancellationToken);
- public async Task GetOrDefaultAsync(int idWell, DateOnly date, CancellationToken cancellationToken)
- {
- var entity = await GetQuery()
- .AsNoTracking()
- .SingleOrDefaultAsync(d => d.IdWell == idWell && d.Date == date, cancellationToken);
+ var timezoneOffset = wellService.GetTimezone(idWell).Offset;
+ var dtos = entities.Select(entity => Convert(entity, timezoneOffset));
- return entity is null ? null : Convert(entity);
- }
+ return dtos;
+ }
- protected override DailyReportDto Convert(DailyReport src)
- {
- var dto = new DailyReportDto
- {
- Id = src.Id,
- IdWell = src.IdWell,
- DateLastUpdate = src.DateLastUpdate,
- Date = src.Date,
- SignBlock = src.SignBlock?.Adapt(),
- TimeBalanceBlock = src.TimeBalanceBlock?.Adapt(),
- SubsystemBlock = src.SubsystemBlock?.Adapt()
- };
-
- return dto;
- }
+ public async Task GetOrDefaultAsync(int idWell, DateOnly date, CancellationToken cancellationToken)
+ {
+ var entity = await GetQuery()
+ .AsNoTracking()
+ .SingleOrDefaultAsync(d => d.IdWell == idWell && d.Date == date, cancellationToken);
+
+ return entity is null ? null : Convert(entity);
+ }
+
+ protected DailyReportDto Convert(DailyReport src, TimeSpan timezoneOffset)
+ {
+ var dto = new DailyReportDto
+ {
+ Id = src.Id,
+ IdWell = src.IdWell,
+ DateLastUpdate = src.DateLastUpdate?.ToOffset(timezoneOffset),
+ Date = src.Date,
+ SignBlock = src.SignBlock?.Adapt(),
+ TimeBalanceBlock = src.TimeBalanceBlock?.Adapt(),
+ SubsystemBlock = src.SubsystemBlock?.Adapt()
+ };
+
+ return dto;
+ }
}
\ No newline at end of file
diff --git a/AsbCloudInfrastructure/Repository/DepositRepository.cs b/AsbCloudInfrastructure/Repository/DepositRepository.cs
index 7f19f1d7..804d130e 100644
--- a/AsbCloudInfrastructure/Repository/DepositRepository.cs
+++ b/AsbCloudInfrastructure/Repository/DepositRepository.cs
@@ -4,6 +4,7 @@ using AsbCloudApp.Services;
using AsbCloudDb.Model;
using Mapster;
using Microsoft.EntityFrameworkCore;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
@@ -111,7 +112,8 @@ namespace AsbCloudInfrastructure.Repository
{
var dto = well.Adapt();
dto.WellType = well.WellType.Caption;
- dto.LastTelemetryDate = wellService.GetLastTelemetryDate(well.Id);
+ dto.LastTelemetryDate = wellService.GetLastTelemetryDate(well.Id)
+ .ToOffset(TimeSpan.FromHours(well.Timezone.Hours));
dto.Cluster = gCluster.Key.Caption;
dto.Deposit = gDeposit.Key.Caption;
return dto;
diff --git a/AsbCloudInfrastructure/Repository/FileRepository.cs b/AsbCloudInfrastructure/Repository/FileRepository.cs
index cafc5649..3e97da03 100644
--- a/AsbCloudInfrastructure/Repository/FileRepository.cs
+++ b/AsbCloudInfrastructure/Repository/FileRepository.cs
@@ -36,9 +36,6 @@ namespace AsbCloudInfrastructure.Repository
var query = dbSetConfigured
.Where(e => e.IdWell == request.IdWell);
- double timezoneOffsetHours = query.FirstOrDefault()
- ?.Well.Timezone.Hours ?? 5d;
-
if (request.IdCategory is not null)
query = query.Where(x => x.IdCategory == request.IdCategory);
@@ -53,13 +50,13 @@ namespace AsbCloudInfrastructure.Repository
if (request.Begin is not null)
{
- var beginUtc = request.Begin.Value.ToUtcDateTimeOffset(timezoneOffsetHours);
+ var beginUtc = request.Begin.Value.ToUniversalTime();
query = query.Where(e => e.UploadDate >= beginUtc);
}
if (request.End is not null)
{
- var endUtc = request.End.Value.ToUtcDateTimeOffset(timezoneOffsetHours);
+ var endUtc = request.End.Value.ToUniversalTime();
query = query.Where(e => e.UploadDate <= endUtc);
}
@@ -184,7 +181,7 @@ namespace AsbCloudInfrastructure.Repository
var newFileMark = fileMarkDto.Adapt();
newFileMark.Id = default;
- newFileMark.DateCreated = DateTime.UtcNow;
+ newFileMark.DateCreated = DateTimeOffset.UtcNow;
newFileMark.IdUser = idUser;
newFileMark.User = null!;
@@ -244,7 +241,7 @@ namespace AsbCloudInfrastructure.Repository
IdAuthor = newItem.IdAuthor,
IdCategory = newItem.IdCategory,
Name = newItem.Name,
- UploadDate = DateTime.UtcNow,
+ UploadDate = DateTimeOffset.UtcNow,
IsDeleted = false,
Size = newItem.Size,
};
@@ -278,11 +275,11 @@ namespace AsbCloudInfrastructure.Repository
private static FileInfoDto Convert(FileInfo entity, double timezoneOffset)
{
var dto = entity.Adapt();
- dto.UploadDate = entity.UploadDate.ToRemoteDateTime(timezoneOffset);
+ dto.UploadDate = entity.UploadDate.ToOffset(TimeSpan.FromHours(timezoneOffset));
dto.FileMarks = entity.FileMarks.Select(m =>
{
var mark = m.Adapt();
- mark.DateCreated = m.DateCreated.ToRemoteDateTime(timezoneOffset);
+ mark.DateCreated = m.DateCreated.ToOffset(TimeSpan.FromHours(timezoneOffset));
return mark;
});
return dto;
diff --git a/AsbCloudInfrastructure/Repository/LimitingParameterRepository.cs b/AsbCloudInfrastructure/Repository/LimitingParameterRepository.cs
index 8f3c42c1..67fc5960 100644
--- a/AsbCloudInfrastructure/Repository/LimitingParameterRepository.cs
+++ b/AsbCloudInfrastructure/Repository/LimitingParameterRepository.cs
@@ -39,8 +39,8 @@ namespace AsbCloudInfrastructure.Repository
IdWell = request.IdWell,
IdTelemetry = x.IdTelemetry,
IdFeedRegulator = x.IdFeedRegulator,
- DateStart = DateTime.SpecifyKind(x.DateStart.UtcDateTime + timezoneSpan, DateTimeKind.Unspecified),
- DateEnd = DateTime.SpecifyKind(x.DateEnd.UtcDateTime + timezoneSpan, DateTimeKind.Unspecified),
+ DateStart = x.DateStart.ToOffset(timezoneSpan),
+ DateEnd = x.DateEnd.ToOffset(timezoneSpan),
DepthStart = x.DepthStart,
DepthEnd = x.DepthEnd
});
@@ -56,13 +56,13 @@ namespace AsbCloudInfrastructure.Repository
if (request.GtDate.HasValue)
{
- var gtDate = request.GtDate.Value.ToUtcDateTimeOffset(timezoneHours);
+ var gtDate = request.GtDate.Value.ToUniversalTime();
query = query.Where(x => x.DateEnd >= gtDate);
}
if (request.LtDate.HasValue)
{
- var ltDate = request.LtDate.Value.ToUtcDateTimeOffset(timezoneHours);
+ var ltDate = request.LtDate.Value.ToUniversalTime();
query = query.Where(x => x.DateStart <= ltDate);
}
diff --git a/AsbCloudInfrastructure/Repository/NotificationRepository.cs b/AsbCloudInfrastructure/Repository/NotificationRepository.cs
index 6f1e4a98..7e184f02 100644
--- a/AsbCloudInfrastructure/Repository/NotificationRepository.cs
+++ b/AsbCloudInfrastructure/Repository/NotificationRepository.cs
@@ -110,10 +110,10 @@ public class NotificationRepository : CrudRepositoryBase n.IdNotificationCategory == request.IdCategory.Value);
if (request.LtSentDate.HasValue)
- query = query.Where(n => n.SentDate <= request.LtSentDate.Value);
+ query = query.Where(n => n.SentDate <= request.LtSentDate.Value.ToUniversalTime());
if (request.LtReadDate.HasValue)
- query = query.Where(n => n.ReadDate <= request.LtReadDate.Value);
+ query = query.Where(n => n.ReadDate <= request.LtReadDate.Value.ToUniversalTime());
dbContext.Notifications.RemoveRange(query);
diff --git a/AsbCloudInfrastructure/Repository/ScheduleRepository.cs b/AsbCloudInfrastructure/Repository/ScheduleRepository.cs
index e7c2aa1f..413bb661 100644
--- a/AsbCloudInfrastructure/Repository/ScheduleRepository.cs
+++ b/AsbCloudInfrastructure/Repository/ScheduleRepository.cs
@@ -24,7 +24,7 @@ namespace AsbCloudInfrastructure.Repository
this.wellService = wellService;
}
- public async Task> GetAsync(int idWell, DateTime workTime, CancellationToken token)
+ public async Task> GetAsync(int idWell, DateTimeOffset workTime, CancellationToken token)
{
var entities = await BuildQuery(idWell, workTime)
.AsNoTracking()
@@ -33,7 +33,7 @@ namespace AsbCloudInfrastructure.Repository
return entities.Select(Convert);
}
- public async Task GetOrDefaultDrillerAsync(int idWell, DateTime workTime, CancellationToken token)
+ public async Task GetOrDefaultDrillerAsync(int idWell, DateTimeOffset workTime, CancellationToken token)
{
var entities = await BuildQuery(idWell, workTime)
.AsNoTracking()
@@ -43,8 +43,7 @@ namespace AsbCloudInfrastructure.Repository
return null;
var hoursOffset = wellService.GetTimezone(idWell).Hours;
- var remoteDate = workTime.ToUtcDateTimeOffset(hoursOffset).ToRemoteDateTime(hoursOffset);
- var time = new TimeOnly(remoteDate.Hour, remoteDate.Minute, remoteDate.Second);
+ var time = new TimeOnly(workTime.Hour, workTime.Minute, workTime.Second);
var entity = entities.FirstOrDefault(s =>
s.ShiftStart > s.ShiftEnd ^
@@ -69,11 +68,11 @@ namespace AsbCloudInfrastructure.Repository
}
- private IQueryable BuildQuery(int idWell, DateTime workTime)
+ private IQueryable BuildQuery(int idWell, DateTimeOffset workTime)
{
var hoursOffset = wellService.GetTimezone(idWell).Hours;
- var workTimeDateTime = workTime.ToUtcDateTimeOffset(hoursOffset);
+ var workTimeDateTime = workTime.ToUniversalTime();
return GetQuery().Where(s => s.IdWell == idWell
&& s.DrillStart <= workTimeDateTime
@@ -82,19 +81,20 @@ namespace AsbCloudInfrastructure.Repository
protected override Schedule Convert(ScheduleDto dto)
{
- var hoursOffset = wellService.GetTimezone(dto.IdWell).Hours;
var entity = base.Convert(dto);
- entity.DrillStart = dto.DrillStart.ToUtcDateTimeOffset(hoursOffset);
- entity.DrillEnd = dto.DrillEnd.ToUtcDateTimeOffset(hoursOffset);
+ entity.DrillStart = dto.DrillStart.ToUniversalTime();
+ entity.DrillEnd = dto.DrillEnd.ToUniversalTime();
return entity;
}
protected override ScheduleDto Convert(Schedule entity)
{
var hoursOffset = wellService.GetTimezone(entity.IdWell).Hours;
+ var timeSpan = TimeSpan.FromHours(hoursOffset);
+
var dto = base.Convert(entity);
- dto.DrillStart = entity.DrillStart.ToRemoteDateTime(hoursOffset);
- dto.DrillEnd = entity.DrillEnd.ToRemoteDateTime(hoursOffset);
+ dto.DrillStart = entity.DrillStart.ToOffset(timeSpan);
+ dto.DrillEnd = entity.DrillEnd.ToOffset(timeSpan);
return dto;
}
}
diff --git a/AsbCloudInfrastructure/Repository/SetpointsRequestRepository.cs b/AsbCloudInfrastructure/Repository/SetpointsRequestRepository.cs
index 838ae15b..2c1f7905 100644
--- a/AsbCloudInfrastructure/Repository/SetpointsRequestRepository.cs
+++ b/AsbCloudInfrastructure/Repository/SetpointsRequestRepository.cs
@@ -50,15 +50,14 @@ namespace AsbCloudInfrastructure.Repository
{
var result = base.Convert(src);
var timezoneOffsetHours = wellService.GetTimezone(src.IdWell).Hours;
- result.UploadDate = src.UploadDate.ToRemoteDateTime(timezoneOffsetHours);
+ result.UploadDate = src.UploadDate.ToOffset(TimeSpan.FromHours(timezoneOffsetHours));
return result;
}
protected override SetpointsRequest Convert(SetpointsRequestDto src)
{
var result = base.Convert(src);
- var timezoneOffsetHours = wellService.GetTimezone(src.IdWell).Hours;
- result.UploadDate = src.UploadDate.ToUtcDateTimeOffset(timezoneOffsetHours);
+ result.UploadDate = src.UploadDate.ToUniversalTime();
return result;
}
}
diff --git a/AsbCloudInfrastructure/Repository/TelemetryWirelineRunOutRepository.cs b/AsbCloudInfrastructure/Repository/TelemetryWirelineRunOutRepository.cs
index 81427cf6..af2b6438 100644
--- a/AsbCloudInfrastructure/Repository/TelemetryWirelineRunOutRepository.cs
+++ b/AsbCloudInfrastructure/Repository/TelemetryWirelineRunOutRepository.cs
@@ -5,6 +5,7 @@ using AsbCloudApp.Services;
using AsbCloudDb.Model;
using Mapster;
using Microsoft.EntityFrameworkCore;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
@@ -93,14 +94,14 @@ namespace AsbCloudInfrastructure.Repository
{
var entity = dto.Adapt();
entity.IdTelemetry = idTelemetry;
- entity.DateTime = dto.DateTime.ToUtcDateTimeOffset(timezoneOffset);
+ entity.DateTime = dto.DateTime.ToUniversalTime();
return entity;
}
private static TelemetryWirelineRunOutDto Convert(TelemetryWirelineRunOut entity, WellDto well, double timezoneOffset)
{
var dto = entity.Adapt();
- dto.DateTime = entity.DateTime.ToRemoteDateTime(timezoneOffset);
+ dto.DateTime = entity.DateTime.ToOffset(TimeSpan.FromHours(timezoneOffset));
dto.WellInfo = well;
return dto;
}
diff --git a/AsbCloudInfrastructure/Repository/TrajectoryEditableRepository.cs b/AsbCloudInfrastructure/Repository/TrajectoryEditableRepository.cs
index 4c8ab283..6aca2284 100644
--- a/AsbCloudInfrastructure/Repository/TrajectoryEditableRepository.cs
+++ b/AsbCloudInfrastructure/Repository/TrajectoryEditableRepository.cs
@@ -37,11 +37,10 @@ namespace AsbCloudInfrastructure.Repository
if (!trajectoryRows.All(r => r.IdWell == idWell))
throw new ArgumentInvalidException(nameof(trajectoryRows), "Все строки должны относиться к одной скважине");
- var offsetHours = wellService.GetTimezone(idWell).Hours;
var entities = trajectoryRows
.Select(e =>
{
- var entity = Convert(e, offsetHours);
+ var entity = Convert(e);
entity.Id = 0;
return entity;
});
@@ -52,8 +51,7 @@ namespace AsbCloudInfrastructure.Repository
public async Task AddAsync(Tdto trajectoryRow, CancellationToken token)
{
- var offsetHours = wellService.GetTimezone(trajectoryRow.IdWell).Hours;
- var entity = Convert(trajectoryRow, offsetHours);
+ var entity = Convert(trajectoryRow);
entity.Id = 0;
db.Set().Add(entity);
return await db.SaveChangesAsync(token)
@@ -98,8 +96,7 @@ namespace AsbCloudInfrastructure.Repository
public async Task UpdateAsync(Tdto row, CancellationToken token)
{
- var offsetHours = wellService.GetTimezone(row.IdWell).Hours;
- var entity = Convert(row, offsetHours);
+ var entity = Convert(row);
db.Set().Update(entity);
return await db.SaveChangesAsync(token)
.ConfigureAwait(false);
@@ -108,14 +105,14 @@ namespace AsbCloudInfrastructure.Repository
private static Tdto Convert(TEntity entity, double offsetHours)
{
var dto = entity.Adapt();
- dto.UpdateDate = entity.UpdateDate.ToRemoteDateTime(offsetHours);
+ dto.UpdateDate = entity.UpdateDate.ToOffset(TimeSpan.FromHours(offsetHours));
return dto;
}
- private static TEntity Convert(Tdto dto, double offsetHours)
+ private static TEntity Convert(Tdto dto)
{
var entity = dto.Adapt();
- entity.UpdateDate = DateTime.Now.ToUtcDateTimeOffset(offsetHours);
+ entity.UpdateDate = DateTimeOffset.UtcNow;
return entity;
}
}
diff --git a/AsbCloudInfrastructure/Repository/TrajectoryNnbRepository.cs b/AsbCloudInfrastructure/Repository/TrajectoryNnbRepository.cs
index a55e465f..69c2cccc 100644
--- a/AsbCloudInfrastructure/Repository/TrajectoryNnbRepository.cs
+++ b/AsbCloudInfrastructure/Repository/TrajectoryNnbRepository.cs
@@ -38,13 +38,13 @@ namespace AsbCloudInfrastructure.Repository
if (request.GeDate.HasValue)
{
- var geDate = request.GeDate.Value.ToUtcDateTimeOffset(timezone.Hours);
+ var geDate = request.GeDate.Value.ToUniversalTime();
query = query.Where(r => r.DateTime >= geDate);
}
if (request.LeDate.HasValue)
{
- var leDate = request.LeDate.Value.ToUtcDateTimeOffset(timezone.Hours);
+ var leDate = request.LeDate.Value.ToUniversalTime();
query = query.Where(r => r.DateTime <= leDate);
}
diff --git a/AsbCloudInfrastructure/Repository/WellOperationCategoryRepository.cs b/AsbCloudInfrastructure/Repository/WellOperationCategoryRepository.cs
index 84da5f3d..927a424e 100644
--- a/AsbCloudInfrastructure/Repository/WellOperationCategoryRepository.cs
+++ b/AsbCloudInfrastructure/Repository/WellOperationCategoryRepository.cs
@@ -1,11 +1,10 @@
-using AsbCloudApp.Data;
-using AsbCloudApp.Repositories;
+using AsbCloudApp.Repositories;
using AsbCloudDb.Model;
using Mapster;
using Microsoft.Extensions.Caching.Memory;
-using System;
using System.Collections.Generic;
using System.Linq;
+using AsbCloudApp.Data.WellOperation;
namespace AsbCloudInfrastructure.Repository;
diff --git a/AsbCloudInfrastructure/Repository/WellOperationRepository.cs b/AsbCloudInfrastructure/Repository/WellOperationRepository.cs
index acdb1ef0..3b67eb54 100644
--- a/AsbCloudInfrastructure/Repository/WellOperationRepository.cs
+++ b/AsbCloudInfrastructure/Repository/WellOperationRepository.cs
@@ -1,4 +1,11 @@
-using AsbCloudApp.Data;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using AsbCloudApp.Data;
+using AsbCloudApp.Data.WellOperation;
+using AsbCloudApp.Exceptions;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Services;
@@ -7,697 +14,350 @@ using AsbCloudDb.Model;
using Mapster;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Caching.Memory;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.Diagnostics;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Repository;
-///
-/// репозиторий операций по скважине
-///
-public class WellOperationRepository : IWellOperationRepository
+public class WellOperationRepository : CrudRepositoryBase,
+ IWellOperationRepository
{
- private const string KeyCacheSections = "OperationsBySectionSummarties";
-
- private readonly IAsbCloudDbContext db;
- private readonly IMemoryCache memoryCache;
- private readonly IWellService wellService;
- private readonly IWellOperationCategoryRepository wellOperationCategoryRepository;
-
- public WellOperationRepository(IAsbCloudDbContext db, IMemoryCache memoryCache, IWellService wellService, IWellOperationCategoryRepository wellOperationCategoryRepository)
- {
- this.db = db;
- this.memoryCache = memoryCache;
- this.wellService = wellService;
- this.wellOperationCategoryRepository = wellOperationCategoryRepository;
- }
-
- public IEnumerable GetSectionTypes() =>
- memoryCache
- .GetOrCreateBasic(db.Set())
- .OrderBy(s => s.Order)
- .Select(s => s.Adapt());
-
- public async Task GetOperationsPlanAsync(int idWell, DateTime? currentDate, CancellationToken token)
- {
- var timezone = wellService.GetTimezone(idWell);
- var request = new WellOperationRequest()
- {
- IdWell = idWell,
- OperationType = WellOperation.IdOperationTypePlan,
- };
-
- var dtos = await BuildQuery(request)
- .AsNoTracking()
- .ToArrayAsync(token);
-
- var dateLastAssosiatedPlanOperation = await GetDateLastAssosiatedPlanOperationAsync(idWell, currentDate, timezone.Hours, token);
-
- var result = new WellOperationPlanDto()
- {
- WellOperationsPlan = dtos.Select(Convert),
- DateLastAssosiatedPlanOperation = dateLastAssosiatedPlanOperation
- };
-
- return result;
- }
-
- private async Task GetDateLastAssosiatedPlanOperationAsync(
- int idWell,
- DateTime? lessThenDate,
- double timeZoneHours,
- CancellationToken token)
- {
- if (lessThenDate is null)
- return null;
-
- var currentDateOffset = lessThenDate.Value.ToUtcDateTimeOffset(timeZoneHours);
- var timeZoneOffset = TimeSpan.FromHours(timeZoneHours);
-
- var lastFactOperation = await db.WellOperations
- .Where(o => o.IdWell == idWell)
- .Where(o => o.IdType == WellOperation.IdOperationTypeFact)
- .Where(o => o.IdPlan != null)
- .Where(o => o.DateStart < currentDateOffset)
- .Include(x => x.OperationPlan)
- .OrderByDescending(x => x.DateStart)
- .FirstOrDefaultAsync(token)
- .ConfigureAwait(false);
-
- if (lastFactOperation is not null)
- return DateTime.SpecifyKind(lastFactOperation.OperationPlan!.DateStart.UtcDateTime + timeZoneOffset, DateTimeKind.Unspecified);
-
- return null;
- }
-
- ///
- public async Task> GetSectionsAsync(IEnumerable idsWells, CancellationToken token)
- {
- var cache = await memoryCache.GetOrCreateAsync(KeyCacheSections, async (entry) =>
- {
- entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(30);
-
- var query = db.Set()
- .GroupBy(operation => new
- {
- operation.IdWell,
- operation.IdType,
- operation.IdWellSectionType,
- operation.WellSectionType.Caption,
- })
- .Select(group => new
- {
- group.Key.IdWell,
- group.Key.IdType,
- group.Key.IdWellSectionType,
- group.Key.Caption,
-
- First = group
- .OrderBy(operation => operation.DateStart)
- .Select(operation => new
- {
- operation.DateStart,
- operation.DepthStart,
- })
- .First(),
-
- Last = group
- .OrderByDescending(operation => operation.DateStart)
- .Select(operation => new
- {
- operation.DateStart,
- operation.DurationHours,
- operation.DepthEnd,
- })
- .First(),
- });
- var dbData = await query.ToArrayAsync(token);
- var sections = dbData.Select(
- item => new SectionByOperationsDto
- {
- IdWell = item.IdWell,
- IdType = item.IdType,
- IdWellSectionType = item.IdWellSectionType,
-
- Caption = item.Caption,
-
- DateStart = item.First.DateStart,
- DepthStart = item.First.DepthStart,
-
- DateEnd = item.Last.DateStart.AddHours(item.Last.DurationHours),
- DepthEnd = item.Last.DepthEnd,
- })
- .ToArray()
- .AsEnumerable();
-
- entry.Value = sections;
- return sections;
- });
-
- var sections = cache.Where(s => idsWells.Contains(s.IdWell));
- return sections;
- }
-
- public async Task GetDatesRangeAsync(int idWell, int idType, CancellationToken cancellationToken)
- {
- var timezone = wellService.GetTimezone(idWell);
-
- var query = db.WellOperations.Where(o => o.IdWell == idWell && o.IdType == idType);
-
- if (!await query.AnyAsync(cancellationToken))
- return null;
-
- var minDate = await query.MinAsync(o => o.DateStart, cancellationToken);
- var maxDate = await query.MaxAsync(o => o.DateStart, cancellationToken);
-
- return new DatesRangeDto
- {
- From = minDate.ToRemoteDateTime(timezone.Hours),
- To = maxDate.ToRemoteDateTime(timezone.Hours)
- };
- }
-
- ///
- public DateTimeOffset? FirstOperationDate(int idWell)
- {
- var sections = GetSectionsAsync(new[] { idWell }, CancellationToken.None).Result;
- var first = sections.FirstOrDefault(section => section.IdType == WellOperation.IdOperationTypeFact)
- ?? sections.FirstOrDefault(section => section.IdType == WellOperation.IdOperationTypePlan);
-
- return first?.DateStart;
- }
-
- ///
- public async Task> GetAsync(
- WellOperationRequest request,
- CancellationToken token)
- {
- var query = BuildQuery(request)
- .AsNoTracking();
-
- var dtos = await query.ToArrayAsync(token);
-
- return dtos.Select(Convert);
- }
-
- public async Task> GetAsync(
- WellsOperationRequest request,
- CancellationToken token)
- {
- var query = BuildQuery(request)
- .AsNoTracking();
-
- var dtos = await query.ToArrayAsync(token);
- return dtos;
- }
-
- ///
- public async Task> GetPageAsync(
- WellOperationRequest request,
- CancellationToken token)
- {
- var query = BuildQuery(request);
-
- var result = new PaginationContainer
- {
- Skip = request.Skip ?? 0,
- Take = request.Take ?? 32,
- Count = await query.CountAsync(token),
- };
-
- var dtos = await query.ToArrayAsync(token);
-
- result.Items = dtos.Select(Convert);
-
- return result;
- }
-
- ///
- public async Task GetOrDefaultAsync(int id,
- CancellationToken token)
- {
- var entity = await db.WellOperations
- .Include(s => s.WellSectionType)
- .Include(s => s.OperationCategory)
- .FirstOrDefaultAsync(e => e.Id == id, token)
- .ConfigureAwait(false);
-
- if (entity is null)
- return null;
-
- var timezone = wellService.GetTimezone(entity.IdWell);
-
- var dto = entity.Adapt();
- dto.WellSectionTypeName = entity.WellSectionType.Caption;
- dto.DateStart = entity.DateStart.ToRemoteDateTime(timezone.Hours);
- dto.CategoryName = entity.OperationCategory.Name;
- return dto;
- }
-
- ///
- public async Task> GetGroupOperationsStatAsync(
- WellOperationRequest request,
- CancellationToken token)
- {
- // TODO: Rename controller method
- request.OperationType = WellOperation.IdOperationTypeFact;
- var query = BuildQuery(request);
- var entities = await query
- .Select(o => new
- {
- o.IdCategory,
- DurationMinutes = o.DurationHours * 60,
- DurationDepth = o.DepthEnd - o.DepthStart
- })
- .ToListAsync(token);
- var parentRelationDictionary = wellOperationCategoryRepository.Get(true)
- .ToDictionary(c => c.Id, c => new
- {
- c.Name,
- c.IdParent
- });
-
- var dtos = entities
- .GroupBy(o => o.IdCategory)
- .Select(g => new WellGroupOpertionDto
- {
- IdCategory = g.Key,
- Category = parentRelationDictionary[g.Key].Name,
- Count = g.Count(),
- MinutesAverage = g.Average(o => o.DurationMinutes),
- MinutesMin = g.Min(o => o.DurationMinutes),
- MinutesMax = g.Max(o => o.DurationMinutes),
- TotalMinutes = g.Sum(o => o.DurationMinutes),
- DeltaDepth = g.Sum(o => o.DurationDepth),
- IdParent = parentRelationDictionary[g.Key].IdParent
- });
-
- while (dtos.All(x => x.IdParent != null))
- {
- dtos = dtos
- .GroupBy(o => o.IdParent!)
- .Select(g =>
- {
- var idCategory = g.Key ?? int.MinValue;
- var category = parentRelationDictionary.GetValueOrDefault(idCategory);
- var newDto = new WellGroupOpertionDto
- {
- IdCategory = idCategory,
- Category = category?.Name ?? "unknown",
- Count = g.Sum(o => o.Count),
- DeltaDepth = g.Sum(o => o.DeltaDepth),
- TotalMinutes = g.Sum(o => o.TotalMinutes),
- Items = g.ToList(),
- IdParent = category?.IdParent,
- };
- return newDto;
- });
- }
- return dtos;
- }
-
- ///
- public async Task InsertRangeAsync(
- IEnumerable wellOperationDtos,
- CancellationToken token)
- {
- var firstOperation = wellOperationDtos
- .FirstOrDefault();
- if (firstOperation is null)
- return 0;
-
- var idWell = firstOperation.IdWell;
-
- var timezone = wellService.GetTimezone(idWell);
- foreach (var dto in wellOperationDtos)
- {
- var entity = dto.Adapt();
- entity.Id = default;
- entity.DateStart = dto.DateStart.DateTime.ToUtcDateTimeOffset(timezone.Hours);
- entity.IdWell = idWell;
- entity.LastUpdateDate = DateTimeOffset.UtcNow;
- db.WellOperations.Add(entity);
- }
-
- var result = await db.SaveChangesAsync(token);
- if (result > 0)
- memoryCache.Remove(KeyCacheSections);
- return result;
-
- }
-
- ///
- public async Task UpdateAsync(
- WellOperationDto dto, CancellationToken token)
- {
- var timezone = wellService.GetTimezone(dto.IdWell);
- var entity = dto.Adapt();
- entity.DateStart = dto.DateStart.DateTime.ToUtcDateTimeOffset(timezone.Hours);
- entity.LastUpdateDate = DateTimeOffset.UtcNow;
- db.WellOperations.Update(entity);
-
- var result = await db.SaveChangesAsync(token);
- if (result > 0)
- memoryCache.Remove(KeyCacheSections);
- return result;
- }
-
- ///
- public async Task DeleteAsync(IEnumerable ids,
- CancellationToken token)
- {
- var query = db.WellOperations.Where(e => ids.Contains(e.Id));
- db.WellOperations.RemoveRange(query);
-
- var result = await db.SaveChangesAsync(token);
- if (result > 0)
- memoryCache.Remove(KeyCacheSections);
- return result;
- }
-
- ///
- /// В результате попрежнему требуется конвертировать дату
- ///
- ///
- ///
- ///
- private IQueryable BuildQuery(WellOperationRequest request)
- {
- var timezone = wellService.GetTimezone(request.IdWell);
- var timeZoneOffset = timezone.Hours;
-
- var query = db.WellOperations
- .Include(s => s.WellSectionType)
- .Include(s => s.OperationCategory)
- .Where(o => o.IdWell == request.IdWell);
-
- if (request.OperationType.HasValue)
- query = query.Where(e => e.IdType == request.OperationType.Value);
-
- if (request.SectionTypeIds?.Any() == true)
- query = query.Where(e => request.SectionTypeIds.Contains(e.IdWellSectionType));
-
- if (request.OperationCategoryIds?.Any() == true)
- query = query.Where(e => request.OperationCategoryIds.Contains(e.IdCategory));
-
- if (request.GeDepth.HasValue)
- query = query.Where(e => e.DepthEnd >= request.GeDepth.Value);
-
- if (request.LeDepth.HasValue)
- query = query.Where(e => e.DepthEnd <= request.LeDepth.Value);
-
- if (request.GeDate.HasValue)
- {
- var geDateOffset = request.GeDate.Value.ToUtcDateTimeOffset(timeZoneOffset);
- query = query.Where(e => e.DateStart >= geDateOffset);
- }
-
- if (request.LtDate.HasValue)
- {
- var ltDateOffset = request.LtDate.Value.ToUtcDateTimeOffset(timeZoneOffset);
- query = query.Where(e => e.DateStart < ltDateOffset);
- }
-
- var currentWellOperations = db.WellOperations
- .Where(subOp => subOp.IdWell == request.IdWell);
-
- var wellOperationsWithCategoryNpt = currentWellOperations
- .Where(subOp => subOp.IdType == 1)
- .Where(subOp => WellOperationCategory.NonProductiveTimeSubIds.Contains(subOp.IdCategory));
-
- var firstOperations = db.Set()
- .Where(o => o.IdWell == request.IdWell)
- .GroupBy(o => o.IdType)
- .Select(group => new {
- idType = group.Key,
- Date = group.Min(o => o.DateStart),
- }).ToDictionary(e => e.idType, e => e.Date);
-
- var dtos = query.Select(o => new WellOperationDto
- {
- Id = o.Id,
- IdPlan = o.IdPlan,
- IdType = o.IdType,
- IdWell = o.IdWell,
- IdWellSectionType = o.IdWellSectionType,
- IdCategory = o.IdCategory,
- IdParentCategory = o.OperationCategory.IdParent,
-
- CategoryName = o.OperationCategory.Name,
- WellSectionTypeName = o.WellSectionType.Caption,
- DateStart = o.DateStart,
- DepthStart = o.DepthStart,
- DepthEnd = o.DepthEnd,
- DurationHours = o.DurationHours,
- CategoryInfo = o.CategoryInfo,
- Comment = o.Comment,
-
- NptHours = wellOperationsWithCategoryNpt
- .Where(subOp => subOp.DateStart <= o.DateStart)
- .Select(subOp => subOp.DurationHours)
- .Sum(),
-
- Day = (o.DateStart - firstOperations[o.IdType])
- .TotalDays,
- IdUser = o.IdUser,
- LastUpdateDate = o.LastUpdateDate,
- });
-
- if (request.SortFields?.Any() == true)
- {
- dtos = dtos.SortBy(request.SortFields);
- }
-
- dtos = dtos
- .OrderBy(e => e.DateStart)
- .ThenBy(e => e.DepthEnd)
- .ThenBy(e => e.Id);
-
- if (request.Skip.HasValue)
- dtos = dtos.Skip(request.Skip.Value);
-
- if (request.Take.HasValue)
- dtos = dtos.Take(request.Take.Value);
-
- return dtos.AsNoTracking();
- }
-
- ///
- /// Получение данных по запросу
- ///
- ///
- ///
- ///
- private IQueryable BuildQuery(WellsOperationRequest request)
- {
- var query = db.WellOperations
- .Where(o => request.IdsWell.Contains(o.IdWell))
- .Where(o => request.OperationType == o.IdType);
-
- if (request.SectionTypeIds?.Any() == true)
- query = query.Where(o => request.SectionTypeIds.Contains(o.IdWellSectionType));
-
- if (request.OperationCategoryIds?.Any() == true)
- query = query.Where(o => request.OperationCategoryIds.Contains(o.IdCategory));
-
- // TODO: Вынести query.Select из метода BuildQuery
- var dtos = query.Select(o => new WellOperationDataDto
- {
- DepthStart = o.DepthStart,
- DurationHours = o.DurationHours,
- IdCategory = o.IdCategory,
- IdWell = o.IdWell,
- IdWellSectionType = o.IdWellSectionType,
- OperationCategoryName = o.OperationCategory.Name,
- WellSectionTypeCaption = o.WellSectionType.Caption,
- });
-
- if (request.SortFields?.Any() == true)
- {
- dtos = dtos.SortBy(request.SortFields);
- }
-
- if (request.Skip.HasValue)
- dtos = dtos.Skip(request.Skip.Value);
-
- if (request.Take.HasValue)
- dtos = dtos.Take(request.Take.Value);
-
- return dtos.AsNoTracking();
- }
-
- private WellOperationDto Convert(WellOperationDto dto)
- {
- var timezone = wellService.GetTimezone(dto.IdWell);
- var timezoneOffset = TimeSpan.FromHours(timezone.Hours);
-
- var dtoWithRemoteDateTime = dto.Adapt();
-
- dtoWithRemoteDateTime.DateStart = dto.DateStart.ToOffset(TimeSpan.FromHours(timezoneOffset.Hours));
- dtoWithRemoteDateTime.LastUpdateDate = dto.LastUpdateDate?.ToOffset(TimeSpan.FromHours(timezoneOffset.Hours));
-
- return dtoWithRemoteDateTime;
- }
-
- public async Task RemoveDuplicates(Action onProgressCallback, CancellationToken token)
- {
- IQueryable dbset = db.Set();
- var query = dbset
- .GroupBy(o => new { o.IdWell, o.IdType })
- .Select(g => new { g.Key.IdWell, g.Key.IdType });
-
- var groups = await query
- .ToArrayAsync(token);
-
- var count = groups.Count();
- var i = 0;
- var totalRemoved = 0;
- var total = 0;
- foreach (var group in groups)
- {
- var result = await RemoveDuplicatesInGroup(group.IdWell, group.IdType, token);
- totalRemoved += result.removed;
- total += result.total;
- var percent = i++ / count;
- var message = $"RemoveDuplicates [{i} of {count}] wellId: {group.IdWell}, opType: {group.IdType}, affected: {result.removed} of {result.total}";
- onProgressCallback?.Invoke(message, percent);
- Trace.TraceInformation(message);
- }
- var messageDone = $"RemoveDuplicates done [{i} of {count}] totalAffected: {totalRemoved} of {total}";
- Trace.TraceInformation(messageDone);
- onProgressCallback?.Invoke(messageDone, 1);
- return totalRemoved;
- }
-
- private async Task<(int removed, int total)> RemoveDuplicatesInGroup(int idWell, int idType, CancellationToken token)
- {
- var dbset = db.Set();
- var entities = await dbset
- .Where(o => o.IdWell == idWell && o.IdType == idType)
- .OrderBy(o => o.DateStart)
- .ToListAsync(token);
-
- using var entitiesEnumerator = entities.GetEnumerator();
-
- if (!entitiesEnumerator.MoveNext())
- return (0, 0);
-
- var preEntity = entitiesEnumerator.Current;
- while (entitiesEnumerator.MoveNext())
- {
- var entity = entitiesEnumerator.Current;
- if (preEntity.IsSame(entity))
- dbset.Remove(entity);
- else
- preEntity = entity;
- }
- var removed = await db.SaveChangesAsync(token);
- return (removed, entities.Count);
- }
-
- public async Task TrimOverlapping(DateTimeOffset? geDate, DateTimeOffset leDate, Action onProgressCallback, CancellationToken token)
- {
- var leDateUtc = leDate.ToUniversalTime();
- IQueryable query = db.Set();
- if (geDate.HasValue)
- {
- var geDateUtc = geDate.Value.ToUniversalTime();
- query = query.Where(e => e.DateStart >= geDateUtc);
- }
-
- var groups = await query
- .GroupBy(o => new { o.IdWell, o.IdType })
- .Select(g => new{
- MaxDate = g.Max(o => o.DateStart),
- g.Key.IdWell,
- g.Key.IdType,
- })
- .Where(g => g.MaxDate <= leDateUtc)
- .ToArrayAsync(token);
-
- var count = groups.Count();
- var i = 0;
- (int takeover, int trimmed,int total) totalResult = (0, 0, 0);
- foreach (var group in groups)
- {
- var result = await TrimOverlapping(group.IdWell, group.IdType, token);
- totalResult.takeover += result.takeover;
- totalResult.trimmed += result.trimmed;
- totalResult.total += result.total;
- var percent = i++ / count;
- var message = $"TrimOverlapping [{i} of {count}] wellId: {group.IdWell}, opType: {group.IdType}, takeover:{result.takeover}, trimmed:{result.trimmed}, of {result.total}";
- onProgressCallback?.Invoke(message, percent);
- Trace.TraceInformation(message);
- }
- var messageDone = $"TrimOverlapping done [{i} of {count}] total takeover:{totalResult.takeover}, total trimmed:{totalResult.trimmed} of {totalResult.total}";
- Trace.TraceInformation(messageDone);
- onProgressCallback?.Invoke(messageDone, 1);
- return totalResult.takeover + totalResult.trimmed;
- }
-
- private async Task<(int takeover, int trimmed, int total)> TrimOverlapping(int idWell, int idType, CancellationToken token)
- {
- var dbset = db.Set();
- var query = dbset
- .Where(o => o.IdWell == idWell)
- .Where(o => o.IdType == idType)
- .OrderBy(o => o.DateStart)
- .ThenBy(o => o.DepthStart);
-
- var entities = await query
- .ToListAsync(token);
-
- using var entitiesEnumerator = entities.GetEnumerator();
-
- if (!entitiesEnumerator.MoveNext())
- return (0, 0, 0);
-
- int takeover = 0;
- int trimmed = 0;
- var preEntity = entitiesEnumerator.Current;
- while (entitiesEnumerator.MoveNext())
- {
- var entity = entitiesEnumerator.Current;
- var preDepth = preEntity.DepthEnd;
-
- if (preEntity.DepthEnd >= entity.DepthEnd)
- {
- dbset.Remove(entity);
- takeover++;
- continue;
- }
-
- if (preEntity.DepthEnd > entity.DepthStart)
- {
- entity.DepthStart = preEntity.DepthEnd;
- trimmed++;
- }
-
- var preDate = preEntity.DateStart.AddHours(preEntity.DurationHours);
-
- if (preDate >= entity.DateStart.AddHours(entity.DurationHours))
- {
- dbset.Remove(entity);
- takeover++;
- continue;
- }
-
- if (preDate > entity.DateStart)
- {
- var entityDateEnd = entity.DateStart.AddHours(entity.DurationHours);
- entity.DateStart = preDate;
- entity.DurationHours = (entityDateEnd - entity.DateStart).TotalHours;
- trimmed++;
- }
-
- preEntity = entity;
- }
- var affected = await db.SaveChangesAsync(token);
- return (takeover, trimmed, entities.Count);
- }
-}
+ private readonly IMemoryCache memoryCache;
+ private readonly IWellOperationCategoryRepository wellOperationCategoryRepository;
+ private readonly IWellService wellService;
+
+ public WellOperationRepository(IAsbCloudDbContext context,
+ IMemoryCache memoryCache,
+ IWellOperationCategoryRepository wellOperationCategoryRepository,
+ IWellService wellService)
+ : base(context, dbSet => dbSet.Include(e => e.WellSectionType)
+ .Include(e => e.OperationCategory))
+ {
+ this.memoryCache = memoryCache;
+ this.wellOperationCategoryRepository = wellOperationCategoryRepository;
+ this.wellService = wellService;
+ }
+
+ public IEnumerable GetSectionTypes() =>
+ memoryCache
+ .GetOrCreateBasic(dbContext.WellSectionTypes)
+ .OrderBy(s => s.Order)
+ .Select(s => s.Adapt());
+
+ public async Task> GetAsync(WellOperationRequest request, CancellationToken token)
+ {
+ var query = BuildQuery(request);
+
+ if (request.Skip.HasValue)
+ query = query.Skip(request.Skip.Value);
+
+ if (request.Take.HasValue)
+ query = query.Take(request.Take.Value);
+
+ var entities = await query.AsNoTracking()
+ .ToArrayAsync(token);
+
+ return await ConvertWithDrillingDaysAndNpvHoursAsync(entities, token);
+ }
+
+ public async Task> GetPageAsync(WellOperationRequest request, CancellationToken token)
+ {
+ var skip = request.Skip ?? 0;
+ var take = request.Take ?? 32;
+
+ var query = BuildQuery(request);
+
+ var entities = await query.Skip(skip)
+ .Take(take)
+ .AsNoTracking()
+ .ToArrayAsync(token);
+
+ var paginationContainer = new PaginationContainer
+ {
+ Skip = skip,
+ Take = take,
+ Count = await query.CountAsync(token),
+ Items = await ConvertWithDrillingDaysAndNpvHoursAsync(entities, token)
+ };
+
+ return paginationContainer;
+ }
+
+ public async Task> GetGroupOperationsStatAsync(WellOperationRequest request, CancellationToken token)
+ {
+ var query = BuildQuery(request);
+ var entities = await query
+ .Select(o => new
+ {
+ o.IdCategory,
+ DurationMinutes = o.DurationHours * 60,
+ DurationDepth = o.DepthEnd - o.DepthStart
+ })
+ .ToArrayAsync(token);
+
+ var parentRelationDictionary = wellOperationCategoryRepository.Get(true)
+ .ToDictionary(c => c.Id, c => new
+ {
+ c.Name,
+ c.IdParent
+ });
+
+ var dtos = entities
+ .GroupBy(o => o.IdCategory)
+ .Select(g => new WellGroupOpertionDto
+ {
+ IdCategory = g.Key,
+ Category = parentRelationDictionary[g.Key].Name,
+ Count = g.Count(),
+ MinutesAverage = g.Average(o => o.DurationMinutes),
+ MinutesMin = g.Min(o => o.DurationMinutes),
+ MinutesMax = g.Max(o => o.DurationMinutes),
+ TotalMinutes = g.Sum(o => o.DurationMinutes),
+ DeltaDepth = g.Sum(o => o.DurationDepth),
+ IdParent = parentRelationDictionary[g.Key].IdParent
+ });
+
+ while (dtos.All(x => x.IdParent != null))
+ {
+ dtos = dtos
+ .GroupBy(o => o.IdParent!)
+ .Select(g =>
+ {
+ var idCategory = g.Key ?? int.MinValue;
+ var category = parentRelationDictionary.GetValueOrDefault(idCategory);
+ var newDto = new WellGroupOpertionDto
+ {
+ IdCategory = idCategory,
+ Category = category?.Name ?? "unknown",
+ Count = g.Sum(o => o.Count),
+ DeltaDepth = g.Sum(o => o.DeltaDepth),
+ TotalMinutes = g.Sum(o => o.TotalMinutes),
+ Items = g.ToList(),
+ IdParent = category?.IdParent,
+ };
+ return newDto;
+ });
+ }
+
+ return dtos;
+ }
+
+ public async Task InsertRangeAsync(IEnumerable dtos,
+ bool deleteBeforeInsert,
+ CancellationToken token)
+ {
+ EnsureValidWellOperations(dtos);
+
+ if (!deleteBeforeInsert)
+ return await InsertRangeAsync(dtos, token);
+
+ var idType = dtos.First().IdType;
+ var idWell = dtos.First().IdWell;
+
+ var existingOperationIds = await dbContext.WellOperations
+ .Where(e => e.IdWell == idWell && e.IdType == idType)
+ .Select(e => e.Id)
+ .ToArrayAsync(token);
+
+ await DeleteRangeAsync(existingOperationIds, token);
+
+ return await InsertRangeAsync(dtos, token);
+ }
+
+ public override Task UpdateRangeAsync(IEnumerable dtos, CancellationToken token)
+ {
+ EnsureValidWellOperations(dtos);
+
+ return base.UpdateRangeAsync(dtos, token);
+ }
+
+ private static void EnsureValidWellOperations(IEnumerable dtos)
+ {
+ if (dtos.GroupBy(d => d.IdType).Count() > 1)
+ throw new ArgumentInvalidException(nameof(dtos), "Все операции должны быть одного типа");
+
+ if (dtos.GroupBy(d => d.IdType).Count() > 1)
+ throw new ArgumentInvalidException(nameof(dtos), "Все операции должны принадлежать одной скважине");
+ }
+
+ private IQueryable BuildQuery(WellOperationRequest request)
+ {
+ var query = GetQuery()
+ .Where(e => request.IdsWell != null && request.IdsWell.Contains(e.IdWell))
+ .OrderBy(e => e.DateStart)
+ .AsQueryable();
+
+ if (request.OperationType.HasValue)
+ query = query.Where(e => e.IdType == request.OperationType.Value);
+
+ if (request.SectionTypeIds?.Any() is true)
+ query = query.Where(e => request.SectionTypeIds.Contains(e.IdWellSectionType));
+
+ if (request.OperationCategoryIds?.Any() is true)
+ query = query.Where(e => request.OperationCategoryIds.Contains(e.IdCategory));
+
+ if (request.GeDepth.HasValue)
+ query = query.Where(e => e.DepthEnd >= request.GeDepth.Value);
+
+ if (request.LeDepth.HasValue)
+ query = query.Where(e => e.DepthEnd <= request.LeDepth.Value);
+
+ if (request.GeDate.HasValue)
+ {
+ var geDateUtc = request.GeDate.Value.UtcDateTime;
+ query = query.Where(e => e.DateStart >= geDateUtc);
+ }
+
+ if (request.LeDate.HasValue)
+ {
+ var leDateUtc = request.LeDate.Value.UtcDateTime;
+ query = query.Where(e => e.DateStart <= leDateUtc);
+ }
+
+ if (request.SortFields?.Any() is true)
+ query = query.SortBy(request.SortFields);
+
+ return query;
+ }
+
+ public async Task> GetSectionsAsync(IEnumerable idsWells, CancellationToken token)
+ {
+ const string keyCacheSections = "OperationsBySectionSummarties";
+
+ var cache = await memoryCache.GetOrCreateAsync(keyCacheSections, async (entry) =>
+ {
+ entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(30);
+
+ var query = dbContext.Set()
+ .GroupBy(operation => new
+ {
+ operation.IdWell,
+ operation.IdType,
+ operation.IdWellSectionType,
+ operation.WellSectionType.Caption,
+ })
+ .Select(group => new
+ {
+ group.Key.IdWell,
+ group.Key.IdType,
+ group.Key.IdWellSectionType,
+ group.Key.Caption,
+
+ First = group
+ .OrderBy(operation => operation.DateStart)
+ .Select(operation => new
+ {
+ operation.DateStart,
+ operation.DepthStart,
+ })
+ .First(),
+
+ Last = group
+ .OrderByDescending(operation => operation.DateStart)
+ .Select(operation => new
+ {
+ operation.DateStart,
+ operation.DurationHours,
+ operation.DepthEnd,
+ })
+ .First(),
+ })
+ .Where(s => idsWells.Contains(s.IdWell));
+ var dbData = await query.ToArrayAsync(token);
+ var sections = dbData.Select(
+ item => new SectionByOperationsDto
+ {
+ IdWell = item.IdWell,
+ IdType = item.IdType,
+ IdWellSectionType = item.IdWellSectionType,
+
+ Caption = item.Caption,
+
+ DateStart = item.First.DateStart,
+ DepthStart = item.First.DepthStart,
+
+ DateEnd = item.Last.DateStart.AddHours(item.Last.DurationHours),
+ DepthEnd = item.Last.DepthEnd,
+ })
+ .ToArray()
+ .AsEnumerable();
+
+ entry.Value = sections;
+ return sections;
+ });
+
+ return cache;
+ }
+
+ public async Task GetDatesRangeAsync(int idWell, int idType, CancellationToken cancellationToken)
+ {
+ var query = dbContext.WellOperations.Where(o => o.IdWell == idWell && o.IdType == idType);
+
+ if (!await query.AnyAsync(cancellationToken))
+ return null;
+
+ var timeZoneOffset = wellService.GetTimezone(idWell).Offset;
+
+ var minDate = await query.MinAsync(o => o.DateStart, cancellationToken);
+ var maxDate = await query.MaxAsync(o => o.DateStart, cancellationToken);
+
+ return new DatesRangeDto
+ {
+ From = minDate.ToOffset(timeZoneOffset),
+ To = maxDate.ToOffset(timeZoneOffset)
+ };
+ }
+
+ private async Task> ConvertWithDrillingDaysAndNpvHoursAsync(IEnumerable entities,
+ CancellationToken token)
+ {
+ var idsWell = entities.Select(e => e.IdWell).Distinct();
+
+ var currentWellOperations = GetQuery()
+ .Where(entity => idsWell.Contains(entity.IdWell));
+
+ var dateFirstDrillingOperationByIdWell = await currentWellOperations
+ .Where(entity => entity.IdType == WellOperation.IdOperationTypeFact)
+ .GroupBy(entity => entity.IdWell)
+ .ToDictionaryAsync(g => g.Key, g => g.Min(o => o.DateStart), token);
+
+ var operationsWithNptByIdWell = await currentWellOperations.Where(entity =>
+ entity.IdType == WellOperation.IdOperationTypeFact &&
+ WellOperationCategory.NonProductiveTimeSubIds.Contains(entity.IdCategory))
+ .GroupBy(entity => entity.IdWell)
+ .ToDictionaryAsync(g => g.Key, g => g.Select(o => o), token);
+
+ var dtos = entities.Select(entity =>
+ {
+ var dto = Convert(entity);
+
+ if (dateFirstDrillingOperationByIdWell.TryGetValue(entity.IdWell, out var dateFirstDrillingOperation))
+ dto.Day = (entity.DateStart - dateFirstDrillingOperation).TotalDays;
+
+ if (operationsWithNptByIdWell.TryGetValue(entity.IdWell, out var wellOperationsWithNtp))
+ dto.NptHours = wellOperationsWithNtp
+ .Where(o => o.DateStart <= entity.DateStart)
+ .Sum(e => e.DurationHours);
+
+ return dto;
+ });
+
+ return dtos;
+ }
+
+ protected override WellOperation Convert(WellOperationDto src)
+ {
+ var entity = src.Adapt();
+ entity.DateStart = src.DateStart.UtcDateTime;
+ return entity;
+ }
+
+ protected override WellOperationDto Convert(WellOperation src)
+ {
+ //TODO: пока такое получение TimeZone скважины, нужно исправить на Lazy
+ //Хоть мы и тянем данные из кэша, но от получения TimeZone в этом методе нужно избавиться, пока так
+ var timeZoneOffset = wellService.GetTimezone(src.IdWell).Offset;
+ var dto = src.Adapt();
+ dto.DateStart = src.DateStart.ToOffset(timeZoneOffset);
+ dto.LastUpdateDate = src.LastUpdateDate.ToOffset(timeZoneOffset);
+ return dto;
+ }
+}
\ No newline at end of file
diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs
index 43fb0abf..21fba541 100644
--- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs
+++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs
@@ -13,6 +13,7 @@ using AsbCloudApp.Data.DailyReport.Blocks.Sign;
using AsbCloudApp.Data.DailyReport.Blocks.Subsystems;
using AsbCloudApp.Data.DailyReport.Blocks.TimeBalance;
using AsbCloudApp.Data.DailyReport.Blocks.WellOperation;
+using AsbCloudApp.Data.WellOperation;
using AsbCloudApp.Requests;
using AsbCloudApp.Services.DailyReport;
using AsbCloudApp.Services.ProcessMaps.WellDrilling;
@@ -83,7 +84,7 @@ public class DailyReportService : IDailyReportService
editableBlock.IdUser = idUser;
editableBlock.LastUpdateDate = DateTime.UtcNow;
- dailyReport.DateLastUpdate = DateTime.UtcNow;
+ dailyReport.DateLastUpdate = DateTimeOffset.UtcNow;
if (dailyReport.Id == 0)
return await dailyReportRepository.InsertAsync(dailyReport, cancellationToken);
@@ -106,15 +107,15 @@ public class DailyReportService : IDailyReportService
IdWell = well.Id
};
- var geDate = dailyReport.Date.ToDateTime(TimeOnly.MinValue, DateTimeKind.Unspecified);
- var ltDate = dailyReport.Date.AddDays(1).ToDateTime(TimeOnly.MinValue, DateTimeKind.Unspecified);
-
- var factOperationRequest = new WellOperationRequest
- {
- IdWell = idWell,
+ var offsetHours = wellService.GetTimezone(dailyReport.IdWell).Hours;
+ var geDate = new DateTimeOffset(dailyReport.Date, TimeOnly.MinValue, TimeSpan.FromHours(offsetHours));
+ var leDate = new DateTimeOffset(dailyReport.Date.AddDays(1), TimeOnly.MinValue, TimeSpan.FromHours(offsetHours));
+
+ var factOperationRequest = new WellOperationRequest(new []{ idWell })
+ {
OperationType = WellOperation.IdOperationTypeFact,
GeDate = geDate,
- LtDate = ltDate
+ LeDate = leDate
};
var factWellOperations = (await wellOperationRepository.GetAsync(factOperationRequest, cancellationToken))
@@ -130,12 +131,12 @@ public class DailyReportService : IDailyReportService
dailyReport.DepthStart = factWellOperations.FirstOrDefault()?.DepthStart;
dailyReport.DepthEnd = factWellOperations.LastOrDefault()?.DepthEnd;
- await UpdateTimeBalanceBlockAsync(dailyReport, factWellOperations, cancellationToken);
- await UpdateSubsystemBlockAsync(dailyReport, cancellationToken);
+ await UpdateTimeBalanceBlockAsync(dailyReport, factWellOperations, geDate, leDate, cancellationToken);
+ await UpdateSubsystemBlockAsync(dailyReport, geDate, leDate, cancellationToken);
- await AddTrajectoryBlockAsync(dailyReport, cancellationToken);
- await AddScheduleBlockAsync(dailyReport, cancellationToken);
- await AddProcessMapWellDrillingBlockAsync(dailyReport, cancellationToken);
+ await AddTrajectoryBlockAsync(dailyReport, geDate, leDate, cancellationToken);
+ await AddScheduleBlockAsync(dailyReport, geDate, cancellationToken);
+ await AddProcessMapWellDrillingBlockAsync(dailyReport, geDate, leDate, cancellationToken);
AddFactWellOperationBlock(dailyReport, factWellOperations);
@@ -152,46 +153,43 @@ public class DailyReportService : IDailyReportService
Items = Enumerable.Empty()
};
- var datesRange = await GetDatesRangeAsync(idWell, cancellationToken);
+ var datesRange = await wellOperationRepository.GetDatesRangeAsync(idWell, WellOperation.IdOperationTypeFact, cancellationToken);
if (datesRange is null)
return result;
var dailyReports = new List();
-
- if (request.GeDate.HasValue)
- {
- var startDate = new DateTime(request.GeDate.Value.Year, request.GeDate.Value.Month,
- request.GeDate.Value.Day);
+ TimeSpan offset = wellService.GetTimezone(idWell).Offset;
- if (startDate.Date >= datesRange.From.Date)
+ if (request.GeDate.HasValue)
+ {
+ var startDate = new DateTimeOffset(request.GeDate.Value, TimeOnly.MinValue, offset);
+
+ if (startDate >= datesRange.From)
datesRange.From = startDate;
}
if (request.LeDate.HasValue)
{
- var finishDate = new DateTime(request.LeDate.Value.Year, request.LeDate.Value.Month,
- request.LeDate.Value.Day);
+ var finishDate = new DateTimeOffset(request.LeDate.Value, TimeOnly.MinValue, offset);
- if (finishDate.Date <= datesRange.To.Date)
+ if (finishDate <= datesRange.To)
datesRange.To = finishDate;
}
- if (datesRange.From.AddDays(result.Skip) <= datesRange.To)
- result.Count = (int)(Math.Ceiling((datesRange.To - DateTime.UnixEpoch).TotalDays) -
- Math.Floor((datesRange.From - DateTime.UnixEpoch).TotalDays)) + 1;
+ result.Count = (int)(Math.Ceiling((datesRange.To - DateTimeOffset.UnixEpoch).TotalDays)
+ - Math.Floor((datesRange.From - DateTimeOffset.UnixEpoch).TotalDays));
var existingDailyReports = await dailyReportRepository.GetAsync(idWell, request, cancellationToken);
var geDateFactWellOperation = datesRange.From.AddDays(result.Skip);
- var ltDateFactWellOperation = geDateFactWellOperation.AddDays(result.Take);
+ var leDateFactWellOperation = geDateFactWellOperation.AddDays(result.Take);
- var factWellOperationRequest = new WellOperationRequest
+ var factWellOperationRequest = new WellOperationRequest(new[] { idWell })
{
- IdWell = idWell,
OperationType = WellOperation.IdOperationTypeFact,
GeDate = geDateFactWellOperation,
- LtDate = ltDateFactWellOperation
+ LeDate = leDateFactWellOperation
};
var factWellOperations = await wellOperationRepository.GetAsync(factWellOperationRequest, cancellationToken);
@@ -200,7 +198,7 @@ public class DailyReportService : IDailyReportService
{
for (var day = result.Skip; day - result.Skip < result.Take && datesRange.To.AddDays(-day) >= datesRange.From; day++)
{
- var dateDailyReport = DateOnly.FromDateTime(datesRange.To.AddDays(-day));
+ var dateDailyReport = DateOnly.FromDateTime(datesRange.To.AddDays(-day).DateTime);
AddDailyReport(dateDailyReport);
}
@@ -209,7 +207,7 @@ public class DailyReportService : IDailyReportService
{
for (var day = result.Skip; day - result.Skip < result.Take && datesRange.From.AddDays(day) <= datesRange.To; day++)
{
- var dateDailyReport = DateOnly.FromDateTime(datesRange.From.AddDays(day));
+ var dateDailyReport = DateOnly.FromDateTime(datesRange.From.AddDays(day).DateTime);
AddDailyReport(dateDailyReport);
}
@@ -228,11 +226,11 @@ public class DailyReportService : IDailyReportService
IdWell = idWell
};
- var geDate = date.ToDateTime(TimeOnly.MinValue, DateTimeKind.Unspecified);
- var leDate = date.AddDays(1).ToDateTime(TimeOnly.MinValue, DateTimeKind.Unspecified);
+ var geDate = new DateTimeOffset(date, TimeOnly.MinValue, offset);
+ var leDate = new DateTimeOffset(date.AddDays(1), TimeOnly.MinValue, offset);
- var factWellOperationPerDay = factWellOperations.Where(o => o.DateStart.Date >= geDate &&
- o.DateStart.Date <= leDate);
+ var factWellOperationPerDay = factWellOperations.Where(o => o.DateStart >= geDate &&
+ o.DateStart <= leDate);
AddFactWellOperationBlock(dailyReport, factWellOperationPerDay);
@@ -240,36 +238,8 @@ public class DailyReportService : IDailyReportService
}
}
- public async Task GetDatesRangeAsync(int idWell, CancellationToken cancellationToken)
- {
- var timezone = wellService.GetTimezone(idWell);
- var currentDate = DateTimeOffset.UtcNow.ToRemoteDateTime(timezone.Hours);
-
- var factOperationDatesRange = await wellOperationRepository.GetDatesRangeAsync(idWell, WellOperation.IdOperationTypeFact,
- cancellationToken);
-
- if (factOperationDatesRange is null)
- return null;
-
- var from = (factOperationDatesRange.From.AddDays(1) <= DateTime.UtcNow ?
- factOperationDatesRange.From :
- currentDate.AddDays(-1))
- .Date;
-
- var to = (factOperationDatesRange.To.AddDays(1) <= DateTime.UtcNow ?
- factOperationDatesRange.To :
- currentDate.AddDays(-1))
- .Date;
-
- return new DatesRangeDto
- {
- From = from,
- To = to
- };
- }
-
private async Task UpdateTimeBalanceBlockAsync(DailyReportDto dailyReport, IEnumerable