last ...
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
|
using xDataService.Providers;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
|
||||||
|
namespace xFileService.Configurations.Entities
|
||||||
|
{
|
||||||
|
public class XFileEntityConfiguration : XBaseEntityTypeConfiguration<XFile, Guid>
|
||||||
|
{
|
||||||
|
public override void Configure(EntityTypeBuilder<XFile> builder)
|
||||||
|
{
|
||||||
|
builder.ToTable("Files");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.EntityFrameworkCore.Query;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using xCommons.Configurations;
|
||||||
|
using xCommons.Providers;
|
||||||
|
using xDataService.Controllers;
|
||||||
|
using xDataService.Interfaces;
|
||||||
|
using xFileService.Interfaces.Entities;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
|
||||||
|
namespace xFileService.Controllers
|
||||||
|
{
|
||||||
|
public abstract class XFileRepositoryControllerBase : XBaseRepositoryController<XFile, Guid>, IXBaseRepositoryController<XFile, Guid>
|
||||||
|
{
|
||||||
|
protected XFileRepositoryControllerBase(
|
||||||
|
ILogger<XFileRepositoryControllerBase> logger,
|
||||||
|
XAppConfiguration appConfiguration,
|
||||||
|
XValidationProvider validationProvider,
|
||||||
|
IXFileRepository repository,
|
||||||
|
Func<IQueryable<XFile>, IOrderedQueryable<XFile>> defaultOrderBuilder = null,
|
||||||
|
Func<IQueryable<XFile>, IIncludableQueryable<XFile, object>> defaultIncludeBuilder = null
|
||||||
|
) : base(
|
||||||
|
logger,
|
||||||
|
appConfiguration,
|
||||||
|
validationProvider,
|
||||||
|
repository,
|
||||||
|
defaultOrderBuilder,
|
||||||
|
defaultIncludeBuilder
|
||||||
|
)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.EntityFrameworkCore.Query;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using xCommons.Configurations;
|
||||||
|
using xCommons.Providers;
|
||||||
|
using xFileService.Interfaces.Entities;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
using xFileService.Providers.Entities;
|
||||||
|
using xIdentityService.Interfaces;
|
||||||
|
using xPushService.Controllers;
|
||||||
|
using xPushService.Interfaces;
|
||||||
|
|
||||||
|
namespace xFileService.Controllers
|
||||||
|
{
|
||||||
|
public abstract class XFileRepositoryProviderControllerBase : XBaseRepositoryProviderController<XFile, Guid, XFileEntityHub>, IXBaseRepositoryProviderController<XFile, Guid, XFileEntityHub>
|
||||||
|
{
|
||||||
|
protected XFileRepositoryProviderControllerBase(
|
||||||
|
ILogger<XFileRepositoryProviderControllerBase> logger,
|
||||||
|
XAppConfiguration appConfiguration,
|
||||||
|
IXIdentityProvider identityProvider,
|
||||||
|
XValidationProvider validationProvider,
|
||||||
|
IXFileRepositoryProvider provider,
|
||||||
|
Func<IQueryable<XFile>, IOrderedQueryable<XFile>> defaultOrderBuilder = null,
|
||||||
|
Func<IQueryable<XFile>, IIncludableQueryable<XFile, object>> defaultIncludeBuilder = null
|
||||||
|
) : base(
|
||||||
|
logger,
|
||||||
|
appConfiguration,
|
||||||
|
identityProvider,
|
||||||
|
validationProvider,
|
||||||
|
provider,
|
||||||
|
defaultOrderBuilder,
|
||||||
|
defaultIncludeBuilder
|
||||||
|
)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,623 +1,34 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using Microsoft.EntityFrameworkCore.Query;
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using xCommons.Configurations;
|
using xCommons.Configurations;
|
||||||
using xCommons.Extensions;
|
|
||||||
using xCommons.Providers;
|
using xCommons.Providers;
|
||||||
using xFileService.Interfaces;
|
using xDataService.Controllers;
|
||||||
using xIdentityService.Controllers;
|
using xDataService.Interfaces;
|
||||||
using xIdentityService.Interfaces;
|
using xFileService.Interfaces.Dtos;
|
||||||
using xModels.Dtos;
|
using xFileService.Models.Dtos;
|
||||||
using XFileDto = xFileService.Models.Dtos.XFileDto;
|
using xFileService.Models.Entities;
|
||||||
|
|
||||||
namespace xFileService.Controllers
|
namespace xFileService.Controllers
|
||||||
{
|
{
|
||||||
/// <summary>
|
public abstract class XFileServiceControllerBase : XBaseServiceController<XFile, XFileDto, Guid>, IXBaseServiceController<XFile, XFileDto, Guid>
|
||||||
/// a Controller base Class which implement based Actions to Provides File Provider Access ...
|
|
||||||
/// </summary>
|
|
||||||
public abstract class XFileServiceControllerBase : XIBaseProviderController, IXFileServiceControllerActions
|
|
||||||
{
|
{
|
||||||
//
|
|
||||||
#region Props ...
|
|
||||||
public IXFileProvider FileProvider { get; }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
//
|
|
||||||
#region Constructor ...
|
|
||||||
protected XFileServiceControllerBase(
|
protected XFileServiceControllerBase(
|
||||||
ILogger logger,
|
ILogger<XFileServiceControllerBase> logger,
|
||||||
IXFileProvider fileProvider,
|
|
||||||
XAppConfiguration appConfiguration,
|
XAppConfiguration appConfiguration,
|
||||||
IXIdentityProvider identityProvider,
|
XValidationProvider validationProvider,
|
||||||
XValidationProvider validationProvider
|
IXFileRepositoryService repositoryService,
|
||||||
|
Func<IQueryable<XFile>, IOrderedQueryable<XFile>> defaultOrderBuilder = null,
|
||||||
|
Func<IQueryable<XFile>, IIncludableQueryable<XFile, object>> defaultIncludeBuilder = null
|
||||||
) : base(
|
) : base(
|
||||||
logger,
|
logger,
|
||||||
appConfiguration,
|
appConfiguration,
|
||||||
identityProvider,
|
validationProvider,
|
||||||
validationProvider
|
repositoryService,
|
||||||
|
defaultOrderBuilder,
|
||||||
|
defaultIncludeBuilder
|
||||||
)
|
)
|
||||||
{
|
{ }
|
||||||
//
|
|
||||||
FileProvider = fileProvider;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
//
|
|
||||||
#region Tags ...
|
|
||||||
/// <summary>
|
|
||||||
/// Attach Tag to Specified Model ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="tag"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost("{id}/Tags/Attach")]
|
|
||||||
public virtual async Task<ActionResult> AttachTag(
|
|
||||||
[FromRoute] Guid id,
|
|
||||||
[FromQuery] string tag
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Do ...
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Retrieve User Info ...
|
|
||||||
var userInfo = await GetUserInfo();
|
|
||||||
var connectionId = GetConnectionId();
|
|
||||||
bool isAdmin = userInfo.Roles.Any(r => r.ToNormalString() == "admin");
|
|
||||||
var userId = userInfo.UserId;
|
|
||||||
|
|
||||||
//
|
|
||||||
await FileProvider.AttachTag(
|
|
||||||
id: id,
|
|
||||||
tag: tag,
|
|
||||||
userInfo: userInfo,
|
|
||||||
connectionId: connectionId
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = GetExceptionActionResult(ex);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Detach Tag From Specified Model ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="tag"></param>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpDelete("{id}/Tags/Detach")]
|
|
||||||
public virtual async Task<ActionResult> DetachTag(
|
|
||||||
[FromRoute] Guid id,
|
|
||||||
[FromQuery] string tag
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Do ...
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Retrieve User Info ...
|
|
||||||
var userInfo = await GetUserInfo();
|
|
||||||
var connectionId = GetConnectionId();
|
|
||||||
bool isAdmin = userInfo.Roles.Any(r => r.ToNormalString() == "admin");
|
|
||||||
var userId = userInfo.UserId;
|
|
||||||
|
|
||||||
//
|
|
||||||
await FileProvider.DetachTag(
|
|
||||||
id: id,
|
|
||||||
tag: tag,
|
|
||||||
userInfo: userInfo,
|
|
||||||
connectionId: connectionId
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = GetExceptionActionResult(ex);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Attach Tags to Specified Model ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="tags"></param>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost("{id}/Tags/AttachMany")]
|
|
||||||
public virtual async Task<ActionResult> AttachTags(
|
|
||||||
[FromRoute] Guid id,
|
|
||||||
[FromQuery] string tags
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Do ...
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var tagsList = tags.ParseListString<string>();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Retrieve User Info ...
|
|
||||||
var userInfo = await GetUserInfo();
|
|
||||||
var connectionId = GetConnectionId();
|
|
||||||
bool isAdmin = userInfo.Roles.Any(r => r.ToNormalString() == "admin");
|
|
||||||
var userId = userInfo.UserId;
|
|
||||||
|
|
||||||
//
|
|
||||||
await FileProvider.AttachTags(
|
|
||||||
id: id,
|
|
||||||
tags: tagsList,
|
|
||||||
userInfo: userInfo,
|
|
||||||
connectionId: connectionId
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = GetExceptionActionResult(ex);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Detach Tags From Specified Model ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="tags"></param>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpDelete("{id}/Tags/DetachMany")]
|
|
||||||
public virtual async Task<ActionResult> DetachTags(
|
|
||||||
[FromRoute] Guid id,
|
|
||||||
[FromQuery] string tags
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Do ...
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var tagsList = tags.ParseListString<string>();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Retrieve User Info ...
|
|
||||||
var userInfo = await GetUserInfo();
|
|
||||||
var connectionId = GetConnectionId();
|
|
||||||
bool isAdmin = userInfo.Roles.Any(r => r.ToNormalString() == "admin");
|
|
||||||
var userId = userInfo.UserId;
|
|
||||||
|
|
||||||
//
|
|
||||||
await FileProvider.DetachTags(
|
|
||||||
id: id,
|
|
||||||
tags: tagsList,
|
|
||||||
userInfo: userInfo,
|
|
||||||
connectionId: connectionId
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = GetExceptionActionResult(ex);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Retrieve Tags of Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("{id}/Tags")]
|
|
||||||
public virtual async Task<ActionResult<IEnumerable<string>>> GetTags(
|
|
||||||
[FromRoute] Guid id
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Do ...
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = await FileProvider.GetTags(id);
|
|
||||||
|
|
||||||
//
|
|
||||||
return Ok(result
|
|
||||||
.ToDynamicObject());
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = GetExceptionActionResult(ex);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
//
|
|
||||||
#region Tools ...
|
|
||||||
/// <summary>
|
|
||||||
/// Stream Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("{id}/Stream/ById")]
|
|
||||||
public virtual async Task<ActionResult> Stream(
|
|
||||||
[FromRoute] Guid id
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Do ...
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = await FileProvider.Stream(id);
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = GetExceptionActionResult(ex);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Stream Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("{name}/Stream/ByName")]
|
|
||||||
public virtual async Task<ActionResult> Stream(
|
|
||||||
[FromRoute] string name
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Do ...
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = await FileProvider.Stream(name);
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = GetExceptionActionResult(ex);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Download Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("{id}/Download/ById")]
|
|
||||||
public virtual async Task<ActionResult> Download(
|
|
||||||
[FromRoute] Guid id
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Do ...
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = await FileProvider.Download(id);
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = GetExceptionActionResult(ex);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Download Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fileName"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("{name}/Download/ByName")]
|
|
||||||
public virtual async Task<ActionResult> Download(
|
|
||||||
[FromRoute] string name
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Do ...
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = await FileProvider.Download(name);
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = GetExceptionActionResult(ex);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Upload Files ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="files"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost("")]
|
|
||||||
[RequestSizeLimit(966_367_641)]
|
|
||||||
public virtual async Task<ActionResult<IEnumerable<XFileDto>>> Upload(
|
|
||||||
[FromForm] IFormFileCollection files
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Do ...
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Retrieve User Info ...
|
|
||||||
var userInfo = await GetUserInfo();
|
|
||||||
var connectionId = GetConnectionId();
|
|
||||||
bool isAdmin = userInfo.Roles.Any(r => r.ToNormalString() == "admin");
|
|
||||||
var userId = userInfo.UserId;
|
|
||||||
|
|
||||||
//
|
|
||||||
var result = await FileProvider.Upload(
|
|
||||||
files: files,
|
|
||||||
userInfo: userInfo,
|
|
||||||
connectionId: connectionId
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
return Ok(result
|
|
||||||
.ToDynamicObject());
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = GetExceptionActionResult(ex);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove Specified Files ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ids"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
/// [HttpDelete("Remove")]
|
|
||||||
[HttpDelete("")]
|
|
||||||
public virtual async Task<ActionResult<IEnumerable<Guid>>> Remove(
|
|
||||||
[FromQuery] string ids
|
|
||||||
) {
|
|
||||||
//
|
|
||||||
// Do ...
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Retrieve User Info ...
|
|
||||||
var userInfo = await GetUserInfo();
|
|
||||||
var connectionId = GetConnectionId();
|
|
||||||
bool isAdmin = userInfo.Roles.Any(r => r.ToNormalString() == "admin");
|
|
||||||
var userId = userInfo.UserId;
|
|
||||||
|
|
||||||
//
|
|
||||||
var result = await FileProvider.Remove(
|
|
||||||
ids: ids,
|
|
||||||
userInfo: userInfo,
|
|
||||||
connectionId: connectionId
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
return Ok(result
|
|
||||||
.ToDynamicObject());
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = GetExceptionActionResult(ex);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
//
|
|
||||||
#region Model ...
|
|
||||||
/// <summary>
|
|
||||||
/// Get Specified File Model ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("{id}")]
|
|
||||||
public virtual async Task<ActionResult<XFileDto>> Get(
|
|
||||||
[FromRoute] Guid id
|
|
||||||
) {
|
|
||||||
//
|
|
||||||
// Do ...
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = await FileProvider.Get(id);
|
|
||||||
|
|
||||||
//
|
|
||||||
return Ok(result
|
|
||||||
.ToDynamicObject());
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = GetExceptionActionResult(ex);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get All Exists File Models ...
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("All")]
|
|
||||||
public virtual async Task<ActionResult<IEnumerable<XFileDto>>> GetAll() {
|
|
||||||
//
|
|
||||||
// Do ...
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = await FileProvider.GetAll();
|
|
||||||
|
|
||||||
//
|
|
||||||
return Ok(result
|
|
||||||
.ToDynamicObject());
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = GetExceptionActionResult(ex);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// retrieve Entities based on XQuery Pagination structure ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="query"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("Query")]
|
|
||||||
public virtual async Task<ActionResult<XQueryResult<XFileDto>>> Query(
|
|
||||||
[FromQuery] XQuery query
|
|
||||||
) {
|
|
||||||
//
|
|
||||||
// Do ...
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = await FileProvider.Query(query);
|
|
||||||
|
|
||||||
//
|
|
||||||
return Ok(result
|
|
||||||
.ToDynamicObject());
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = GetExceptionActionResult(ex);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// retrieve Owned Entities based on XQuery Pagination structure ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="query"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("Query/Owned")]
|
|
||||||
public virtual async Task<ActionResult<XQueryResult<XFileDto>>> QueryOwned(
|
|
||||||
[FromQuery] XQuery query
|
|
||||||
) {
|
|
||||||
//
|
|
||||||
// Do ...
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Retrieve User Info ...
|
|
||||||
var userInfo = await GetUserInfo();
|
|
||||||
|
|
||||||
//
|
|
||||||
var result = await FileProvider.QueryOwned(
|
|
||||||
query: query,
|
|
||||||
userInfo: userInfo
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
return Ok(result
|
|
||||||
.ToDynamicObject());
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = GetExceptionActionResult(ex);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// count all exists Entities ...
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("Count")]
|
|
||||||
public virtual async Task<ActionResult<int>> Count() {
|
|
||||||
//
|
|
||||||
// Do ...
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = await FileProvider.Count();
|
|
||||||
|
|
||||||
//
|
|
||||||
return Ok(result
|
|
||||||
.ToDynamicObject());
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = GetExceptionActionResult(ex);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Check an Entity exists or not ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("{id}/IsExists")]
|
|
||||||
public virtual async Task<ActionResult<bool>> IsExists(
|
|
||||||
[FromRoute] Guid id
|
|
||||||
) {
|
|
||||||
//
|
|
||||||
// Do ...
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = await FileProvider.IsExists(id);
|
|
||||||
|
|
||||||
//
|
|
||||||
return Ok(result
|
|
||||||
.ToDynamicObject());
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = GetExceptionActionResult(ex);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.EntityFrameworkCore.Query;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using xCommons.Configurations;
|
||||||
|
using xCommons.Providers;
|
||||||
|
using xFileService.Interfaces.Dtos;
|
||||||
|
using xFileService.Models.Dtos;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
using xFileService.Providers.Dtos;
|
||||||
|
using xIdentityService.Interfaces;
|
||||||
|
using xPushService.Controllers;
|
||||||
|
using xPushService.Interfaces;
|
||||||
|
|
||||||
|
namespace xFileService.Controllers
|
||||||
|
{
|
||||||
|
public abstract class XFileServiceProviderControllerBase : XBaseServiceProviderController<XFile, XFileDto, Guid, XFileDtoHub>, IXBaseServiceProviderController<XFile, XFileDto, Guid, XFileDtoHub>
|
||||||
|
{
|
||||||
|
protected XFileServiceProviderControllerBase(
|
||||||
|
ILogger<XFileServiceProviderControllerBase> logger,
|
||||||
|
XAppConfiguration appConfiguration,
|
||||||
|
IXIdentityProvider identityProvider,
|
||||||
|
XValidationProvider validationProvider,
|
||||||
|
IXFileServiceProvider provider,
|
||||||
|
Func<IQueryable<XFile>, IOrderedQueryable<XFile>> defaultOrderBuilder = null,
|
||||||
|
Func<IQueryable<XFile>, IIncludableQueryable<XFile, object>> defaultIncludeBuilder = null
|
||||||
|
) : base(
|
||||||
|
logger,
|
||||||
|
appConfiguration,
|
||||||
|
identityProvider,
|
||||||
|
validationProvider,
|
||||||
|
provider,
|
||||||
|
defaultOrderBuilder,
|
||||||
|
defaultIncludeBuilder
|
||||||
|
)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
+135
-33
@@ -1,12 +1,20 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using xCommons.Extensions;
|
using xCommons.Extensions;
|
||||||
|
using xCommons.Helpers;
|
||||||
|
using xDataService.Constants;
|
||||||
|
using xDataService.Db;
|
||||||
|
using xDataService.DI;
|
||||||
|
using xDataService.Models;
|
||||||
using xExceptions.Constants;
|
using xExceptions.Constants;
|
||||||
using xFileService.Interfaces;
|
using xPushService.DI;
|
||||||
|
using xPushService.Helpers;
|
||||||
|
using xFileService.Helpers;
|
||||||
|
using xFileService.Interfaces.Dtos;
|
||||||
using xFileService.Interfaces.Entities;
|
using xFileService.Interfaces.Entities;
|
||||||
using xFileService.Providers;
|
using xFileService.Providers.Dtos;
|
||||||
using xStorageService.Interfaces;
|
using xFileService.Providers.Entities;
|
||||||
using xTagService.Interfaces;
|
|
||||||
|
|
||||||
namespace xFileService.DI
|
namespace xFileService.DI
|
||||||
{
|
{
|
||||||
@@ -16,21 +24,83 @@ namespace xFileService.DI
|
|||||||
/// Register Service ...
|
/// Register Service ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="services"></param>
|
/// <param name="services"></param>
|
||||||
/// <param name="config"></param>
|
/// <param name="repositoryType"></param>
|
||||||
|
/// <param name="lifeTime"></param>
|
||||||
public static void AddXFileService(
|
public static void AddXFileService(
|
||||||
this IServiceCollection services,
|
this IServiceCollection services,
|
||||||
ServiceLifetime lifeTime
|
XRepositoryType repositoryType,
|
||||||
|
ServiceLifetime lifeTime = ServiceLifetime.Scoped
|
||||||
|
)
|
||||||
|
{
|
||||||
|
AddFileService(
|
||||||
|
contextType: null,
|
||||||
|
services: services,
|
||||||
|
lifeTime: lifeTime,
|
||||||
|
repositoryType: repositoryType
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Register Service ...
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TContext"></typeparam>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
/// <param name="repositoryType"></param>
|
||||||
|
/// <param name="lifeTime"></param>
|
||||||
|
public static void AddXFileService<TContext>(
|
||||||
|
this IServiceCollection services,
|
||||||
|
XRepositoryType repositoryType,
|
||||||
|
ServiceLifetime lifeTime = ServiceLifetime.Scoped
|
||||||
|
)
|
||||||
|
where TContext : XDbContext
|
||||||
|
{
|
||||||
|
AddFileService(
|
||||||
|
services: services,
|
||||||
|
lifeTime: lifeTime,
|
||||||
|
contextType: typeof(TContext),
|
||||||
|
repositoryType: repositoryType
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Use XFileService Middleware ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="app"></param>
|
||||||
|
/// <param name="isDevelopmentEnvironment"></param>
|
||||||
|
public static void UseXFileService(
|
||||||
|
this IApplicationBuilder app,
|
||||||
|
bool isDevelopmentEnvironment = false
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
AddFileService(
|
#region Using XFile Hubs ...
|
||||||
services,
|
//
|
||||||
lifeTime
|
var pushHelper = new XPushServiceHelper();
|
||||||
);
|
|
||||||
|
//
|
||||||
|
pushHelper.AddHub<XFileDtoHub>("fileDto");
|
||||||
|
pushHelper.AddHub<XFileEntityHub>("fileEntity");
|
||||||
|
|
||||||
|
//
|
||||||
|
app.UseXPushService(pushHelper);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
// Using XFile Repository Descriptor ...
|
||||||
|
if (!descriptor.IsNull())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
app.UseXRepository(
|
||||||
|
descriptor: descriptor,
|
||||||
|
isDevelopmentEnvironment: isDevelopmentEnvironment
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
#region Private ...
|
#region Private ...
|
||||||
|
private static XRepositoryDescriptor descriptor = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// a LogTag for Service ...
|
/// a LogTag for Service ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -49,10 +119,14 @@ namespace xFileService.DI
|
|||||||
/// Register Service ...
|
/// Register Service ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="services"></param>
|
/// <param name="services"></param>
|
||||||
|
/// <param name="repositoryType"></param>
|
||||||
|
/// <param name="contextType"></param>
|
||||||
/// <param name="lifeTime"></param>
|
/// <param name="lifeTime"></param>
|
||||||
private static void AddFileService(
|
private static void AddFileService(
|
||||||
IServiceCollection services,
|
IServiceCollection services,
|
||||||
ServiceLifetime lifeTime
|
XRepositoryType repositoryType,
|
||||||
|
Type contextType = null,
|
||||||
|
ServiceLifetime lifeTime = ServiceLifetime.Scoped
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -64,7 +138,7 @@ namespace xFileService.DI
|
|||||||
if (!isServicesExists)
|
if (!isServicesExists)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
Log("AddFileService failed, services not provided ...");
|
Log("Service Registration failed, services not provided ...");
|
||||||
throw exception;
|
throw exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,46 +148,74 @@ namespace xFileService.DI
|
|||||||
if (!isLifetimeExists)
|
if (!isLifetimeExists)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
Log("AddFileService failed, lifetime not provided ...");
|
Log("Service Registration failed, lifetime not provided ...");
|
||||||
throw exception;
|
throw exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check Dependencies Exists ...
|
// Validate Repository Type ...
|
||||||
var isDependenciesPassed = !services
|
var isRepositoryTypeValid =
|
||||||
.GetRegisteredService<IXStorageProvider>()
|
(repositoryType == XRepositoryType.EF &&
|
||||||
.IsNull() &&
|
!contextType.IsNull()) ||
|
||||||
!services.GetRegisteredService<IXTagProvider>().IsNull();
|
((repositoryType == XRepositoryType.Mongo ||
|
||||||
if (!isDependenciesPassed)
|
repositoryType == XRepositoryType.InMemory) &&
|
||||||
|
contextType.IsNull());
|
||||||
|
if (!isRepositoryTypeValid)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
Log("AddFileService failed due Dependencies Issues, IXTagProvider, IXStorageProvider not provided ...");
|
Log("Service Registration failed, Invalid Repository Type and Context Type ...");
|
||||||
throw exception;
|
throw exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check Repository Exists ...
|
// Maske Instance of Repository Descriptor
|
||||||
var isRepositoryExists = !services
|
// Based on Provided Type ...
|
||||||
.GetRegisteredService<IXFileRepository>()
|
switch (repositoryType)
|
||||||
.IsNull();
|
|
||||||
if (!isRepositoryExists)
|
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
Log("AddFileService failed, IXFileRepository not provided ...");
|
case XRepositoryType.EF:
|
||||||
throw exception;
|
//
|
||||||
|
descriptor = typeof(XFileServiceHelper)
|
||||||
|
.InvokeGenericMethod<XRepositoryDescriptor>(
|
||||||
|
methodName: "GetXFileEFRepositoryDescriptor",
|
||||||
|
runtimeType: contextType,
|
||||||
|
args: null
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case XRepositoryType.Mongo:
|
||||||
|
descriptor = XFileServiceHelper.GetXFileMongoRepositoryDescriptor();
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case XRepositoryType.InMemory:
|
||||||
|
descriptor = XFileServiceHelper.GetXFileInMemoryRepositoryDescriptor();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Register Tag Provider for Files ...
|
// Register XFile Repository Descriptor ...
|
||||||
services.Add(new ServiceDescriptor(typeof(IXFileTagProvider), typeof(XFileTagProvider), lifeTime));
|
services.AddXRepository(
|
||||||
|
lifeTime: lifeTime,
|
||||||
|
descriptor: descriptor
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Register Main Provider ...
|
// Register Dto Services ...
|
||||||
services.Add(new ServiceDescriptor(typeof(IXFileProvider), typeof(XFileProvider), lifeTime));
|
services.Add(
|
||||||
|
new ServiceDescriptor(typeof(IXFileServiceProvider), typeof(XFileServiceProvider), lifeTime)
|
||||||
|
);
|
||||||
|
services.Add(
|
||||||
|
new ServiceDescriptor(typeof(IXFileRepositoryService), typeof(XFileRepositoryService), lifeTime)
|
||||||
|
);
|
||||||
|
services.Add(
|
||||||
|
new ServiceDescriptor(typeof(IXFileRepositoryProvider), typeof(XFileRepositoryProvider), lifeTime)
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
Log("AddFileService Succeed ...");
|
Log("Service Regitration Succeed ...");
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
using xDataService.Events;
|
|
||||||
using xFileService.Interfaces.Entities;
|
|
||||||
using xFileService.Models.Entities;
|
|
||||||
|
|
||||||
namespace xFileService.DataHelper.Events
|
|
||||||
{
|
|
||||||
public class XFileEvents : XBaseRepositoryEvents<XFile>, IXFileEvents
|
|
||||||
{ }
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,149 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using xCommons.Extensions;
|
||||||
|
using xDataService.Extensions;
|
||||||
|
using xDataService.Models;
|
||||||
|
using xFileService.Models.Dtos;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
|
||||||
|
namespace xFileService.Extensions
|
||||||
|
{
|
||||||
|
public static class XModelExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Extract References of a Model ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IList<XReference<string>> GetReferences(
|
||||||
|
this XFile source
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = new List<XReference<string>>();
|
||||||
|
|
||||||
|
//
|
||||||
|
if (
|
||||||
|
!source.IsNullOrDefault() &&
|
||||||
|
!source.References.IsNullOrEmpty()
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = source.References
|
||||||
|
.ParseXReferenceList<string>()
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extract References of a Model ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IList<XReference<string>> GetReferences(
|
||||||
|
this XFileDto source
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = new List<XReference<string>>();
|
||||||
|
|
||||||
|
//
|
||||||
|
if (
|
||||||
|
!source.IsNullOrDefault() &&
|
||||||
|
!source.References.IsNullOrEmpty()
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = source.References
|
||||||
|
.ParseXReferenceList<string>()
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update a Model's References by Providing References List ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <param name="references"></param>
|
||||||
|
/// <param name="forceClean"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static XFile UpdateReferences(
|
||||||
|
this XFile source,
|
||||||
|
IList<XReference<string>> references,
|
||||||
|
bool forceClean = true
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XFile result = source;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!source.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = source;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (forceClean)
|
||||||
|
{
|
||||||
|
result.References = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!references.IsNull() &&
|
||||||
|
references.HasChild())
|
||||||
|
{
|
||||||
|
result.References = references.ToXReferenceString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update a Model's References by Providing References List ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <param name="references"></param>
|
||||||
|
/// <param name="forceClean"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static XFileDto UpdateReferences(
|
||||||
|
this XFileDto source,
|
||||||
|
IList<XReference<string>> references,
|
||||||
|
bool forceClean = true
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XFileDto result = source;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!source.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = source;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (forceClean)
|
||||||
|
{
|
||||||
|
result.References = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!references.IsNull() &&
|
||||||
|
references.HasChild())
|
||||||
|
{
|
||||||
|
result.References = references.ToXReferenceString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using xCommons.Extensions;
|
|
||||||
using xDataService.Extensions;
|
|
||||||
using xFileService.Models.Dtos;
|
|
||||||
using xFileService.Models.Entities;
|
|
||||||
|
|
||||||
namespace xFileService.Extensions
|
|
||||||
{
|
|
||||||
public static class xFileServiceExtensions
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Map Global Properties From XFile to XFile Dto ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="source"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static XFileDto ToDto(this XFile source)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XFileDto result = null;
|
|
||||||
|
|
||||||
//
|
|
||||||
if (!source.IsNullOrDefault())
|
|
||||||
{
|
|
||||||
//
|
|
||||||
result = new XFileDto();
|
|
||||||
result = result.UpdateData(
|
|
||||||
updateWith: source,
|
|
||||||
propertyBlackList: new List<string>
|
|
||||||
{
|
|
||||||
nameof(XFileDto.Owner),
|
|
||||||
nameof(XFile.Deleted),
|
|
||||||
nameof(XFile.References),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Preparing List ...
|
|
||||||
if (!source.References.IsNullOrEmpty())
|
|
||||||
{
|
|
||||||
result.References = source.References.ParseXReferenceList<string>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Converts a Dto to Entity Representation ...
|
|
||||||
/// Ignore ID Property ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="source"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static XFile FromDto(this XFileDto source)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = new XFile();
|
|
||||||
|
|
||||||
//
|
|
||||||
if (!source.IsNull())
|
|
||||||
{
|
|
||||||
//
|
|
||||||
result = result.UpdateData(
|
|
||||||
updateWith: source,
|
|
||||||
propertyBlackList: new List<string>
|
|
||||||
{
|
|
||||||
nameof(XFile.Deleted),
|
|
||||||
nameof(XFile.References),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
if (!source.References.IsNull() && source.References.HasChild())
|
|
||||||
{
|
|
||||||
result.References = source.References.ToXReferenceString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,280 @@
|
|||||||
|
using System;
|
||||||
|
using GraphQL.Types;
|
||||||
|
using xDataService.Db;
|
||||||
|
using xDataService.Models;
|
||||||
|
using xDataService.Providers;
|
||||||
|
using xFileService.Interfaces;
|
||||||
|
using xFileService.Interfaces.Entities;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
using xFileService.Providers.Entities;
|
||||||
|
using xFileService.Providers.GraphQL;
|
||||||
|
|
||||||
|
namespace xFileService.Helpers
|
||||||
|
{
|
||||||
|
public static class XFileServiceHelper
|
||||||
|
{
|
||||||
|
//
|
||||||
|
#region EF Repository Descriptor Provider(s) ...
|
||||||
|
public static XEFRepositoryDescriptor<
|
||||||
|
XFile,
|
||||||
|
Guid,
|
||||||
|
IXFileKeyGenerator,
|
||||||
|
XFileKeyGenerator,
|
||||||
|
IXFileRepositoryEvents,
|
||||||
|
XFileRepositoryEvents,
|
||||||
|
XFileGraphType,
|
||||||
|
GuidGraphType,
|
||||||
|
XFileGraphQuery,
|
||||||
|
IXFileGraphQLTypeHelper,
|
||||||
|
XFileGraphQLTypeHelper,
|
||||||
|
XFileGraphSchema,
|
||||||
|
IXFileRepository,
|
||||||
|
XFileEFRepository<TContext>,
|
||||||
|
TContext
|
||||||
|
> GetXFileEFRepositoryDescriptor<TContext>()
|
||||||
|
where TContext : XDbContext
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = new XEFRepositoryDescriptor<
|
||||||
|
XFile,
|
||||||
|
Guid,
|
||||||
|
IXFileKeyGenerator,
|
||||||
|
XFileKeyGenerator,
|
||||||
|
IXFileRepositoryEvents,
|
||||||
|
XFileRepositoryEvents,
|
||||||
|
XFileGraphType,
|
||||||
|
GuidGraphType,
|
||||||
|
XFileGraphQuery,
|
||||||
|
IXFileGraphQLTypeHelper,
|
||||||
|
XFileGraphQLTypeHelper,
|
||||||
|
XFileGraphSchema,
|
||||||
|
IXFileRepository,
|
||||||
|
XFileEFRepository<TContext>,
|
||||||
|
TContext
|
||||||
|
>();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static XEFRepositoryDescriptor<
|
||||||
|
XFile,
|
||||||
|
Guid,
|
||||||
|
IXFileKeyGenerator,
|
||||||
|
XFileKeyGenerator,
|
||||||
|
IXFileRepositoryEvents,
|
||||||
|
XFileRepositoryEvents,
|
||||||
|
XFileGraphType,
|
||||||
|
GuidGraphType,
|
||||||
|
XFileGraphQuery,
|
||||||
|
IXFileGraphQLTypeHelper,
|
||||||
|
XFileGraphQLTypeHelper,
|
||||||
|
XFileGraphSchema,
|
||||||
|
IXFileRepository,
|
||||||
|
XFileEFRepository<TContext>,
|
||||||
|
TContext,
|
||||||
|
IXFileSeeder,
|
||||||
|
TSeederImplementation
|
||||||
|
> GetXFileEFRepositoryDescriptor<TContext, TSeederImplementation>()
|
||||||
|
where TContext : XDbContext
|
||||||
|
where TSeederImplementation : XBaseDbSeeder<XFile, Guid>
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = new XEFRepositoryDescriptor<
|
||||||
|
XFile,
|
||||||
|
Guid,
|
||||||
|
IXFileKeyGenerator,
|
||||||
|
XFileKeyGenerator,
|
||||||
|
IXFileRepositoryEvents,
|
||||||
|
XFileRepositoryEvents,
|
||||||
|
XFileGraphType,
|
||||||
|
GuidGraphType,
|
||||||
|
XFileGraphQuery,
|
||||||
|
IXFileGraphQLTypeHelper,
|
||||||
|
XFileGraphQLTypeHelper,
|
||||||
|
XFileGraphSchema,
|
||||||
|
IXFileRepository,
|
||||||
|
XFileEFRepository<TContext>,
|
||||||
|
TContext,
|
||||||
|
IXFileSeeder,
|
||||||
|
TSeederImplementation
|
||||||
|
>();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Mongo Repository Descriptor Provider(s) ...
|
||||||
|
public static XMongoRepositoryDescriptor<
|
||||||
|
XFile,
|
||||||
|
Guid,
|
||||||
|
IXFileKeyGenerator,
|
||||||
|
XFileKeyGenerator,
|
||||||
|
IXFileRepositoryEvents,
|
||||||
|
XFileRepositoryEvents,
|
||||||
|
XFileGraphType,
|
||||||
|
GuidGraphType,
|
||||||
|
XFileGraphQuery,
|
||||||
|
IXFileGraphQLTypeHelper,
|
||||||
|
XFileGraphQLTypeHelper,
|
||||||
|
XFileGraphSchema,
|
||||||
|
IXFileRepository,
|
||||||
|
XFileMongoRepository
|
||||||
|
> GetXFileMongoRepositoryDescriptor()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = new XMongoRepositoryDescriptor<
|
||||||
|
XFile,
|
||||||
|
Guid,
|
||||||
|
IXFileKeyGenerator,
|
||||||
|
XFileKeyGenerator,
|
||||||
|
IXFileRepositoryEvents,
|
||||||
|
XFileRepositoryEvents,
|
||||||
|
XFileGraphType,
|
||||||
|
GuidGraphType,
|
||||||
|
XFileGraphQuery,
|
||||||
|
IXFileGraphQLTypeHelper,
|
||||||
|
XFileGraphQLTypeHelper,
|
||||||
|
XFileGraphSchema,
|
||||||
|
IXFileRepository,
|
||||||
|
XFileMongoRepository
|
||||||
|
>();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static XMongoRepositoryDescriptor<
|
||||||
|
XFile,
|
||||||
|
Guid,
|
||||||
|
IXFileKeyGenerator,
|
||||||
|
XFileKeyGenerator,
|
||||||
|
IXFileRepositoryEvents,
|
||||||
|
XFileRepositoryEvents,
|
||||||
|
XFileGraphType,
|
||||||
|
GuidGraphType,
|
||||||
|
XFileGraphQuery,
|
||||||
|
IXFileGraphQLTypeHelper,
|
||||||
|
XFileGraphQLTypeHelper,
|
||||||
|
XFileGraphSchema,
|
||||||
|
IXFileRepository,
|
||||||
|
XFileMongoRepository,
|
||||||
|
IXFileSeeder,
|
||||||
|
TSeederImplementation
|
||||||
|
> GetXFileMongoRepositoryDescriptor<TSeederImplementation>()
|
||||||
|
where TSeederImplementation : XBaseDbSeeder<XFile, Guid>
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = new XMongoRepositoryDescriptor<
|
||||||
|
XFile,
|
||||||
|
Guid,
|
||||||
|
IXFileKeyGenerator,
|
||||||
|
XFileKeyGenerator,
|
||||||
|
IXFileRepositoryEvents,
|
||||||
|
XFileRepositoryEvents,
|
||||||
|
XFileGraphType,
|
||||||
|
GuidGraphType,
|
||||||
|
XFileGraphQuery,
|
||||||
|
IXFileGraphQLTypeHelper,
|
||||||
|
XFileGraphQLTypeHelper,
|
||||||
|
XFileGraphSchema,
|
||||||
|
IXFileRepository,
|
||||||
|
XFileMongoRepository,
|
||||||
|
IXFileSeeder,
|
||||||
|
TSeederImplementation
|
||||||
|
>();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region InMemory Repository Descriptor Provider(s) ...
|
||||||
|
public static XInMemoryRepositoryDescriptor<
|
||||||
|
XFile,
|
||||||
|
Guid,
|
||||||
|
IXFileKeyGenerator,
|
||||||
|
XFileKeyGenerator,
|
||||||
|
IXFileRepositoryEvents,
|
||||||
|
XFileRepositoryEvents,
|
||||||
|
XFileGraphType,
|
||||||
|
GuidGraphType,
|
||||||
|
XFileGraphQuery,
|
||||||
|
IXFileGraphQLTypeHelper,
|
||||||
|
XFileGraphQLTypeHelper,
|
||||||
|
XFileGraphSchema,
|
||||||
|
IXFileRepository,
|
||||||
|
XFileInMemoryRepository
|
||||||
|
> GetXFileInMemoryRepositoryDescriptor()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = new XInMemoryRepositoryDescriptor<
|
||||||
|
XFile,
|
||||||
|
Guid,
|
||||||
|
IXFileKeyGenerator,
|
||||||
|
XFileKeyGenerator,
|
||||||
|
IXFileRepositoryEvents,
|
||||||
|
XFileRepositoryEvents,
|
||||||
|
XFileGraphType,
|
||||||
|
GuidGraphType,
|
||||||
|
XFileGraphQuery,
|
||||||
|
IXFileGraphQLTypeHelper,
|
||||||
|
XFileGraphQLTypeHelper,
|
||||||
|
XFileGraphSchema,
|
||||||
|
IXFileRepository,
|
||||||
|
XFileInMemoryRepository
|
||||||
|
>();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static XInMemoryRepositoryDescriptor<
|
||||||
|
XFile,
|
||||||
|
Guid,
|
||||||
|
IXFileKeyGenerator,
|
||||||
|
XFileKeyGenerator,
|
||||||
|
IXFileRepositoryEvents,
|
||||||
|
XFileRepositoryEvents,
|
||||||
|
XFileGraphType,
|
||||||
|
GuidGraphType,
|
||||||
|
XFileGraphQuery,
|
||||||
|
IXFileGraphQLTypeHelper,
|
||||||
|
XFileGraphQLTypeHelper,
|
||||||
|
XFileGraphSchema,
|
||||||
|
IXFileRepository,
|
||||||
|
XFileInMemoryRepository,
|
||||||
|
IXFileSeeder,
|
||||||
|
TSeederImplementation
|
||||||
|
> GetXFileInMemoryRepositoryDescriptor<TSeederImplementation>()
|
||||||
|
where TSeederImplementation : XBaseDbSeeder<XFile, Guid>
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = new XInMemoryRepositoryDescriptor<
|
||||||
|
XFile,
|
||||||
|
Guid,
|
||||||
|
IXFileKeyGenerator,
|
||||||
|
XFileKeyGenerator,
|
||||||
|
IXFileRepositoryEvents,
|
||||||
|
XFileRepositoryEvents,
|
||||||
|
XFileGraphType,
|
||||||
|
GuidGraphType,
|
||||||
|
XFileGraphQuery,
|
||||||
|
IXFileGraphQLTypeHelper,
|
||||||
|
XFileGraphQLTypeHelper,
|
||||||
|
XFileGraphSchema,
|
||||||
|
IXFileRepository,
|
||||||
|
XFileInMemoryRepository,
|
||||||
|
IXFileSeeder,
|
||||||
|
TSeederImplementation
|
||||||
|
>();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using xFileService.Models.Entities;
|
|
||||||
using xPushService.Base;
|
|
||||||
|
|
||||||
namespace xFileService.Hubs
|
|
||||||
{
|
|
||||||
public class XFileEntityHub : XBaseEntityHub<XFile, Guid>
|
|
||||||
{
|
|
||||||
//
|
|
||||||
#region Constructor ...
|
|
||||||
public XFileEntityHub(ILogger<XBaseHub> logger) : base(logger)
|
|
||||||
{ }
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using xFileService.Models.Dtos;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
using xPushService.Interfaces;
|
||||||
|
|
||||||
|
namespace xFileService.Interfaces.Dtos
|
||||||
|
{
|
||||||
|
public interface IXFileDtoHub : IXBaseDtoHub<XFile, XFileDto, Guid>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using xDataService.Interfaces;
|
||||||
|
using xFileService.Models.Dtos;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
|
||||||
|
namespace xFileService.Interfaces.Dtos
|
||||||
|
{
|
||||||
|
public interface IXFileRepositoryService : IXBaseRepositoryService<XFile, XFileDto, Guid>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
using xFileService.Models.Dtos;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
using xFileService.Providers.Dtos;
|
||||||
|
using xPushService.Interfaces;
|
||||||
|
|
||||||
|
namespace xFileService.Interfaces.Dtos
|
||||||
|
{
|
||||||
|
public interface IXFileServiceProvider : IXBaseDtoProvider<XFile, XFileDto, Guid, XFileDtoHub>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using System;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
using xPushService.Interfaces;
|
||||||
|
|
||||||
|
namespace xFileService.Interfaces.Entities
|
||||||
|
{
|
||||||
|
public interface IXFileEntityHub : IXBaseEntityHub<XFile, Guid>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using System;
|
||||||
|
using xDataService.Interfaces;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
|
||||||
|
namespace xFileService.Interfaces.Entities
|
||||||
|
{
|
||||||
|
public interface IXFileKeyGenerator : IXKeyGenerator<XFile, Guid>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -3,6 +3,6 @@ using xFileService.Models.Entities;
|
|||||||
|
|
||||||
namespace xFileService.Interfaces.Entities
|
namespace xFileService.Interfaces.Entities
|
||||||
{
|
{
|
||||||
public interface IXFileEvents : IXBaseRepositoryEvents<XFile>
|
public interface IXFileRepositoryEvents : IXBaseRepositoryEvents<XFile>
|
||||||
{ }
|
{ }
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
using xFileService.Providers.Entities;
|
||||||
|
using xPushService.Interfaces;
|
||||||
|
|
||||||
|
namespace xFileService.Interfaces.Entities
|
||||||
|
{
|
||||||
|
public interface IXFileRepositoryProvider : IXBaseEntityProvider<XFile, Guid, XFileEntityHub>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using xFileService.Models.Dtos;
|
|
||||||
using xIdentityModels.Models;
|
|
||||||
using xIdentityService.Interfaces;
|
|
||||||
using XFileDto = xFileService.Models.Dtos.XFileDto;
|
|
||||||
|
|
||||||
namespace xFileService.Interfaces
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Implementing XBaseFileProvider ...
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TKey"></typeparam>
|
|
||||||
public interface IXBaseFileProvider<TKey> : IXIdentityBaseReferencedProvider<XFileDto, TKey>
|
|
||||||
{
|
|
||||||
//
|
|
||||||
#region Props ...
|
|
||||||
/// <summary>
|
|
||||||
/// Specified Provider Repositroy ...
|
|
||||||
/// </summary>
|
|
||||||
IXFileProvider FileProvider { get; }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
//
|
|
||||||
#region Tools ...
|
|
||||||
/// <summary>
|
|
||||||
/// Stream Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<FileStreamResult> Stream(Guid id);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Stream Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fileName"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<FileStreamResult> Stream(string fileName);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Download Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<PhysicalFileResult> Download(Guid id);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Download Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fileName"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<PhysicalFileResult> Download(string fileName);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Upload Files ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="forProvidedId"></param>
|
|
||||||
/// <param name="files"></param>
|
|
||||||
/// <param name="connectionId"></param>
|
|
||||||
/// <param name="userInfo"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<IEnumerable<XFileDto>> Upload(
|
|
||||||
TKey forProvidedId,
|
|
||||||
IFormFileCollection files,
|
|
||||||
string connectionId = null,
|
|
||||||
XUserClaimsInfoDto userInfo = null
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Retrieve Specified File Streaming Info ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<XFileStreamDescriptorDto> GetFileDescriptor(Guid id);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Retrieve Specified File Streaming Info ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fileName"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<XFileStreamDescriptorDto> GetFileDescriptor(string fileName);
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,398 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.AspNetCore.SignalR;
|
|
||||||
using xDataService.Configuration;
|
|
||||||
using xFileService.Hubs;
|
|
||||||
using xFileService.Interfaces.Entities;
|
|
||||||
using xFileService.Models.Dtos;
|
using xFileService.Models.Dtos;
|
||||||
using xFileService.Models.Entities;
|
using xFileService.Models.Entities;
|
||||||
using xIdentityModels.Models;
|
using xFileService.Providers.Dtos;
|
||||||
using xIdentityService.Interfaces;
|
using xIdentityService.Interfaces;
|
||||||
using xModels.Dtos;
|
using xTagService.Interfaces;
|
||||||
using xStorageService.Interfaces;
|
|
||||||
using XFileDto = xFileService.Models.Dtos.XFileDto;
|
|
||||||
|
|
||||||
namespace xFileService.Interfaces
|
namespace xFileService.Interfaces
|
||||||
{
|
{
|
||||||
public interface IXFileProvider
|
public interface IXFileProvider : IXBaseProvidedHasTag<XFile, XFileDto, Guid, XFileDtoHub>, IXBaseReferenced
|
||||||
{
|
{}
|
||||||
//
|
|
||||||
#region Props ...
|
|
||||||
IXFileTagProvider TagProvider { get; }
|
|
||||||
IHubContext<XFileEntityHub> Hub { get; }
|
|
||||||
IXFileRepository FileRepository { get; }
|
|
||||||
IXStorageProvider StorageProvider { get; }
|
|
||||||
IXIdentityProvider IdentityProvider { get; }
|
|
||||||
XDataServiceConfiguration DataSercviceConfiguration { get; }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
//
|
|
||||||
#region Helpers ...
|
|
||||||
/// <summary>
|
|
||||||
/// Converts an Entity to Dto ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="model"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<XFileDto> ToDto(XFile model);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Convert a List of Entities to Dto ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="list"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<IEnumerable<XFileDto>> ToDtoList(IEnumerable<XFile> list);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Converts an Entity Query Result to Dto ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="queryResult"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<XQueryResult<XFileDto>> ToDtoQueryResult(XQueryResult<XFile> queryResult);
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
//
|
|
||||||
#region Tags ...
|
|
||||||
/// <summary>
|
|
||||||
/// Attach Tag to Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="tag"></param>
|
|
||||||
/// <param name="userInfo"></param>
|
|
||||||
/// <param name="connectionId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task AttachTag(
|
|
||||||
Guid id,
|
|
||||||
string tag,
|
|
||||||
XUserClaimsInfoDto userInfo = null,
|
|
||||||
string connectionId = null
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Detach Tag fro Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="tag"></param>
|
|
||||||
/// <param name="userInfo"></param>
|
|
||||||
/// <param name="connectionId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task DetachTag(
|
|
||||||
Guid id,
|
|
||||||
string tag,
|
|
||||||
XUserClaimsInfoDto userInfo = null,
|
|
||||||
string connectionId = null
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Attach Tags for Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="tags"></param>
|
|
||||||
/// <param name="userInfo"></param>
|
|
||||||
/// <param name="connectionId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task AttachTags(
|
|
||||||
Guid id,
|
|
||||||
IEnumerable<string> tags,
|
|
||||||
XUserClaimsInfoDto userInfo = null,
|
|
||||||
string connectionId = null
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Detach Tags for Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="tags"></param>
|
|
||||||
/// <param name="userInfo"></param>
|
|
||||||
/// <param name="connectionId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task DetachTags(
|
|
||||||
Guid id,
|
|
||||||
IEnumerable<string> tags,
|
|
||||||
XUserClaimsInfoDto userInfo = null,
|
|
||||||
string connectionId = null
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Detach all Attached Tags for Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="userInfo"></param>
|
|
||||||
/// <param name="connectionId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task DetachTags(
|
|
||||||
Guid id,
|
|
||||||
XUserClaimsInfoDto userInfo = null,
|
|
||||||
string connectionId = null
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get Specified Model's Tag ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<IEnumerable<string>> GetTags(Guid id);
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
//
|
|
||||||
#region Tools ...
|
|
||||||
/// <summary>
|
|
||||||
/// Stream Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<FileStreamResult> Stream(Guid id);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Stream Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fileName"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<FileStreamResult> Stream(string fileName);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Download Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<PhysicalFileResult> Download(Guid id);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Download Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fileName"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<PhysicalFileResult> Download(string fileName);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Upload Files ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="files"></param>
|
|
||||||
/// <param name="userInfo"></param>
|
|
||||||
/// <param name="connectionId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<IEnumerable<XFileDto>> Upload(
|
|
||||||
IFormFileCollection files,
|
|
||||||
XUserClaimsInfoDto userInfo = null,
|
|
||||||
string connectionId = null
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove Specified Files ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ids"></param>
|
|
||||||
/// <param name="userInfo"></param>
|
|
||||||
/// <param name="connectionId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<IEnumerable<Guid>> Remove(
|
|
||||||
string ids,
|
|
||||||
XUserClaimsInfoDto userInfo = null,
|
|
||||||
string connectionId = null
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Retrieve Specified File Streaming Info ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<XFileStreamDescriptorDto> GetFileDescriptor(Guid id);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Retrieve Specified File Streaming Info ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fileName"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<XFileStreamDescriptorDto> GetFileDescriptor(string fileName);
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
//
|
|
||||||
#region Reference ...
|
|
||||||
/// <summary>
|
|
||||||
/// Get Reference Identifier for Specified Provider and Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="providedFor"></param>
|
|
||||||
/// <param name="forProvidedId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
string GetIdentifier<TKey>(
|
|
||||||
string providedFor,
|
|
||||||
TKey forProvidedId
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Check Specified File has Refernce to Provider ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="providedFor"></param>
|
|
||||||
/// <param name="forProvidedId"></param>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<bool> IsProvidedFor<TKey>(
|
|
||||||
string providedFor,
|
|
||||||
TKey forProvidedId,
|
|
||||||
Guid id
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Add Specified Reference to Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="providedFor"></param>
|
|
||||||
/// <param name="forProvidedId"></param>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="forIndex"></param>
|
|
||||||
/// <param name="userInfo"></param>
|
|
||||||
/// <param name="connectionId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task AddReference<TKey>(
|
|
||||||
string providedFor,
|
|
||||||
TKey forProvidedId,
|
|
||||||
Guid id,
|
|
||||||
int forIndex = 0,
|
|
||||||
XUserClaimsInfoDto userInfo = null,
|
|
||||||
string connectionId = null
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove Specified Reference from Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="providedFor"></param>
|
|
||||||
/// <param name="forProvidedId"></param>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="forIndex"></param>
|
|
||||||
/// <param name="userInfo"></param>
|
|
||||||
/// <param name="connectionId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task RemoveReference<TKey>(
|
|
||||||
string providedFor,
|
|
||||||
TKey forProvidedId,
|
|
||||||
Guid id,
|
|
||||||
int forIndex = 0,
|
|
||||||
XUserClaimsInfoDto userInfo = null,
|
|
||||||
string connectionId = null
|
|
||||||
);
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
//
|
|
||||||
#region Data Model ...
|
|
||||||
/// <summary>
|
|
||||||
/// Get Specified File Model ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="ignoreSoftDeleteds"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<XFileDto> Get(
|
|
||||||
Guid id
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get All Exists File Models ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ignoreSoftDeleteds"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<IEnumerable<XFileDto>> GetAll();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// find an Entity by providing a Conditional Expression ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="whereClause"></param>
|
|
||||||
Task<XFileDto> FindOne(Expression<Func<XFile, bool>> whereClause);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// find a collection of Entities by proving a Conditional Expression ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="whereClause"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<IEnumerable<XFileDto>> FindMany(
|
|
||||||
Expression<Func<XFile, bool>> whereClause
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// retrieve Entities based on XQuery Pagination structure ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="query"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<XQueryResult<XFileDto>> Query(
|
|
||||||
XQuery query
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// retrieve Owned Entities based on XQuery Pagination structure ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="query"></param>
|
|
||||||
/// <param name="userInfo"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<XQueryResult<XFileDto>> QueryOwned(
|
|
||||||
XQuery query,
|
|
||||||
XUserClaimsInfoDto userInfo = null
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// retrieve Entities based on XQuery Pagination structure by providing a Conditional Expression ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="whereClause"></param>
|
|
||||||
/// <param name="query"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<XQueryResult<XFileDto>> ConditionalQuery(
|
|
||||||
Expression<Func<XFile, bool>> whereClause,
|
|
||||||
XQuery query
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// retrieve Owned Entities based on XQuery Pagination structure by providing a Conditional Expression ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="whereClause"></param>
|
|
||||||
/// <param name="query"></param>
|
|
||||||
/// <param name="userInfo"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<XQueryResult<XFileDto>> ConditionalQueryOwned(
|
|
||||||
Expression<Func<XFile, bool>> whereClause,
|
|
||||||
XQuery query,
|
|
||||||
XUserClaimsInfoDto userInfo = null
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Update an Entity values ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="item"></param>
|
|
||||||
/// <param name="userInfo"></param>
|
|
||||||
/// <param name="connectionId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<XFileDto> Update(
|
|
||||||
Guid id,
|
|
||||||
XFileDto item,
|
|
||||||
XUserClaimsInfoDto userInfo = null,
|
|
||||||
string connectionId = null
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// remove an Entity ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="item"></param>
|
|
||||||
/// <param name="userInfo"></param>
|
|
||||||
/// <param name="connectionId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<XFileDto> Remove(
|
|
||||||
Guid id,
|
|
||||||
XUserClaimsInfoDto userInfo = null,
|
|
||||||
string connectionId = null
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// count all exists Entities ...
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<int> Count();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Check an Entity exists or not ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<bool> IsExists(
|
|
||||||
Guid id
|
|
||||||
);
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace xFileService.Interfaces
|
||||||
|
{
|
||||||
|
public interface IXFileProviderController
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using System;
|
||||||
|
using xDataService.Interfaces;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
|
||||||
|
namespace xFileService.Interfaces
|
||||||
|
{
|
||||||
|
public interface IXFileSeeder : IXBaseDbSeeder<XFile, Guid>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -1,181 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using xFileService.Models.Dtos;
|
|
||||||
using xModels.Dtos;
|
|
||||||
using XFileDto = xFileService.Models.Dtos.XFileDto;
|
|
||||||
|
|
||||||
namespace xFileService.Interfaces
|
|
||||||
{
|
|
||||||
public interface IXFileServiceControllerActions
|
|
||||||
{
|
|
||||||
//
|
|
||||||
#region Tags ...
|
|
||||||
/// <summary>
|
|
||||||
/// Attach Tag to Specified Model ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="tag"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<ActionResult> AttachTag(
|
|
||||||
[FromRoute] Guid id,
|
|
||||||
[FromQuery] string tag
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Detach Tag From Specified Model ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="tag"></param>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<ActionResult> DetachTag(
|
|
||||||
[FromRoute] Guid id,
|
|
||||||
[FromQuery] string tag
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Attach Tags to Specified Model ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="tags"></param>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<ActionResult> AttachTags(
|
|
||||||
[FromRoute] Guid id,
|
|
||||||
[FromQuery] string tags
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Detach Tags From Specified Model ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="tags"></param>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<ActionResult> DetachTags(
|
|
||||||
[FromRoute] Guid id,
|
|
||||||
[FromQuery] string tags
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Retrieve Tags of Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<ActionResult<IEnumerable<string>>> GetTags(
|
|
||||||
[FromRoute] Guid id
|
|
||||||
);
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
//
|
|
||||||
#region Tools ...
|
|
||||||
/// <summary>
|
|
||||||
/// Stream Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<ActionResult> Stream(
|
|
||||||
[FromRoute] Guid id
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Stream Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fileName"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<ActionResult> Stream(
|
|
||||||
[FromRoute] string fileName
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Download Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<ActionResult> Download(
|
|
||||||
[FromRoute] Guid id
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Download Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<ActionResult> Download(
|
|
||||||
[FromRoute] string name
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Upload Files ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="files"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<ActionResult<IEnumerable<XFileDto>>> Upload(
|
|
||||||
[FromForm] IFormFileCollection files
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove Specified Files ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ids"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<ActionResult<IEnumerable<Guid>>> Remove(
|
|
||||||
[FromQuery] string ids
|
|
||||||
);
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
//
|
|
||||||
#region Model ...
|
|
||||||
/// <summary>
|
|
||||||
/// Get Specified File Model ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="ignoreSoftDeleteds"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<ActionResult<XFileDto>> Get(
|
|
||||||
[FromRoute] Guid id
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get All Exists File Models ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ignoreSoftDeleteds"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<ActionResult<IEnumerable<XFileDto>>> GetAll();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// retrieve Entities based on XQuery Pagination structure ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="query"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<ActionResult<XQueryResult<XFileDto>>> Query(
|
|
||||||
[FromQuery] XQuery query
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// retrieve Owned Entities based on XQuery Pagination structure ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="query"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<ActionResult<XQueryResult<XFileDto>>> QueryOwned(
|
|
||||||
[FromQuery] XQuery query
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// count all exists Entities ...
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<ActionResult<int>> Count();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Check an Entity exists or not ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<ActionResult<bool>> IsExists(
|
|
||||||
[FromRoute] Guid id
|
|
||||||
);
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using xCommons.Constants;
|
using xCommons.Constants;
|
||||||
using xDataService.Models;
|
|
||||||
using xModels.Base;
|
using xModels.Base;
|
||||||
using xModels.Dtos;
|
using xModels.Dtos;
|
||||||
|
|
||||||
namespace xFileService.Models.Dtos
|
namespace xFileService.Models.Dtos
|
||||||
{
|
{
|
||||||
public class XFileDto : XBaseDto
|
public class XFileDto : XBaseGuidIDEntityDto
|
||||||
{
|
{
|
||||||
public Guid Id { get; set; }
|
|
||||||
|
|
||||||
public XFileType Type { get; set; }
|
public XFileType Type { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Thumb { get; set; }
|
public string Thumb { get; set; }
|
||||||
@@ -22,6 +18,6 @@ namespace xFileService.Models.Dtos
|
|||||||
public string OwnerId { get; set; }
|
public string OwnerId { get; set; }
|
||||||
public XPersonDto Owner { get; set; }
|
public XPersonDto Owner { get; set; }
|
||||||
|
|
||||||
public IList<XReference<string>> References = new List<XReference<string>>();
|
public string References { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using xFileService.Interfaces.Dtos;
|
||||||
|
using xFileService.Models.Dtos;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
using xPushService.Base;
|
||||||
|
|
||||||
|
namespace xFileService.Providers.Dtos
|
||||||
|
{
|
||||||
|
public class XFileDtoHub : XBaseDtoHub<XFile, XFileDto, Guid>, IXFileDtoHub
|
||||||
|
{
|
||||||
|
public XFileDtoHub(
|
||||||
|
ILogger<XFileDtoHub> logger
|
||||||
|
) : base(logger)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using AutoMapper;
|
||||||
|
using xDataService.Providers;
|
||||||
|
using xFileService.Interfaces.Dtos;
|
||||||
|
using xFileService.Interfaces.Entities;
|
||||||
|
using xFileService.Models.Dtos;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
|
||||||
|
namespace xFileService.Providers.Dtos
|
||||||
|
{
|
||||||
|
public class XFileRepositoryService : XBaseRepositoryService<XFile, XFileDto, Guid>, IXFileRepositoryService
|
||||||
|
{
|
||||||
|
public XFileRepositoryService(
|
||||||
|
IXFileRepository repository,
|
||||||
|
IEnumerable<Profile> mapperProfiles = null
|
||||||
|
) : base(
|
||||||
|
repository,
|
||||||
|
mapperProfiles
|
||||||
|
)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.AspNetCore.SignalR;
|
||||||
|
using xDataService.Configuration;
|
||||||
|
using xFileService.Interfaces.Dtos;
|
||||||
|
using xFileService.Models.Dtos;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
using xIdentityService.Interfaces;
|
||||||
|
using xPushService.Base;
|
||||||
|
|
||||||
|
namespace xFileService.Providers.Dtos
|
||||||
|
{
|
||||||
|
public class XFileServiceProvider : XBaseDtoProvider<XFile, XFileDto, Guid, XFileDtoHub>, IXFileServiceProvider
|
||||||
|
{
|
||||||
|
public XFileServiceProvider(
|
||||||
|
IHubContext<XFileDtoHub> hub,
|
||||||
|
XDataServiceConfiguration dataConfiguration,
|
||||||
|
IXFileRepositoryService service,
|
||||||
|
IXIdentityProvider identityProvider = null
|
||||||
|
) : base(
|
||||||
|
hub,
|
||||||
|
dataConfiguration,
|
||||||
|
service,
|
||||||
|
identityProvider
|
||||||
|
)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using xDataService.Configuration;
|
||||||
|
using xDataService.Db;
|
||||||
|
using xDataService.Interfaces;
|
||||||
|
using xDataService.Providers;
|
||||||
|
using xFileService.Interfaces.Entities;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
|
||||||
|
namespace xFileService.Providers.Entities
|
||||||
|
{
|
||||||
|
public class XFileEFRepository<TContext> : XBaseEFRepository<XFile, Guid, TContext>, IXFileRepository
|
||||||
|
where TContext : XDbContext
|
||||||
|
{
|
||||||
|
public XFileEFRepository(
|
||||||
|
IXUnitOfWorks<TContext> unitOfWorks,
|
||||||
|
XDataServiceConfiguration configuration,
|
||||||
|
IXFileKeyGenerator keyGenerator = null,
|
||||||
|
IXFileRepositoryEvents baseRepositoryEvents = null
|
||||||
|
) : base(
|
||||||
|
unitOfWorks,
|
||||||
|
configuration,
|
||||||
|
keyGenerator,
|
||||||
|
baseRepositoryEvents
|
||||||
|
)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using xFileService.Interfaces.Entities;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
using xPushService.Base;
|
||||||
|
|
||||||
|
namespace xFileService.Providers.Entities
|
||||||
|
{
|
||||||
|
public class XFileEntityHub : XBaseEntityHub<XFile, Guid>, IXFileEntityHub
|
||||||
|
{
|
||||||
|
public XFileEntityHub(
|
||||||
|
ILogger<XFileEntityHub> logger
|
||||||
|
) : base(logger)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using xDataService.Configuration;
|
||||||
|
using xDataService.Providers;
|
||||||
|
using xFileService.Interfaces.Entities;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
|
||||||
|
namespace xFileService.Providers.Entities
|
||||||
|
{
|
||||||
|
public class XFileInMemoryRepository : XBaseInMemoryRepository<XFile, Guid>, IXFileRepository
|
||||||
|
{
|
||||||
|
public XFileInMemoryRepository(
|
||||||
|
XDataServiceConfiguration configuration,
|
||||||
|
IXFileKeyGenerator keyGenerator = null,
|
||||||
|
IXFileRepositoryEvents baseRepositoryEvents = null
|
||||||
|
) : base(
|
||||||
|
configuration,
|
||||||
|
keyGenerator,
|
||||||
|
baseRepositoryEvents
|
||||||
|
)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using xDataService.Providers;
|
||||||
|
using xFileService.Interfaces.Entities;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
|
||||||
|
namespace xFileService.Providers.Entities
|
||||||
|
{
|
||||||
|
public class XFileKeyGenerator : XGuidKeyGenerator<XFile>, IXFileKeyGenerator
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using xDataService.Configuration;
|
||||||
|
using xDataService.Providers;
|
||||||
|
using xFileService.Interfaces.Entities;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
|
||||||
|
namespace xFileService.Providers.Entities
|
||||||
|
{
|
||||||
|
public class XFileMongoRepository : XBaseMongoRepository<XFile, Guid>, IXFileRepository
|
||||||
|
{
|
||||||
|
public XFileMongoRepository(
|
||||||
|
XDataBaseConfiguration dbConfiguration,
|
||||||
|
XDataServiceConfiguration configuration,
|
||||||
|
string collectionName = null,
|
||||||
|
IXFileKeyGenerator keyGenerator = null,
|
||||||
|
IXFileRepositoryEvents baseRepositoryEvents = null
|
||||||
|
) : base(
|
||||||
|
dbConfiguration,
|
||||||
|
configuration,
|
||||||
|
collectionName,
|
||||||
|
keyGenerator,
|
||||||
|
baseRepositoryEvents
|
||||||
|
)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using xDataService.Providers;
|
||||||
|
using xFileService.Interfaces.Entities;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
|
||||||
|
namespace xFileService.Providers.Entities
|
||||||
|
{
|
||||||
|
public class XFileRepositoryEvents : XBaseRepositoryEvents<XFile>, IXFileRepositoryEvents
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.AspNetCore.SignalR;
|
||||||
|
using xDataService.Configuration;
|
||||||
|
using xFileService.Interfaces.Entities;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
using xIdentityService.Interfaces;
|
||||||
|
using xPushService.Base;
|
||||||
|
|
||||||
|
namespace xFileService.Providers.Entities
|
||||||
|
{
|
||||||
|
public class XFileRepositoryProvider : XBaseEntityProvider<XFile, Guid, XFileEntityHub>, IXFileRepositoryProvider
|
||||||
|
{
|
||||||
|
public XFileRepositoryProvider(
|
||||||
|
IHubContext<XFileEntityHub> hub,
|
||||||
|
IXFileRepository repository,
|
||||||
|
XDataServiceConfiguration dataConfiguration,
|
||||||
|
IXIdentityProvider identityProvider = null
|
||||||
|
) : base(
|
||||||
|
hub,
|
||||||
|
repository,
|
||||||
|
dataConfiguration,
|
||||||
|
identityProvider
|
||||||
|
)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -4,7 +4,7 @@ using xDataService.GraphQL;
|
|||||||
using xFileService.Interfaces.Entities;
|
using xFileService.Interfaces.Entities;
|
||||||
using xFileService.Models.Entities;
|
using xFileService.Models.Entities;
|
||||||
|
|
||||||
namespace xFileService.DataHelper.GraphQL
|
namespace xFileService.Providers.GraphQL
|
||||||
{
|
{
|
||||||
public class XFileGraphQLTypeHelper : XBaseGraphQLTypeHelper<XFile, Guid>, IXFileGraphQLTypeHelper
|
public class XFileGraphQLTypeHelper : XBaseGraphQLTypeHelper<XFile, Guid>, IXFileGraphQLTypeHelper
|
||||||
{
|
{
|
||||||
@@ -5,7 +5,7 @@ using xDataService.GraphQL;
|
|||||||
using xFileService.Interfaces.Entities;
|
using xFileService.Interfaces.Entities;
|
||||||
using xFileService.Models.Entities;
|
using xFileService.Models.Entities;
|
||||||
|
|
||||||
namespace xFileService.DataHelper.GraphQL
|
namespace xFileService.Providers.GraphQL
|
||||||
{
|
{
|
||||||
public class XFileGraphQuery : XBaseGraphQLQuery<XFile, Guid, XFileGraphType, GuidGraphType>
|
public class XFileGraphQuery : XBaseGraphQLQuery<XFile, Guid, XFileGraphType, GuidGraphType>
|
||||||
{
|
{
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using GraphQL.Types;
|
using GraphQL.Types;
|
||||||
|
|
||||||
namespace xFileService.DataHelper.GraphQL
|
namespace xFileService.Providers.GraphQL
|
||||||
{
|
{
|
||||||
public class XFileGraphSchema : Schema
|
public class XFileGraphSchema : Schema
|
||||||
{
|
{
|
||||||
@@ -9,5 +9,6 @@ namespace xFileService.DataHelper.GraphQL
|
|||||||
{
|
{
|
||||||
Query = (XFileGraphQuery)services.GetService(typeof(XFileGraphQuery));
|
Query = (XFileGraphQuery)services.GetService(typeof(XFileGraphQuery));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,20 +2,21 @@ using System;
|
|||||||
using xDataService.GraphQL;
|
using xDataService.GraphQL;
|
||||||
using xFileService.Models.Entities;
|
using xFileService.Models.Entities;
|
||||||
|
|
||||||
namespace xFileService.DataHelper.GraphQL
|
namespace xFileService.Providers.GraphQL
|
||||||
{
|
{
|
||||||
public class XFileGraphType : XBaseGraphObjectType<XFile, Guid>
|
public class XFileGraphType : XBaseGraphObjectType<XFile, Guid>
|
||||||
{
|
{
|
||||||
public XFileGraphType() : base()
|
public XFileGraphType() : base()
|
||||||
{
|
{
|
||||||
Field(x => x.Type);
|
Field(x => x.Type);
|
||||||
Field(x => x.OwnerId);
|
|
||||||
Field(x => x.Name);
|
Field(x => x.Name);
|
||||||
Field(x => x.Path);
|
Field(x => x.Path);
|
||||||
Field(x => x.Thumb);
|
Field(x => x.Thumb);
|
||||||
|
Field(x => x.OwnerId);
|
||||||
|
Field(x => x.FileName);
|
||||||
Field(x => x.ThumbPath);
|
Field(x => x.ThumbPath);
|
||||||
Field(x => x.UploadedOn);
|
Field(x => x.UploadedOn);
|
||||||
Field(x => x.FileName);
|
Field(x => x.References);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using xDataService.Interfaces;
|
||||||
|
using xDataService.Providers;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
|
||||||
|
namespace xFileService.Providers
|
||||||
|
{
|
||||||
|
public class XFileEntityRegisterar : XBaseEntityRegisterar, IXEntityRegisterar
|
||||||
|
{
|
||||||
|
public XFileEntityRegisterar()
|
||||||
|
: base(nameof(XFileEntityRegisterar))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Add XFile Entity ...
|
||||||
|
AddEntity<XFile, Guid>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Configure Entities ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="modelBuilder"></param>
|
||||||
|
public override void ConfigureEntities(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
base.ConfigureEntities(modelBuilder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+156
-1582
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using xDataService.Configuration;
|
||||||
|
using xDataService.Providers;
|
||||||
|
using xFileService.Interfaces;
|
||||||
|
using xFileService.Interfaces.Entities;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
|
||||||
|
namespace xFileService.Providers
|
||||||
|
{
|
||||||
|
public abstract class XFileSeederBase : XBaseDbSeeder<XFile, Guid>, IXFileSeeder
|
||||||
|
{
|
||||||
|
protected XFileSeederBase(
|
||||||
|
string entity,
|
||||||
|
string database,
|
||||||
|
IXFileRepository repository,
|
||||||
|
XDataServiceConfiguration dataServiceConfiguration
|
||||||
|
) : base(
|
||||||
|
entity,
|
||||||
|
database,
|
||||||
|
repository,
|
||||||
|
dataServiceConfiguration
|
||||||
|
)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using xFileService.Interfaces;
|
using xFileService.Interfaces;
|
||||||
using xFileService.Models.Entities;
|
using xFileService.Models.Entities;
|
||||||
using xTagService.Interfaces;
|
using xTagService.Interfaces.Dtos;
|
||||||
using xTagService.Providers;
|
using xTagService.Providers;
|
||||||
|
|
||||||
namespace xFileService.Providers
|
namespace xFileService.Providers
|
||||||
@@ -9,9 +9,10 @@ namespace xFileService.Providers
|
|||||||
public class XFileTagProvider : XBaseTagProvider<Guid>, IXFileTagProvider
|
public class XFileTagProvider : XBaseTagProvider<Guid>, IXFileTagProvider
|
||||||
{
|
{
|
||||||
public XFileTagProvider(
|
public XFileTagProvider(
|
||||||
IXTagProvider tagProvider
|
string providedFor,
|
||||||
|
IXTagServiceProvider tagProvider
|
||||||
) : base(
|
) : base(
|
||||||
providedFor: nameof(XFile),
|
providedFor: nameof(XFile),
|
||||||
tagProvider: tagProvider
|
tagProvider: tagProvider
|
||||||
)
|
)
|
||||||
{ }
|
{ }
|
||||||
|
|||||||
+2
-1
@@ -1,7 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<packageSources>
|
<packageSources>
|
||||||
|
<!-- <add key="megan" value="https://hub.megan.ir/nuget/index.json" /> -->
|
||||||
<add key="nuget" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
<add key="nuget" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
||||||
<add key="baget" value="https://nuget.saherelmhub.ir/v3/index.json" protocolVersion="3" />
|
<add key="baget" value="https://nuget.saherelmhub.ir/v3/index.json" protocolVersion="3" disableTLSCertificateValidation="true" />
|
||||||
</packageSources>
|
</packageSources>
|
||||||
</configuration>
|
</configuration>
|
||||||
+3
-6
@@ -24,7 +24,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- <PackageReference Include="xDashboard.xTagService" Version="1.0.0" /> -->
|
<!-- <PackageReference Include="xDashboard.xTagService" Version="1.0.0" /> -->
|
||||||
<!-- <PackageReference Include="xDashboard.xDataService" Version="1.0.0" /> -->
|
<!-- <PackageReference Include="xDashboard.xDataService" Version="1.0.0" /> -->
|
||||||
<!-- <PackageReference Include="xDashboard.xStringService" Version="1.0.0" /> -->
|
<!-- <PackageReference Include="xDashboard.xPushService" Version="1.0.0" /> -->
|
||||||
<!-- <PackageReference Include="xDashboard.xStorageService" Version="1.0.0" /> -->
|
<!-- <PackageReference Include="xDashboard.xStorageService" Version="1.0.0" /> -->
|
||||||
<!-- <PackageReference Include="xDashboard.xIdentityService" Version="1.0.0" /> -->
|
<!-- <PackageReference Include="xDashboard.xIdentityService" Version="1.0.0" /> -->
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -32,13 +32,10 @@
|
|||||||
<!-- Local Dependencies -->
|
<!-- Local Dependencies -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="../xTagService/xTagService.csproj" />
|
<ProjectReference Include="../xTagService/xTagService.csproj" />
|
||||||
<ProjectReference Include="../xPushService/xPushService.csproj" />
|
|
||||||
<ProjectReference Include="../xIdentityService/xIdentityService.csproj" />
|
|
||||||
<ProjectReference Include="../xDataService/xDataService.csproj" />
|
<ProjectReference Include="../xDataService/xDataService.csproj" />
|
||||||
|
<ProjectReference Include="../xPushService/xPushService.csproj" />
|
||||||
<ProjectReference Include="../xStorageService/xStorageService.csproj" />
|
<ProjectReference Include="../xStorageService/xStorageService.csproj" />
|
||||||
<!--
|
<ProjectReference Include="../xIdentityService/xIdentityService.csproj" />
|
||||||
<ProjectReference Include="../xStringService/xStringService.csproj" />
|
|
||||||
-->
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user