forked from ddrilling/AsbCloudServer
CS2-104: Added .Include() filemarks to fileInfoDto queries
This commit is contained in:
parent
8d73f0e471
commit
dd0385c4dd
@ -33,7 +33,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async Task<string> GetFileWebUrlAsync(FileInfoDto fileInfo, string userLogin,
|
public async Task<string> GetFileWebUrlAsync(FileInfoDto fileInfo, string userLogin,
|
||||||
CancellationToken token = default)
|
CancellationToken token)
|
||||||
{
|
{
|
||||||
var fileWebUrl = fileInfo.PublishInfo?.WebStorageFileUrl;
|
var fileWebUrl = fileInfo.PublishInfo?.WebStorageFileUrl;
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async Task<FileInfoDto> MoveAsync(int idWell, int? idUser, int idCategory,
|
public async Task<FileInfoDto> MoveAsync(int idWell, int? idUser, int idCategory,
|
||||||
string destinationFileName, string srcFilePath, CancellationToken token = default)
|
string destinationFileName, string srcFilePath, CancellationToken token)
|
||||||
{
|
{
|
||||||
destinationFileName = Path.GetFileName(destinationFileName);
|
destinationFileName = Path.GetFileName(destinationFileName);
|
||||||
srcFilePath = Path.GetFullPath(srcFilePath);
|
srcFilePath = Path.GetFullPath(srcFilePath);
|
||||||
@ -82,7 +82,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async Task<FileInfoDto> SaveAsync(int idWell, int? idUser, int idCategory,
|
public async Task<FileInfoDto> SaveAsync(int idWell, int? idUser, int idCategory,
|
||||||
string fileFullName, Stream fileStream, CancellationToken token = default)
|
string fileFullName, Stream fileStream, CancellationToken token)
|
||||||
{
|
{
|
||||||
//save info to db
|
//save info to db
|
||||||
var fileInfo = new AsbCloudDb.Model.FileInfo()
|
var fileInfo = new AsbCloudDb.Model.FileInfo()
|
||||||
@ -119,7 +119,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<FileInfoDto>> GetInfosByCategoryAsync(int idWell,
|
public async Task<IEnumerable<FileInfoDto>> GetInfosByCategoryAsync(int idWell,
|
||||||
int idCategory, CancellationToken token = default)
|
int idCategory, CancellationToken token)
|
||||||
{
|
{
|
||||||
var entities = await dbSetConfigured
|
var entities = await dbSetConfigured
|
||||||
.Include(f => f.FileMarks)
|
.Include(f => f.FileMarks)
|
||||||
@ -137,19 +137,18 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
DateTime end = default, int skip = 0, int take = 32, CancellationToken token = default)
|
DateTime end = default, int skip = 0, int take = 32, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var query = dbSetConfigured
|
var query = dbSetConfigured
|
||||||
|
.Include(f => f.FileMarks)
|
||||||
.Where(e => e.IdWell == idWell &&
|
.Where(e => e.IdWell == idWell &&
|
||||||
e.IdCategory == idCategory);
|
e.IdCategory == idCategory &&
|
||||||
|
!e.IsDeleted);
|
||||||
query = query.Where(e => !e.IsDeleted);
|
|
||||||
|
|
||||||
if (idCategory == 13)
|
|
||||||
query = query.Include(f => f.FileMarks);
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(companyName))
|
if (!string.IsNullOrEmpty(companyName))
|
||||||
query = query
|
query = query
|
||||||
.Include(file => file.Author)
|
.Include(file => file.Author)
|
||||||
.ThenInclude(a => a.Company)
|
.ThenInclude(a => a.Company)
|
||||||
.Where(e => (e.Author == null) || (e.Author.Company == null) || e.Author.Company.Caption.Contains(companyName));
|
.Where(e => (e.Author == null) ||
|
||||||
|
(e.Author.Company == null) ||
|
||||||
|
e.Author.Company.Caption.Contains(companyName));
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(fileName))
|
if (!string.IsNullOrEmpty(fileName))
|
||||||
query = query.Where(e => e.Name.ToLower().Contains(fileName.ToLower()));
|
query = query.Where(e => e.Name.ToLower().Contains(fileName.ToLower()));
|
||||||
@ -189,9 +188,10 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async Task<FileInfoDto> GetInfoAsync(int fileId,
|
public async Task<FileInfoDto> GetInfoAsync(int fileId,
|
||||||
CancellationToken token = default)
|
CancellationToken token)
|
||||||
{
|
{
|
||||||
var entity = await dbSetConfigured
|
var entity = await dbSetConfigured
|
||||||
|
.Include(f => f.FileMarks)
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.FirstOrDefaultAsync(f => f.Id == fileId, token)
|
.FirstOrDefaultAsync(f => f.Id == fileId, token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
@ -289,7 +289,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> PublishFileToCloudAsync(string filePath, string originalName,
|
private async Task<string> PublishFileToCloudAsync(string filePath, string originalName,
|
||||||
CancellationToken token = default)
|
CancellationToken token)
|
||||||
{
|
{
|
||||||
await using var fileStream = File.Open(filePath, FileMode.Open);
|
await using var fileStream = File.Open(filePath, FileMode.Open);
|
||||||
var uploadedFileId = await googleDriveService.UploadFileAsync(fileStream, originalName,
|
var uploadedFileId = await googleDriveService.UploadFileAsync(fileStream, originalName,
|
||||||
@ -304,7 +304,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async Task<int> SaveWeblinkToFileInfo(int idFileInfo, string userLogin, string weblink,
|
private async Task<int> SaveWeblinkToFileInfo(int idFileInfo, string userLogin, string weblink,
|
||||||
CancellationToken token = default)
|
CancellationToken token)
|
||||||
{
|
{
|
||||||
var fileInfo = await db.Files.FirstOrDefaultAsync(f => f.Id == idFileInfo, token)
|
var fileInfo = await db.Files.FirstOrDefaultAsync(f => f.Id == idFileInfo, token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user