123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- using Microsoft.AspNetCore.Builder;
- using Microsoft.AspNetCore.Hosting;
- using Microsoft.AspNetCore.HttpsPolicy;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Configuration;
- using Microsoft.Extensions.DependencyInjection;
- using Microsoft.Extensions.Hosting;
- using Microsoft.Extensions.Logging;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Serialization;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Threading.Tasks;
- using XYY.Authentication.Standard;
- using XYY.Core.Standard.ApiClient;
- using XYY.Core.Standard.Data.Infrastructure;
- using XYY.Data.Standard.Tasks;
- using XYY.Service.Standard.RegionService;
- using XYY.TaskTrack.Standard;
- namespace XYY.Api.Order
- {
- public class Startup
- {
- public Startup(IConfiguration configuration)
- {
- Configuration = configuration;
- }
- public IConfiguration Configuration { get; }
- readonly string MyAllowSpecificOrigins = "_myAllowSpecificOrigins";//Ãû×ÖËæ±ãÆð
- // This method gets called by the runtime. Use this method to add services to the container.
- public void ConfigureServices(IServiceCollection services)
- {
- services.AddXYYService(new ServiceOption
- {
- USEDBTransferAsMVC = true,
- CacheType = DistributedCacheType.Memory,
- SqlServiceConnection = Configuration[DefaultConfig.SqlServiceConnectionKey],
- UseRabbit = true,
- //UseFiddler=true,
- }, Configuration);
- services.ConfigAspectCore("BoxService");
- services.AddCors(option => option.AddPolicy(MyAllowSpecificOrigins, policy =>
- policy.AllowAnyHeader().AllowAnyOrigin().WithMethods("GET", "POST", "HEAD", "PUT", "DELETE", "OPTIONS")));
- services.AddControllers().AddNewtonsoftJson(options =>
- {
- options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
- options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
- options.SerializerSettings.ContractResolver = new DefaultContractResolver();
- });
- services.AddAuthentication(BasicAuthenticationScheme.DefaultScheme)
- .AddScheme<BasicAuthenticationOption, BasicAuthenticationHandler>(BasicAuthenticationScheme.DefaultScheme, null
- );
- services.AddXYYService(new ServiceOption
- {
- SqlServiceConnection = Configuration[DefaultConfig.SqlServiceConnectionKey],
- UseFinanceChargesRedis = true,
- FinanceChargesRedisConnection = "r-wz9o30bx758o8jhbrapd.redis.rds.aliyuncs.com",
- USEDBTransferAsMVC = false,
- UseRabbit = true
- }, Configuration);
- services.AddSingleton<Service.Standard.Finance.Charging.Attached.ITAttachedZipSet>();
- //ºöÂÔÖ¤Êé´íÎó
- 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.UseBasicAuthentication();
- app.UseAuthentication();
- app.UseAuthorization();
- app.UseWebSockets();
- app.UseEndpoints(endpoints =>
- {
- endpoints.MapControllers();
- });
- }
- }
- }
|