//using AyCode.Core.Loggers;
using AyCode.Core.Loggers;
using DevExpress.AspNetCore;
using FruitBank.Common;
using FruitBank.Common.Interfaces;
using FruitBank.Common.Server.Interfaces;
using FruitBank.Common.Server.Services.Loggers;
using FruitBank.Common.Server.Services.SignalRs;
using Mango.Nop.Services;
using Mango.Nop.Services.Loggers;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http.Connections;
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.Data;
using Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers;
using Nop.Plugin.Misc.FruitBankPlugin.Controllers;
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 System.Net.Http.Headers;
namespace Nop.Plugin.Misc.FruitBankPlugin.Infrastructure;
public class PluginNopStartup : INopStartup
{
///
/// Add and configure any of the middleware
///
/// Collection of service descriptors
/// Configuration of the application
public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
services.AddScoped();
services.AddTransient();
services.AddScoped();
services.AddSingleton();
//services.AddSingleton();
services.Configure(options =>
{
options.ViewLocationExpanders.Add(new ViewLocationExpander());
});
services.AddSingleton();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
//services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped, EventConsumer>();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddHttpClient(client =>
{
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", "r8_MUApXYIE5mRjxqy20tsGLehWBJkCzNj0Cwvrh");
});
//services.AddScoped();
//services.AddScoped();
//services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
//services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddControllersWithViews(options =>
{
options.Filters.AddService();
});
services.AddSignalR(hubOptions =>
{
hubOptions.EnableDetailedErrors = true;
hubOptions.MaximumReceiveMessageSize = 30_000_000; // 256 * 1024; unlimited: null;
hubOptions.KeepAliveInterval = TimeSpan.FromSeconds(FruitBankConstClient.SignalRKeepAliveIntervalSecond);
hubOptions.ClientTimeoutInterval = TimeSpan.FromSeconds(FruitBankConstClient.SignarlRTimeoutIntervalSecond);
//hubOptions.MaximumParallelInvocationsPerClient = 1; //default: 1;
hubOptions.StatefulReconnectBufferSize = 30_000_000; //30MB; //default: 100,000 bytes;
//hubOptions.HandshakeTimeout = TimeSpan.FromSeconds(15); //default timeout is 15 seconds
});
}
///
/// Configure the using of added middleware
///
/// Builder for configuring an application's request pipeline
public void Configure(IApplicationBuilder application)
{
var fruitBankHubEndPoint = $"/{FruitBankConstClient.DefaultHubName}";
application.UseWhen(context => context.Request.Path.StartsWithSegments(fruitBankHubEndPoint), app =>
{
app.UseEndpoints(endpoints =>
{
endpoints.MapHub(fruitBankHubEndPoint, options =>
{
options.Transports = HttpTransportType.WebSockets;// | HttpTransportType.LongPolling;
options.WebSockets.CloseTimeout = TimeSpan.FromSeconds(10); //default: 5 sec.
//options.LongPolling.PollTimeout = new TimeSpan(0, 0, 90); //default: 90 sec.
options.AllowStatefulReconnects = true;
options.TransportMaxBufferSize = 30_000_000; // Increasing this value allows the server to receive larger messages. default: 65KB; unlimited: 0;
options.ApplicationMaxBufferSize = 30_000_000; //Increasing this value allows the server to send larger messages. default: 65KB; unlimited: 0;
options.TransportSendTimeout = TimeSpan.FromSeconds(60); //default: 10 sec.
});
});
});
var loggrHubEndPoint = $"/{FruitBankConstClient.LoggerHubName}";
application.UseWhen(context => context.Request.Path.StartsWithSegments(loggrHubEndPoint), app =>
{
app.UseEndpoints(endpoints =>
{
endpoints.MapHub(loggrHubEndPoint, options =>
{
options.AllowStatefulReconnects = false;
});
});
});
}
///
/// Gets order of this startup configuration implementation
///
public int Order => 4000;
}