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