| | |
| | | using System.Linq; |
| | | using System.Reflection; |
| | | using Tiger.IBusiness; |
| | | using Tiger.IBusiness.Utility; |
| | | |
| | | namespace Tiger.Api |
| | | { |
| | |
| | | public Startup(IConfiguration configuration) |
| | | { |
| | | Configuration = configuration; |
| | | //初始化 ApiConfig |
| | | ApiConfig.InitConfig(configuration); |
| | | |
| | | //测试代码 |
| | |
| | | { |
| | | //services.RegisterAssembly("Tiger.Service"); |
| | | //services.AddTransient(typeof(IBaseService<>), typeof(BaseService<>)); |
| | | services.AddControllers().AddNewtonsoftJson(opt => |
| | | services.AddControllersWithViews().AddNewtonsoftJson(opt => |
| | | { |
| | | opt.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver(); |
| | | opt.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss"; |
| | |
| | | app.UseCors(anyAllowSpecificOrigins);//支持跨域:允许特定来源的主机访问 |
| | | |
| | | //app.UseHttpsRedirection(); |
| | | app.UseStaticFiles(); |
| | | |
| | | //app.UseAuthorization(); |
| | | app.UseEndpoints(endpoints => |
| | | { |
| | | endpoints.MapControllers().RequireCors(anyAllowSpecificOrigins); |
| | | //endpoints.MapControllers(); |
| | | endpoints.MapControllerRoute(name: "default", pattern: "{controller=Home}/{action=Index}/{id?}").RequireCors(anyAllowSpecificOrigins); |
| | | //endpoints.MapControllers().RequireCors(anyAllowSpecificOrigins); |
| | | }); |
| | | |
| | | ConsoleExt.Write($"Api Run as{((ApiConfig.IsDevVersion || ApiConfig.IsTestVersion) ? ((ApiConfig.IsDevVersion ? " Dev" : "") + (ApiConfig.IsTestVersion ? " Test" : "")) : " Release")} Edition", ConsoleColor.Cyan); |
| | |
| | | (BizConfig.Configuration[$"Databases:Main:ConnectionString"].Split(';').Any(q => q.Contains("port")) ? "," : "") + |
| | | BizConfig.Configuration[$"Databases:Main:ConnectionString"].Split(';').Where(q => q.Contains("Data Source") || q.Contains("DataSource") || q.Contains("database")).FirstOrDefault(), ConsoleColor.Cyan); |
| | | } |
| | | |
| | | //初始化Business的AutoFacContainer |
| | | DI.Resolve<IBiz>().SetContainer(AutoFacContainer.Instance); |
| | | //开启Api监控总线 |
| | |
| | | DI.Resolve<IServicesBus>().StartServices(app.ApplicationServices.GetService<ISchedulerFactory>()); |
| | | //开启DB缓存自动更新 |
| | | DI.Resolve<IDbCacheBus>().StartAutoUpdate(); |
| | | //开启MQTT服务 |
| | | MQTTHelper.Start(); |
| | | } |
| | | |
| | | /// <summary> |