120 lines
4.8 KiB
C#
120 lines
4.8 KiB
C#
//using AyCode.Core.Loggers;
|
|
|
|
using AyCode.Core.Loggers;
|
|
using DevExpress.AspNetCore;
|
|
|
|
using FruitBank.Common;
|
|
using FruitBank.Common.Interfaces;
|
|
using FruitBank.Common.Server.Services.Loggers;
|
|
using FruitBank.Common.Server.Services.SignalRs;
|
|
using Mango.Nop.Core.Loggers;
|
|
using Mango.Nop.Services;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Mvc.Razor;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Nop.Core.Domain.Orders;
|
|
using Nop.Core.Infrastructure;
|
|
using Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
|
using Nop.Plugin.Misc.FruitBankPlugin.Factories;
|
|
using Nop.Plugin.Misc.FruitBankPlugin.Filters;
|
|
using Nop.Plugin.Misc.FruitBankPlugin.Models;
|
|
using Nop.Plugin.Misc.FruitBankPlugin.Services;
|
|
using Nop.Services.Catalog;
|
|
using Nop.Services.Common;
|
|
using Nop.Services.Events;
|
|
using Nop.Web.Areas.Admin.Factories;
|
|
using Nop.Web.Areas.Admin.Models.Catalog;
|
|
using Nop.Web.Areas.Admin.Models.Orders;
|
|
using FruitBankDataController = Nop.Plugin.Misc.FruitBankPlugin.Controllers.FruitBankDataController;
|
|
|
|
namespace Nop.Plugin.Misc.FruitBankPlugin.Infrastructure;
|
|
|
|
public class PluginNopStartup : INopStartup
|
|
{
|
|
/// <summary>
|
|
/// Add and configure any of the middleware
|
|
/// </summary>
|
|
/// <param name="services">Collection of service descriptors</param>
|
|
/// <param name="configuration">Configuration of the application</param>
|
|
public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
|
|
{
|
|
services.Configure<RazorViewEngineOptions>(options =>
|
|
{
|
|
options.ViewLocationExpanders.Add(new ViewLocationExpander());
|
|
});
|
|
|
|
//register services and interfaces
|
|
|
|
services.AddSingleton<ILockService, LockService>();
|
|
|
|
services.AddScoped<IAcLogWriterBase, ConsoleLogWriter>();
|
|
//services.AddScoped<IAcLogWriterBase, NopLogWriter>();
|
|
services.AddScoped<LoggerToLoggerApiController2>();
|
|
//services.AddSingleton<SessionService>();
|
|
|
|
services.AddScoped<FruitBankAttributeService>();
|
|
services.AddScoped<PartnerDbTable>();
|
|
services.AddScoped<ShippingDbTable>();
|
|
services.AddScoped<ShippingDocumentDbTable>();
|
|
services.AddScoped<ShippingItemDbTable>();
|
|
services.AddScoped<ShippingItemPalletDbTable>();
|
|
|
|
services.AddScoped<FruitBankDbContext>();
|
|
services.AddScoped<IFruitBankDataControllerServer, FruitBankDataController>();
|
|
|
|
//services.AddScoped<CustomModelFactory, ICustomerModelFactory>();
|
|
services.AddScoped<IPriceCalculationService, CustomPriceCalculationService>();
|
|
services.AddScoped<PriceCalculationService, CustomPriceCalculationService>();
|
|
services.AddScoped<IConsumer<OrderPlacedEvent>, EventConsumer>();
|
|
services.AddScoped<IOrderMeasurementService, OrderMeasurementService>();
|
|
services.AddScoped<PendingMeasurementCheckoutFilter>();
|
|
services.AddScoped<OrderListModel, OrderListModelExtended>();
|
|
services.AddScoped<OrderModel, OrderModelExtended>();
|
|
services.AddScoped<OrderSearchModel, OrderSearchModelExtended>();
|
|
services.AddScoped<IOrderModelFactory, CustomOrderModelFactory>();
|
|
services.AddScoped<IGenericAttributeService, GenericAttributeService>();
|
|
services.AddScoped<CerebrasAPIService>();
|
|
services.AddScoped<OpenAIApiService>();
|
|
//services.AddScoped<IAIAPIService, OpenAIApiService>();
|
|
services.AddScoped<AICalculationService>();
|
|
services.AddControllersWithViews(options =>
|
|
{
|
|
options.Filters.AddService<PendingMeasurementCheckoutFilter>();
|
|
});
|
|
|
|
services.AddSignalR(options => options.MaximumReceiveMessageSize = 256 * 1024);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Configure the using of added middleware
|
|
/// </summary>
|
|
/// <param name="application">Builder for configuring an application's request pipeline</param>
|
|
public void Configure(IApplicationBuilder application)
|
|
{
|
|
var fruitBankHubEndPoint = $"/{FruitBankConstClient.DefaultHubName}";
|
|
application.UseWhen(context => context.Request.Path.StartsWithSegments(fruitBankHubEndPoint), app =>
|
|
{
|
|
app.UseEndpoints(endpoints =>
|
|
{
|
|
endpoints.MapHub<DevAdminSignalRHub>(fruitBankHubEndPoint);
|
|
|
|
});
|
|
});
|
|
|
|
var loggrHubEndPoint = $"/{FruitBankConstClient.LoggerHubName}";
|
|
application.UseWhen(context => context.Request.Path.StartsWithSegments(loggrHubEndPoint), app =>
|
|
{
|
|
app.UseEndpoints(endpoints =>
|
|
{
|
|
endpoints.MapHub<LoggerSignalRHub2>(loggrHubEndPoint);
|
|
});
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets order of this startup configuration implementation
|
|
/// </summary>
|
|
public int Order => 4000;
|
|
} |