Files
wcs/WCS.WebApi/Program.cs
hehaibing-1996 e89b64ea3a !提交代码
2024-04-15 18:43:28 +08:00

82 lines
3.1 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 TouchSocket.Core;
using TouchSocket.Sockets;
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;
using TcpClient = TouchSocket.Sockets.TcpClient;
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>();
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");
}
}
}