last ...
This commit is contained in:
@@ -16,105 +16,107 @@ using xPushService.Constants;
|
||||
|
||||
namespace xApi.Base
|
||||
{
|
||||
[ApiController]
|
||||
[ApiVersion("1.0")]
|
||||
[RequireXPowered(true)]
|
||||
[Route("api/v{version:apiVersion}/entities/[controller]")]
|
||||
public abstract class XIBaseV1EntityController<TEntity, TKey> : XIBaseEntityController<TEntity, TKey>
|
||||
where TEntity : XBaseEntity<TKey>
|
||||
{
|
||||
//
|
||||
#region Constructor ...
|
||||
protected XIBaseV1EntityController(
|
||||
ILogger<XIBaseV1EntityController<TEntity, TKey>> logger,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider,
|
||||
IXBaseRepository<TEntity, TKey> repository
|
||||
) : base(
|
||||
logger,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider,
|
||||
repository
|
||||
)
|
||||
{ }
|
||||
#endregion
|
||||
}
|
||||
// TODO: Fix this ...
|
||||
// [ApiController]
|
||||
// [ApiVersion("1.0")]
|
||||
// [RequireXPowered(true)]
|
||||
// [Route("api/v{version:apiVersion}/entities/[controller]")]
|
||||
// public abstract class XIBaseV1EntityController<TEntity, TKey> : XIBaseEntityController<TEntity, TKey>
|
||||
// where TEntity : XBaseEntity<TKey>
|
||||
// {
|
||||
// //
|
||||
// #region Constructor ...
|
||||
// protected XIBaseV1EntityController(
|
||||
// ILogger<XIBaseV1EntityController<TEntity, TKey>> logger,
|
||||
// XAppConfiguration appConfiguration,
|
||||
// IXIdentityProvider identityProvider,
|
||||
// XValidationProvider validationProvider,
|
||||
// IXBaseRepository<TEntity, TKey> repository
|
||||
// ) : base(
|
||||
// logger,
|
||||
// appConfiguration,
|
||||
// identityProvider,
|
||||
// validationProvider,
|
||||
// repository
|
||||
// )
|
||||
// { }
|
||||
// #endregion
|
||||
// }
|
||||
|
||||
public abstract class XIBaseV1EntityHubController<TEntity, TKey> : XIBaseV1EntityController<TEntity, TKey>
|
||||
where TEntity : XBaseEntity<TKey>
|
||||
{
|
||||
//
|
||||
#region Props ...
|
||||
public IHubContext<XBaseEntityHub<TEntity, TKey>> Hub { get; }
|
||||
#endregion
|
||||
// public abstract class XIBaseV1EntityHubController<TEntity, TKey> : XIBaseV1EntityController<TEntity, TKey>
|
||||
// where TEntity : XBaseEntity<TKey>
|
||||
// {
|
||||
// //
|
||||
// #region Props ...
|
||||
// public IHubContext<XBaseEntityHub<TEntity, TKey>> Hub { get; }
|
||||
// #endregion
|
||||
|
||||
//
|
||||
#region Constructor ...
|
||||
protected XIBaseV1EntityHubController(
|
||||
ILogger<XIBaseV1EntityHubController<TEntity, TKey>> logger,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider,
|
||||
IXBaseRepository<TEntity, TKey> repository,
|
||||
IHubContext<XBaseEntityHub<TEntity, TKey>> hub = null
|
||||
) : base(
|
||||
logger,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider,
|
||||
repository
|
||||
)
|
||||
{
|
||||
Hub = hub;
|
||||
}
|
||||
#endregion
|
||||
// //
|
||||
// #region Constructor ...
|
||||
// protected XIBaseV1EntityHubController(
|
||||
// ILogger<XIBaseV1EntityHubController<TEntity, TKey>> logger,
|
||||
// XAppConfiguration appConfiguration,
|
||||
// IXIdentityProvider identityProvider,
|
||||
// XValidationProvider validationProvider,
|
||||
// IXBaseRepository<TEntity, TKey> repository,
|
||||
// IHubContext<XBaseEntityHub<TEntity, TKey>> hub = null
|
||||
// ) : base(
|
||||
// logger,
|
||||
// appConfiguration,
|
||||
// identityProvider,
|
||||
// validationProvider,
|
||||
// repository
|
||||
// )
|
||||
// {
|
||||
// Hub = hub;
|
||||
// }
|
||||
// #endregion
|
||||
|
||||
//
|
||||
#region Hub ...
|
||||
[NonAction]
|
||||
public async Task SendPush(
|
||||
string action,
|
||||
string payLoad
|
||||
)
|
||||
{
|
||||
//
|
||||
var actions = new List<string>
|
||||
{
|
||||
XBaseEntityHubAction.Add.GetStringValue(),
|
||||
XBaseEntityHubAction.Update.GetStringValue(),
|
||||
XBaseEntityHubAction.Delete.GetStringValue(),
|
||||
XBaseEntityHubAction.AddMany.GetStringValue(),
|
||||
XBaseEntityHubAction.DeleteMany.GetStringValue(),
|
||||
XBaseEntityHubAction.UpdateMany.GetStringValue(),
|
||||
XBaseEntityHubAction.AddOrUpdate.GetStringValue(),
|
||||
};
|
||||
// //
|
||||
// #region Hub ...
|
||||
// [NonAction]
|
||||
// public async Task SendPush(
|
||||
// string action,
|
||||
// string payLoad
|
||||
// )
|
||||
// {
|
||||
// //
|
||||
// var actions = new List<string>
|
||||
// {
|
||||
// XBaseEntityHubAction.Add.GetStringValue(),
|
||||
// XBaseEntityHubAction.Update.GetStringValue(),
|
||||
// XBaseEntityHubAction.Delete.GetStringValue(),
|
||||
// XBaseEntityHubAction.AddMany.GetStringValue(),
|
||||
// XBaseEntityHubAction.DeleteMany.GetStringValue(),
|
||||
// XBaseEntityHubAction.UpdateMany.GetStringValue(),
|
||||
// XBaseEntityHubAction.AddOrUpdate.GetStringValue(),
|
||||
// };
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
var isValid =
|
||||
!Hub.IsNull() &&
|
||||
!action.IsNullOrEmpty() &&
|
||||
!payLoad.IsNullOrEmpty() &&
|
||||
actions.Contains(action);
|
||||
if (!isValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// //
|
||||
// // Validate ...
|
||||
// var isValid =
|
||||
// !Hub.IsNull() &&
|
||||
// !action.IsNullOrEmpty() &&
|
||||
// !payLoad.IsNullOrEmpty() &&
|
||||
// actions.Contains(action);
|
||||
// if (!isValid)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
//
|
||||
// Retrieve Connection Id ...
|
||||
var connectionId = GetConnectionId();
|
||||
var clients = Hub.Clients.All;
|
||||
if (!connectionId.IsNullOrEmpty())
|
||||
{
|
||||
clients = Hub.Clients.AllExcept(connectionId);
|
||||
}
|
||||
// //
|
||||
// // Retrieve Connection Id ...
|
||||
// var connectionId = GetConnectionId();
|
||||
// var clients = Hub.Clients.All;
|
||||
// if (!connectionId.IsNullOrEmpty())
|
||||
// {
|
||||
// clients = Hub.Clients.AllExcept(connectionId);
|
||||
// }
|
||||
|
||||
//
|
||||
await clients.SendAsync(action, payLoad, connectionId);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
// //
|
||||
// await clients.SendAsync(action, payLoad, connectionId);
|
||||
// }
|
||||
// #endregion
|
||||
// }
|
||||
}
|
||||
+20
-41
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using IdentityModel.AspNetCore.OAuth2Introspection;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@@ -15,10 +15,11 @@ using Newtonsoft.Json.Serialization;
|
||||
using xApi.Extensions;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Extensions;
|
||||
using xDataService.DI;
|
||||
using xDataService.Models;
|
||||
using xHttpService.DI;
|
||||
using xIdentityService.DI;
|
||||
using xServices.Databases;
|
||||
using xServices.DI;
|
||||
|
||||
namespace xApi
|
||||
{
|
||||
@@ -32,6 +33,9 @@ namespace xApi
|
||||
{
|
||||
//
|
||||
Configuration = configuration;
|
||||
|
||||
//
|
||||
// Create an Api Descriptor Class Instance ...
|
||||
apiDatabaseDescriptor = new XApiDatabaseDescriptor();
|
||||
}
|
||||
|
||||
@@ -61,24 +65,8 @@ namespace xApi
|
||||
services.AddXHttpService(Configuration);
|
||||
|
||||
//
|
||||
// Register Api Versioning ...
|
||||
services.AddApiVersioning(opt =>
|
||||
{
|
||||
//
|
||||
// Set Default Api Version ...
|
||||
opt.DefaultApiVersion = new ApiVersion(1, 0);
|
||||
|
||||
//
|
||||
// Set Routing to Default API Version, if Version unspecified ...
|
||||
opt.AssumeDefaultVersionWhenUnspecified = true;
|
||||
|
||||
//
|
||||
// Report All Available Api Versions on Response ...
|
||||
opt.ReportApiVersions = true;
|
||||
});
|
||||
|
||||
//
|
||||
var lifeTime = ServiceLifetime.Scoped;
|
||||
// Add Api V1 Versioning ...
|
||||
services.AddXApiV1Versioning();
|
||||
|
||||
//
|
||||
// OAuthIntrospectin Http Client Handler ...
|
||||
@@ -120,26 +108,22 @@ namespace xApi
|
||||
});
|
||||
|
||||
//
|
||||
// Check Data Service ...
|
||||
var dataServiceConfig = Configuration.GetXDataServiceConfiguration();
|
||||
|
||||
//
|
||||
// Check DataBase Registration ...
|
||||
services.AddXDatabase(
|
||||
lifetime: lifeTime,
|
||||
// Register Services ...
|
||||
services.AddXServices(
|
||||
configuration: Configuration,
|
||||
descriptor: apiDatabaseDescriptor
|
||||
databases: new List<XDatabaseDescriptor>
|
||||
{
|
||||
apiDatabaseDescriptor
|
||||
},
|
||||
lifeTime: ServiceLifetime.Scoped
|
||||
);
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
//
|
||||
var withPlayground = false;
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
//
|
||||
withPlayground = true;
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
@@ -181,18 +165,13 @@ namespace xApi
|
||||
|
||||
//
|
||||
// Use xDataService Middleware ...
|
||||
app.UseXDatabase(
|
||||
descriptor: apiDatabaseDescriptor,
|
||||
app.UseXServices(
|
||||
databases: new List<XDatabaseDescriptor>
|
||||
{
|
||||
apiDatabaseDescriptor
|
||||
},
|
||||
isDevelopmentEnvironment: env.IsDevelopment()
|
||||
);
|
||||
|
||||
//
|
||||
// Using Services ...
|
||||
// app.UseXServices();
|
||||
|
||||
//
|
||||
// Use xGraphQL Middleware ...
|
||||
// app.UseXGraphQL(withPlayground: withPlayground);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-17
@@ -70,7 +70,7 @@
|
||||
}
|
||||
},
|
||||
"EnableTracking": true,
|
||||
"EnableSoftDelete": false,
|
||||
"EnableSoftDelete": true,
|
||||
"EnableDetailedErrors": false,
|
||||
"SeedingMode": "AddIfNotExists",
|
||||
"EnableSensitiveDataLogging": true,
|
||||
@@ -81,22 +81,6 @@
|
||||
},
|
||||
"GraphQLBasePath": "/graphs"
|
||||
},
|
||||
"DbSeeder": {
|
||||
"UpdateExists": false,
|
||||
"Strings": [],
|
||||
"Terms": [
|
||||
{
|
||||
"Language": "fa-IR",
|
||||
"ResourceTitle": "terms",
|
||||
"TranslatedValue": "توافقنامه استفاده از خدمات و شرایط و ضوابط عضویت"
|
||||
},
|
||||
{
|
||||
"Language": "en-US",
|
||||
"ResourceTitle": "terms",
|
||||
"TranslatedValue": "Terms and Conditions of Using Yuze Services"
|
||||
}
|
||||
]
|
||||
},
|
||||
"HttpServiceConfiguration": {
|
||||
"DisableSSLCheck": true,
|
||||
"DefaultClientTimeout": -1
|
||||
|
||||
Reference in New Issue
Block a user