82 lines
3.2 KiB
C#
82 lines
3.2 KiB
C#
|
||
using Microsoft.AspNetCore.Mvc;
|
||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||
using System.Net;
|
||
using System.Net.Http;
|
||
using System.Net.Sockets;
|
||
using System.Text;
|
||
using WCS.BLL.Manager;
|
||
using WCS.BLL.Services.IService;
|
||
using WCS.BLL.Services.Service;
|
||
using WCS.DAL;
|
||
using WCS.DAL.Db;
|
||
using WCS.WebApi;
|
||
using WCS.WebApi.Controllers;
|
||
|
||
namespace WebApi
|
||
{
|
||
public class Program
|
||
{
|
||
public static void Main(string[] args)
|
||
{
|
||
|
||
|
||
//LocalStatic.wCSTcpCleint = new WCS.BLL.TCPClient("127.0.0.1:20002");
|
||
//LocalStatic.wCSTcpCleint.Send(new byte[] { 0x08, 0x00, 0x00, 0x11, 0x12, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
|
||
|
||
DbHelp.InitDb();
|
||
AuthDbHelp.InitDb();
|
||
|
||
ShelfManager.InitShelves();
|
||
|
||
|
||
var builder = WebApplication.CreateBuilder(args);
|
||
//// 配置Kestrel
|
||
//builder.WebHost.ConfigureKestrel((context, options) =>
|
||
//{
|
||
// // 设置监听端口
|
||
// options.Listen(IPAddress.Any, 8888); // 监听所有IP地址的5001端口
|
||
|
||
// // 设置请求限制
|
||
// options.Limits.MaxRequestBodySize = 10 * 1024 * 1024; // 最大请求体大小为10MB
|
||
// options.Limits.MaxConcurrentConnections = 1000; // 最大并发连接数
|
||
// options.Limits.MinRequestBodyDataRate = new MinDataRate(bytesPerSecond: 100, gracePeriod: TimeSpan.FromSeconds(10)); // 请求体的最小数据传输速率
|
||
|
||
// // 如果需要配置SSL/TLS,可以在这里添加代码
|
||
// // 例如: options.Listen(IPAddress.Any, 5000, listenOptions => { listenOptions.UseHttps("path_to_certificate.pfx", "certificate_password"); });
|
||
//});
|
||
// Add services to the container.
|
||
builder.Services.AddControllers();
|
||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||
builder.Services.AddEndpointsApiExplorer();
|
||
builder.Services.AddSwaggerGen();
|
||
|
||
builder.Services.AddScoped<IInstoreService, InstoreService>();
|
||
builder.Services.AddScoped<IOutstoreService, OutstoreService>();
|
||
builder.Services.AddScoped<IHomerService, HomerService>();
|
||
builder.Services.AddScoped<IUserService, UserService>();
|
||
builder.Services.AddScoped<IInterfaceRecordService, InterfaceRecordService>();
|
||
builder.Services.AddScoped<IMatBaseInfoService, MatBaseInfoService>();
|
||
builder.Services.AddScoped<IMatInventoryDetailService, MatInventoryDetailService>();
|
||
builder.Services.AddScoped<IStoreInfoService, StoreInfoService>();
|
||
builder.Services.AddScoped<IStockTakingService, StockTakingService>();
|
||
//生成物料码、生成单据码采用单例模式
|
||
builder.Services.AddSingleton<IGenerateService, GenerateService>();
|
||
|
||
var app = builder.Build();
|
||
|
||
app.UseMiddleware<RequestResponseLoggingMiddleware>();
|
||
// Configure the HTTP request pipeline.
|
||
if (app.Environment.IsDevelopment())
|
||
{
|
||
app.UseSwagger();
|
||
app.UseSwaggerUI();
|
||
}
|
||
|
||
app.UseAuthorization();
|
||
app.MapControllers();
|
||
app.Run("http://+:8888");
|
||
}
|
||
}
|
||
}
|