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>
[AllowAnonymous]
[RequireXPowered(true)]
public partial class AccountController : XIBaseController
public partial class AccountController : XBaseIdentityController
{
//
#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 ...
/// </summary>
[RequireXPowered (false)]
public class TestIdentity : XIBaseController {
public class TestIdentity : XBaseIdentityController {
public TestIdentity (
ILogger<TestIdentity> logger,
XAppConfiguration appConfiguration,
+35 -57
View File
@@ -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,18 +15,9 @@ using Newtonsoft.Json.Serialization;
using xApi.Extensions;
using xCommons.Configurations;
using xCommons.Extensions;
// using xDataHelper;
// using xDataHelper.DbSeeder;
// using xDataHelper.Helpers;
using xDataService.Configuration;
using xDataService.Constants;
using xDataService.DI;
using xDataService.Interfaces;
using xDataService.Models;
using xHttpService.DI;
using xIdentityService.DI;
// using xPushHelper.DI;
using xPushService.DI;
using xPushService.Helpers;
using xServices.Databases;
using xServices.DI;
@@ -42,6 +33,9 @@ namespace xApi
{
//
Configuration = configuration;
//
// Create an Api Descriptor Class Instance ...
apiDatabaseDescriptor = new XApiDatabaseDescriptor();
}
@@ -71,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 ...
@@ -114,27 +92,38 @@ namespace xApi
x.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
});
// //
// // Check Data Service ...
// var dataServiceConfig = Configuration.GetXDataServiceConfiguration();
//
// Custom ...
//
// Check DataBase Registration ...
services.AddXDatabase(
lifetime: lifeTime,
services.Configure<IISServerOptions>(options =>
{
options.AllowSynchronousIO = true;
});
//
services.Configure<KestrelServerOptions>(options =>
{
options.AllowSynchronousIO = true;
});
//
// 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();
}
@@ -165,26 +154,15 @@ namespace xApi
endpoints.MapControllers();
});
//
#region XPushService ...
// //
// var helper = new XPushServiceHelper();
// //
// app.UseXPushService(helper);
#endregion
//
// Use xDataService Middleware ...
app.UseXDatabase(apiDatabaseDescriptor);
//
// Using Services ...
// app.UseXServices();
//
// Use xGraphQL Middleware ...
// app.UseXGraphQL(withPlayground: withPlayground);
app.UseXServices(
databases: new List<XDatabaseDescriptor>
{
apiDatabaseDescriptor
},
isDevelopmentEnvironment: env.IsDevelopment()
);
}
}
}
+69 -18
View File
@@ -16,6 +16,9 @@
"Name": "Hadi Khazaee Asl",
"Email": "hadi_khazaee_asl@yahoo.com",
"Url": "https://www.saherelm.ir"
},
"DefaultValues": {
"version": "1.0"
}
},
"MessageConfiguration": {
@@ -54,12 +57,25 @@
"Databases": {
"xApiDb": {
"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,
"EnableSoftDelete": false,
"EnableSoftDelete": true,
"EnableDetailedErrors": false,
"SeedingMode": "AddIfNotExists",
"EnableSensitiveDataLogging": true,
"PagingConfiguration": {
"DefaultPageSize": 20,
@@ -68,22 +84,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
@@ -120,6 +120,57 @@
"ThumbQuality": 72,
"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": {
"SummaryEndsWdith": " ...",
"ContentSummaryMaxLength": 255
+15 -4
View File
@@ -1,20 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<!-- Runtime Definition -->
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<PackageId>xSaherElm.xApi</PackageId>
<Version>1.0.0</Version>
<LangVersion>12.0</LangVersion>
<Authors>Hadi Khazaee Asl</Authors>
<PackageId>xSaherElm.xApi</PackageId>
<Company>SaherElm IT Center</Company>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Description>
a WebAPI Project which contains all Business Logic of xSaherElm Project.
a WebAPI Project which contains all Business Logic of xSaherElm Project.
</Description>
<!-- Icon Definition -->
<PackageIcon>icon.png</PackageIcon>
<!-- Fix Duplicate TargetFramework Issue -->
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<!-- Icon Handling -->
<ItemGroup>
<None Include="../../Resources/Images/favicon.png" Link="icon.png" Pack="true"
PackagePath="\icon.png" />
</ItemGroup>
<!-- Local Dependencies -->
<!-- Local Projects -->
@@ -49,4 +60,4 @@
<Target Name="CreateRequiredFolder" AfterTargets="AfterPublish">
<MakeDir Directories="$(PublishDir)wwwroot" Condition="!Exists('$(PublishDir)wwwroot')" />
</Target>
</Project>
</Project>