forked from ddrilling/AsbCloudServer
Merge branch 'dev' into feature/ProcessMap_pressure_to_deltaPressure
This commit is contained in:
commit
c15fd956d0
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using AsbCloudApp.ValidationAttributes;
|
||||||
|
using System;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace AsbCloudApp.Data
|
namespace AsbCloudApp.Data
|
||||||
@ -87,6 +88,7 @@ namespace AsbCloudApp.Data
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Дата начала операции
|
/// Дата начала операции
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[DateValidation(GtDate = "2010-01-01T00:00:00")]
|
||||||
public DateTime DateStart { get; set; }
|
public DateTime DateStart { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -25,7 +25,8 @@ namespace AsbCloudApp.Services
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idWell"></param>
|
/// <param name="idWell"></param>
|
||||||
/// <param name="stream"></param>
|
/// <param name="stream"></param>
|
||||||
|
/// <param name="idUser"></param>
|
||||||
/// <param name="deleteWellOperationsBeforeImport">Очистить старые перед импортом (если файл проходит валидацию)</param>
|
/// <param name="deleteWellOperationsBeforeImport">Очистить старые перед импортом (если файл проходит валидацию)</param>
|
||||||
void Import(int idWell, Stream stream, bool deleteWellOperationsBeforeImport = false);
|
void Import(int idWell, Stream stream, int idUser, bool deleteWellOperationsBeforeImport = false);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -73,12 +73,15 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
|||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Import(int idWell, Stream stream, bool deleteWellOperationsBeforeImport = false)
|
public void Import(int idWell, Stream stream, int idUser, bool deleteWellOperationsBeforeImport = false)
|
||||||
{
|
{
|
||||||
using var workbook = new XLWorkbook(stream, XLEventTracking.Disabled);
|
using var workbook = new XLWorkbook(stream, XLEventTracking.Disabled);
|
||||||
var operations = ParseFileStream(stream);
|
var operations = ParseFileStream(stream);
|
||||||
foreach (var operation in operations)
|
foreach (var operation in operations)
|
||||||
|
{
|
||||||
operation.IdWell = idWell;
|
operation.IdWell = idWell;
|
||||||
|
operation.IdUser = idUser;
|
||||||
|
}
|
||||||
|
|
||||||
SaveOperations(idWell, operations, deleteWellOperationsBeforeImport);
|
SaveOperations(idWell, operations, deleteWellOperationsBeforeImport);
|
||||||
}
|
}
|
||||||
@ -177,6 +180,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
|||||||
var entity = o.Adapt<WellOperation>();
|
var entity = o.Adapt<WellOperation>();
|
||||||
entity.IdWell = idWell;
|
entity.IdWell = idWell;
|
||||||
entity.DateStart = o.DateStart.ToUtcDateTimeOffset(timezone.Hours);
|
entity.DateStart = o.DateStart.ToUtcDateTimeOffset(timezone.Hours);
|
||||||
|
entity.LastUpdateDate = DateTimeOffset.UtcNow;
|
||||||
return entity;
|
return entity;
|
||||||
});
|
});
|
||||||
db.WellOperations.AddRange(entities);
|
db.WellOperations.AddRange(entities);
|
||||||
|
@ -308,7 +308,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
wellOperationImportService.Import(idWell, stream, (options & 1) > 0);
|
wellOperationImportService.Import(idWell, stream, idUser.Value, (options & 1) > 0);
|
||||||
}
|
}
|
||||||
catch (FileFormatException ex)
|
catch (FileFormatException ex)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user