using AutoMapper;
|
using CommonToolsCore;
|
using IServices;
|
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http.Features;
|
using Microsoft.AspNetCore.HttpsPolicy;
|
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.EntityFrameworkCore;
|
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.FileProviders;
|
using Microsoft.Extensions.Hosting;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Serialization;
|
using Services;
|
using System;
|
using System.Collections.Generic;
|
using System.IO;
|
using System.Linq;
|
using System.Threading.Tasks;
|
using UEditor.Core;
|
using zhengcaioa.IService;
|
using zhengcaioa.Model;
|
using zhengcaioa.Models;
|
using zhengcaioa.Service;
|
using zhengcaioa.Timer;
|
|
namespace zhengcaioa
|
{
|
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)
|
{
|
// Ìí¼Ócors ·þÎñ ÅäÖÿçÓò´¦Àí
|
services.AddCors(options =>
|
{
|
options.AddPolicy("any", builder =>
|
{
|
builder.WithMethods("GET", "POST", "HEAD", "PUT", "DELETE", "OPTIONS")
|
.AllowAnyHeader()
|
//.AllowCredentials()//Ö¸¶¨´¦Àícookie
|
.AllowAnyOrigin(); //ÔÊÐíÈκÎÀ´Ô´µÄÖ÷»ú·ÃÎÊ
|
});
|
});
|
//services.AddCors(option => option.AddPolicy("cors", policy => policy.AllowAnyHeader().AllowAnyMethod().AllowCredentials().AllowAnyOrigin()));
|
|
services.AddSession(options =>
|
{
|
options.IdleTimeout = TimeSpan.FromMinutes(60);
|
});
|
services.Configure<CookiePolicyOptions>(options =>
|
{
|
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
|
options.CheckConsentNeeded = context => true;
|
options.MinimumSameSitePolicy = SameSiteMode.None;
|
});
|
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
|
var connectionString = Configuration.GetConnectionString("DefaultConnection");
|
services.AddDbContext<zhengcaioaContext>(options =>
|
options.UseSqlServer(connectionString));
|
services.AddControllersWithViews();
|
|
services.AddScoped(typeof(ISimService), typeof(SimService));
|
services.AddScoped(typeof(IHrSalaryService), typeof(HrSalaryService));
|
|
services.AddScoped(typeof(IUserService), typeof(UserService));
|
services.AddScoped(typeof(ILiaotianService), typeof(LiaotianService));
|
services.AddScoped(typeof(IProjectService), typeof(ProjectService));
|
services.AddScoped(typeof(ISysCodeService), typeof(SysCodeService));
|
services.AddScoped(typeof(IPltRoleService), typeof(PltRoleService));
|
services.AddScoped(typeof(IPltPageService), typeof(PltPageService));
|
services.AddScoped(typeof(IHrPositionService), typeof(HrPositionService));
|
services.AddScoped(typeof(IHrDeptService), typeof(HrDeptService));
|
services.AddScoped(typeof(ICooperatecustomCustomerService), typeof(CooperatecustomCustomerService));
|
services.AddScoped(typeof(IIntentionCustomerService), typeof(IntentionCustomerService));
|
services.AddScoped(typeof(IIntentionVisitService), typeof(IntentionVisitService));
|
services.AddScoped(typeof(ICooperVisitService), typeof(CooperVisitService));
|
services.AddScoped(typeof(IIntentionOrderService), typeof(IntentionOrderService));
|
services.AddScoped(typeof(ICooperOrderService), typeof(CooperOrderService));
|
services.AddScoped(typeof(ISystemsettingService), typeof(SystemsettingService));
|
services.AddScoped(typeof(IGroupTopicService), typeof(GroupTopicService));
|
services.AddScoped(typeof(IGroupGrouptypeService), typeof(GroupGrouptypeService));
|
services.AddScoped(typeof(IGroupGroupService), typeof(GroupGroupService));
|
services.AddScoped(typeof(IGroupTuiguangService), typeof(GroupTuiguangService));
|
services.AddScoped(typeof(IExpertService), typeof(ExpertService));
|
services.AddScoped(typeof(IAdmSigninService), typeof(AdmSigninService));
|
services.AddScoped(typeof(IDailyManagementService), typeof(DailyManagementService));
|
services.AddScoped(typeof(IFiSubjectService), typeof(FiSubjectService));
|
services.AddScoped(typeof(IFiAccountService), typeof(FiAccountService));
|
services.AddScoped(typeof(IFiOrderrecievemoneyService), typeof(FiOrderrecievemoneyService));
|
services.AddScoped(typeof(IFiPiecerateService), typeof(FiPiecerateService));
|
services.AddScoped(typeof(IAdmDocBaseService), typeof(AdmDocBaseService));
|
services.AddScoped(typeof(IAdmDocDocService), typeof(AdmDocDocService));
|
services.AddScoped(typeof(IAdmEvaluateService), typeof(AdmEvaluateService));
|
services.AddScoped(typeof(IAreaService), typeof(AreaService));
|
services.AddScoped(typeof(IPltRoleDeptService), typeof(PltRoleDeptService));
|
services.AddScoped(typeof(IAdmGoodsClassifyService), typeof(AdmGoodsClassifyService));
|
services.AddScoped(typeof(IAdmGoodsManageService), typeof(AdmGoodsManageService));
|
services.AddScoped(typeof(IAdmPieceCheckService), typeof(AdmPieceCheckService));
|
services.AddScoped(typeof(IAdmBreakPrecedentService), typeof(AdmBreakPrecedentService));
|
services.AddScoped(typeof(ISysAttachmentService), typeof(SysAttachmentService));
|
services.AddScoped(typeof(IPltJiatingchengyuanService), typeof(PltJiatingchengyuanService));
|
services.AddScoped(typeof(IFiAccountRecordService), typeof(FiAccountRecordService));
|
|
services.AddScoped(typeof(IFiServiceService), typeof(FiServiceService));
|
services.AddScoped(typeof(IFiMemberService), typeof(FiMemberService));
|
services.AddScoped(typeof(IFiBookService), typeof(FiBookService));
|
|
services.AddScoped(typeof(IAdmAttendanceRuleService), typeof(AdmAttendanceRuleService));
|
|
services.AddScoped(typeof(IAdmAttendanceDtlService), typeof(AdmAttendanceDtlService));
|
services.AddScoped(typeof(IAdmAttendanceService), typeof(AdmAttendanceService));
|
|
services.AddScoped(typeof(IHrJibengongziService), typeof(HrJibengongziService));
|
|
services.AddScoped(typeof(IHrJixiaotichengService), typeof(HrJixiaotichengService));
|
|
services.AddScoped(typeof(IHrSalaryService), typeof(HrSalaryService));
|
|
services.AddScoped(typeof(ICusFangwenjiluService), typeof(CusFangwenjiluService));
|
|
services.AddScoped(typeof(ILZhuanjiahuidumService), typeof(LZhuanjiahuidumService));
|
|
services.AddScoped(typeof(IWfApplytypeService), typeof(WfApplytypeService));
|
services.AddScoped(typeof(IWfRunProcessService), typeof(WfRunProcessService));
|
services.AddScoped(typeof(IWfNeeddeelService), typeof(WfNeeddeelService));
|
services.AddScoped(typeof(IWfHistoryService), typeof(WfHistorieservice));
|
services.AddScoped(typeof(IOrderBanciDtlService), typeof(OrderBanciDtlService));
|
services.AddScoped(typeof(IOrderBanciService), typeof(OrderBanciService));
|
services.AddScoped(typeof(IOrderBanciOrderService), typeof(OrderBanciOrderService));
|
|
|
//¶¨Ê±Ö´ÐÐ
|
services.AddHostedService<TimedBackgroundService>();
|
|
|
services.AddAutoMapper(typeof(AutoMapperConfigs));
|
services.AddUEditorService("ueditor.json", true, "wwwroot");
|
services.AddMvc(options =>{
|
options.Filters.Add<HttpGlobalExceptionFilter>();//È«¾Ö×¢²á
|
options.Filters.Add<AntiSqlAttribute>();//È«¾Ö×¢²á
|
|
});
|
services.Configure<IISServerOptions>(options =>
|
{
|
options.MaxRequestBodySize = 52428800;
|
});
|
//services.AddMvc().AddJsonOptions(opt =>
|
//{
|
// opt.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver();//json×Ö·û´®´óСдÔÑùÊä³ö
|
//});
|
//È«¾ÖÅäÖÃJsonÐòÁл¯´¦Àí
|
services.AddMvc().AddNewtonsoftJson(options =>
|
{
|
//ºöÂÔÑ»·ÒýÓÃ
|
options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
|
//²»Ê¹ÓÃÍÕ·åÑùʽµÄkey
|
options.SerializerSettings.ContractResolver = new DefaultContractResolver();
|
//ÉèÖÃʱ¼ä¸ñʽ
|
options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
|
});
|
services.AddHttpClient();
|
|
}
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
{
|
app.UseSession();
|
if (env.IsDevelopment())
|
{
|
app.UseDeveloperExceptionPage();
|
}
|
else
|
{
|
app.UseExceptionHandler("/Home/Error");
|
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
app.UseHsts();
|
}
|
app.UseHttpsRedirection();
|
app.UseStaticFiles();
|
|
app.UseRouting();
|
|
app.UseAuthorization();
|
app.UseCors("any");
|
app.UseEndpoints(endpoints =>
|
{
|
endpoints.MapControllerRoute(
|
name: "default",
|
pattern: "{controller=Home}/{action=Index}/{id?}").RequireCors("any");
|
});
|
|
// app.UseStaticFiles(new StaticFileOptions
|
// {
|
// FileProvider = new PhysicalFileProvider(
|
//Path.Combine(Directory.GetCurrentDirectory(), "UploadingFiles")),
|
// RequestPath = "/UploadingFiles",
|
// OnPrepareResponse = ctx =>
|
// {
|
// ctx.Context.Response.Headers.Append("Cache-Control", "public,max-age=36000");
|
// }
|
// });
|
|
//app.UseMiddleware<CorsMiddleware>();
|
}
|
}
|
}
|