Compare commits

...
10 Commits
9 changed files with 164 additions and 263 deletions
-33
View File
@@ -1,33 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using xCommons.Attributes;
using xCommons.Configurations;
using xCommons.Providers;
using xIdentityService.Controllers;
using xIdentityService.Interfaces;
namespace xApi.Base
{
[ApiController]
[ApiVersion("1.0")]
[RequireXPowered(true)]
[Route("api/v{version:apiVersion}/[controller]")]
public abstract class XIBaseV1Controller : XIBaseController
{
//
#region Constructor ...
protected XIBaseV1Controller(
ILogger<XIBaseV1Controller> logger,
XAppConfiguration appConfiguration,
IXIdentityProvider identityProvider,
XValidationProvider validationProvider
) : base(
logger,
appConfiguration,
identityProvider,
validationProvider
)
{ }
#endregion
}
}
-120
View File
@@ -1,120 +0,0 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Logging;
using xCommons.Attributes;
using xCommons.Configurations;
using xCommons.Extensions;
using xCommons.Providers;
using xDataService.Interfaces;
using xIdentityService.Controllers;
using xIdentityService.Interfaces;
using xModels.Base;
using xPushService.Base;
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
}
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 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;
}
//
// 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
}
}
-29
View File
@@ -1,29 +0,0 @@
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Logging;
using xCommons.Configurations;
using xCommons.Providers;
using xIdentityService.Controllers;
using xIdentityService.Interfaces;
namespace xApi.Base
{
[Route("api/v{version:apiVersion}/services/[controller]")]
public abstract class XIBaseV1ProviderController : XIBaseProviderController
{
//
#region Constructor ...
protected XIBaseV1ProviderController(
ILogger logger,
XAppConfiguration appConfiguration,
IXIdentityProvider identityProvider,
XValidationProvider validationProvider
) : base(
logger,
appConfiguration,
identityProvider,
validationProvider
)
{ }
#endregion
}
}
+1 -1
View File
@@ -13,7 +13,7 @@ namespace xApi.Controllers
/// </summary> /// </summary>
[AllowAnonymous] [AllowAnonymous]
[RequireXPowered(true)] [RequireXPowered(true)]
public partial class AccountController : XIBaseController public partial class AccountController : XBaseIdentityController
{ {
// //
#region Props ... #region Props ...
+43
View File
@@ -0,0 +1,43 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using xCategoryService.Interfaces;
using xCommons.Configurations;
using xCommons.Controllers;
using xCommons.Providers;
namespace xApi.Controllers
{
[AllowAnonymous]
public class TestFeaturesController : XBaseApiController
{
private readonly IXSubCategoryTitleResourceProvider subCategoryTitleResourceProvider;
public TestFeaturesController(
ILogger<TestFeaturesController> logger,
XAppConfiguration appConfiguration,
XValidationProvider validationProvider,
IXSubCategoryTitleResourceProvider subCategoryTitleResourceProvider
) : base(
logger,
appConfiguration,
validationProvider
)
{
this.subCategoryTitleResourceProvider = subCategoryTitleResourceProvider;
}
[HttpGet]
public async Task<ActionResult> TestFeature()
{
//
var result = await subCategoryTitleResourceProvider.GetLanguages(
identifier: "SSSSAAALLLAAAM"
);
//
return Ok(result);
}
}
}
+1 -1
View File
@@ -14,7 +14,7 @@ namespace xApi.Controllers {
/// Test all Authentication Policies ... /// Test all Authentication Policies ...
/// </summary> /// </summary>
[RequireXPowered (false)] [RequireXPowered (false)]
public class TestIdentity : XIBaseController { public class TestIdentity : XBaseIdentityController {
public TestIdentity ( public TestIdentity (
ILogger<TestIdentity> logger, ILogger<TestIdentity> logger,
XAppConfiguration appConfiguration, XAppConfiguration appConfiguration,
+35 -57
View File
@@ -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,18 +15,9 @@ using Newtonsoft.Json.Serialization;
using xApi.Extensions; using xApi.Extensions;
using xCommons.Configurations; using xCommons.Configurations;
using xCommons.Extensions; using xCommons.Extensions;
// using xDataHelper; using xDataService.Models;
// using xDataHelper.DbSeeder;
// using xDataHelper.Helpers;
using xDataService.Configuration;
using xDataService.Constants;
using xDataService.DI;
using xDataService.Interfaces;
using xHttpService.DI; using xHttpService.DI;
using xIdentityService.DI; using xIdentityService.DI;
// using xPushHelper.DI;
using xPushService.DI;
using xPushService.Helpers;
using xServices.Databases; using xServices.Databases;
using xServices.DI; using xServices.DI;
@@ -42,6 +33,9 @@ namespace xApi
{ {
// //
Configuration = configuration; Configuration = configuration;
//
// Create an Api Descriptor Class Instance ...
apiDatabaseDescriptor = new XApiDatabaseDescriptor(); apiDatabaseDescriptor = new XApiDatabaseDescriptor();
} }
@@ -71,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 ...
@@ -114,27 +92,38 @@ namespace xApi
x.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); x.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
}); });
// // //
// // Check Data Service ... // Custom ...
// var dataServiceConfig = Configuration.GetXDataServiceConfiguration();
// //
// Check DataBase Registration ... services.Configure<IISServerOptions>(options =>
services.AddXDatabase( {
lifetime: lifeTime, options.AllowSynchronousIO = true;
});
//
services.Configure<KestrelServerOptions>(options =>
{
options.AllowSynchronousIO = true;
});
//
// Register Services ...
services.AddXServices(
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();
} }
@@ -165,26 +154,15 @@ namespace xApi
endpoints.MapControllers(); endpoints.MapControllers();
}); });
//
#region XPushService ...
// //
// var helper = new XPushServiceHelper();
// //
// app.UseXPushService(helper);
#endregion
// //
// Use xDataService Middleware ... // Use xDataService Middleware ...
app.UseXDatabase(apiDatabaseDescriptor); app.UseXServices(
databases: new List<XDatabaseDescriptor>
// {
// Using Services ... apiDatabaseDescriptor
// app.UseXServices(); },
isDevelopmentEnvironment: env.IsDevelopment()
// );
// Use xGraphQL Middleware ...
// app.UseXGraphQL(withPlayground: withPlayground);
} }
} }
} }
+69 -18
View File
@@ -16,6 +16,9 @@
"Name": "Hadi Khazaee Asl", "Name": "Hadi Khazaee Asl",
"Email": "hadi_khazaee_asl@yahoo.com", "Email": "hadi_khazaee_asl@yahoo.com",
"Url": "https://www.saherelm.ir" "Url": "https://www.saherelm.ir"
},
"DefaultValues": {
"version": "1.0"
} }
}, },
"MessageConfiguration": { "MessageConfiguration": {
@@ -54,12 +57,25 @@
"Databases": { "Databases": {
"xApiDb": { "xApiDb": {
"Provider": "SQLITE", "Provider": "SQLITE",
"ConnectionString": "Filename=./Db/XApi.db" "ConnectionString": "Filename=./Db/XApi.db",
"SeedItems": {
"XTest": [
{
"Firstname": "Hadi",
"Lastname": "Khazaee Asl"
},
{
"Firstname": "Amir Ali",
"Lastname": "Khazaee Asl"
}
]
}
} }
}, },
"EnableTracking": true, "EnableTracking": true,
"EnableSoftDelete": false, "EnableSoftDelete": true,
"EnableDetailedErrors": false, "EnableDetailedErrors": false,
"SeedingMode": "AddIfNotExists",
"EnableSensitiveDataLogging": true, "EnableSensitiveDataLogging": true,
"PagingConfiguration": { "PagingConfiguration": {
"DefaultPageSize": 20, "DefaultPageSize": 20,
@@ -68,22 +84,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
@@ -120,6 +120,57 @@
"ThumbQuality": 72, "ThumbQuality": 72,
"MaxFileSize": 41943040 "MaxFileSize": 41943040
}, },
"TermsAndConditionsService": {
"ResourceTitle": "terms_and_conditions",
"SeedingMode": "AddIfNotExists",
"TermsAndConditions": [
{
"Language": "fa-IR",
"TranslatedValue": "شرایط و ضوابط ثبت نام در سامانه"
}
]
},
"CategoryServiceConfiguration": {
"Categories": [],
"SubCategories": [
{
"titles": {
"locales": [
{
"language": "fa-IR",
"value": "ورزشی"
}
]
},
"descriptions": {
"locales": [
{
"language": "fa-IR",
"value": "موارد مرتبط با ورزش"
}
]
},
"category": {
"titles": {
"locales": [
{
"language": "fa-IR",
"value": "خبر"
}
]
},
"descriptions": {
"locales": [
{
"language": "fa-IR",
"value": "اخبار در این گروه قرار می گیرند"
}
]
}
}
}
]
},
"ServicesConfiguration": { "ServicesConfiguration": {
"SummaryEndsWdith": " ...", "SummaryEndsWdith": " ...",
"ContentSummaryMaxLength": 255 "ContentSummaryMaxLength": 255
+14 -3
View File
@@ -1,20 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<!-- Runtime Definition --> <!-- Runtime Definition -->
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<PackageId>xSaherElm.xApi</PackageId>
<Version>1.0.0</Version> <Version>1.0.0</Version>
<LangVersion>12.0</LangVersion>
<Authors>Hadi Khazaee Asl</Authors> <Authors>Hadi Khazaee Asl</Authors>
<PackageId>xSaherElm.xApi</PackageId>
<Company>SaherElm IT Center</Company> <Company>SaherElm IT Center</Company>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Description> <Description>
a WebAPI Project which contains all Business Logic of xSaherElm Project. a WebAPI Project which contains all Business Logic of xSaherElm Project.
</Description> </Description>
<!-- Icon Definition -->
<PackageIcon>icon.png</PackageIcon>
<!-- Fix Duplicate TargetFramework Issue --> <!-- Fix Duplicate TargetFramework Issue -->
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute> <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup> </PropertyGroup>
<!-- Icon Handling -->
<ItemGroup>
<None Include="../../Resources/Images/favicon.png" Link="icon.png" Pack="true"
PackagePath="\icon.png" />
</ItemGroup>
<!-- Local Dependencies --> <!-- Local Dependencies -->
<!-- Local Projects --> <!-- Local Projects -->