bklLiudl
2024-07-10 6d5c3dee0d97798f70bf965e48c3a782b3df9e7d
Wms/Wms/Startup.cs
@@ -21,6 +21,7 @@
using Microsoft.Extensions.Options;
using Microsoft.AspNetCore.Http;
using SqlSugar;
using Utility.Job;
namespace Wms
{
@@ -42,9 +43,10 @@
            var url2 = Configuration.GetSection("ApiUrlConfig:AgvHost").Value + Configuration.GetSection("ApiUrlConfig:IssueComApiUrl").Value;
            //调用定时任务
            services.AddHostedService<DailyTaskService>(provider =>
            new DailyTaskService(url,url2));
            new DailyTaskService(url, url2));
            services.AddControllers(options => {
            services.AddControllers(options =>
            {
                options.Filters.Add<RequestAuditLogFilter>();
            })
                .AddJsonOptions(options =>
@@ -90,7 +92,7 @@
                            .SetIsOriginAllowed(_ => true)
                            .AllowAnyHeader()
                            .AllowCredentials();
                    });
            });
            #endregion
@@ -112,6 +114,12 @@
            services.Configure<ApiUrlConfig>(Configuration.GetSection("ApiUrlConfig"));
            //数据库配置
            BaseDbConfig.ConnectionString = Configuration.GetSection("AppSettings:ConnectionString").Value;
            //验签配置文件
            SignConfig.ERPAppKey = Configuration.GetSection("SignConfig:ERPAppKey").Value;
            SignConfig.MESAppKey = Configuration.GetSection("SignConfig:MESAppKey").Value;
            SignConfig.LIMSAppKey = Configuration.GetSection("SignConfig:LIMSAppKey").Value;
            SignConfig.FuMaAppKey = Configuration.GetSection("SignConfig:FuMaAppKey").Value;
            SignConfig.Minutes = double.Parse(Configuration.GetSection("SignConfig:Minutes").Value);
            #region AutoMapper注入
@@ -125,6 +133,12 @@
            services.AddScoped<UnitOfWorkAttribute>();
            services.AddSingleton<ISqlSugarClient>(DataContext.Db); // 单例注册
            services.AddTransient<IUnitOfWork, SqlSugarUnitOfWork>(); // 事务与工作单元注册
            services.AddHostedService<HostedService>();
            services.AddSingleton<SchedulerCenter>();
            services.AddTransient<UserManager>();
            services.AddTransient<IHttpContextAccessor, HttpContextAccessor>();
        }
        public void ConfigureContainer(ContainerBuilder builder)
        {
@@ -157,7 +171,7 @@
            //app.UseHttpsRedirection();
            app.UseRouting();
            app.UseAuthentication();
            app.UseAuthorization();
            app.UseCors("MyCors");//跨域