2021-08-09 15:41:42 +05:00
|
|
|
|
using AsbCloudApp.Data;
|
|
|
|
|
using System;
|
2021-07-23 17:40:31 +05:00
|
|
|
|
using System.Collections.Generic;
|
2021-09-10 11:28:57 +05:00
|
|
|
|
using System.IO;
|
2021-08-11 16:54:42 +05:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
2021-07-23 17:40:31 +05:00
|
|
|
|
|
|
|
|
|
namespace AsbCloudApp.Services
|
|
|
|
|
{
|
2022-08-05 17:52:42 +05:00
|
|
|
|
//TODO: refactor IFileService
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Сервис доступа к файлам
|
|
|
|
|
/// </summary>
|
2021-07-23 17:40:31 +05:00
|
|
|
|
public interface IFileService
|
|
|
|
|
{
|
2022-08-05 17:52:42 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Директория хранения файлов
|
|
|
|
|
/// </summary>
|
2021-07-23 17:40:31 +05:00
|
|
|
|
string RootPath { get; }
|
|
|
|
|
|
2022-08-05 17:52:42 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// получить url Google drive
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idFileInfo"></param>
|
|
|
|
|
/// <param name="idUser"></param>
|
|
|
|
|
/// <param name="fileShareService"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2021-11-17 13:06:48 +05:00
|
|
|
|
Task<string> GetSharedUrlAsync(int idFileInfo, int idUser, IFileShareService fileShareService, CancellationToken token);
|
2022-08-05 17:52:42 +05:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// получить url Google drive
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="dto"></param>
|
|
|
|
|
/// <param name="idUser"></param>
|
|
|
|
|
/// <param name="fileShareService"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2021-11-17 13:06:48 +05:00
|
|
|
|
Task<string> GetSharedUrlAsync(FileInfoDto dto, int idUser, IFileShareService fileShareService,
|
2021-10-29 16:03:24 +05:00
|
|
|
|
CancellationToken token = default);
|
2021-10-29 12:47:18 +05:00
|
|
|
|
|
2022-08-05 17:52:42 +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>
|
2021-09-01 15:55:10 +05:00
|
|
|
|
Task<FileInfoDto> SaveAsync(int idWell, int? idUser, int idCategory, string fileFullName, Stream fileStream, CancellationToken token = default);
|
2021-08-19 16:32:04 +05:00
|
|
|
|
|
2022-08-05 17:52:42 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Получить список файлов в контейнере
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idWell"></param>
|
|
|
|
|
/// <param name="idCategory"></param>
|
|
|
|
|
/// <param name="companyName"></param>
|
|
|
|
|
/// <param name="fileName"></param>
|
|
|
|
|
/// <param name="begin"></param>
|
|
|
|
|
/// <param name="end"></param>
|
|
|
|
|
/// <param name="skip"></param>
|
|
|
|
|
/// <param name="take"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2021-08-29 17:25:16 +05:00
|
|
|
|
Task<PaginationContainer<FileInfoDto>> GetInfosAsync(int idWell,
|
2021-08-31 18:01:26 +05:00
|
|
|
|
int idCategory, string companyName = default, string fileName = default, DateTime begin = default, DateTime end = default,
|
|
|
|
|
int skip = 0, int take = 32, CancellationToken token = default);
|
2021-07-23 17:40:31 +05:00
|
|
|
|
|
2022-08-05 17:52:42 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Инфо о файле
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idFile"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2021-11-09 17:36:44 +05:00
|
|
|
|
Task<FileInfoDto> GetInfoAsync(int idFile,
|
2021-08-11 17:26:02 +05:00
|
|
|
|
CancellationToken token);
|
2021-08-19 16:58:26 +05:00
|
|
|
|
|
2022-08-05 17:52:42 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Пометить файл как удаленный
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idFile"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2021-08-29 17:25:16 +05:00
|
|
|
|
Task<int> MarkAsDeletedAsync(int idFile,
|
2021-08-19 16:58:26 +05:00
|
|
|
|
CancellationToken token = default);
|
2022-08-05 17:52:42 +05:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Получить файлы определенной категории
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idWell"></param>
|
|
|
|
|
/// <param name="idCategory"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2021-08-29 17:25:16 +05:00
|
|
|
|
Task<IEnumerable<FileInfoDto>> GetInfosByCategoryAsync(int idWell, int idCategory, CancellationToken token = default);
|
2022-08-05 17:52:42 +05:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// удалить файл
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2021-10-06 18:07:35 +05:00
|
|
|
|
Task<int> DeleteAsync(int id, CancellationToken token);
|
2022-08-05 17:52:42 +05:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// удалить файлы
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ids"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2022-02-12 11:28:16 +05:00
|
|
|
|
Task<int> DeleteAsync(IEnumerable<int> ids, CancellationToken token);
|
2022-08-05 17:52:42 +05:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// получить путь для скачивания
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="fileInfo"></param>
|
|
|
|
|
/// <returns></returns>
|
2021-09-23 10:52:10 +05:00
|
|
|
|
string GetUrl(FileInfoDto fileInfo);
|
2022-08-05 17:52:42 +05:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// получить путь для скачивания
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idFile"></param>
|
|
|
|
|
/// <returns></returns>
|
2021-09-23 10:52:10 +05:00
|
|
|
|
string GetUrl(int idFile);
|
2022-08-05 17:52:42 +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:52:10 +05:00
|
|
|
|
string GetUrl(int idWell, int idCategory, int idFile, string dotExtention);
|
2022-08-05 17:52:42 +05:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// добавить метку на файл
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="fileMarkDto"></param>
|
|
|
|
|
/// <param name="idUser"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2021-11-09 17:36:44 +05:00
|
|
|
|
Task<int> CreateFileMarkAsync(FileMarkDto fileMarkDto, int idUser, CancellationToken token);
|
2022-08-05 17:52:42 +05:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// пометить метку файла как удаленную
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idMark"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2021-11-09 17:36:44 +05:00
|
|
|
|
Task<int> MarkFileMarkAsDeletedAsync(int idMark, CancellationToken token);
|
2022-08-05 17:52:42 +05:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// переместить файл
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idWell"></param>
|
|
|
|
|
/// <param name="idUser"></param>
|
|
|
|
|
/// <param name="idCategory"></param>
|
|
|
|
|
/// <param name="destinationFileName"></param>
|
|
|
|
|
/// <param name="srcFileFullName"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2021-09-23 11:55:25 +05:00
|
|
|
|
Task<FileInfoDto> MoveAsync(int idWell, int? idUser, int idCategory, string destinationFileName, string srcFileFullName, CancellationToken token = default);
|
2022-08-05 17:52:42 +05:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// получить инфо о файле по метке
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idMark"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2021-11-09 17:36:44 +05:00
|
|
|
|
Task<FileInfoDto> GetByMarkId(int idMark, CancellationToken token);
|
2022-08-05 17:52:42 +05:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// пометить метки файлов как удаленные
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idsMarks"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2022-02-12 11:28:16 +05:00
|
|
|
|
Task<int> MarkFileMarkAsDeletedAsync(IEnumerable<int> idsMarks, CancellationToken token);
|
2021-07-23 17:40:31 +05:00
|
|
|
|
}
|
|
|
|
|
}
|