forked from ddrilling/AsbCloudServer
Merge branch 'dev' into SubsystemsOperationTime
This commit is contained in:
commit
edb53fb4e7
@ -1,5 +1,6 @@
|
||||
namespace AsbCloudApp.Data
|
||||
{
|
||||
#nullable enable
|
||||
/// <summary>
|
||||
/// DTO категории файла
|
||||
/// </summary>
|
||||
@ -11,11 +12,12 @@
|
||||
/// <summary>
|
||||
/// полное название
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// сокращенное название
|
||||
/// </summary>
|
||||
public string ShortName { get; set; }
|
||||
public string ShortName { get; set; } = string.Empty;
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
31
AsbCloudApp/Data/WellCaseDto.cs
Normal file
31
AsbCloudApp/Data/WellCaseDto.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudApp.Data
|
||||
{
|
||||
#nullable enable
|
||||
/// <summary>
|
||||
/// Дела скважины
|
||||
/// </summary>
|
||||
public class WellCaseDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Скважина
|
||||
/// </summary>
|
||||
public int IdWell { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Разрешение для текущего пользователя добавлять ответственных
|
||||
/// </summary>
|
||||
public bool PermissionToSetPubliher { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Документ дела скважины
|
||||
/// </summary>
|
||||
public IEnumerable<WellFinalDocumentDto> WellFinalDocuments { get; set; } = Enumerable.Empty<WellFinalDocumentDto>();
|
||||
}
|
||||
#nullable disable
|
||||
}
|
25
AsbCloudApp/Data/WellFinalDocumentDBDto.cs
Normal file
25
AsbCloudApp/Data/WellFinalDocumentDBDto.cs
Normal file
@ -0,0 +1,25 @@
|
||||
namespace AsbCloudApp.Data
|
||||
{
|
||||
#nullable enable
|
||||
/// <summary>
|
||||
/// DTO Дело скважины
|
||||
/// </summary>
|
||||
public class WellFinalDocumentDBDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Идентификатор скважины
|
||||
/// </summary>
|
||||
public int IdWell { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Идентификатор ответственного
|
||||
/// </summary>
|
||||
public int IdUser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Идентификатор категории файла
|
||||
/// </summary>
|
||||
public int IdCategory { get; set; }
|
||||
}
|
||||
#nullable disable
|
||||
}
|
43
AsbCloudApp/Data/WellFinalDocumentDto.cs
Normal file
43
AsbCloudApp/Data/WellFinalDocumentDto.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace AsbCloudApp.Data
|
||||
{
|
||||
#nullable enable
|
||||
/// <summary>
|
||||
/// DTO Документ дела скважины
|
||||
/// </summary>
|
||||
public class WellFinalDocumentDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Идентификатор категории файла
|
||||
/// </summary>
|
||||
public int IdCategory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Наименование категории файла
|
||||
/// </summary>
|
||||
public string NameCategory { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Разрешение для текущего пользователя загружать документ
|
||||
/// </summary>
|
||||
public bool PermissionToUpload { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Список ответственных
|
||||
/// </summary>
|
||||
public IEnumerable<UserDto> Publishers { get; set; } = Enumerable.Empty<UserDto>();
|
||||
|
||||
/// <summary>
|
||||
/// Количество файлов этой категории загруженных ранее
|
||||
/// </summary>
|
||||
public int FilesCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Актуальный файл
|
||||
/// </summary>
|
||||
public FileInfoDto? File { get; set; }
|
||||
}
|
||||
#nullable disable
|
||||
}
|
23
AsbCloudApp/Data/WellFinalDocumentInputDto.cs
Normal file
23
AsbCloudApp/Data/WellFinalDocumentInputDto.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace AsbCloudApp.Data
|
||||
{
|
||||
#nullable enable
|
||||
/// <summary>
|
||||
/// DTO Для сохранения категорий дела скважины
|
||||
/// </summary>
|
||||
public class WellFinalDocumentInputDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Идентификатор категории файла
|
||||
/// </summary>
|
||||
public int IdCategory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Список ответственных
|
||||
/// </summary>
|
||||
public IEnumerable<int> IdsPublishers { get; set; } = Enumerable.Empty<int>();
|
||||
}
|
||||
#nullable disable
|
||||
}
|
27
AsbCloudApp/Data/WellFinalDocumentsHistoryDto.cs
Normal file
27
AsbCloudApp/Data/WellFinalDocumentsHistoryDto.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AsbCloudApp.Data
|
||||
{
|
||||
#nullable enable
|
||||
/// <summary>
|
||||
/// DTO Дело скважины, история файлов
|
||||
/// </summary>
|
||||
public class WellFinalDocumentsHistoryDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Вышка
|
||||
/// </summary>
|
||||
public int IdWell { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Наименование категории файла
|
||||
/// </summary>
|
||||
public int IdCategory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Файлы
|
||||
/// </summary>
|
||||
public IEnumerable<FileInfoDto>? File { get; set; }
|
||||
}
|
||||
#nullable disable
|
||||
}
|
21
AsbCloudApp/Services/IFileCategoryService.cs
Normal file
21
AsbCloudApp/Services/IFileCategoryService.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using AsbCloudApp.Data;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudApp.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Сервис "Категории документов (файлов)"
|
||||
/// </summary>
|
||||
public interface IFileCategoryService
|
||||
{
|
||||
Task<FileCategoryDto> GetOrDefaultAsync(int id, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Получение справочника категорий файлов
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<FileCategoryDto>> GetWellCaseCategoriesAsync(CancellationToken token);
|
||||
}
|
||||
}
|
@ -159,5 +159,21 @@ namespace AsbCloudApp.Services
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> MarkFileMarkAsDeletedAsync(IEnumerable<int> idsMarks, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Инфо о файле
|
||||
/// </summary>
|
||||
/// <param name="idsFile"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<FileInfoDto>> GetInfoByIdsAsync(List<int> idsFile, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Получение файлов по скважине
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<FileInfoDto>> GetInfosByWellIdAsync(int idWell, CancellationToken token);
|
||||
}
|
||||
}
|
||||
|
62
AsbCloudApp/Services/IWellFinalDocumentsService.cs
Normal file
62
AsbCloudApp/Services/IWellFinalDocumentsService.cs
Normal file
@ -0,0 +1,62 @@
|
||||
using AsbCloudApp.Data;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudApp.Services
|
||||
{
|
||||
#nullable enable
|
||||
/// <summary>
|
||||
/// Сервис "Дело скважины"
|
||||
/// </summary>
|
||||
public interface IWellFinalDocumentsService
|
||||
{
|
||||
/// <summary>
|
||||
/// Обновление записей дела скважины
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="dtos"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> UpdateRangeAsync(int idWell, IEnumerable<WellFinalDocumentInputDto>? dtos, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Получение всех записей
|
||||
/// </summary>
|
||||
/// <param name = "idWell" ></param >
|
||||
/// <param name = "idUser" ></param >
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<WellCaseDto> GetByWellId(int idWell, int idUser, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Получение списка ответственных
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<UserDto>> GetAvailableUsersAsync(int idWell, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Получение истории файлов
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="idCategory"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<WellFinalDocumentsHistoryDto> GetFilesHistoryByIdCategory(int idWell, int idCategory, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Сохранение файла
|
||||
/// </summary>
|
||||
/// <param name="idDto"></param>
|
||||
/// <param name="idUser"></param>
|
||||
/// <param name="fileStream"></param>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> SaveCategoryFile(int idWell, int idCategory, int idUser, Stream fileStream, string fileName, CancellationToken token);
|
||||
}
|
||||
#nullable disable
|
||||
}
|
6523
AsbCloudDb/Migrations/20220818105738_update_file_category.Designer.cs
generated
Normal file
6523
AsbCloudDb/Migrations/20220818105738_update_file_category.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
286
AsbCloudDb/Migrations/20220818105738_update_file_category.cs
Normal file
286
AsbCloudDb/Migrations/20220818105738_update_file_category.cs
Normal file
@ -0,0 +1,286 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
public partial class update_file_category : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.InsertData(
|
||||
table: "t_file_category",
|
||||
columns: new[] { "id", "name", "short_name" },
|
||||
values: new object[,]
|
||||
{
|
||||
{ 10000, "Проект на бурение транспортного и горизонтального участков скважины", null },
|
||||
{ 10001, "Программа на бурение транспортного и горизонтального участков скважины", null },
|
||||
{ 10002, "Акт о начале бурения", null },
|
||||
{ 10003, "План работ спуска и цементирования направления", null },
|
||||
{ 10004, "Программа цементирования направления", null },
|
||||
{ 10005, "Мера обсадных труб (направление)", null },
|
||||
{ 10006, "Акт на выполненные работы по цементированию направления", null },
|
||||
{ 10007, "Отчет по цементированию направления (график)", null },
|
||||
{ 10008, "План работ спуска и цементирования кондуктора", null },
|
||||
{ 10009, "Программа цементирования (кондуктор)", null },
|
||||
{ 10010, "Мера обсадных труб (кондуктор)", null },
|
||||
{ 10011, "Карта крепления кондуктора", null },
|
||||
{ 10012, "Акт на выполненные работы по цементированию кондуктора", null },
|
||||
{ 10013, "Отчет по цементированию кондуктора (график)", null },
|
||||
{ 10014, "Акт о замере расстояния от стола ротора до муфты кондуктора", null },
|
||||
{ 10015, "Акт опресовки цементного кольца за кондуктором", null },
|
||||
{ 10016, "Акт опресовки ППГ с глухими плашками совместно с кондуктором", null },
|
||||
{ 10017, "Акт опресовки ПУГ, ППГ с трубными плашками совместно с кондуктором", null },
|
||||
{ 10018, "План работ на крепление обсадной колонны (эк. колонна)", null },
|
||||
{ 10019, "Программа цементирования (эк. колонна)", null },
|
||||
{ 10020, "Мера труб эксплуатационной колонны", null },
|
||||
{ 10021, "Карта по креплению скважины (эк. колонна)", null },
|
||||
{ 10022, "Акт на установку пружинных центраторов", null },
|
||||
{ 10023, "Отчет по цементированию эксплуатационной колонны (график)", null },
|
||||
{ 10024, "Акт на выполненные работы по цементированию эксплуатационной колонны", null },
|
||||
{ 10025, "Акт об испытании эк. колонны на герметичность (СТОП)", null },
|
||||
{ 10026, "Акт опресовки ППГ с глухими плашками совместно с э/колонной", null },
|
||||
{ 10027, "Акт опресовки ПУГ, ППГ с трубными плашками совместно с э/колонной", null },
|
||||
{ 10028, "Акт на вскрытие продуктивного пласта", null },
|
||||
{ 10029, "Акт замера параметров раствора при бурении горизонтального участка", null },
|
||||
{ 10030, "Разрешение на спуск «хвостовика» (телефонограмма)", null },
|
||||
{ 10031, "План работ на спуск «хвостовика»", null },
|
||||
{ 10032, "Акт готовности бурового и энергетического оборудования к спуску «хвостовика»", null },
|
||||
{ 10033, "Акт шаблонировки ствола скважины перед спуском «хвостовика»", null },
|
||||
{ 10034, "Мера обсадных труб (хвостовик)", null },
|
||||
{ 10035, "Акт выполненных работ по спуску хвостовика с закачкой (нефти, солевого раствора", null },
|
||||
{ 10036, "Акт о переводе скважины на тех. воду", null },
|
||||
{ 10037, "Акт об окончании бурения", null },
|
||||
{ 10038, "Акт на передачу скважины в освоение (КРС)", null },
|
||||
{ 10039, "Акт на опресовку межколонного пространства с КРС", null },
|
||||
{ 10040, "Акт на сдачу скважины в ЦДНГ", null },
|
||||
{ 10041, "Паспорт ОУС (заполняется геологами)", null },
|
||||
{ 10042, "Паспорт скважины (заполняется геологами)", null },
|
||||
{ 10043, "Фактические данные бурения (вставляются в паспорт скважины)", null }
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10000);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10001);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10002);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10003);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10004);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10005);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10006);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10007);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10008);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10009);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10010);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10011);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10012);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10013);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10014);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10015);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10016);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10017);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10018);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10019);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10020);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10021);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10022);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10023);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10024);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10025);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10026);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10027);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10028);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10029);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10030);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10031);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10032);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10033);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10034);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10035);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10036);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10037);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10038);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10039);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10040);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10041);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10042);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 10043);
|
||||
}
|
||||
}
|
||||
}
|
6597
AsbCloudDb/Migrations/20220825062446_AddTable_t_well_final_documents.Designer.cs
generated
Normal file
6597
AsbCloudDb/Migrations/20220825062446_AddTable_t_well_final_documents.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,79 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
public partial class AddTable_t_well_final_documents : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "t_well_final_documents",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
id_well = table.Column<int>(type: "integer", nullable: false),
|
||||
id_user = table.Column<int>(type: "integer", nullable: false),
|
||||
id_category = table.Column<int>(type: "integer", nullable: false),
|
||||
id_file = table.Column<int>(type: "integer", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("t_well_final_documents_pk", x => x.id);
|
||||
table.ForeignKey(
|
||||
name: "FK_t_well_final_documents_t_file_category_id_category",
|
||||
column: x => x.id_category,
|
||||
principalTable: "t_file_category",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_t_well_final_documents_t_file_info_id_file",
|
||||
column: x => x.id_file,
|
||||
principalTable: "t_file_info",
|
||||
principalColumn: "id");
|
||||
table.ForeignKey(
|
||||
name: "FK_t_well_final_documents_t_user_id_user",
|
||||
column: x => x.id_user,
|
||||
principalTable: "t_user",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_t_well_final_documents_t_well_id_well",
|
||||
column: x => x.id_well,
|
||||
principalTable: "t_well",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
},
|
||||
comment: "Дело скважины");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_t_well_final_documents_id_category",
|
||||
table: "t_well_final_documents",
|
||||
column: "id_category");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_t_well_final_documents_id_file",
|
||||
table: "t_well_final_documents",
|
||||
column: "id_file");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_t_well_final_documents_id_user",
|
||||
table: "t_well_final_documents",
|
||||
column: "id_user");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_t_well_final_documents_id_well",
|
||||
table: "t_well_final_documents",
|
||||
column: "id_well");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "t_well_final_documents");
|
||||
}
|
||||
}
|
||||
}
|
6663
AsbCloudDb/Migrations/20220826073454_AddPermission.Designer.cs
generated
Normal file
6663
AsbCloudDb/Migrations/20220826073454_AddPermission.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
101
AsbCloudDb/Migrations/20220826073454_AddPermission.cs
Normal file
101
AsbCloudDb/Migrations/20220826073454_AddPermission.cs
Normal file
@ -0,0 +1,101 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
public partial class AddPermission : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.InsertData(
|
||||
table: "t_permission",
|
||||
columns: new[] { "id", "description", "name" },
|
||||
values: new object[,]
|
||||
{
|
||||
{ 500, "Разрешение удалять Категорий документов файлов", "FileCategory.delete" },
|
||||
{ 501, "Разрешение редактировать Категорий документов файлов", "FileCategory.edit" },
|
||||
{ 502, "Разрешение просматривать Категорий документов файлов", "FileCategory.get" },
|
||||
{ 503, "Разрешение удалять Дело скважины", "WellFinalDocument.delete" },
|
||||
{ 504, "Разрешение редактировать Дело скважины", "WellFinalDocument.edit" },
|
||||
{ 505, "Разрешение просматривать Дело скважины", "WellFinalDocument.get" }
|
||||
});
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "t_relation_user_role_permission",
|
||||
columns: new[] { "id_permission", "id_user_role" },
|
||||
values: new object[,]
|
||||
{
|
||||
{ 500, 1 },
|
||||
{ 501, 1 },
|
||||
{ 502, 1 },
|
||||
{ 503, 1 },
|
||||
{ 504, 1 },
|
||||
{ 505, 1 }
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_relation_user_role_permission",
|
||||
keyColumns: new[] { "id_permission", "id_user_role" },
|
||||
keyValues: new object[] { 500, 1 });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_relation_user_role_permission",
|
||||
keyColumns: new[] { "id_permission", "id_user_role" },
|
||||
keyValues: new object[] { 501, 1 });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_relation_user_role_permission",
|
||||
keyColumns: new[] { "id_permission", "id_user_role" },
|
||||
keyValues: new object[] { 502, 1 });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_relation_user_role_permission",
|
||||
keyColumns: new[] { "id_permission", "id_user_role" },
|
||||
keyValues: new object[] { 503, 1 });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_relation_user_role_permission",
|
||||
keyColumns: new[] { "id_permission", "id_user_role" },
|
||||
keyValues: new object[] { 504, 1 });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_relation_user_role_permission",
|
||||
keyColumns: new[] { "id_permission", "id_user_role" },
|
||||
keyValues: new object[] { 505, 1 });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_permission",
|
||||
keyColumn: "id",
|
||||
keyValue: 500);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_permission",
|
||||
keyColumn: "id",
|
||||
keyValue: 501);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_permission",
|
||||
keyColumn: "id",
|
||||
keyValue: 502);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_permission",
|
||||
keyColumn: "id",
|
||||
keyValue: 503);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_permission",
|
||||
keyColumn: "id",
|
||||
keyValue: 504);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_permission",
|
||||
keyColumn: "id",
|
||||
keyValue: 505);
|
||||
}
|
||||
}
|
||||
}
|
6642
AsbCloudDb/Migrations/20220909060026_Update_t_well_final_documents_r.Designer.cs
generated
Normal file
6642
AsbCloudDb/Migrations/20220909060026_Update_t_well_final_documents_r.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,85 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
public partial class Update_t_well_final_documents_r : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_t_well_final_documents_t_file_info_id_file",
|
||||
table: "t_well_final_documents");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "t_well_final_documents_pk",
|
||||
table: "t_well_final_documents");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_t_well_final_documents_id_file",
|
||||
table: "t_well_final_documents");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_t_well_final_documents_id_well",
|
||||
table: "t_well_final_documents");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "id",
|
||||
table: "t_well_final_documents");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "id_file",
|
||||
table: "t_well_final_documents");
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "t_well_final_documents_pk",
|
||||
table: "t_well_final_documents",
|
||||
columns: new[] { "id_well", "id_user", "id_category" });
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "t_well_final_documents_pk",
|
||||
table: "t_well_final_documents");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "id",
|
||||
table: "t_well_final_documents",
|
||||
type: "integer",
|
||||
nullable: false,
|
||||
defaultValue: 0)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "id_file",
|
||||
table: "t_well_final_documents",
|
||||
type: "integer",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "t_well_final_documents_pk",
|
||||
table: "t_well_final_documents",
|
||||
column: "id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_t_well_final_documents_id_file",
|
||||
table: "t_well_final_documents",
|
||||
column: "id_file");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_t_well_final_documents_id_well",
|
||||
table: "t_well_final_documents",
|
||||
column: "id_well");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_t_well_final_documents_t_file_info_id_file",
|
||||
table: "t_well_final_documents",
|
||||
column: "id_file",
|
||||
principalTable: "t_file_info",
|
||||
principalColumn: "id");
|
||||
}
|
||||
}
|
||||
}
|
6648
AsbCloudDb/Migrations/20220913040912_Update_t_permission.Designer.cs
generated
Normal file
6648
AsbCloudDb/Migrations/20220913040912_Update_t_permission.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
25
AsbCloudDb/Migrations/20220913040912_Update_t_permission.cs
Normal file
25
AsbCloudDb/Migrations/20220913040912_Update_t_permission.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
public partial class Update_t_permission : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.InsertData(
|
||||
table: "t_permission",
|
||||
columns: new[] { "id", "description", "name" },
|
||||
values: new object[] { 506, "Разрешение редактировать ответственных за загрузку файла Дело скважины", "WellFinalDocument.editPublisher" });
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_permission",
|
||||
keyColumn: "id",
|
||||
keyValue: 506);
|
||||
}
|
||||
}
|
||||
}
|
6648
AsbCloudDb/Migrations/20220913044712_Update_t_permission_well_doument.Designer.cs
generated
Normal file
6648
AsbCloudDb/Migrations/20220913044712_Update_t_permission_well_doument.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,71 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
public partial class Update_t_permission_well_doument : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.UpdateData(
|
||||
table: "t_permission",
|
||||
keyColumn: "id",
|
||||
keyValue: 503,
|
||||
column: "name",
|
||||
value: "WellFinalDocuments.delete");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "t_permission",
|
||||
keyColumn: "id",
|
||||
keyValue: 504,
|
||||
column: "name",
|
||||
value: "WellFinalDocuments.edit");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "t_permission",
|
||||
keyColumn: "id",
|
||||
keyValue: 505,
|
||||
column: "name",
|
||||
value: "WellFinalDocuments.get");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "t_permission",
|
||||
keyColumn: "id",
|
||||
keyValue: 506,
|
||||
column: "name",
|
||||
value: "WellFinalDocuments.editPublisher");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.UpdateData(
|
||||
table: "t_permission",
|
||||
keyColumn: "id",
|
||||
keyValue: 503,
|
||||
column: "name",
|
||||
value: "WellFinalDocument.delete");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "t_permission",
|
||||
keyColumn: "id",
|
||||
keyValue: 504,
|
||||
column: "name",
|
||||
value: "WellFinalDocument.edit");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "t_permission",
|
||||
keyColumn: "id",
|
||||
keyValue: 505,
|
||||
column: "name",
|
||||
value: "WellFinalDocument.get");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "t_permission",
|
||||
keyColumn: "id",
|
||||
keyValue: 506,
|
||||
column: "name",
|
||||
value: "WellFinalDocument.editPublisher");
|
||||
}
|
||||
}
|
||||
}
|
@ -672,6 +672,226 @@ namespace AsbCloudDb.Migrations
|
||||
{
|
||||
Id = 1008,
|
||||
Name = "Программы цементирования обсадных колонн"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10000,
|
||||
Name = "Проект на бурение транспортного и горизонтального участков скважины"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10001,
|
||||
Name = "Программа на бурение транспортного и горизонтального участков скважины"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10002,
|
||||
Name = "Акт о начале бурения"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10003,
|
||||
Name = "План работ спуска и цементирования направления"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10004,
|
||||
Name = "Программа цементирования направления"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10005,
|
||||
Name = "Мера обсадных труб (направление)"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10006,
|
||||
Name = "Акт на выполненные работы по цементированию направления"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10007,
|
||||
Name = "Отчет по цементированию направления (график)"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10008,
|
||||
Name = "План работ спуска и цементирования кондуктора"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10009,
|
||||
Name = "Программа цементирования (кондуктор)"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10010,
|
||||
Name = "Мера обсадных труб (кондуктор)"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10011,
|
||||
Name = "Карта крепления кондуктора"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10012,
|
||||
Name = "Акт на выполненные работы по цементированию кондуктора"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10013,
|
||||
Name = "Отчет по цементированию кондуктора (график)"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10014,
|
||||
Name = "Акт о замере расстояния от стола ротора до муфты кондуктора"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10015,
|
||||
Name = "Акт опресовки цементного кольца за кондуктором"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10016,
|
||||
Name = "Акт опресовки ППГ с глухими плашками совместно с кондуктором"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10017,
|
||||
Name = "Акт опресовки ПУГ, ППГ с трубными плашками совместно с кондуктором"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10018,
|
||||
Name = "План работ на крепление обсадной колонны (эк. колонна)"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10019,
|
||||
Name = "Программа цементирования (эк. колонна)"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10020,
|
||||
Name = "Мера труб эксплуатационной колонны"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10021,
|
||||
Name = "Карта по креплению скважины (эк. колонна)"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10022,
|
||||
Name = "Акт на установку пружинных центраторов"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10023,
|
||||
Name = "Отчет по цементированию эксплуатационной колонны (график)"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10024,
|
||||
Name = "Акт на выполненные работы по цементированию эксплуатационной колонны"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10025,
|
||||
Name = "Акт об испытании эк. колонны на герметичность (СТОП)"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10026,
|
||||
Name = "Акт опресовки ППГ с глухими плашками совместно с э/колонной"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10027,
|
||||
Name = "Акт опресовки ПУГ, ППГ с трубными плашками совместно с э/колонной"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10028,
|
||||
Name = "Акт на вскрытие продуктивного пласта"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10029,
|
||||
Name = "Акт замера параметров раствора при бурении горизонтального участка"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10030,
|
||||
Name = "Разрешение на спуск «хвостовика» (телефонограмма)"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10031,
|
||||
Name = "План работ на спуск «хвостовика»"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10032,
|
||||
Name = "Акт готовности бурового и энергетического оборудования к спуску «хвостовика»"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10033,
|
||||
Name = "Акт шаблонировки ствола скважины перед спуском «хвостовика»"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10034,
|
||||
Name = "Мера обсадных труб (хвостовик)"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10035,
|
||||
Name = "Акт выполненных работ по спуску хвостовика с закачкой (нефти, солевого раствора"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10036,
|
||||
Name = "Акт о переводе скважины на тех. воду"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10037,
|
||||
Name = "Акт об окончании бурения"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10038,
|
||||
Name = "Акт на передачу скважины в освоение (КРС)"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10039,
|
||||
Name = "Акт на опресовку межколонного пространства с КРС"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10040,
|
||||
Name = "Акт на сдачу скважины в ЦДНГ"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10041,
|
||||
Name = "Паспорт ОУС (заполняется геологами)"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10042,
|
||||
Name = "Паспорт скважины (заполняется геологами)"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 10043,
|
||||
Name = "Фактические данные бурения (вставляются в паспорт скважины)"
|
||||
});
|
||||
});
|
||||
|
||||
@ -1665,6 +1885,48 @@ namespace AsbCloudDb.Migrations
|
||||
Id = 461,
|
||||
Description = "Разрешение просматривать WITS record 61",
|
||||
Name = "WitsRecord61.get"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 500,
|
||||
Description = "Разрешение удалять Категорий документов файлов",
|
||||
Name = "FileCategory.delete"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 501,
|
||||
Description = "Разрешение редактировать Категорий документов файлов",
|
||||
Name = "FileCategory.edit"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 502,
|
||||
Description = "Разрешение просматривать Категорий документов файлов",
|
||||
Name = "FileCategory.get"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 503,
|
||||
Description = "Разрешение удалять Дело скважины",
|
||||
Name = "WellFinalDocuments.delete"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 504,
|
||||
Description = "Разрешение редактировать Дело скважины",
|
||||
Name = "WellFinalDocuments.edit"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 505,
|
||||
Description = "Разрешение просматривать Дело скважины",
|
||||
Name = "WellFinalDocuments.get"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 506,
|
||||
Description = "Разрешение редактировать ответственных за загрузку файла Дело скважины",
|
||||
Name = "WellFinalDocuments.editPublisher"
|
||||
});
|
||||
});
|
||||
|
||||
@ -2290,6 +2552,36 @@ namespace AsbCloudDb.Migrations
|
||||
{
|
||||
IdUserRole = 2007,
|
||||
IdPermission = 204
|
||||
},
|
||||
new
|
||||
{
|
||||
IdUserRole = 1,
|
||||
IdPermission = 500
|
||||
},
|
||||
new
|
||||
{
|
||||
IdUserRole = 1,
|
||||
IdPermission = 501
|
||||
},
|
||||
new
|
||||
{
|
||||
IdUserRole = 1,
|
||||
IdPermission = 502
|
||||
},
|
||||
new
|
||||
{
|
||||
IdUserRole = 1,
|
||||
IdPermission = 503
|
||||
},
|
||||
new
|
||||
{
|
||||
IdUserRole = 1,
|
||||
IdPermission = 504
|
||||
},
|
||||
new
|
||||
{
|
||||
IdUserRole = 1,
|
||||
IdPermission = 505
|
||||
});
|
||||
});
|
||||
|
||||
@ -4139,6 +4431,32 @@ namespace AsbCloudDb.Migrations
|
||||
b.HasComment("Композитная скважина");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.WellFinalDocument", b =>
|
||||
{
|
||||
b.Property<int>("IdWell")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_well");
|
||||
|
||||
b.Property<int>("IdUser")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_user");
|
||||
|
||||
b.Property<int>("IdCategory")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_category");
|
||||
|
||||
b.HasKey("IdWell", "IdUser", "IdCategory")
|
||||
.HasName("t_well_final_documents_pk");
|
||||
|
||||
b.HasIndex("IdCategory");
|
||||
|
||||
b.HasIndex("IdUser");
|
||||
|
||||
b.ToTable("t_well_final_documents");
|
||||
|
||||
b.HasComment("Дело скважины");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.WellOperation", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -6247,6 +6565,33 @@ namespace AsbCloudDb.Migrations
|
||||
b.Navigation("WellSrc");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.WellFinalDocument", b =>
|
||||
{
|
||||
b.HasOne("AsbCloudDb.Model.FileCategory", "Category")
|
||||
.WithMany()
|
||||
.HasForeignKey("IdCategory")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AsbCloudDb.Model.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("IdUser")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AsbCloudDb.Model.Well", "Well")
|
||||
.WithMany()
|
||||
.HasForeignKey("IdWell")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Category");
|
||||
|
||||
b.Navigation("User");
|
||||
|
||||
b.Navigation("Well");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.WellOperation", b =>
|
||||
{
|
||||
b.HasOne("AsbCloudDb.Model.WellOperationCategory", "OperationCategory")
|
||||
|
@ -50,6 +50,7 @@ namespace AsbCloudDb.Model
|
||||
public virtual DbSet<Driller> Drillers => Set<Driller>();
|
||||
public virtual DbSet<Schedule> Schedule => Set<Schedule>();
|
||||
public virtual DbSet<OperationValue> OperationValues => Set<OperationValue>();
|
||||
public virtual DbSet<WellFinalDocument> WellFinalDocuments => Set<WellFinalDocument>();
|
||||
|
||||
// WITS
|
||||
public DbSet<WITS.Record1> Record1 => Set<WITS.Record1>();
|
||||
@ -345,6 +346,12 @@ namespace AsbCloudDb.Model
|
||||
entity.HasKey(nameof(UserSetting.IdUser), nameof(UserSetting.Key));
|
||||
});
|
||||
|
||||
modelBuilder.Entity<WellFinalDocument>(entity =>
|
||||
{
|
||||
entity.HasKey(x => new { x.IdWell, x.IdUser, x.IdCategory })
|
||||
.HasName("t_well_final_documents_pk");
|
||||
});
|
||||
|
||||
DefaultData.DefaultContextData.Fill(modelBuilder);
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,51 @@
|
||||
new () {Id = 1006, Name = "Программа геофизических исследований"},
|
||||
new () {Id = 1007, Name = "Планы спусков обсадных колонн"},
|
||||
new () {Id = 1008, Name = "Программы цементирования обсадных колонн"},
|
||||
|
||||
new () {Id = 10000, Name = "Проект на бурение транспортного и горизонтального участков скважины"},
|
||||
new () {Id = 10001, Name = "Программа на бурение транспортного и горизонтального участков скважины"},
|
||||
new () {Id = 10002, Name = "Акт о начале бурения"},
|
||||
new () {Id = 10003, Name = "План работ спуска и цементирования направления"},
|
||||
new () {Id = 10004, Name = "Программа цементирования направления"},
|
||||
new () {Id = 10005, Name = "Мера обсадных труб (направление)"},
|
||||
new () {Id = 10006, Name = "Акт на выполненные работы по цементированию направления"},
|
||||
new () {Id = 10007, Name = "Отчет по цементированию направления (график)"},
|
||||
new () {Id = 10008, Name = "План работ спуска и цементирования кондуктора"},
|
||||
new () {Id = 10009, Name = "Программа цементирования (кондуктор)"},
|
||||
new () {Id = 10010, Name = "Мера обсадных труб (кондуктор)"},
|
||||
new () {Id = 10011, Name = "Карта крепления кондуктора"},
|
||||
new () {Id = 10012, Name = "Акт на выполненные работы по цементированию кондуктора"},
|
||||
new () {Id = 10013, Name = "Отчет по цементированию кондуктора (график)"},
|
||||
new () {Id = 10014, Name = "Акт о замере расстояния от стола ротора до муфты кондуктора"},
|
||||
new () {Id = 10015, Name = "Акт опресовки цементного кольца за кондуктором"},
|
||||
new () {Id = 10016, Name = "Акт опресовки ППГ с глухими плашками совместно с кондуктором"},
|
||||
new () {Id = 10017, Name = "Акт опресовки ПУГ, ППГ с трубными плашками совместно с кондуктором"},
|
||||
new () {Id = 10018, Name = "План работ на крепление обсадной колонны (эк. колонна)"},
|
||||
new () {Id = 10019, Name = "Программа цементирования (эк. колонна)"},
|
||||
new () {Id = 10020, Name = "Мера труб эксплуатационной колонны"},
|
||||
new () {Id = 10021, Name = "Карта по креплению скважины (эк. колонна)"},
|
||||
new () {Id = 10022, Name = "Акт на установку пружинных центраторов"},
|
||||
new () {Id = 10023, Name = "Отчет по цементированию эксплуатационной колонны (график)"},
|
||||
new () {Id = 10024, Name = "Акт на выполненные работы по цементированию эксплуатационной колонны"},
|
||||
new () {Id = 10025, Name = "Акт об испытании эк. колонны на герметичность (СТОП)"},
|
||||
new () {Id = 10026, Name = "Акт опресовки ППГ с глухими плашками совместно с э/колонной"},
|
||||
new () {Id = 10027, Name = "Акт опресовки ПУГ, ППГ с трубными плашками совместно с э/колонной"},
|
||||
new () {Id = 10028, Name = "Акт на вскрытие продуктивного пласта"},
|
||||
new () {Id = 10029, Name = "Акт замера параметров раствора при бурении горизонтального участка"},
|
||||
new () {Id = 10030, Name = "Разрешение на спуск «хвостовика» (телефонограмма)"},
|
||||
new () {Id = 10031, Name = "План работ на спуск «хвостовика»"},
|
||||
new () {Id = 10032, Name = "Акт готовности бурового и энергетического оборудования к спуску «хвостовика»"},
|
||||
new () {Id = 10033, Name = "Акт шаблонировки ствола скважины перед спуском «хвостовика»"},
|
||||
new () {Id = 10034, Name = "Мера обсадных труб (хвостовик)"},
|
||||
new () {Id = 10035, Name = "Акт выполненных работ по спуску хвостовика с закачкой (нефти, солевого раствора"},
|
||||
new () {Id = 10036, Name = "Акт о переводе скважины на тех. воду"},
|
||||
new () {Id = 10037, Name = "Акт об окончании бурения"},
|
||||
new () {Id = 10038, Name = "Акт на передачу скважины в освоение (КРС)"},
|
||||
new () {Id = 10039, Name = "Акт на опресовку межколонного пространства с КРС"},
|
||||
new () {Id = 10040, Name = "Акт на сдачу скважины в ЦДНГ"},
|
||||
new () {Id = 10041, Name = "Паспорт ОУС (заполняется геологами)"},
|
||||
new () {Id = 10042, Name = "Паспорт скважины (заполняется геологами)"},
|
||||
new () {Id = 10043, Name = "Фактические данные бурения (вставляются в паспорт скважины)"},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -127,6 +127,14 @@
|
||||
new (){ Id = 450, Name="WitsRecord50.get", Description="Разрешение просматривать WITS record 50"},
|
||||
new (){ Id = 460, Name="WitsRecord60.get", Description="Разрешение просматривать WITS record 60"},
|
||||
new (){ Id = 461, Name="WitsRecord61.get", Description="Разрешение просматривать WITS record 61"},
|
||||
|
||||
new (){ Id = 500, Name="FileCategory.delete", Description="Разрешение удалять Категорий документов файлов"},
|
||||
new (){ Id = 501, Name="FileCategory.edit", Description="Разрешение редактировать Категорий документов файлов"},
|
||||
new (){ Id = 502, Name="FileCategory.get", Description="Разрешение просматривать Категорий документов файлов"},
|
||||
new (){ Id = 503, Name="WellFinalDocuments.delete", Description="Разрешение удалять Дело скважины"},
|
||||
new (){ Id = 504, Name="WellFinalDocuments.edit", Description="Разрешение редактировать Дело скважины"},
|
||||
new (){ Id = 505, Name="WellFinalDocuments.get", Description="Разрешение просматривать Дело скважины"},
|
||||
new (){ Id = 506, Name="WellFinalDocuments.editPublisher", Description="Разрешение редактировать ответственных за загрузку файла Дело скважины"},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,7 @@
|
||||
new (){ IdUserRole = 2005, IdPermission = 247}, new (){ IdUserRole = 2005, IdPermission = 205}, new (){ IdUserRole = 2005, IdPermission = 204},
|
||||
new (){ IdUserRole = 2006, IdPermission = 243}, new (){ IdUserRole = 2006, IdPermission = 205}, new (){ IdUserRole = 2006, IdPermission = 204},
|
||||
new (){ IdUserRole = 2007, IdPermission = 241}, new (){ IdUserRole = 2007, IdPermission = 205}, new (){ IdUserRole = 2007, IdPermission = 204},
|
||||
new (){ IdUserRole = 1, IdPermission = 500}, new (){ IdUserRole = 1, IdPermission = 501}, new (){ IdUserRole = 1, IdPermission = 502}, new (){ IdUserRole = 1, IdPermission = 503}, new (){ IdUserRole = 1, IdPermission = 504}, new (){ IdUserRole = 1, IdPermission = 505},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ namespace AsbCloudDb.Model
|
||||
DbSet<Driller> Drillers { get; }
|
||||
DbSet<Schedule> Schedule { get; }
|
||||
DbSet<OperationValue> OperationValues { get; }
|
||||
DbSet<WellFinalDocument> WellFinalDocuments { get; }
|
||||
|
||||
DbSet<Record1> Record1 { get; }
|
||||
DbSet<Record7> Record7 { get; }
|
||||
|
29
AsbCloudDb/Model/WellFinalDocument.cs
Normal file
29
AsbCloudDb/Model/WellFinalDocument.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace AsbCloudDb.Model
|
||||
{
|
||||
#nullable disable
|
||||
[Table("t_well_final_documents"), Comment("Дело скважины")]
|
||||
public class WellFinalDocument : IWellRelated
|
||||
{
|
||||
[Column("id_well")]
|
||||
public int IdWell { get; set; }
|
||||
|
||||
[Column("id_user")]
|
||||
public int IdUser { get; set; }
|
||||
|
||||
[Column("id_category")]
|
||||
public int IdCategory { get; set; }
|
||||
|
||||
[ForeignKey(nameof(IdWell))]
|
||||
public virtual Well Well { get; set; }
|
||||
|
||||
[ForeignKey(nameof(IdUser))]
|
||||
public virtual User User { get; set; }
|
||||
|
||||
[ForeignKey(nameof(IdCategory))]
|
||||
public virtual FileCategory Category { get; set; }
|
||||
}
|
||||
}
|
@ -71,6 +71,12 @@ namespace AsbCloudInfrastructure
|
||||
.ForType<ClusterDto, Cluster>()
|
||||
.Ignore(dst => dst.Deposit,
|
||||
dst => dst.Wells);
|
||||
|
||||
TypeAdapterConfig.GlobalSettings.Default.Config
|
||||
.ForType<FileCategoryDto, FileCategory>();
|
||||
|
||||
TypeAdapterConfig.GlobalSettings.Default.Config
|
||||
.ForType<WellFinalDocumentDto, WellFinalDocument>();
|
||||
}
|
||||
|
||||
public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration)
|
||||
@ -123,6 +129,8 @@ namespace AsbCloudInfrastructure
|
||||
services.AddTransient<IScheduleRepository, ScheduleRepository>();
|
||||
services.AddTransient<IRepositoryWellRelated<OperationValueDto>, CrudWellRelatedServiceBase<OperationValueDto, OperationValue>>();
|
||||
services.AddTransient<IUserSettingsRepository, UserSettingsRepository>();
|
||||
services.AddTransient<IWellFinalDocumentsService, WellFinalDocumentsService>();
|
||||
services.AddTransient<IFileCategoryService, FileCategoryService>();
|
||||
|
||||
// admin crud services:
|
||||
services.AddTransient<ICrudService<TelemetryDto>, CrudServiceBase<TelemetryDto, Telemetry>>(s =>
|
||||
|
@ -359,8 +359,8 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram
|
||||
var file = await fileService.GetInfoAsync(fileMark.IdFile, token);
|
||||
var well = await wellService.GetOrDefaultAsync(file.IdWell, token);
|
||||
var user = file.Author;
|
||||
var factory = new MailBodyFactory(configuration);
|
||||
var subject = MailBodyFactory.MakeSubject(well, "Загруженный вами документ полностью согласован");
|
||||
var factory = new DrillingMailBodyFactory(configuration);
|
||||
var subject = factory.MakeSubject(well, "Загруженный вами документ полностью согласован");
|
||||
var body = factory.MakeMailBodyForPublisherOnFullAccept(well, user.Name, file.Id, file.Name);
|
||||
|
||||
emailService.EnqueueSend(user.Email, subject, body);
|
||||
@ -371,8 +371,8 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram
|
||||
var file = await fileService.GetInfoAsync(fileMark.IdFile, token);
|
||||
var well = await wellService.GetOrDefaultAsync(file.IdWell, token);
|
||||
var user = file.Author;
|
||||
var factory = new MailBodyFactory(configuration);
|
||||
var subject = MailBodyFactory.MakeSubject(well, "Загруженный вами документ отклонен");
|
||||
var factory = new DrillingMailBodyFactory(configuration);
|
||||
var subject = factory.MakeSubject(well, "Загруженный вами документ отклонен");
|
||||
var body = factory.MakeMailBodyForPublisherOnReject(well, user.Name, file.Id, file.Name, fileMark);
|
||||
|
||||
emailService.EnqueueSend(user.Email, subject, body);
|
||||
@ -381,8 +381,8 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram
|
||||
private async Task NotifyApproversAsync(DrillingProgramPart part, int idFile, string fileName, CancellationToken token)
|
||||
{
|
||||
var well = await wellService.GetOrDefaultAsync(part.IdWell, token);
|
||||
var factory = new MailBodyFactory(configuration);
|
||||
var subject = MailBodyFactory.MakeSubject(well, "Загружен новый документ для согласования.");
|
||||
var factory = new DrillingMailBodyFactory(configuration);
|
||||
var subject = factory.MakeSubject(well, "Загружен новый документ для согласования.");
|
||||
var users = part.RelatedUsers
|
||||
.Where(r => r.IdUserRole == idUserRoleApprover)
|
||||
.Select(r => r.User);
|
||||
@ -397,8 +397,8 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram
|
||||
private async Task NotifyNewPublisherAsync(int idWell, UserDto user, string documentCategory, CancellationToken token)
|
||||
{
|
||||
var well = await wellService.GetOrDefaultAsync(idWell, token);
|
||||
var factory = new MailBodyFactory(configuration);
|
||||
var subject = MailBodyFactory.MakeSubject(well, $"От вас ожидается загрузка на портал документа «{documentCategory}»");
|
||||
var factory = new DrillingMailBodyFactory(configuration);
|
||||
var subject = factory.MakeSubject(well, $"От вас ожидается загрузка на портал документа «{documentCategory}»");
|
||||
var body = factory.MakeMailBodyForNewPublisher(well, user.Name, documentCategory);
|
||||
emailService.EnqueueSend(user.Email, subject, body);
|
||||
}
|
||||
|
55
AsbCloudInfrastructure/Services/Email/BaseFactory.cs
Normal file
55
AsbCloudInfrastructure/Services/Email/BaseFactory.cs
Normal file
@ -0,0 +1,55 @@
|
||||
using AsbCloudApp.Data;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace AsbCloudInfrastructure.Services.Email
|
||||
{
|
||||
public class BaseFactory
|
||||
{
|
||||
private readonly string platformName;
|
||||
private readonly string platformUrl;
|
||||
private readonly string companyName;
|
||||
private readonly string supportMail;
|
||||
|
||||
public BaseFactory(IConfiguration configuration)
|
||||
{
|
||||
platformName = configuration.GetValue("email:platformName", "Цифровое бурение");
|
||||
platformUrl = configuration.GetValue("email:platformUrl", "https://cloud.digitaldrilling.ru/");
|
||||
companyName = configuration.GetValue("email:companyName", "ООО \"Цифровое бурение\"");
|
||||
supportMail = configuration.GetValue("email:supportMail", "support@digitaldrilling.ru");
|
||||
}
|
||||
|
||||
public static string GetImageBase64(string resourceFileName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(resourceFileName))
|
||||
return null;
|
||||
|
||||
var baseDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
|
||||
var resoursesDir = "Res";
|
||||
|
||||
var logoFilePath = Path.Combine(baseDir, resoursesDir, resourceFileName);
|
||||
|
||||
var imageBytes = File.ReadAllBytes(logoFilePath);
|
||||
var format = Path.GetExtension(resourceFileName).Trim('.');
|
||||
return "data:image/" + format + ";base64," + Convert.ToBase64String(imageBytes);
|
||||
}
|
||||
|
||||
public static string MakeHref(string url, string text)
|
||||
=> $"<a href=\"{url}\">{text}</a>";
|
||||
|
||||
public string MakeSignatue()
|
||||
{
|
||||
var logo = GetImageBase64("logo_32.png");
|
||||
var sign = $"<br><br>---<br><img src=\"{logo}\"/><br>" +
|
||||
$"{companyName}<br>" +
|
||||
$"Это письмо сформировано автоматически.<br>" +
|
||||
$"Для получения помощи по работе на портале {platformName}" +
|
||||
$"обращайтесь по адресу {supportMail}";
|
||||
return sign;
|
||||
}
|
||||
|
||||
public virtual string MakeSubject(WellDto well, string action)
|
||||
=> $"{well.Deposit}, {well.Cluster}, {well.Caption}. {action}";
|
||||
}
|
||||
}
|
@ -1,26 +1,24 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudInfrastructure.Services.Email;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace AsbCloudInfrastructure
|
||||
{
|
||||
class MailBodyFactory
|
||||
{
|
||||
class DrillingMailBodyFactory : BaseFactory
|
||||
{
|
||||
private readonly string platformName;
|
||||
private readonly string platformUrl;
|
||||
private readonly string companyName;
|
||||
private readonly string supportMail;
|
||||
|
||||
public MailBodyFactory(IConfiguration configuration)
|
||||
public DrillingMailBodyFactory(IConfiguration configuration)
|
||||
: base(configuration)
|
||||
{
|
||||
platformName = configuration.GetValue("email:platformName", "Цифровое бурение");
|
||||
platformUrl = configuration.GetValue("email:platformUrl", "https://cloud.digitaldrilling.ru/");
|
||||
companyName = configuration.GetValue("email:companyName", "ООО \"Цифровое бурение\"");
|
||||
supportMail = configuration.GetValue("email:supportMail", "support@digitaldrilling.ru");
|
||||
}
|
||||
|
||||
public static string MakeSubject(WellDto well, string action)
|
||||
public override string MakeSubject(WellDto well, string action)
|
||||
{
|
||||
var subj = $"{well.Deposit}, {well.Cluster}, {well.Caption}. Программа бурения. {action}";
|
||||
return subj;
|
||||
@ -85,34 +83,5 @@ namespace AsbCloudInfrastructure
|
||||
var drillingProgramHref = MakeHref(drillingProgramUrl, well.Caption);
|
||||
return drillingProgramHref;
|
||||
}
|
||||
|
||||
private static string MakeHref(string url, string text)
|
||||
=> $"<a href=\"{url}\">{text}</a>";
|
||||
|
||||
protected string MakeSignatue()
|
||||
{
|
||||
var logo = GetImageBase64("logo_32.png");
|
||||
var sign = $"<br><br>---<br><img src=\"{logo}\"/><br>" +
|
||||
$"{companyName}<br>" +
|
||||
$"Это письмо сформировано автоматически.<br>" +
|
||||
$"Для получения помощи по работе на портале {platformName}" +
|
||||
$"обращайтесь по адресу {supportMail}";
|
||||
return sign;
|
||||
}
|
||||
|
||||
public static string GetImageBase64(string resourceFileName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(resourceFileName))
|
||||
return null;
|
||||
|
||||
var baseDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
|
||||
var resoursesDir = "Res";
|
||||
|
||||
var logoFilePath = Path.Combine(baseDir, resoursesDir, resourceFileName);
|
||||
|
||||
var imageBytes = File.ReadAllBytes(logoFilePath);
|
||||
var format = Path.GetExtension(resourceFileName).Trim('.');
|
||||
return "data:image/" + format + ";base64," + Convert.ToBase64String(imageBytes);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudInfrastructure.Services.Email;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace AsbCloudInfrastructure
|
||||
{
|
||||
class WellFinalDocumentMailBodyFactory : BaseFactory
|
||||
{
|
||||
private readonly string platformName;
|
||||
|
||||
public WellFinalDocumentMailBodyFactory(IConfiguration configuration)
|
||||
: base(configuration)
|
||||
{
|
||||
platformName = configuration.GetValue("email:platformName", "Цифровое бурение");
|
||||
}
|
||||
|
||||
public override string MakeSubject(WellDto well, string action)
|
||||
=> $"{well.Deposit}, {well.Cluster}, {well.Caption}. Дело скважины. {action}";
|
||||
|
||||
public string MakeMailBodyForWellFinalDocument(WellDto well, string publisherName, string message)
|
||||
{
|
||||
var body = $"<html><body><h2>Здравствуйте, {publisherName}.</h2>" +
|
||||
$"На портале {platformName} {message}," +
|
||||
$" куст {well.Cluster}, месторождение {well.Deposit}." +
|
||||
MakeSignatue() +
|
||||
$"</body></html>";
|
||||
return body;
|
||||
}
|
||||
}
|
||||
}
|
31
AsbCloudInfrastructure/Services/FileCategoryService.cs
Normal file
31
AsbCloudInfrastructure/Services/FileCategoryService.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudDb.Model;
|
||||
using AsbCloudInfrastructure.Repository;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
public class FileCategoryService : CrudCacheServiceBase<FileCategoryDto, FileCategory>, IFileCategoryService
|
||||
{
|
||||
public FileCategoryService(IAsbCloudDbContext context)
|
||||
: base(context)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<FileCategoryDto>> GetWellCaseCategoriesAsync(CancellationToken token)
|
||||
{
|
||||
var cache = await GetCacheAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
var dtos = cache
|
||||
.Where(kv => kv.Key >= 10000)
|
||||
.Where(kv => kv.Key <= 20000)
|
||||
.Select(kv => kv.Value);
|
||||
|
||||
return dtos;
|
||||
}
|
||||
}
|
||||
}
|
@ -330,6 +330,50 @@ namespace AsbCloudInfrastructure.Services
|
||||
fileMark.IsDeleted = true;
|
||||
|
||||
return await db.SaveChangesAsync(token);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<FileInfoDto>> GetInfoByIdsAsync(List<int> idsFile, CancellationToken token)
|
||||
{
|
||||
var result = new List<FileInfoDto>();
|
||||
|
||||
var entities = await dbSetConfigured
|
||||
.AsNoTracking()
|
||||
.Where(f => idsFile.Contains(f.Id))
|
||||
.ToListAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
if (entity is null)
|
||||
{
|
||||
throw new FileNotFoundException($"fileId:{entity.Id} not found");
|
||||
}
|
||||
|
||||
var ext = Path.GetExtension(entity.Name);
|
||||
|
||||
var relativePath = GetUrl(entity.IdWell, entity.IdCategory, entity.Id, ext);
|
||||
var fullPath = Path.GetFullPath(relativePath);
|
||||
if (!File.Exists(fullPath))
|
||||
{
|
||||
throw new FileNotFoundException("not found", relativePath);
|
||||
}
|
||||
|
||||
result.Add(Convert(entity));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<FileInfoDto>> GetInfosByWellIdAsync(int idWell, CancellationToken token)
|
||||
{
|
||||
var entities = await dbSetConfigured
|
||||
.Where(e => e.IdWell == idWell && e.IsDeleted == false)
|
||||
.AsNoTracking()
|
||||
.ToListAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var dtos = entities.Select(e => Convert(e));
|
||||
return dtos;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
200
AsbCloudInfrastructure/Services/WellFinalDocumentsService.cs
Normal file
200
AsbCloudInfrastructure/Services/WellFinalDocumentsService.cs
Normal file
@ -0,0 +1,200 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Exceptions;
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudDb.Model;
|
||||
using Mapster;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
#nullable enable
|
||||
/// <summary>
|
||||
/// Сервис "Дело скважины"
|
||||
/// </summary>
|
||||
public class WellFinalDocumentsService : IWellFinalDocumentsService
|
||||
{
|
||||
private readonly IAsbCloudDbContext context;
|
||||
private readonly IFileService fileService;
|
||||
private readonly IUserService userService;
|
||||
private readonly IWellService wellService;
|
||||
private readonly IConfiguration configuration;
|
||||
private readonly IEmailService emailService;
|
||||
private readonly IFileCategoryService fileCategoryService;
|
||||
|
||||
private const int FileServiceThrewException = -1;
|
||||
|
||||
public WellFinalDocumentsService(IAsbCloudDbContext context,
|
||||
IFileService fileService,
|
||||
IUserService userService,
|
||||
IWellService wellService,
|
||||
IConfiguration configuration,
|
||||
IEmailService emailService,
|
||||
IFileCategoryService fileCategoryService)
|
||||
{
|
||||
this.context = context;
|
||||
this.fileService = fileService;
|
||||
this.userService = userService;
|
||||
this.wellService = wellService;
|
||||
this.configuration = configuration;
|
||||
this.emailService = emailService;
|
||||
this.fileCategoryService = fileCategoryService;
|
||||
}
|
||||
|
||||
public async Task<int> UpdateRangeAsync(int idWell, IEnumerable<WellFinalDocumentInputDto>? dtos, CancellationToken token)
|
||||
{
|
||||
if (dtos is not null)
|
||||
{
|
||||
var entities = dtos
|
||||
.Where(dto => dto.IdsPublishers?.Any() == true)
|
||||
.SelectMany(dto => dto.IdsPublishers
|
||||
.Select(idUser => new WellFinalDocument
|
||||
{
|
||||
IdCategory = dto.IdCategory,
|
||||
IdWell = idWell,
|
||||
IdUser = idUser
|
||||
}));
|
||||
|
||||
var itemsToDelete = context.WellFinalDocuments.Where(d => d.IdWell == idWell);
|
||||
context.WellFinalDocuments.RemoveRange(itemsToDelete);
|
||||
|
||||
await context.WellFinalDocuments.AddRangeAsync(entities).ConfigureAwait(false);
|
||||
var data = await context.SaveChangesAsync(token).ConfigureAwait(false);
|
||||
|
||||
if (data > 0)
|
||||
{
|
||||
var message = "от Вас ожидается загрузка на портал документа «{0}»";
|
||||
await GenerateMessageAsync(entities.Select(x => Convert(x)), message, token);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
throw new ArgumentInvalidException("Данные по категориям отсутствуют.");
|
||||
}
|
||||
|
||||
public async Task<WellCaseDto> GetByWellId(int idWell, int idUser, CancellationToken token)
|
||||
{
|
||||
var entities = await context.WellFinalDocuments
|
||||
.Include(d => d.Category)
|
||||
.Include(d => d.User)
|
||||
.Where(d => d.IdWell == idWell)
|
||||
.AsNoTracking()
|
||||
.ToArrayAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var entitiesGroups = entities
|
||||
.GroupBy(d => d.IdCategory);
|
||||
|
||||
var categoriesIds = entitiesGroups
|
||||
.Select(g => g.Key);
|
||||
|
||||
var files = (await fileService
|
||||
.GetInfosByWellIdAsync(idWell, token)
|
||||
.ConfigureAwait(false))
|
||||
.Where(f => categoriesIds.Contains(f.IdCategory))
|
||||
.ToArray();
|
||||
|
||||
var docs = entitiesGroups.Select((g) => new WellFinalDocumentDto
|
||||
{
|
||||
IdCategory = g.Key,
|
||||
FilesCount = files
|
||||
.Where(f => f.IdCategory == g.Key)
|
||||
.Count(),
|
||||
File = files
|
||||
.Where(f => f.IdCategory == g.Key)
|
||||
.OrderBy(f => f.UploadDate)
|
||||
.LastOrDefault(),
|
||||
NameCategory = g.First().Category.Name,
|
||||
Publishers = g.Select(i => i.User.Adapt<UserDto>()),
|
||||
PermissionToUpload = g.Any(i => i.IdUser == idUser),
|
||||
});
|
||||
|
||||
var result = new WellCaseDto
|
||||
{
|
||||
IdWell = idWell,
|
||||
PermissionToSetPubliher = userService.HasPermission(idUser, "WellFinalDocument.editPublisher"),
|
||||
WellFinalDocuments = docs,
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<UserDto>> GetAvailableUsersAsync(int idWell, CancellationToken token)
|
||||
{
|
||||
var companyIds = await context.RelationCompaniesWells
|
||||
.Where(x => x.IdWell == idWell).Select(x => x.IdCompany)
|
||||
.ToListAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var allUsers = await userService.GetAllAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return allUsers.Where(x => {
|
||||
var idCompany = x.IdCompany ?? default(int);
|
||||
return companyIds.Contains(idCompany);
|
||||
})
|
||||
.OrderBy(x => x.Surname)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
public async Task<int> SaveCategoryFile(int idWell, int idCategory, int idUser, Stream fileStream, string fileName, CancellationToken token)
|
||||
{
|
||||
var entity = await context.WellFinalDocuments
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync(x => x.IdWell == idWell && x.IdCategory == idCategory && x.IdUser == idUser);
|
||||
|
||||
if (entity is null)
|
||||
throw new ArgumentInvalidException("Пользователь не является ответственным за загрузку файла для данной категории.");
|
||||
|
||||
var dto = Convert(entity);
|
||||
|
||||
var file = await fileService.SaveAsync(dto.IdWell, dto.IdUser, dto.IdCategory, fileName,
|
||||
fileStream, token).ConfigureAwait(false);
|
||||
|
||||
return file?.Id ?? FileServiceThrewException; //TODO: изменить когда файловый сервис будет переведен на nullable
|
||||
}
|
||||
|
||||
public async Task<WellFinalDocumentsHistoryDto> GetFilesHistoryByIdCategory(int idWell, int idCategory, CancellationToken token)
|
||||
{
|
||||
var files = await fileService.GetInfosByCategoryAsync(idWell, idCategory, token).ConfigureAwait(false);
|
||||
|
||||
return new WellFinalDocumentsHistoryDto {
|
||||
IdWell = idWell,
|
||||
IdCategory = idCategory,
|
||||
File = files
|
||||
};
|
||||
}
|
||||
|
||||
private async Task GenerateMessageAsync(IEnumerable<WellFinalDocumentDBDto> dtos, string message, CancellationToken token)
|
||||
{
|
||||
foreach (var item in dtos)
|
||||
{
|
||||
var user = await userService.GetOrDefaultAsync(item.IdUser, token);
|
||||
if (user?.Email is not null)
|
||||
{
|
||||
var category = await fileCategoryService.GetOrDefaultAsync(item.IdCategory, token);
|
||||
var well = await wellService.GetOrDefaultAsync(item.IdWell, token);
|
||||
|
||||
SendMessage(well, user, category.Name, message, token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SendMessage(WellDto? well, UserDto user, string documentCategory, string message, CancellationToken token)
|
||||
{
|
||||
var factory = new WellFinalDocumentMailBodyFactory(configuration);
|
||||
var subject = factory.MakeSubject(well, documentCategory);
|
||||
var body = factory.MakeMailBodyForWellFinalDocument(well, user.Name ?? user.Surname, string.Format(message, documentCategory));
|
||||
emailService.EnqueueSend(user.Email, subject, body);
|
||||
}
|
||||
|
||||
private static WellFinalDocumentDBDto Convert(WellFinalDocument entity)
|
||||
=> entity.Adapt<WellFinalDocumentDBDto>();
|
||||
}
|
||||
#nullable disable
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
using AsbCloudApp.Requests;
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudDb.Model;
|
||||
using AsbCloudInfrastructure.Repository;
|
||||
using AsbCloudInfrastructure.Services;
|
||||
using AsbCloudInfrastructure.Services.Cache;
|
||||
using AsbCloudInfrastructure.Services.DetectOperations;
|
||||
@ -124,10 +125,10 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
||||
var wellServiceMock = new Mock<IWellService>();
|
||||
wellServiceMock.Setup(s => s.GetTimezone(It.IsAny<int>())).Returns(timezone);
|
||||
wellServiceMock.Setup(s => s.GetOrDefaultAsync(It.IsAny<int>(),CancellationToken.None)).Returns(Task.Run(() => wellDto));
|
||||
var operationValueService = new OperationValueService(context);
|
||||
//var operationValueService = new OperationValueService(context);
|
||||
var scheduleService = new ScheduleRepository(context, wellServiceMock.Object);
|
||||
|
||||
service = new DetectedOperationService(context, wellServiceMock.Object, operationValueService, scheduleService);
|
||||
service = new DetectedOperationService(context, wellServiceMock.Object, /*operationValueService*/ null, scheduleService);
|
||||
request = new DetectedOperationRequest
|
||||
{
|
||||
IdWell = 1,
|
||||
|
@ -0,0 +1,36 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudDb.Model;
|
||||
using AsbCloudInfrastructure.Services;
|
||||
using AsbCloudInfrastructure.Services.Cache;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace AsbCloudWebApi.Tests.ServicesTests
|
||||
{
|
||||
public class FileCategoryServiceTest
|
||||
{
|
||||
private readonly AsbCloudDbContext context;
|
||||
private FileCategoryService service;
|
||||
|
||||
public FileCategoryServiceTest()
|
||||
{
|
||||
|
||||
context = TestHelpter.MakeTestContext();
|
||||
context.SaveChanges();
|
||||
service = new FileCategoryService(context);
|
||||
}
|
||||
|
||||
~FileCategoryServiceTest()
|
||||
{
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetWellCategoryAsync_return_cnt_file_category()
|
||||
{
|
||||
var cnt = (await service.GetWellCaseCategoriesAsync(CancellationToken.None)).Count();
|
||||
Assert.NotEqual(0, cnt);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudDb.Model;
|
||||
using AsbCloudInfrastructure.Services;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Moq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace AsbCloudWebApi.Tests.ServicesTests
|
||||
{
|
||||
public class WellFinalDocumentsServiceTest
|
||||
{
|
||||
private readonly AsbCloudDbContext context;
|
||||
private WellFinalDocumentsService service;
|
||||
private readonly Mock<IFileService> fileServiceMock;
|
||||
private readonly Mock<IUserService> userServiceMock;
|
||||
private readonly Mock<IWellService> wellServiceMock;
|
||||
private readonly Mock<IConfiguration> configurationMock;
|
||||
private readonly Mock<IEmailService> emailServiceMock;
|
||||
private readonly Mock<IFileCategoryService> fileCategoryService;
|
||||
|
||||
private readonly IEnumerable<UserDto> users = new List<UserDto> {
|
||||
new UserDto {
|
||||
Id = 1,
|
||||
IdCompany = 1,
|
||||
Name = "test",
|
||||
Email = "test@test.com"
|
||||
},
|
||||
new UserDto {
|
||||
Id = 3,
|
||||
IdCompany = 1,
|
||||
Name = "test1",
|
||||
Email = "test1@test1.com"
|
||||
}
|
||||
};
|
||||
|
||||
public WellFinalDocumentsServiceTest()
|
||||
{
|
||||
context = TestHelpter.MakeTestContext();
|
||||
context.SaveChanges();
|
||||
|
||||
fileServiceMock = new Mock<IFileService>();
|
||||
userServiceMock = new Mock<IUserService>();
|
||||
userServiceMock.Setup(x => x.GetAllAsync(CancellationToken.None)).Returns(Task.Run(() => users.Select(x => (UserExtendedDto)x)));
|
||||
|
||||
wellServiceMock = new Mock<IWellService>();
|
||||
configurationMock = new Mock<IConfiguration>();
|
||||
emailServiceMock = new Mock<IEmailService>();
|
||||
fileCategoryService = new Mock<IFileCategoryService>();
|
||||
|
||||
service = new WellFinalDocumentsService(
|
||||
context: context,
|
||||
fileService: fileServiceMock.Object,
|
||||
userService: userServiceMock.Object,
|
||||
wellService: wellServiceMock.Object,
|
||||
configuration: configurationMock.Object,
|
||||
emailService: emailServiceMock.Object,
|
||||
fileCategoryService: fileCategoryService.Object);
|
||||
}
|
||||
|
||||
~WellFinalDocumentsServiceTest()
|
||||
{
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetWellFinalDocument_return_collection_rows()
|
||||
{
|
||||
var data = await service.GetByWellId(90, 1,CancellationToken.None);
|
||||
Assert.NotNull(data);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetListResponsibles_return_cnt_users()
|
||||
{
|
||||
var data = await service.GetAvailableUsersAsync(90, CancellationToken.None);
|
||||
Assert.NotNull(data);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetHistoryFileByIdCategory_return_data_hitory()
|
||||
{
|
||||
var data = await service.GetFilesHistoryByIdCategory(90, 10018, CancellationToken.None);
|
||||
Assert.NotNull(data);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SaveCategoryFile_return_id_edit_record()
|
||||
{
|
||||
var stream = new FileStream("D:\\test\\test.txt", FileMode.Open);
|
||||
var data = await service.SaveCategoryFile(21, 10018, 78, stream, "test.txt", CancellationToken.None);
|
||||
Assert.Equal(21, data);
|
||||
}
|
||||
}
|
||||
}
|
21
AsbCloudWebApi/Controllers/FileCategoryController.cs
Normal file
21
AsbCloudWebApi/Controllers/FileCategoryController.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace AsbCloudWebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Категорий документов файлов
|
||||
/// </summary>
|
||||
[Route("api/[Controller]")]
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
public class FileCategoryController : CrudController<FileCategoryDto, ICrudService<FileCategoryDto>>
|
||||
{
|
||||
public FileCategoryController(ICrudService<FileCategoryDto> service, IFileCategoryService fileCategoryService)
|
||||
: base(service)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
155
AsbCloudWebApi/Controllers/WellFinalDocumentsController.cs
Normal file
155
AsbCloudWebApi/Controllers/WellFinalDocumentsController.cs
Normal file
@ -0,0 +1,155 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace AsbCloudWebApi.Controllers
|
||||
{
|
||||
#nullable enable
|
||||
/// <summary>
|
||||
/// Дело скважины
|
||||
/// </summary>
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
public class WellFinalDocumentsController : ControllerBase
|
||||
{
|
||||
private readonly IWellFinalDocumentsService wellFinalDocumentsService;
|
||||
private readonly IWellService wellService;
|
||||
private readonly IFileCategoryService fileCategoryService;
|
||||
public WellFinalDocumentsController(
|
||||
IWellFinalDocumentsService wellFinalDocumentsService,
|
||||
IWellService wellService,
|
||||
IFileCategoryService fileCategoryService)
|
||||
{
|
||||
this.wellFinalDocumentsService = wellFinalDocumentsService;
|
||||
this.wellService = wellService;
|
||||
this.fileCategoryService = fileCategoryService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение всех записей
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{idWell}")]
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(WellCaseDto), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetAsync(int idWell, CancellationToken token = default)
|
||||
{
|
||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var idUser = User?.GetUserId();
|
||||
var data = await this.wellFinalDocumentsService.GetByWellId(idWell, idUser ?? default, token);
|
||||
return Ok(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение списка ответственных
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{idWell}/availableUsers")]
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(IEnumerable<UserDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetAvailableUsersAsync(int idWell, CancellationToken token = default)
|
||||
{
|
||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var data = await this.wellFinalDocumentsService.GetAvailableUsersAsync(idWell, token);
|
||||
return Ok(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление записи
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="dtos"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("{idWell}")]
|
||||
[Permission("WellFinalDocuments.editPublisher")]
|
||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> UpdateRangeAsync(int idWell, [Required] IEnumerable<WellFinalDocumentInputDto> dtos, CancellationToken token = default)
|
||||
{
|
||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var data = await this.wellFinalDocumentsService.UpdateRangeAsync(idWell, dtos, token);
|
||||
return Ok(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение истории файлов
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="idCategory"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{idWell}/history")]
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(WellFinalDocumentsHistoryDto), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetFilesHistoryByIdCategory(int idWell,
|
||||
[Required] int idCategory,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var data = await this.wellFinalDocumentsService.GetFilesHistoryByIdCategory(idWell, idCategory, token);
|
||||
return Ok(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Сохранение файла
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="idCategory"></param>
|
||||
/// <param name="file"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("{idWell}")]
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> SaveCategoryFile(int idWell, [Required] int idCategory, [Required] IFormFile file, CancellationToken token = default)
|
||||
{
|
||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var idUser = User.GetUserId() ?? -1;
|
||||
var fileStream = file.OpenReadStream();
|
||||
var data = await this.wellFinalDocumentsService.SaveCategoryFile(idWell, idCategory, idUser, fileStream, file.FileName, token);
|
||||
return Ok(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение справочника категорий файлов
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("wellCaseCategories")]
|
||||
[Permission]
|
||||
public async Task<IActionResult> GetWellCaseCategoriesAsync(CancellationToken token = default)
|
||||
{
|
||||
var data = await fileCategoryService.GetWellCaseCategoriesAsync(token);
|
||||
return Ok(data);
|
||||
}
|
||||
|
||||
private async Task<bool> CanUserAccessToWellAsync(int idWell, CancellationToken token = default)
|
||||
{
|
||||
int? idCompany = User.GetCompanyId();
|
||||
return idCompany is not null && await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||
idWell, token).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
#nullable disable
|
||||
}
|
Loading…
Reference in New Issue
Block a user