forked from ddrilling/AsbCloudServer
Merge branch 'dev' into feature/subsystems
This commit is contained in:
commit
4a9011e430
@ -1,61 +1,60 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace AsbCloudApp.Data.User
|
namespace AsbCloudApp.Data.User;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Контакт
|
||||||
|
/// </summary>
|
||||||
|
public class ContactDto : IId
|
||||||
{
|
{
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Контакт
|
/// ключ типа компании
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
[Range(1, int.MaxValue)]
|
||||||
|
public int IdCompanyType { get; set; }
|
||||||
|
|
||||||
public class ContactDto : IId
|
/// <summary>
|
||||||
{
|
/// ключ скважины
|
||||||
/// <inheritdoc/>
|
/// </summary>
|
||||||
public int Id { get; set; }
|
[Required]
|
||||||
|
[Range(1,int.MaxValue)]
|
||||||
|
public int IdWell { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ключ типа компании
|
/// ФИО
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Required]
|
[Required]
|
||||||
public int IdCompanyType { get; set; }
|
[StringLength(260, MinimumLength = 0, ErrorMessage = "Допустимая длина ФИО от 1 до 260 символов")]
|
||||||
|
public string FullName { get; set; } = null!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ключ скважины
|
/// Email
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Required]
|
[RegularExpression(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", ErrorMessage = "Некорректный email")]
|
||||||
public int IdWell { get; set; }
|
public string? Email { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ФИО
|
/// Phone
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Required]
|
[RegularExpression(@"^(?:\+7|8)\s?(?:\(\d{3}\)|\d{3})\s?\d{3}-?\d{2}-?\d{2}$", ErrorMessage = "Некорректный номер телефона")]
|
||||||
[StringLength(260, MinimumLength = 0, ErrorMessage = "Допустимая длина ФИО от 1 до 260 символов")]
|
public string? Phone { get; set; }
|
||||||
public string FullName { get; set; } = null!;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Email
|
/// Должность
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegularExpression(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", ErrorMessage = "Некорректный email")]
|
[Required]
|
||||||
public string? Email { get; set; }
|
[StringLength(260, MinimumLength = 1, ErrorMessage = "Допустимая длина должности от 1 до 260 символов")]
|
||||||
|
public string Position { get; set; } = null!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Phone
|
/// Компания
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegularExpression(@"^(?:\+7|8)\s?(?:\(\d{3}\)|\d{3})\s?\d{3}-?\d{2}-?\d{2}$", ErrorMessage = "Некорректный номер телефона")]
|
[Required]
|
||||||
public string? Phone { get; set; }
|
[StringLength(260, MinimumLength = 3, ErrorMessage = "Допустимая длина названия компании от 3 до 260 символов")]
|
||||||
|
public string Company { get; set; } = null!;
|
||||||
/// <summary>
|
|
||||||
/// Должность
|
|
||||||
/// </summary>
|
|
||||||
[Required]
|
|
||||||
[StringLength(260, MinimumLength = 1, ErrorMessage = "Допустимая длина должности от 1 до 260 символов")]
|
|
||||||
public string Position { get; set; } = null!;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Компания
|
|
||||||
/// </summary>
|
|
||||||
[Required]
|
|
||||||
[StringLength(260, MinimumLength = 3, ErrorMessage = "Допустимая длина должности от 3 до 260 символов")]
|
|
||||||
public string Company { get; set; } = null!;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace AsbCloudDb
|
namespace AsbCloudDb
|
||||||
{
|
{
|
||||||
@ -12,12 +13,16 @@ namespace AsbCloudDb
|
|||||||
db.SetCommandTimeout(TimeSpan.FromMinutes(5));
|
db.SetCommandTimeout(TimeSpan.FromMinutes(5));
|
||||||
if (db.EnsureCreated())
|
if (db.EnsureCreated())
|
||||||
{
|
{
|
||||||
|
Trace.TraceInformation("Creating DB");
|
||||||
|
Console.WriteLine("Creating DB");
|
||||||
db.CreateMigrationTable();
|
db.CreateMigrationTable();
|
||||||
db.WriteMigrationsInfo();
|
db.WriteMigrationsInfo();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Trace.TraceInformation("Migrating DB");
|
||||||
db.SetCommandTimeout(TimeSpan.FromMinutes(20));
|
db.SetCommandTimeout(TimeSpan.FromMinutes(20));
|
||||||
|
Console.WriteLine("db.Migrate()");
|
||||||
db.Migrate();
|
db.Migrate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
@ -12,7 +12,6 @@ public class DetectorDrilling : DetectorAbstract
|
|||||||
public const string ExtraDataKeyHasOscillation = "hasOscillation";
|
public const string ExtraDataKeyHasOscillation = "hasOscillation";
|
||||||
public const string ExtraDataKeyDispersionOfNormalizedRotorSpeed = "dispersionOfNormalizedRotorSpeed";
|
public const string ExtraDataKeyDispersionOfNormalizedRotorSpeed = "dispersionOfNormalizedRotorSpeed";
|
||||||
public const string ExtraDataKeyAvgRotorSpeed = "avgRotorSpeed";
|
public const string ExtraDataKeyAvgRotorSpeed = "avgRotorSpeed";
|
||||||
public const string ExtraDataKeyIsAfbEnabled = "isAfbEnabled";
|
|
||||||
|
|
||||||
protected override bool DetectBegin(DetectableTelemetry[] telemetry, int position, DetectedOperation? previousOperation)
|
protected override bool DetectBegin(DetectableTelemetry[] telemetry, int position, DetectedOperation? previousOperation)
|
||||||
{
|
{
|
||||||
@ -45,7 +44,8 @@ public class DetectorDrilling : DetectorAbstract
|
|||||||
=> CalcRop(telemetry, begin, end);
|
=> CalcRop(telemetry, begin, end);
|
||||||
|
|
||||||
protected override bool IsValidOperationDetectorResult(OperationDetectorResult operationDetectorResult) =>
|
protected override bool IsValidOperationDetectorResult(OperationDetectorResult operationDetectorResult) =>
|
||||||
Math.Abs(operationDetectorResult.Operation.DepthStart - operationDetectorResult.Operation.DepthEnd) > 0.01;
|
base.IsValidOperationDetectorResult(operationDetectorResult)
|
||||||
|
&& (operationDetectorResult.Operation.DepthEnd - operationDetectorResult.Operation.DepthStart) > 0.01;
|
||||||
|
|
||||||
protected override (int Begin, int End) RefineEdges(DetectableTelemetry[] telemetry, int begin, int end)
|
protected override (int Begin, int End) RefineEdges(DetectableTelemetry[] telemetry, int begin, int end)
|
||||||
{
|
{
|
||||||
|
@ -38,13 +38,6 @@ namespace AsbCloudInfrastructure
|
|||||||
backgroundWorker.Add(MakeMemoryMonitoringWork(), TimeSpan.FromMinutes(1));
|
backgroundWorker.Add(MakeMemoryMonitoringWork(), TimeSpan.FromMinutes(1));
|
||||||
|
|
||||||
var notificationBackgroundWorker = provider.GetRequiredService<NotificationBackgroundWorker>();
|
var notificationBackgroundWorker = provider.GetRequiredService<NotificationBackgroundWorker>();
|
||||||
|
|
||||||
Task.Delay(1_000)
|
|
||||||
.ContinueWith(async (_) =>
|
|
||||||
{
|
|
||||||
await backgroundWorker.StartAsync(CancellationToken.None);
|
|
||||||
await notificationBackgroundWorker.StartAsync(CancellationToken.None);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Work MakeMemoryMonitoringWork()
|
static Work MakeMemoryMonitoringWork()
|
||||||
|
@ -17,10 +17,10 @@ public class DetectorDrillingTests : DetectorDrilling
|
|||||||
public void DefineDrillingOperation_ShouldReturn_DrillingRotor(DetectableTelemetry[] telemetryRange)
|
public void DefineDrillingOperation_ShouldReturn_DrillingRotor(DetectableTelemetry[] telemetryRange)
|
||||||
{
|
{
|
||||||
//act
|
//act
|
||||||
var result = GetIdOperation.Invoke(telemetryRange, 0, telemetryRange.Length);
|
var result = GetSpecificInformation(telemetryRange, 0, telemetryRange.Length);
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.Equal(idRotor, result);
|
Assert.Equal(idRotor, result.IdCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
@ -28,10 +28,10 @@ public class DetectorDrillingTests : DetectorDrilling
|
|||||||
public void DefineDrillingOperation_ShouldReturn_DrillingSlide(DetectableTelemetry[] telemetryRange)
|
public void DefineDrillingOperation_ShouldReturn_DrillingSlide(DetectableTelemetry[] telemetryRange)
|
||||||
{
|
{
|
||||||
//act
|
//act
|
||||||
var result = GetIdOperation.Invoke(telemetryRange, 0, telemetryRange.Length);
|
var result = GetSpecificInformation(telemetryRange, 0, telemetryRange.Length);
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.Equal(idSlide, result);
|
Assert.Equal(idSlide, result.IdCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
@ -39,10 +39,13 @@ public class DetectorDrillingTests : DetectorDrilling
|
|||||||
public void DefineDrillingOperation_ShouldReturn_DrillingSlideWithOscillation(DetectableTelemetry[] telemetryRange)
|
public void DefineDrillingOperation_ShouldReturn_DrillingSlideWithOscillation(DetectableTelemetry[] telemetryRange)
|
||||||
{
|
{
|
||||||
//act
|
//act
|
||||||
var result = GetIdOperation.Invoke(telemetryRange, 0, telemetryRange.Length);
|
var result = GetSpecificInformation(telemetryRange, 0, telemetryRange.Length);
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.Equal(idSlideWithOscillation, result);
|
var oHasOscillation = result.ExtraData[ExtraDataKeyHasOscillation];
|
||||||
|
|
||||||
|
Assert.Equal(idSlide, result.IdCategory);
|
||||||
|
Assert.True(oHasOscillation is bool hasOscillation && hasOscillation);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@ -53,10 +56,11 @@ public class DetectorDrillingTests : DetectorDrilling
|
|||||||
{
|
{
|
||||||
Operation = new DetectedOperation
|
Operation = new DetectedOperation
|
||||||
{
|
{
|
||||||
IdReasonOfEnd = IdReasonOfEnd_PressureIsLo,
|
|
||||||
DepthStart = 5000,
|
DepthStart = 5000,
|
||||||
DepthEnd = 6000
|
DepthEnd = 6000,
|
||||||
}
|
DateStart = System.DateTimeOffset.Now.AddMinutes(-1),
|
||||||
|
DateEnd = System.DateTimeOffset.Now,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//act
|
//act
|
||||||
@ -74,10 +78,11 @@ public class DetectorDrillingTests : DetectorDrilling
|
|||||||
{
|
{
|
||||||
Operation = new DetectedOperation
|
Operation = new DetectedOperation
|
||||||
{
|
{
|
||||||
IdReasonOfEnd = IdReasonOfEnd_PressureIsLo,
|
|
||||||
DepthStart = 5000,
|
DepthStart = 5000,
|
||||||
DepthEnd = 5000
|
DepthEnd = 5000,
|
||||||
}
|
DateStart = System.DateTimeOffset.Now.AddMinutes(-1),
|
||||||
|
DateEnd = System.DateTimeOffset.Now,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//act
|
//act
|
||||||
|
@ -86,7 +86,7 @@ public class PeriodicBackgroundWorkerTest
|
|||||||
service.Add(badWork, TimeSpan.FromSeconds(2));
|
service.Add(badWork, TimeSpan.FromSeconds(2));
|
||||||
service.Add(goodWork, TimeSpan.FromSeconds(2));
|
service.Add(goodWork, TimeSpan.FromSeconds(2));
|
||||||
|
|
||||||
await Task.Delay(TimeSpan.FromMilliseconds(20));
|
await Task.Delay(TimeSpan.FromMilliseconds(128));
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.Equal(expectadResult, result);
|
Assert.Equal(expectadResult, result);
|
||||||
|
@ -16,6 +16,8 @@ using AsbCloudApp.Data.WellOperationImport;
|
|||||||
using AsbCloudApp.Services.WellOperationImport;
|
using AsbCloudApp.Services.WellOperationImport;
|
||||||
using AsbCloudApp.Data.WellOperationImport.Options;
|
using AsbCloudApp.Data.WellOperationImport.Options;
|
||||||
using AsbCloudApp.Exceptions;
|
using AsbCloudApp.Exceptions;
|
||||||
|
using AsbCloudDb.Model;
|
||||||
|
using AsbCloudInfrastructure;
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
@ -266,7 +268,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (!await CanUserEditWellOperationsAsync(idWell, cancellationToken))
|
if (!await CanUserEditWellOperationsAsync(idWell, cancellationToken))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
if (deleteBeforeInsert && wellOperations.Any())
|
if (deleteBeforeInsert)
|
||||||
{
|
{
|
||||||
var existingOperations = await operationRepository.GetAsync(new WellOperationRequest
|
var existingOperations = await operationRepository.GetAsync(new WellOperationRequest
|
||||||
{
|
{
|
||||||
@ -344,46 +346,85 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Импорт операций из excel (xlsx) файла. Стандартный заполненный шаблон
|
/// Импорт фактических операций из excel (xlsx) файла. Стандартный заполненный шаблон
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell">id скважины</param>
|
||||||
|
/// <param name="files">Коллекция из одного файла xlsx</param>
|
||||||
|
/// <param name="deleteBeforeInsert">Удалить операции перед сохранением</param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("import/fact/default/{deleteBeforeInsert:bool}")]
|
||||||
|
[ProducesResponseType(typeof(IEnumerable<WellOperationDto>), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
|
[Permission]
|
||||||
|
public Task<IActionResult> ImportFactDefaultExcelFileAsync(int idWell,
|
||||||
|
[FromForm] IFormFileCollection files,
|
||||||
|
bool deleteBeforeInsert,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var options = new WellOperationImportDefaultOptionsDto
|
||||||
|
{
|
||||||
|
IdType = WellOperation.IdOperationTypeFact
|
||||||
|
};
|
||||||
|
|
||||||
|
return ImportExcelFileAsync(idWell, files, options,
|
||||||
|
(stream, _) => wellOperationDefaultExcelParser.Parse(stream, options),
|
||||||
|
deleteBeforeInsert,
|
||||||
|
cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Импорт плановых операций из excel (xlsx) файла. Стандартный заполненный шаблон
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idWell">id скважины</param>
|
/// <param name="idWell">id скважины</param>
|
||||||
/// <param name="options">Параметры для парсинга файла</param>
|
|
||||||
/// <param name="files">Коллекция из одного файла xlsx</param>
|
/// <param name="files">Коллекция из одного файла xlsx</param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost("import/default")]
|
[HttpPost("import/plan/default")]
|
||||||
[ProducesResponseType(typeof(IEnumerable<WellOperationDto>), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(IEnumerable<WellOperationDto>), StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
||||||
[Permission]
|
[Permission]
|
||||||
public Task<IActionResult> ImportDefaultExcelFileAsync(int idWell,
|
public Task<IActionResult> ImportPlanDefaultExcelFileAsync(int idWell,
|
||||||
[FromQuery] WellOperationImportDefaultOptionsDto options,
|
|
||||||
[FromForm] IFormFileCollection files,
|
[FromForm] IFormFileCollection files,
|
||||||
CancellationToken cancellationToken) => ImportExcelFileAsync(idWell, files, options,
|
CancellationToken cancellationToken)
|
||||||
(stream, _) => wellOperationDefaultExcelParser.Parse(stream, options),
|
{
|
||||||
cancellationToken);
|
var options = new WellOperationImportDefaultOptionsDto
|
||||||
|
{
|
||||||
|
IdType = WellOperation.IdOperationTypePlan
|
||||||
|
};
|
||||||
|
|
||||||
|
return ImportExcelFileAsync(idWell, files, options,
|
||||||
|
(stream, _) => wellOperationDefaultExcelParser.Parse(stream, options),
|
||||||
|
null,
|
||||||
|
cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Импорт операций из excel (xlsx) файла. ГПНХ (Хантос)
|
/// Импорт операций из excel (xlsx) файла. ГПНХ (Хантос)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idWell">id скважины</param>
|
/// <param name="idWell">id скважины</param>
|
||||||
/// <param name="options">Параметры для парсинга файла</param>
|
|
||||||
/// <param name="files">Коллекция из одного файла xlsx</param>
|
/// <param name="files">Коллекция из одного файла xlsx</param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost("import/gazpromKhantos")]
|
[HttpPost("import/plan/gazpromKhantos")]
|
||||||
[ProducesResponseType(typeof(IEnumerable<WellOperationDto>), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(IEnumerable<WellOperationDto>), StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
||||||
[Permission]
|
[Permission]
|
||||||
public Task<IActionResult> ImportGazpromKhantosExcelFileAsync(int idWell,
|
public Task<IActionResult> ImportPlanGazpromKhantosExcelFileAsync(int idWell,
|
||||||
[FromQuery] WellOperationImportGazpromKhantosOptionsDto options,
|
|
||||||
[FromForm] IFormFileCollection files,
|
[FromForm] IFormFileCollection files,
|
||||||
CancellationToken cancellationToken) => ImportExcelFileAsync(idWell, files, options,
|
CancellationToken cancellationToken)
|
||||||
(stream, _) => wellOperationGazpromKhantosExcelParser.Parse(stream, options),
|
{
|
||||||
cancellationToken);
|
var options = new WellOperationImportGazpromKhantosOptionsDto
|
||||||
|
{
|
||||||
|
IdType = WellOperation.IdOperationTypePlan
|
||||||
|
};
|
||||||
|
|
||||||
|
return ImportExcelFileAsync(idWell, files, options,
|
||||||
|
(stream, _) => wellOperationGazpromKhantosExcelParser.Parse(stream, options),
|
||||||
|
null,
|
||||||
|
cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Создает excel файл с операциями по скважине
|
/// Создает excel файл с операциями по скважине
|
||||||
@ -451,9 +492,11 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
return File(stream, "application/octet-stream", fileName);
|
return File(stream, "application/octet-stream", fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: deleteBeforeInsert тоже быстрый костыль
|
||||||
private async Task<IActionResult> ImportExcelFileAsync<TOptions>(int idWell, [FromForm] IFormFileCollection files,
|
private async Task<IActionResult> ImportExcelFileAsync<TOptions>(int idWell, [FromForm] IFormFileCollection files,
|
||||||
TOptions options,
|
TOptions options,
|
||||||
Func<Stream, TOptions, SheetDto> parseMethod,
|
Func<Stream, TOptions, SheetDto> parseMethod,
|
||||||
|
bool? deleteBeforeInsert,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
where TOptions : IWellOperationImportOptions
|
where TOptions : IWellOperationImportOptions
|
||||||
{
|
{
|
||||||
@ -488,13 +531,22 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
var wellOperations = wellOperationImportService.Import(idWell, idUser.Value, options.IdType, sheet)
|
var wellOperations = wellOperationImportService.Import(idWell, idUser.Value, options.IdType, sheet)
|
||||||
.OrderBy(w => w.DateStart);
|
.OrderBy(w => w.DateStart);
|
||||||
|
|
||||||
var dateStart = wellOperations.Min(w => w.DateStart);
|
var dateStart = wellOperations.MinOrDefault(w => w.DateStart);
|
||||||
|
|
||||||
foreach (var wellOperation in wellOperations)
|
foreach (var wellOperation in wellOperations)
|
||||||
wellOperation.Day = (wellOperation.DateStart - dateStart).TotalDays;
|
{
|
||||||
|
if (dateStart.HasValue)
|
||||||
if (!wellOperations.Any())
|
wellOperation.Day = (wellOperation.DateStart - dateStart.Value).TotalDays;
|
||||||
return NoContent();
|
}
|
||||||
|
|
||||||
|
//TODO: очень быстрый костыль
|
||||||
|
if (deleteBeforeInsert is not null && options.IdType == WellOperation.IdOperationTypeFact)
|
||||||
|
{
|
||||||
|
return await InsertRangeAsync(idWell, options.IdType,
|
||||||
|
deleteBeforeInsert.Value,
|
||||||
|
wellOperations,
|
||||||
|
cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
return Ok(wellOperations);
|
return Ok(wellOperations);
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,8 @@ namespace AsbCloudWebApi
|
|||||||
c.IncludeXmlComments(xmlPath, includeControllerXmlComment);
|
c.IncludeXmlComments(xmlPath, includeControllerXmlComment);
|
||||||
c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "AsbCloudApp.xml"), includeControllerXmlComment);
|
c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "AsbCloudApp.xml"), includeControllerXmlComment);
|
||||||
|
|
||||||
c.AddSignalRSwaggerGen(options => {
|
c.AddSignalRSwaggerGen(options =>
|
||||||
|
{
|
||||||
options.DisplayInDocument("signalr");
|
options.DisplayInDocument("signalr");
|
||||||
options.UseHubXmlCommentsSummaryAsTagDescription = true;
|
options.UseHubXmlCommentsSummaryAsTagDescription = true;
|
||||||
options.UseHubXmlCommentsSummaryAsTag = true;
|
options.UseHubXmlCommentsSummaryAsTag = true;
|
||||||
|
@ -7,8 +7,6 @@ namespace AsbCloudWebApi
|
|||||||
{
|
{
|
||||||
// Uncomment next line to find wired exceptions by tracing.
|
// Uncomment next line to find wired exceptions by tracing.
|
||||||
//static TraceListenerView trace4debug = new TraceListenerView();
|
//static TraceListenerView trace4debug = new TraceListenerView();
|
||||||
enum A { a = 1 << 2 }
|
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
var host = CreateHostBuilder(args).Build();
|
var host = CreateHostBuilder(args).Build();
|
||||||
|
Loading…
Reference in New Issue
Block a user