Add appsettings.json to NopCommerce project! install reference packages; Implement endpoints; Fix CORS; etc...

This commit is contained in:
Loretta 2025-09-03 07:07:23 +02:00
parent 05e3376bb3
commit 68a873f15d
4 changed files with 113 additions and 30 deletions

View File

@ -1,5 +1,5 @@
//using AyCode.Core.Consts; //using AyCode.Core.Consts;
using Mango.Nop.Core; //using Mango.Nop.Core;
namespace Nop.Plugin.Misc.FruitBankPlugin namespace Nop.Plugin.Misc.FruitBankPlugin
{ {

View File

@ -1,4 +1,10 @@
//using AyCode.Core.Loggers; //using AyCode.Core.Loggers;
using AyCode.Core.Loggers;
using FruitBank.Common;
using FruitBank.Common.Server.Controllers;
using FruitBank.Common.Server.Services.Loggers;
using FruitBank.Common.Server.Services.SignalRs;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Mvc.Razor; using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR;
@ -39,10 +45,10 @@ public class PluginNopStartup : INopStartup
//register services and interfaces //register services and interfaces
//services.AddSingleton<LoggerToLoggerApiController>(); services.AddSingleton<LoggerToLoggerApiController>();
//services.AddSingleton<IAcLogWriterBase, ConsoleLogWriter>(); services.AddSingleton<IAcLogWriterBase, ConsoleLogWriter>();
////services.AddSingleton<SessionService>(); //services.AddSingleton<SessionService>();
//services.AddScoped<FruitBankDataController>(); services.AddScoped<FruitBankDataController>();
//services.AddScoped<CustomModelFactory, ICustomerModelFactory>(); //services.AddScoped<CustomModelFactory, ICustomerModelFactory>();
services.AddScoped<IPriceCalculationService, CustomPriceCalculationService>(); services.AddScoped<IPriceCalculationService, CustomPriceCalculationService>();
@ -61,27 +67,24 @@ public class PluginNopStartup : INopStartup
/// <param name="application">Builder for configuring an application's request pipeline</param> /// <param name="application">Builder for configuring an application's request pipeline</param>
public void Configure(IApplicationBuilder application) public void Configure(IApplicationBuilder application)
{ {
//var fruitBankHubEndPoint = $"/{FruitBankConstClient.DefaultHubName}"; var fruitBankHubEndPoint = $"/{FruitBankConstClient.DefaultHubName}";
//application.UseWhen(context => context.Request.Path.StartsWithSegments(fruitBankHubEndPoint), app => application.UseWhen(context => context.Request.Path.StartsWithSegments(fruitBankHubEndPoint), app =>
//{ {
// //app.UseCors("AllowBlazorClient"); app.UseEndpoints(endpoints =>
// //app.UseRouting(); {
// app.UseEndpoints(endpoints => endpoints.MapHub<DevAdminSignalRHub>(fruitBankHubEndPoint);
// {
// //endpoints.MapHub<FruitBankHub>("/fbhub");
// endpoints.MapHub<DevAdminSignalRHub>(fruitBankHubEndPoint);
// }); });
//}); });
//var loggrHubEndPoint = $"/{FruitBankConstClient.LoggerHubName}"; var loggrHubEndPoint = $"/{FruitBankConstClient.LoggerHubName}";
//application.UseWhen(context => context.Request.Path.StartsWithSegments(loggrHubEndPoint), app => application.UseWhen(context => context.Request.Path.StartsWithSegments(loggrHubEndPoint), app =>
//{ {
// app.UseEndpoints(endpoints => app.UseEndpoints(endpoints =>
// { {
// endpoints.MapHub<LoggerSignalRHub>(loggrHubEndPoint); endpoints.MapHub<LoggerSignalRHub>(loggrHubEndPoint);
// }); });
//}); });
} }
/// <summary> /// <summary>

View File

@ -9,6 +9,7 @@
to ensure that the dlls copied from the NuGet cache to the output of your project--> to ensure that the dlls copied from the NuGet cache to the output of your project-->
<CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -42,6 +43,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="$(SolutionDir)\Presentation\Nop.Web\Nop.Web.csproj" /> <ProjectReference Include="$(SolutionDir)\Presentation\Nop.Web\Nop.Web.csproj" />
<ProjectReference Include="..\..\Libraries\Mango.Nop.Core\Mango.Nop.Core.csproj" /> <ProjectReference Include="..\..\Libraries\Mango.Nop.Core\Mango.Nop.Core.csproj" />
<ProjectReference Include="..\..\Libraries\Mango.Nop.Services\Mango.Nop.Services.csproj" />
<ClearPluginAssemblies Include="$(SolutionDir)\Build\ClearPluginAssemblies.proj" /> <ClearPluginAssemblies Include="$(SolutionDir)\Build\ClearPluginAssemblies.proj" />
</ItemGroup> </ItemGroup>
@ -60,6 +62,71 @@
<PackageReference Include="Microsoft.AspNetCore.SignalR.Common" Version="9.0.8" /> <PackageReference Include="Microsoft.AspNetCore.SignalR.Common" Version="9.0.8" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.Json" Version="9.0.8" /> <PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.Json" Version="9.0.8" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="9.0.8" /> <PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="9.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.8" />
<PackageReference Include="SendGrid" Version="9.29.3" />
</ItemGroup>
<ItemGroup>
<Reference Include="AyCode.Core">
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Core.dll</HintPath>
</Reference>
<Reference Include="AyCode.Core.Server">
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Core.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Database">
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Database.dll</HintPath>
</Reference>
<Reference Include="AyCode.Entities">
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Entities.dll</HintPath>
</Reference>
<Reference Include="AyCode.Entities.Server">
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Entities.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Interfaces">
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Interfaces.dll</HintPath>
</Reference>
<Reference Include="AyCode.Interfaces.Server">
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Interfaces.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Models.Server">
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Models.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Services">
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Services.dll</HintPath>
</Reference>
<Reference Include="AyCode.Services.Server">
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Services.Server.dll</HintPath>
</Reference>
<Reference Include="FruitBank.Common">
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\FruitBank.Common.dll</HintPath>
</Reference>
<Reference Include="FruitBank.Common.Server">
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\FruitBank.Common.Server.dll</HintPath>
</Reference>
<Reference Include="MessagePack">
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\MessagePack.dll</HintPath>
</Reference>
<Reference Include="MessagePack.Annotations">
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\MessagePack.Annotations.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNetCore.Http.Connections.Client">
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\Microsoft.AspNetCore.Http.Connections.Client.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNetCore.SignalR.Client">
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\Microsoft.AspNetCore.SignalR.Client.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNetCore.SignalR.Client.Core">
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\Microsoft.AspNetCore.SignalR.Client.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson">
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson.dll</HintPath>
</Reference>
<Reference Include="Microsoft.NET.StringTools">
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\Microsoft.NET.StringTools.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\Newtonsoft.Json.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -41,16 +41,29 @@ public class PluginNopStartup : INopStartup
public void Configure(IApplicationBuilder application) public void Configure(IApplicationBuilder application)
{ {
application.UseWhen(context => context.Request.Path.StartsWithSegments("/fbhub"), app => //application.UseWhen(context => context.Request.Path.StartsWithSegments("/fbhub"), app =>
//{
// app.UseCors("AllowBlazorClient");
// app.UseRouting();
// //app.UseEndpoints(endpoints =>
// //{
// // endpoints.MapHub<FruitBankHub>("/fbhub");
// //});
//});
var fruitBankHubEndPoint = "/fbHub";// $"/{FruitBankConstClient.DefaultHubName}";
application.UseWhen(context => context.Request.Path.StartsWithSegments(fruitBankHubEndPoint), app =>
{ {
app.UseCors("AllowBlazorClient"); app.UseCors("AllowBlazorClient");
app.UseRouting(); app.UseRouting();
//app.UseEndpoints(endpoints =>
//{
// endpoints.MapHub<FruitBankHub>("/fbhub");
//});
}); });
var loggrHubEndPoint = "/loggerHub";//$"/{FruitBankConstClient.LoggerHubName}";
application.UseWhen(context => context.Request.Path.StartsWithSegments(loggrHubEndPoint), app =>
{
app.UseCors("AllowBlazorClient");
app.UseRouting();
});
} }
/// <summary> /// <summary>