forked from ddrilling/AsbCloudServer
fix use fileshare only when needed.
This commit is contained in:
parent
361aceed96
commit
b6c2f60296
@ -9,7 +9,7 @@ namespace AsbCloudApp.Services
|
||||
Task<int> CreateFileMarkAsync(FileMarkDto fileMarkDto, int idUser, CancellationToken token);
|
||||
Task<FileInfoDto> GetOrCreateAsync(int idWell, int fileChangerId,
|
||||
CancellationToken token = default);
|
||||
Task<string> GetOrCreateSharedUrlAsync(int idWell, int idUser, CancellationToken token = default);
|
||||
Task<string> GetOrCreateSharedUrlAsync(int idWell, int idUser, IFileShareService fileShareService, CancellationToken token = default);
|
||||
Task<int> MarkFileMarkAsDeletedAsync(int idMark, CancellationToken token);
|
||||
}
|
||||
}
|
@ -11,8 +11,8 @@ namespace AsbCloudApp.Services
|
||||
{
|
||||
string RootPath { get; }
|
||||
|
||||
Task<string> GetSharedUrlAsync(int idFileInfo, int idUser, CancellationToken token);
|
||||
Task<string> GetSharedUrlAsync(FileInfoDto dto, int idUser,
|
||||
Task<string> GetSharedUrlAsync(int idFileInfo, int idUser, IFileShareService fileShareService, CancellationToken token);
|
||||
Task<string> GetSharedUrlAsync(FileInfoDto dto, int idUser, IFileShareService fileShareService,
|
||||
CancellationToken token = default);
|
||||
|
||||
Task<FileInfoDto> SaveAsync(int idWell, int? idUser, int idCategory, string fileFullName, Stream fileStream, CancellationToken token = default);
|
||||
|
@ -23,4 +23,6 @@ sudo -u postgres pg_dump -Fc -U postgres postgres -W > 2021-11-13_dump.sql.gz
|
||||
#restore
|
||||
```
|
||||
psql postgres < dump_file_name
|
||||
```
|
||||
```
|
||||
|
||||
sudo -u postgres psql -p 5499 -U postgres postgres -W < 2021-11-16_dump.sql.gz
|
@ -26,7 +26,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
this.wellService = wellService;
|
||||
}
|
||||
|
||||
public async Task<string> GetOrCreateSharedUrlAsync(int idWell, int idUser, CancellationToken token = default)
|
||||
public async Task<string> GetOrCreateSharedUrlAsync(int idWell, int idUser, IFileShareService fileShareService, CancellationToken token = default)
|
||||
{
|
||||
var fileInfo = await GetOrCreateAsync(idWell, idUser, token)
|
||||
.ConfigureAwait(false);
|
||||
@ -34,7 +34,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
if (fileInfo is null)
|
||||
return null;
|
||||
|
||||
var sharedUrl = await fileService.GetSharedUrlAsync(fileInfo, idUser, token)
|
||||
var sharedUrl = await fileService.GetSharedUrlAsync(fileInfo, idUser, fileShareService, token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return sharedUrl;
|
||||
|
@ -18,13 +18,11 @@ namespace AsbCloudInfrastructure.Services
|
||||
|
||||
private readonly IQueryable<AsbCloudDb.Model.FileInfo> dbSetConfigured;
|
||||
private readonly IAsbCloudDbContext db;
|
||||
private readonly IFileShareService fileShareService;
|
||||
|
||||
public FileService(IAsbCloudDbContext db, IFileShareService fileShareService)
|
||||
public FileService(IAsbCloudDbContext db)
|
||||
{
|
||||
RootPath = "files";
|
||||
this.db = db;
|
||||
this.fileShareService = fileShareService;
|
||||
dbSetConfigured = db.Files
|
||||
.Include(f => f.Author)
|
||||
.ThenInclude(u => u.Company)
|
||||
@ -33,17 +31,17 @@ namespace AsbCloudInfrastructure.Services
|
||||
.ThenInclude(m => m.User);
|
||||
}
|
||||
|
||||
public async Task<string> GetSharedUrlAsync(int idFileInfo, int idUser,
|
||||
public async Task<string> GetSharedUrlAsync(int idFileInfo, int idUser, IFileShareService fileShareService,
|
||||
CancellationToken token)
|
||||
{
|
||||
var fileInfo = await GetInfoAsync(idFileInfo, token);
|
||||
if (fileInfo is null)
|
||||
return null;
|
||||
var sharedUrl = await GetSharedUrlAsync(fileInfo, idUser, token);
|
||||
var sharedUrl = await GetSharedUrlAsync(fileInfo, idUser, fileShareService, token);
|
||||
return sharedUrl;
|
||||
}
|
||||
|
||||
public async Task<string> GetSharedUrlAsync( FileInfoDto fileInfo, int idUser,
|
||||
public async Task<string> GetSharedUrlAsync( FileInfoDto fileInfo, int idUser, IFileShareService fileShareService,
|
||||
CancellationToken token)
|
||||
{
|
||||
var fileWebUrl = fileInfo.PublishInfo?.WebStorageFileUrl;
|
||||
|
@ -11,7 +11,6 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AsbCloudApp.Services;
|
||||
using Google.Apis.Auth.OAuth2.Responses;
|
||||
|
||||
namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
|
@ -23,7 +23,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
private readonly IReportsBackgroundQueue queue;
|
||||
|
||||
public ReportService(IAsbCloudDbContext db, IConfiguration configuration,
|
||||
ITelemetryService telemetryService, IFileService fileService,
|
||||
ITelemetryService telemetryService,
|
||||
IReportsBackgroundQueue queue)
|
||||
{
|
||||
this.db = db;
|
||||
@ -59,7 +59,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
};
|
||||
generator.Make(reportFileName);
|
||||
|
||||
var fileService = new FileService(context, new GoogleDriveService());
|
||||
var fileService = new FileService(context);
|
||||
var fileInfo = fileService.MoveAsync(idWell, idUser, ReportCategoryId, reportFileName, reportFileName).Result;
|
||||
|
||||
progressHandler.Invoke(new
|
||||
|
@ -55,16 +55,17 @@ namespace AsbCloudWebApi.Controllers
|
||||
|
||||
return PhysicalFile(Path.GetFullPath(relativePath), "application/octet-stream", fileInfo.Name);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Создает программу бурения
|
||||
/// </summary>
|
||||
/// <param name="idWell"> id скважины </param>
|
||||
/// <param name="fileShareService"></param>
|
||||
/// <param name="token"> Токен отмены задачи </param>
|
||||
/// <returns> Возвращает ссылку на файл программы бурения в облаке </returns>
|
||||
[HttpGet("webUrl")]
|
||||
[ProducesResponseType(typeof(string), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetOrCreateSharedUrlAsync(int idWell, CancellationToken token = default)
|
||||
public async Task<IActionResult> GetOrCreateSharedUrlAsync(int idWell, [FromServices]IFileShareService fileShareService, CancellationToken token = default)
|
||||
{
|
||||
var idCompany = User.GetCompanyId();
|
||||
|
||||
@ -76,7 +77,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
return Forbid();
|
||||
|
||||
var sharedUrl = await drillingProgramService.GetOrCreateSharedUrlAsync(idWell,
|
||||
(int)idUser, token)
|
||||
(int)idUser, fileShareService, token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return Ok(sharedUrl);
|
||||
|
Loading…
Reference in New Issue
Block a user