|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Serilog;
|
|
|
|
using System;
|
|
|
|
using System.Configuration;
|
|
|
|
using WMS_GIRAF_Interface.Data;
|
|
|
|
using WMS_GIRAF_Interface.Repositories.Implement;
|
|
|
|
using WMS_GIRAF_Interface.Repositories.Interface;
|
|
|
|
using WMS_GIRAF_Interface.TaskServices;
|
|
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
|
|
// 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<IdestinationIdRepository, destinationIdRepository>();
|
|
|
|
builder.Services.AddScoped<IManageMainRepository, ManageMainRepository>();
|
|
|
|
builder.Services.AddScoped<IIoControlRepository, IoControlRepository>();
|
|
|
|
builder.Services.AddScoped<IIoControlRouteRepository, IoControlRouteRepository>();
|
|
|
|
builder.Services.AddScoped<IProductInformationRepository, ProductInformationRepository>();
|
|
|
|
builder.Services.AddScoped<IWhCellRepository, WhCellRepository>();
|
|
|
|
//����ʹ�õĴ�����
|
|
|
|
builder.Services.AddScoped<ManageTaskService>();
|
|
|
|
builder.Services.AddScoped<CellLogicService>();
|
|
|
|
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
var connectionString = builder.Configuration.GetConnectionString("TestConnectString");
|
|
|
|
|
|
|
|
#else
|
|
|
|
var connectionString = builder.Configuration.GetConnectionString("PrdConnectString");
|
|
|
|
#endif
|
|
|
|
Console.WriteLine($"���ݿ������ַ���: {connectionString}");
|
|
|
|
//��ʼ�����ݿ�����
|
|
|
|
builder.Services.AddDbContext<MichelinDbContext>(options =>
|
|
|
|
options.UseSqlServer(connectionString),
|
|
|
|
ServiceLifetime.Transient);
|
|
|
|
|
|
|
|
|
|
|
|
var configuration = builder.Configuration;
|
|
|
|
// ���� Serilog
|
|
|
|
Log.Logger = new LoggerConfiguration()
|
|
|
|
.ReadFrom.Configuration(configuration)
|
|
|
|
.CreateLogger();
|
|
|
|
Log.Information("Starting web application");
|
|
|
|
builder.Host.UseSerilog();
|
|
|
|
|
|
|
|
builder.Services.AddCors(options =>
|
|
|
|
{
|
|
|
|
options.AddPolicy("AllowSpecificOrigins",
|
|
|
|
corsPolicyBuilder =>
|
|
|
|
{
|
|
|
|
// �����ض���Դ����
|
|
|
|
corsPolicyBuilder.WithOrigins("*")
|
|
|
|
.AllowAnyHeader()
|
|
|
|
.AllowAnyMethod();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
|
|
|
|
|
|
// Configure the HTTP request pipeline.
|
|
|
|
if (app.Environment.IsDevelopment())
|
|
|
|
{
|
|
|
|
app.UseSwagger();
|
|
|
|
app.UseSwaggerUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
// ʹ�� CORS �м���
|
|
|
|
app.UseCors("AllowSpecificOrigins");
|
|
|
|
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
|
|
app.MapControllers();
|
|
|
|
|
|
|
|
app.Run();
|