2021-08-09 15:41:42 +05:00
|
|
|
|
using AsbCloudApp.Data;
|
2022-10-06 14:37:03 +05:00
|
|
|
|
using AsbCloudApp.Repositories;
|
2022-10-11 08:28:37 +05:00
|
|
|
|
using AsbCloudApp.Requests;
|
2021-08-09 15:41:42 +05:00
|
|
|
|
using System.Collections.Generic;
|
2021-08-24 10:59:10 +05:00
|
|
|
|
using System.IO;
|
2021-08-09 15:41:42 +05:00
|
|
|
|
using System.Linq;
|
2021-08-11 16:54:42 +05:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
2021-07-23 17:40:31 +05:00
|
|
|
|
|
2022-10-06 14:37:03 +05:00
|
|
|
|
namespace AsbCloudApp.Services
|
2021-07-23 17:40:31 +05:00
|
|
|
|
{
|
2022-10-11 08:28:37 +05:00
|
|
|
|
#nullable enable
|
2022-10-06 14:37:03 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Сервис доступа к файлам
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class FileService
|
2021-07-23 17:40:31 +05:00
|
|
|
|
{
|
2022-09-28 10:46:12 +05:00
|
|
|
|
private readonly IFileRepository fileRepository;
|
2022-10-06 13:41:46 +05:00
|
|
|
|
private readonly IFileStorageRepository fileStorageRepository;
|
2021-08-31 18:01:26 +05:00
|
|
|
|
|
2022-10-06 14:37:03 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Сервис доступа к файлам
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="fileRepository"></param>
|
|
|
|
|
/// <param name="fileStorageRepository"></param>
|
2022-10-06 13:41:46 +05:00
|
|
|
|
public FileService(IFileRepository fileRepository, IFileStorageRepository fileStorageRepository)
|
2021-07-23 17:40:31 +05:00
|
|
|
|
{
|
2022-09-28 10:46:12 +05:00
|
|
|
|
this.fileRepository = fileRepository;
|
2022-10-06 13:41:46 +05:00
|
|
|
|
this.fileStorageRepository = fileStorageRepository;
|
2021-11-09 17:36:44 +05:00
|
|
|
|
}
|
2021-10-27 17:00:27 +05:00
|
|
|
|
|
2022-10-06 14:37:03 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// переместить файл
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idWell"></param>
|
|
|
|
|
/// <param name="idUser"></param>
|
|
|
|
|
/// <param name="idCategory"></param>
|
|
|
|
|
/// <param name="destinationFileName"></param>
|
|
|
|
|
/// <param name="srcFilePath"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2022-04-11 18:00:34 +05:00
|
|
|
|
public async Task<FileInfoDto> MoveAsync(int idWell, int? idUser, int idCategory,
|
2021-11-09 17:36:44 +05:00
|
|
|
|
string destinationFileName, string srcFilePath, CancellationToken token = default)
|
2021-09-23 11:55:25 +05:00
|
|
|
|
{
|
2021-09-23 14:36:05 +05:00
|
|
|
|
destinationFileName = Path.GetFileName(destinationFileName);
|
|
|
|
|
srcFilePath = Path.GetFullPath(srcFilePath);
|
2022-10-06 13:41:46 +05:00
|
|
|
|
var fileSize = fileStorageRepository.GetLengthFile(srcFilePath);
|
2021-09-23 11:55:25 +05:00
|
|
|
|
|
|
|
|
|
//save info to db
|
2022-09-30 10:49:40 +05:00
|
|
|
|
var dto = new FileInfoDto {
|
|
|
|
|
IdWell = idWell,
|
|
|
|
|
IdAuthor = idUser,
|
|
|
|
|
IdCategory = idCategory,
|
|
|
|
|
Name = destinationFileName,
|
2022-10-06 13:41:46 +05:00
|
|
|
|
Size = fileSize
|
2022-09-30 10:49:40 +05:00
|
|
|
|
};
|
|
|
|
|
var fileId = await fileRepository.InsertAsync(dto, token)
|
2022-09-28 10:46:12 +05:00
|
|
|
|
.ConfigureAwait(false);
|
|
|
|
|
|
2022-10-11 08:28:37 +05:00
|
|
|
|
string filePath = fileStorageRepository.MakeFilePath(idWell, idCategory, destinationFileName, fileId);
|
2022-10-06 13:41:46 +05:00
|
|
|
|
fileStorageRepository.MoveFile(srcFilePath, filePath);
|
2021-09-23 11:55:25 +05:00
|
|
|
|
|
2022-09-28 10:46:12 +05:00
|
|
|
|
return await GetInfoAsync(fileId, token);
|
2021-09-23 11:55:25 +05:00
|
|
|
|
}
|
|
|
|
|
|
2022-10-06 14:37:03 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Сохранить файл
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idWell"></param>
|
|
|
|
|
/// <param name="idUser"></param>
|
|
|
|
|
/// <param name="idCategory"></param>
|
|
|
|
|
/// <param name="fileFullName"></param>
|
|
|
|
|
/// <param name="fileStream"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2022-04-11 18:00:34 +05:00
|
|
|
|
public async Task<FileInfoDto> SaveAsync(int idWell, int? idUser, int idCategory,
|
2021-11-03 15:53:31 +05:00
|
|
|
|
string fileFullName, Stream fileStream, CancellationToken token)
|
2021-07-23 17:40:31 +05:00
|
|
|
|
{
|
2021-08-29 17:25:16 +05:00
|
|
|
|
//save info to db
|
2022-09-30 10:49:40 +05:00
|
|
|
|
var dto = new FileInfoDto
|
|
|
|
|
{
|
|
|
|
|
IdWell = idWell,
|
|
|
|
|
IdAuthor = idUser,
|
|
|
|
|
IdCategory = idCategory,
|
|
|
|
|
Name = Path.GetFileName(fileFullName),
|
|
|
|
|
Size = fileStream?.Length ?? 0
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var fileId = await fileRepository.InsertAsync(dto, token)
|
2022-09-28 10:46:12 +05:00
|
|
|
|
.ConfigureAwait(false);
|
2021-07-23 17:40:31 +05:00
|
|
|
|
|
2021-08-29 17:25:16 +05:00
|
|
|
|
//save stream to disk
|
2022-10-11 08:28:37 +05:00
|
|
|
|
string filePath = fileStorageRepository.MakeFilePath(idWell, idCategory, fileFullName, fileId);
|
2022-10-06 13:41:46 +05:00
|
|
|
|
await fileStorageRepository.CopyFileAsync(filePath, fileStream, token);
|
2022-01-05 17:50:45 +05:00
|
|
|
|
|
2022-09-28 10:46:12 +05:00
|
|
|
|
return await GetInfoAsync(fileId, token);
|
2021-08-29 17:25:16 +05:00
|
|
|
|
}
|
|
|
|
|
|
2022-10-06 14:37:03 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Инфо о файле
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idFile"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2021-11-09 17:36:44 +05:00
|
|
|
|
public async Task<FileInfoDto> GetInfoAsync(int idFile,
|
2021-11-03 15:53:31 +05:00
|
|
|
|
CancellationToken token)
|
2021-07-23 17:40:31 +05:00
|
|
|
|
{
|
2022-09-30 10:49:40 +05:00
|
|
|
|
var dto = await fileRepository.GetOrDefaultAsync(idFile, token).ConfigureAwait(false);
|
2022-02-08 10:25:05 +05:00
|
|
|
|
|
2022-09-28 10:46:12 +05:00
|
|
|
|
var ext = Path.GetExtension(dto.Name);
|
2022-02-08 10:25:05 +05:00
|
|
|
|
|
2022-09-28 10:46:12 +05:00
|
|
|
|
var relativePath = GetUrl(dto.IdWell, dto.IdCategory, dto.Id, ext);
|
2022-02-08 10:25:05 +05:00
|
|
|
|
var fullPath = Path.GetFullPath(relativePath);
|
2022-10-06 13:41:46 +05:00
|
|
|
|
fileStorageRepository.FileExists(fullPath, relativePath);
|
2021-07-23 17:40:31 +05:00
|
|
|
|
|
2021-08-13 17:26:19 +05:00
|
|
|
|
return dto;
|
2021-07-23 17:40:31 +05:00
|
|
|
|
}
|
2021-08-19 16:58:26 +05:00
|
|
|
|
|
2022-10-06 14:37:03 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// удалить файл
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idFile"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2022-02-12 11:28:16 +05:00
|
|
|
|
public Task<int> DeleteAsync(int idFile, CancellationToken token)
|
2022-09-30 10:49:40 +05:00
|
|
|
|
=> DeleteAsync(new int[] { idFile }, token);
|
2022-02-12 11:28:16 +05:00
|
|
|
|
|
2022-10-06 14:37:03 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// удалить файлы
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ids"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2022-02-12 11:28:16 +05:00
|
|
|
|
public async Task<int> DeleteAsync(IEnumerable<int> ids, CancellationToken token)
|
2021-08-29 17:25:16 +05:00
|
|
|
|
{
|
2022-02-12 11:28:16 +05:00
|
|
|
|
if (ids is null || !ids.Any())
|
|
|
|
|
return 0;
|
2021-08-29 17:25:16 +05:00
|
|
|
|
|
2022-09-28 10:46:12 +05:00
|
|
|
|
var files = await fileRepository.DeleteAsync(ids, token).ConfigureAwait(false);
|
2022-02-12 11:28:16 +05:00
|
|
|
|
|
|
|
|
|
if (files is null || !files.Any())
|
2021-08-29 17:25:16 +05:00
|
|
|
|
return 0;
|
|
|
|
|
|
2022-02-12 11:28:16 +05:00
|
|
|
|
foreach (var file in files)
|
|
|
|
|
{
|
|
|
|
|
var fileName = GetUrl(file.IdWell, file.IdCategory, file.Id, Path.GetExtension(file.Name));
|
2022-10-06 13:41:46 +05:00
|
|
|
|
fileStorageRepository.DeleteFile(fileName);
|
2022-02-12 11:28:16 +05:00
|
|
|
|
}
|
|
|
|
|
|
2022-09-28 10:46:12 +05:00
|
|
|
|
return files.Any() ? 1 : 0;
|
2021-08-29 17:25:16 +05:00
|
|
|
|
}
|
|
|
|
|
|
2022-10-06 14:37:03 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// получить путь для скачивания
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idFile"></param>
|
|
|
|
|
/// <returns></returns>
|
2022-09-28 10:46:12 +05:00
|
|
|
|
public async Task<string> GetUrl(int idFile)
|
2021-08-29 17:25:16 +05:00
|
|
|
|
{
|
2022-09-30 10:49:40 +05:00
|
|
|
|
var fileInfo = await fileRepository.GetOrDefaultAsync(idFile, CancellationToken.None).ConfigureAwait(false);
|
2021-09-23 10:53:48 +05:00
|
|
|
|
|
|
|
|
|
return GetUrl(fileInfo.IdWell, fileInfo.IdCategory, fileInfo.Id, Path.GetExtension(fileInfo.Name));
|
2021-08-19 16:58:26 +05:00
|
|
|
|
}
|
2021-09-23 10:53:48 +05:00
|
|
|
|
|
2022-10-06 14:37:03 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// получить путь для скачивания
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="fileInfo"></param>
|
|
|
|
|
/// <returns></returns>
|
2021-11-09 17:36:44 +05:00
|
|
|
|
public string GetUrl(FileInfoDto fileInfo) =>
|
|
|
|
|
GetUrl(fileInfo.IdWell, fileInfo.IdCategory, fileInfo.Id, Path.GetExtension(fileInfo.Name));
|
|
|
|
|
|
2022-10-06 14:37:03 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// получить путь для скачивания
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idWell"></param>
|
|
|
|
|
/// <param name="idCategory"></param>
|
|
|
|
|
/// <param name="idFile"></param>
|
|
|
|
|
/// <param name="dotExtention"></param>
|
|
|
|
|
/// <returns></returns>
|
2021-09-23 10:53:48 +05:00
|
|
|
|
public string GetUrl(int idWell, int idCategory, int idFile, string dotExtention) =>
|
2022-10-06 13:41:46 +05:00
|
|
|
|
Path.Combine(fileStorageRepository.RootPath, idWell.ToString(), idCategory.ToString(), $"{idFile}{dotExtention}");
|
2021-11-01 16:41:25 +05:00
|
|
|
|
|
2022-10-06 14:37:03 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// пометить метку файла как удаленную
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idMark"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2022-02-12 11:28:16 +05:00
|
|
|
|
public Task<int> MarkFileMarkAsDeletedAsync(int idMark,
|
|
|
|
|
CancellationToken token)
|
2022-09-28 10:46:12 +05:00
|
|
|
|
=> fileRepository.MarkFileMarkAsDeletedAsync(new int[] { idMark }, token);
|
2022-02-12 11:28:16 +05:00
|
|
|
|
|
2022-10-06 14:37:03 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Инфо о файле
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idsFile"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2022-09-28 10:46:12 +05:00
|
|
|
|
public async Task<IEnumerable<FileInfoDto>> GetInfoByIdsAsync(IEnumerable<int> idsFile, CancellationToken token)
|
2021-10-29 12:47:18 +05:00
|
|
|
|
{
|
2022-09-28 10:46:12 +05:00
|
|
|
|
var result = await fileRepository.GetInfoByIdsAsync(idsFile, token).ConfigureAwait(false);
|
2022-09-05 09:13:45 +05:00
|
|
|
|
|
2022-09-28 10:46:12 +05:00
|
|
|
|
foreach (var entity in result)
|
2022-09-05 09:13:45 +05:00
|
|
|
|
{
|
2022-09-28 10:46:12 +05:00
|
|
|
|
|
2022-09-05 09:13:45 +05:00
|
|
|
|
var ext = Path.GetExtension(entity.Name);
|
|
|
|
|
var relativePath = GetUrl(entity.IdWell, entity.IdCategory, entity.Id, ext);
|
|
|
|
|
var fullPath = Path.GetFullPath(relativePath);
|
2022-10-06 13:41:46 +05:00
|
|
|
|
fileStorageRepository.FileExists(fullPath, relativePath);
|
2022-09-05 09:13:45 +05:00
|
|
|
|
}
|
2022-10-06 13:41:46 +05:00
|
|
|
|
|
2022-09-05 09:13:45 +05:00
|
|
|
|
return result;
|
|
|
|
|
}
|
2022-09-30 10:49:40 +05:00
|
|
|
|
|
2022-10-06 14:37:03 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Получить список файлов в контейнере
|
|
|
|
|
/// </summary>
|
2022-10-11 08:28:37 +05:00
|
|
|
|
/// <param name="request"></param>
|
2022-10-06 14:37:03 +05:00
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2022-10-11 08:28:37 +05:00
|
|
|
|
public async Task<PaginationContainer<FileInfoDto>> GetInfosAsync(FileServiceRequest request, CancellationToken token)
|
|
|
|
|
=> await fileRepository.GetInfosAsync(request, token)
|
2022-09-30 10:49:40 +05:00
|
|
|
|
.ConfigureAwait(false);
|
|
|
|
|
|
2022-10-06 14:37:03 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Пометить файл как удаленный
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idFile"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2022-09-30 10:49:40 +05:00
|
|
|
|
public async Task<int> MarkAsDeletedAsync(int idFile, CancellationToken token = default)
|
|
|
|
|
=> await fileRepository.MarkAsDeletedAsync(idFile, token)
|
|
|
|
|
.ConfigureAwait(false);
|
|
|
|
|
|
2022-10-06 14:37:03 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// добавить метку на файл
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="fileMarkDto"></param>
|
|
|
|
|
/// <param name="idUser"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2022-09-30 10:49:40 +05:00
|
|
|
|
public async Task<int> CreateFileMarkAsync(FileMarkDto fileMarkDto, int idUser, CancellationToken token)
|
|
|
|
|
=> await fileRepository.CreateFileMarkAsync(fileMarkDto, idUser, token)
|
|
|
|
|
.ConfigureAwait(false);
|
|
|
|
|
|
2022-10-06 14:37:03 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Получить запись по id
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2022-09-30 10:49:40 +05:00
|
|
|
|
public async Task<FileInfoDto> GetOrDefaultAsync(int id, CancellationToken token)
|
|
|
|
|
=> await fileRepository.GetOrDefaultAsync(id, token)
|
|
|
|
|
.ConfigureAwait(false);
|
2022-09-30 11:05:09 +05:00
|
|
|
|
|
2022-10-06 14:37:03 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// получить инфо о файле по метке
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idMark"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2022-09-30 11:05:09 +05:00
|
|
|
|
public async Task<FileInfoDto> GetByMarkId(int idMark, CancellationToken token)
|
|
|
|
|
=> await fileRepository.GetByMarkId(idMark, token)
|
|
|
|
|
.ConfigureAwait(false);
|
2022-09-30 13:34:50 +05:00
|
|
|
|
|
2022-10-06 14:37:03 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// получить инфо о файле по метке
|
|
|
|
|
/// </summary>
|
2022-10-11 08:28:37 +05:00
|
|
|
|
/// <param name="idsMarks"></param>
|
2022-10-06 14:37:03 +05:00
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2022-09-30 13:34:50 +05:00
|
|
|
|
public async Task<int> MarkFileMarkAsDeletedAsync(IEnumerable<int> idsMarks, CancellationToken token)
|
|
|
|
|
=> await fileRepository.MarkFileMarkAsDeletedAsync(idsMarks, token)
|
|
|
|
|
.ConfigureAwait(false);
|
|
|
|
|
|
2022-10-06 14:37:03 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Получение файлов по скважине
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idWell"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2022-09-30 13:34:50 +05:00
|
|
|
|
public async Task<IEnumerable<FileInfoDto>> GetInfosByWellIdAsync(int idWell, CancellationToken token)
|
2022-10-11 08:28:37 +05:00
|
|
|
|
=> await fileRepository.GetInfosByWellIdAsync(new FileServiceRequest { IdWell = idWell, IsDeleted = false }, token)
|
2022-09-30 13:34:50 +05:00
|
|
|
|
.ConfigureAwait(false);
|
|
|
|
|
|
2022-10-06 14:37:03 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Получить файлы определенной категории
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idWell"></param>
|
|
|
|
|
/// <param name="idCategory"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2022-09-30 13:34:50 +05:00
|
|
|
|
public async Task<IEnumerable<FileInfoDto>> GetInfosByCategoryAsync(int idWell, int idCategory, CancellationToken token)
|
|
|
|
|
=> await fileRepository.GetInfosByCategoryAsync(idWell, idCategory, token)
|
|
|
|
|
.ConfigureAwait(false);
|
2022-10-06 14:37:03 +05:00
|
|
|
|
|
2022-10-11 08:28:37 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Удаление всех файлов по скважине помеченных как удаленные
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idWell"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<int> DeleteFilesFromDbMarkedDeletionByIdWell(int idWell, CancellationToken token)
|
2022-10-06 14:37:03 +05:00
|
|
|
|
{
|
2022-10-11 08:28:37 +05:00
|
|
|
|
var files = await fileRepository.GetInfosByWellIdAsync(
|
|
|
|
|
new FileServiceRequest
|
|
|
|
|
{
|
|
|
|
|
IdWell = idWell,
|
|
|
|
|
IsDeleted = true
|
|
|
|
|
},
|
|
|
|
|
token);
|
|
|
|
|
var result = await DeleteAsync(files.Select(x => x.Id), token);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Удаление всех файлов с диска о которых нет информации в базе
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idWell"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
public async Task<int> DeleteFilesNotExistStorage(int idWell, CancellationToken token)
|
|
|
|
|
{
|
|
|
|
|
var files = await fileRepository.GetInfosByWellIdAsync(
|
|
|
|
|
new FileServiceRequest
|
|
|
|
|
{
|
|
|
|
|
IdWell = idWell
|
|
|
|
|
},
|
|
|
|
|
token);
|
|
|
|
|
var result = await Task.FromResult(fileStorageRepository.DeleteFilesNotExistStorage(idWell, files.Select(x => x.Id)));
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Вывод списка всех файлов из базы, для которых нет файла на диске
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idWell"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<IEnumerable<FileInfoDto>> GetListFilesNotDisc(int idWell, CancellationToken token)
|
|
|
|
|
{
|
|
|
|
|
var files = await fileRepository.GetInfosByWellIdAsync(
|
|
|
|
|
new FileServiceRequest
|
|
|
|
|
{
|
|
|
|
|
IdWell = idWell
|
|
|
|
|
},
|
|
|
|
|
token);
|
|
|
|
|
var result = fileStorageRepository.GetListFilesNotDisc(idWell, files);
|
|
|
|
|
return result;
|
2022-10-06 14:37:03 +05:00
|
|
|
|
}
|
2021-07-23 17:40:31 +05:00
|
|
|
|
}
|
2022-10-11 08:28:37 +05:00
|
|
|
|
#nullable disable
|
2021-07-23 17:40:31 +05:00
|
|
|
|
}
|