|
|
|
|
using DS.WMS.PrintApi.Service;
|
|
|
|
|
using DS.WMS.PrintApi.Utils;
|
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using System.Text.Encodings.Web;
|
|
|
|
|
using System.Text.Unicode;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.PrintApi
|
|
|
|
|
{
|
|
|
|
|
public class Startup
|
|
|
|
|
{
|
|
|
|
|
public Startup(IConfiguration configuration)
|
|
|
|
|
{
|
|
|
|
|
Configuration = configuration;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IConfiguration Configuration { get; }
|
|
|
|
|
|
|
|
|
|
// This method gets called by the runtime. Use this method to add services to the container.
|
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
|
|
|
{
|
|
|
|
|
services.AddControllers();
|
|
|
|
|
//ע<><D7A2>IWMSCommonService <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
services.AddSingleton<IOpenPrintService, OpenPrintService>();
|
|
|
|
|
|
|
|
|
|
services.AddControllers(
|
|
|
|
|
(options =>
|
|
|
|
|
{
|
|
|
|
|
// 204Ԥ<34><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//options.Filters.Add<FegCrosFilter>();
|
|
|
|
|
//ȫ<><C8AB><EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD>
|
|
|
|
|
options.Filters.Add<GlobalExceptionsFilter>();
|
|
|
|
|
options.SuppressAsyncSuffixInActionNames = false;
|
|
|
|
|
}))
|
|
|
|
|
.AddNewtonsoftJson(options =>
|
|
|
|
|
{
|
|
|
|
|
//CustomContractResolver <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
options.SerializerSettings.ContractResolver = new CustomContractResolver();
|
|
|
|
|
|
|
|
|
|
// ʱ<><CAB1><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>
|
|
|
|
|
options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
|
|
|
|
|
// <20><><EFBFBD>Կ<EFBFBD>ֵ
|
|
|
|
|
// options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
|
|
|
|
|
})
|
|
|
|
|
.AddJsonOptions(cfg =>
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
cfg.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All);
|
|
|
|
|
});
|
|
|
|
|
//Swagger
|
|
|
|
|
services.AddSwaggerSetup();
|
|
|
|
|
|
|
|
|
|
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
|
|
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
|
|
|
{
|
|
|
|
|
var documentName = AppSetting.Configuration["SwaggerDoc:ContactName"];
|
|
|
|
|
// app.UseHttpsRedirection();
|
|
|
|
|
app.UseSwagger().UseSwaggerUI(c =>
|
|
|
|
|
{
|
|
|
|
|
c.SwaggerEndpoint("/swagger/v1/swagger.json", documentName);
|
|
|
|
|
});
|
|
|
|
|
app.UseRouting();
|
|
|
|
|
//<2F><>̬<EFBFBD>ļ<EFBFBD>
|
|
|
|
|
app.UseStaticFiles();
|
|
|
|
|
// <20>ȿ<EFBFBD><C8BF><EFBFBD><EFBFBD><EFBFBD>֤
|
|
|
|
|
app.UseAuthentication();
|
|
|
|
|
// Ȼ<><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD>м<EFBFBD><D0BC><EFBFBD>
|
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
|
|
|
|
//app.UseMiddleware<ApiAuthMiddleware>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|