DD.WellWorkover.Cloud/AsbCloudApp/Services/IFileService.cs

185 lines
6.9 KiB
C#
Raw Normal View History

using AsbCloudApp.Data;
using System;
using System.Collections.Generic;
2021-09-10 11:28:57 +05:00
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudApp.Services
{
2022-08-05 17:52:42 +05:00
//TODO: refactor IFileService
/// <summary>
/// Сервис доступа к файлам
/// </summary>
public interface IFileService
{
2022-08-05 17:52:42 +05:00
/// <summary>
/// Директория хранения файлов
/// </summary>
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,
CancellationToken token = default);
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>
Task<FileInfoDto> SaveAsync(int idWell, int? idUser, int idCategory, string fileFullName, Stream fileStream, CancellationToken token = default);
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,
int idCategory, string companyName = default, string fileName = default, DateTime begin = default, DateTime end = default,
int skip = 0, int take = 32, CancellationToken token = default);
2022-08-05 17:52:42 +05:00
/// <summary>
/// Инфо о файле
/// </summary>
/// <param name="idFile"></param>
/// <param name="token"></param>
/// <returns></returns>
Task<FileInfoDto> GetInfoAsync(int idFile,
CancellationToken token);
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,
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>
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>
Task<int> DeleteAsync(IEnumerable<int> ids, CancellationToken token);
2022-08-05 17:52:42 +05:00
/// <summary>
/// получить путь для скачивания
/// </summary>
/// <param name="fileInfo"></param>
/// <returns></returns>
string GetUrl(FileInfoDto fileInfo);
2022-08-05 17:52:42 +05:00
/// <summary>
/// получить путь для скачивания
/// </summary>
/// <param name="idFile"></param>
/// <returns></returns>
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>
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>
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>
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>
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>
Task<int> MarkFileMarkAsDeletedAsync(IEnumerable<int> idsMarks, CancellationToken token);
}
}