Files
wcs/WCS.WebApi/Program.cs
hehaibing-1996 97888c6978 提交代码
2024-04-29 08:39:09 +08:00

83 lines
3.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.WebApi;
using WCS.WebApi.Controllers;
namespace WebApi
{
public class Program
{
public static void Main(string[] args)
{
WebSoceketManager.InitWebSocket();
//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 });
DbInit.InitDb();
ShelfManager.InitShelves();
TCPClientManager.InitTcpClient();
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.AddScoped<ISelfCheckService, SelfCheckService>();
//生成物料码、生成单据码采用单例模式
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");
}
}
}