using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using XYY.Api.WarningNotice.WarningNoticeService; using XYY.Data.Standard; using XYY.Service.Standard.DingDing; using XYY.Service.Standard.RegionService; using Microsoft.Extensions.Configuration; using XYY.Common.Standard; using System.Net; using XYY.Service.Strandard.EMailService; namespace XYY.Api.WarningNotice { public class Startup { public IConfiguration Configuration { get; } public Startup(IConfiguration configuration) { Configuration = configuration; } readonly string MyAllowSpecificOrigins = "_myAllowSpecificOrigins";//Ãû×ÖËæ±ãÆð // This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddXYYService(new ServiceOption { USEDBTransferAsMVC = true, CacheType = DistributedCacheType.Redis, SqlServiceConnection = Configuration[DefaultConfig.SqlServiceConnectionKey], RedisConnection = Configuration[DefaultConfig.RedisConnectionKey], UseRabbit = true }, Configuration); services.AddDistributedMemoryCache(); services.AddSingleton(x => new QYWXWebHook("https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=5eb4675a-773a-40a0-9bad-745501122580")); services.AddSingleton(); //services.AddTransient(); services.AddTransient(); services.AddCors(option => option.AddPolicy(MyAllowSpecificOrigins, policy => policy.AllowAnyHeader().AllowAnyOrigin().WithMethods("GET", "POST", "HEAD", "PUT", "DELETE", "OPTIONS"))); services.AddMvcCore(); //ºöÂÔÖ¤Êé´íÎó ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, errors) => { // local dev, just approve all certs return true; }; } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseStatusCodePages(); app.UseRouting(); app.UseCors(MyAllowSpecificOrigins); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); } } }