Example #1
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //Configure DbContext
            services.AddAbpDbContext <JxStudioAPICenterDbContext>(options =>
            {
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
            });

            services.AddMvc(options =>
            {
                options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
            });
            services.AddHttpClient();

            services.AddAlipay();

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info {
                    Title = "My API", Version = "v1"
                });
                c.DocInclusionPredicate((docName, description) => true);
            });

            services.AddCors();
            //Configure Abp and Dependency Injection
            return(services.AddAbp <JxStudioAPICenterWebModule>(options =>
            {
                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                    );
            }));
        }
Example #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews(options =>
            {
                options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
                options.Filters.Add(new AbpAutoValidateAntiforgeryTokenAttribute());
            }).AddNewtonsoftJson(options =>
            {
                options.SerializerSettings.ContractResolver = new AbpMvcContractResolver(IocManager.Instance)
                {
                    NamingStrategy = new CamelCaseNamingStrategy()
                };
            });

            services.AddScoped <IWebResourceManager, WebResourceManager>();

            //Configure DbContext
            services.AddAbpDbContext <AdvertDbContext>(options =>
            {
                //DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, Configuration.GetConnectionString("AdvertContext"));
            });



            //Configure Abp and Dependency Injection
            return(services.AddAbp <AdvertWebSiteModule>(options =>
            {
                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                    );
            }));
        }
Example #3
0
 public static void JTAddAbpDbContext(this IServiceCollection services)
 {
     services.AddAbpDbContext <WebFileSystemCoreDbContext>(options =>
     {
         DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
     });
 }
Example #4
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            new OrderGlobalConfig(_configuration);
            //Configure DbContext
            services.AddAbpDbContext <OrderDbContext>(options =>
            {
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
            });

            services.AddMvc(options =>
            {
                options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
            });
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "Order Api", Version = "v1"
                });
            });
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/build";
            });
            //Configure Abp and Dependency Injection
            return(services.AddAbp <OrderWebModule>(options =>
            {
                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                    );
            }));
        }
Example #5
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //Configure DbContext
            services.AddAbpDbContext <APIDbContext>(options =>
            {
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
            });

            services.AddMvc(options =>
            {
                options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
            });

            services.AddSwaggerGen(options =>
            {
                options.SwaggerDoc("v1", new Info {
                    Title = "GrapePhoto Notification API", Version = "v1"
                });
            });


            //Configure Abp and Dependency Injection
            return(services.AddAbp <APIWebModule>(options =>
            {
                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                    );
            }));
        }
Example #6
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //Configure DbContext
            services.AddAbpDbContext <GalaxyFlowDbContext>(options =>
            {
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
            });
            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options =>
            {
                options.AccessDeniedPath = "/Error/SomethingWrong";
                options.LoginPath        = "/Account/Login";
            });
            services.AddMvc(options =>
            {
                options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
            });

            //Configure Abp and Dependency Injection
            return(services.AddAbp <GalaxyFlowWebModule>(options =>
            {
                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                    );
            }));
        }
Example #7
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //Configure DbContext
            services.AddAbpDbContext <EmployeesApiDbContext>(options =>
            {
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
            });
            services.AddMvc(options =>
            {
                options.Filters.Add(typeof(HttpGlobalExceptionFilter));
            });

            services.AddSwaggerGen(options =>
            {
                options.SwaggerDoc("v1", new Info {
                    Title = "AbpZeroTemplate API", Version = "v1"
                });
                options.DocInclusionPredicate((docName, description) => true);
            });

            //Configure Abp and Dependency Injection
            return(services.AddAbp <EmployeesApiWebModule>(options =>
            {
                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                    );
            }));
        }
Example #8
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //Configure DbContext
            services.AddAbpDbContext <AbpProjectNameDbContext>(options =>
            {
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
            });

            services.AddControllersWithViews(options =>
            {
                options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
            }).AddNewtonsoftJson();

            //Configure Abp and Dependency Injection
            return(services.AddAbp <AbpProjectNameWebModule>(options =>
            {
                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig(
                        _hostingEnvironment.IsDevelopment()
                            ? "log4net.config"
                            : "log4net.Production.config"
                        )
                    );
            }));
        }
Example #9
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //Configure DbContext
            services.AddAbpDbContext <TESTABPDbContext>(options => {
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
            });
            SDKProperties.LogRepository = repository;

            services.AddMvc(options => {
                options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
            });

            // 添加 Cookie 服务
            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(options => {
                options.LoginPath = "/Home/LogIn";
                //options.LogoutPath = "/Account/LogOff";
            });

            //Configure Abp and Dependency Injection
            return(services.AddAbp <TESTABPWebModule>(options => {
                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                    );
            }));
        }
Example #10
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //Configure DbContext
            services.AddAbpDbContext <OnlineTutorDbContext>(options =>
            {
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
            });

            services.AddMvc(options =>
            {
                options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
            });

            services.AddMvc()
            .ConfigureApplicationPartManager(manager =>
            {
                var oldMetadataReferenceFeatureProvider = manager.FeatureProviders.First(f => f is MetadataReferenceFeatureProvider);
                manager.FeatureProviders.Remove(oldMetadataReferenceFeatureProvider);
                manager.FeatureProviders.Add(new ReferencesMetadataReferenceFeatureProvider());
            });

            //Configure Abp and Dependency Injection
            return(services.AddAbp <OnlineTutorWebModule>(options =>
            {
                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                    );
            }));
        }
Example #11
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //Configure DbContext
            services.AddAbpDbContext <ABPAdminLTEDbContext>(options =>
            {
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
            });

            services.AddMvc(options =>
            {
                options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
            });

            IdentityRegistrar.Register(services);

            services.AddScoped <IWebResourceManager, WebResourceManager>();

            //Configure Abp and Dependency Injection
            return(services.AddAbp <ABPAdminLTEWebMvcModule>(options =>
            {
                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                    );
            }));
        }
Example #12
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //Configure DbContext
            services.AddAbpDbContext <SaleAppDbContext>(options =>
            {
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
            });

            services.AddMvc(options =>
            {
                options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
            })
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
            .AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());

            services.AddKendo();

            //Configure Abp and Dependency Injection
            return(services.AddAbp <SaleAppWebModule>(options =>
            {
                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                    );
            }));
        }
Example #13
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //Configure DbContext
            services.AddAbpDbContext <TaobaoAuthorizationDbContext>(options =>
            {
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
            });

            services.Configure <AppSettings>(Configuration.GetSection("AppSettings"));

            services.AddMvc(options =>
            {
                //options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
            });

            services.AddSession();

            //Configure Abp and Dependency Injection
            return(services.AddAbp <TaobaoAuthorizationWebModule>(options =>
            {
                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                    );
            }));
        }
Example #14
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //Configure DbContext
            services.AddAbpDbContext <AiClassRoomDbContext>(options =>
            {
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
            });

            services.AddControllersWithViews(options =>
            {
                options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
                //添加全局异常过滤器
                options.Filters.Add(typeof(HttpGlobalExceptionFilter));
            }).AddNewtonsoftJson();

            services.AddSwaggerGen(options =>
            {
                options.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo {
                    Title = "AiClassRoom", Version = "v1"
                });
                options.DocInclusionPredicate((docName, description) => true);
            });

            //Configure Abp and Dependency Injection
            return(services.AddAbp <AiClassRoomWebModule>(options =>
            {
                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                    );
            }));
        }
Example #15
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            // 注册数据库上下文
            if (!string.IsNullOrWhiteSpace(_configurationRoot.GetConnectionString(IEManageSystemConsts.ConnectionStringName)))
            {
                services.AddAbpDbContext <IEManageSystemDbContext>(options =>
                {
                    DbContextOptionsConfigurer.Configure(
                        options.DbContextOptions,
                        _configurationRoot.GetConnectionString(IEManageSystemConsts.ConnectionStringName),
                        _configurationRoot.GetSection("ConnectionType").Value);

                    if (_env.IsDevelopment())
                    {
                        LoggerFilterOptions loggerFilterOptions = new LoggerFilterOptions();
                        loggerFilterOptions.AddFilter((level) => level >= LogLevel.Information);

                        // 日志过滤器
                        options.DbContextOptions.UseLoggerFactory(new LoggerFactory(new[] { new DebugLoggerProvider() }, loggerFilterOptions));
                    }
                });
            }

            services.AddControllersWithViews(options =>
            {
                // .net core 自动将移除 Async 后缀,如方法 LoginAsync 的路由为 /Controller/Login
                // 设为发 false 则不会移除
                options.SuppressAsyncSuffixInActionNames = false;

                options.Conventions.Insert(0, new IEApiConvention());
            }).AddNewtonsoftJson(options => {
                options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
            });

            // 添加单页
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/build";
            });

            // 添加IEJwtBearer认证
            services.AddIEJwtBearer(
                WebConfiguration.Issuer,
                WebConfiguration.Audience,
                WebConfiguration.SymmetricKey);

            // 添加IE授权
            services.AddIEAuthorization();

            // Configure Abp and Dependency Injection
            return(services.AddAbp <IEManageSystemWebModule>(options =>
            {
                // Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                    );
            }));
        }
Example #16
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //设置接收文件长度的最大值。
            services.Configure <FormOptions>(x =>
            {
                x.ValueLengthLimit            = int.MaxValue;
                x.MultipartBodyLengthLimit    = int.MaxValue;
                x.MultipartHeadersLengthLimit = int.MaxValue;
            });
            //Configure DbContext
            services.AddAbpDbContext <MasterDbContext>(options =>
            {
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
            });
            services.AddSession(); //使用Session
            services.AddSignalR(); //使用SignalR
            services.AddMvc(options =>
            {
                //options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
            }).AddJsonOptions(options => {
                //忽略循环引用
                options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
                //不使用驼峰样式的key
                options.SerializerSettings.ContractResolver = new DefaultContractResolver();
                //设置时间格式
                options.SerializerSettings.DateFormatString = "yyyy-MM-dd";
            });
            services.PostConfigure <MvcJsonOptions>(options =>
            {
                options.SerializerSettings.ContractResolver = new MyContractResolver();
                //options.SerializerSettings.Converters.Add(new BoolConvert());
            });
            //配置jwt
            AuthConfigurer.Configure(services, _appConfiguration);

            /*
             * CO2NET 是从 Senparc.Weixin 分离的底层公共基础模块,经过了长达 6 年的迭代优化,稳定可靠。
             * 关于 CO2NET 在所有项目中的通用设置可参考 CO2NET 的 Sample:
             * https://github.com/Senparc/Senparc.CO2NET/blob/master/Sample/Senparc.CO2NET.Sample.netcore/Startup.cs
             */
            //services.Configure<SenparcWeixinSetting>(_appConfiguration.GetSection("SenparcWeixinSetting"));
            services.AddSenparcGlobalServices(_appConfiguration) //Senparc.CO2NET 全局注册
            .AddSenparcWeixinServices(_appConfiguration);        //Senparc.Weixin 注册

            //Configure Abp and Dependency Injection
            return(services.AddAbp <MasterWebModule>(options =>
            {
                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                    );
                var pluginFolder = System.IO.Path.Combine(_env.ContentRootPath, "Plugins");
                if (System.IO.Directory.Exists(pluginFolder))
                {
                    options.PlugInSources.AddFolder(pluginFolder);
                }
            }));
        }
Example #17
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //Configure DbContext
            services.AddAbpDbContext <LegoAbpDbContext>(options =>
            {
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
            });
            IdentityRegistrar.Register(services);
            services.AddMvc(options =>
            {
                options.Filters.Add(new CorsAuthorizationFilterFactory(_defaultCorsPolicyName));
                //options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
            });
            // Configure CORS for angular2 UI
            services.AddCors(
                options => options.AddPolicy(
                    _defaultCorsPolicyName,
                    builder => builder
                    .WithOrigins(
                        // App:CorsOrigins in appsettings.json can contain more than one address separated by comma.
                        _appConfiguration["App:CorsOrigins"]
                        .Split(",", StringSplitOptions.RemoveEmptyEntries)
                        .Select(o => o.RemovePostFix("/"))
                        .ToArray()
                        ).AllowCredentials()
                    .AllowAnyHeader()
                    .AllowAnyMethod()
                    )
                );
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info {
                    Title = "Lego API", Version = "v1"
                });
                c.DocInclusionPredicate((docName, description) => true);

                // Define the BearerAuth scheme that's in use
                c.AddSecurityDefinition("bearerAuth", new ApiKeyScheme()
                {
                    Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
                    Name        = "Authorization",
                    In          = "header",
                    Type        = "apiKey"
                });
            });
            //Configure Abp and Dependency Injection
            return(services.AddAbp <LegoAbpWebModule>(options =>
            {
                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                    );
            }));
        }
Example #18
0
        /// <summary>
        /// 创建链接
        /// </summary>
        /// <returns></returns>
        public MessageContext CreateDbContext()
        {
            var builder       = new DbContextOptionsBuilder <MessageContext>();
            var configuration = AppConfigurations.Get(AppContext.BaseDirectory);

            DbContextOptionsConfigurer.Configure(
                builder,
                configuration.GetConnectionString("Default")
                );
            return(new MessageContext(builder.Options, _mediator, _capBus));
        }
Example #19
0
        public CloudDbContext CreateDbContext(string[] args)
        {
            var builder       = new DbContextOptionsBuilder <CloudDbContext>();
            var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder());

            DbContextOptionsConfigurer.Configure(
                builder,
                configuration.GetConnectionString(CloudConsts.ConnectionStringName)
                );

            return(new CloudDbContext(builder.Options));
        }
Example #20
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //Configure DbContext
            services.AddAbpDbContext <MasterDbContext>(options =>
            {
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
            });

            services.AddMvc(options =>
            {
                options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
            }).AddJsonOptions(options => {
                //忽略循环引用
                options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
                //不使用驼峰样式的key
                options.SerializerSettings.ContractResolver = new DefaultContractResolver();
                //设置时间格式
                options.SerializerSettings.DateFormatString = "yyyy-MM-dd";
            });
            //配置jwt
            AuthConfigurer.Configure(services, _appConfiguration);

            services.AddSwaggerGen(options =>
            {
                options.SwaggerDoc("v1", new Info {
                    Title = "Master API", Version = "v1"
                });
                options.DocInclusionPredicate((docName, description) => true);

                // Define the BearerAuth scheme that's in use
                //options.AddSecurityDefinition("bearerAuth", new ApiKeyScheme()
                //{
                //    Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
                //    Name = "Authorization",
                //    In = "header",
                //    Type = "apiKey"
                //});
                // Assign scope requirements to operations based on AuthorizeAttribute
                //options.OperationFilter<SecurityRequirementsOperationFilter>();
            });
            //Configure Abp and Dependency Injection
            return(services.AddAbp <MasterWebModule>(options =>
            {
                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                    );
            }));
        }
        public override void PreInitialize()
        {
            Configuration.Modules.AbpEfCore().AddDbContext <WorkFlowDbContext>(options =>
            {
                if (options.ExistingConnection != null)
                {
                    DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ExistingConnection);
                }
                else
                {
                    DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
                }
            });
            Configuration.Modules.AbpAspNetCore()
            .CreateControllersForAppServices(
                typeof(MasterWorkFlowModule).GetAssembly(), "workflow"
                );

            Configuration.Settings.Providers.Add <WorkFlowSettingProvider>();
            Configuration.Features.Providers.Add <WorkFlowFeatureProvider>();

            Configuration.EmbeddedResources.Sources.Add(
                new EmbeddedResourceSet(
                    "/Views/",
                    Assembly.GetExecutingAssembly(),
                    "Master.Views"
                    )
                );
            //dto映射配置
            //Configuration.Modules.AbpAutoMapper().Configurators.Add(config =>
            //{
            //    config.CreateMap<SchedulerTask, ProjectSchedulerTaskDto>()
            //          .ForMember(u => u.Persons, options =>
            //          {
            //              options.MapFrom(input => string.Join(',', input.SchedulerTaskPeople.Where(o=>o.RelativeType==SchedulerTaskPersonRelativeType.Charger).Select(o => o.User.Name)));
            //          })
            //          .ForMember(u => u.RelPersons, options =>
            //          {
            //              options.MapFrom(input => string.Join(',', input.SchedulerTaskPeople.Where(o => o.RelativeType == SchedulerTaskPersonRelativeType.Relative).Select(o => o.User.Name)));
            //          });
            //});

            IocManager.Register <WorkFlowConfiguration>();
            //模块相关设置
            //加入通用模板视图
            //Configuration.Modules.WebCore().CommonViews.Add("../MES/Common");
        }
Example #22
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //Configure DbContext
            services.AddAbpDbContext <UploaderDbContext>(options =>
            {
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
            });

            services.AddControllersWithViews(options =>
            {
                options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
            }).AddNewtonsoftJson();

            if (bool.Parse(_appConfiguration["Abp:Hangfire:IsServerEnabled"]))
            {
                //Hangfire (Enable to use Hangfire instead of default job manager)
                services.AddHangfire(config =>
                {
                    var connectionStringName = "Default";
                    try
                    {
                        connectionStringName = _appConfiguration["Abp:Hangfire:ConnectionString"];
                        if (String.IsNullOrEmpty(connectionStringName))
                        {
                            connectionStringName = "Default";
                        }
                    }
                    catch (Exception)
                    {
                        //supress & fall-back on "Default"
                        //TODO : log exception to logger
                        connectionStringName = "Default";
                    }

                    config.UseSqlServerStorage(_appConfiguration.GetConnectionString(connectionStringName));
                });
            }

            //Configure Abp and Dependency Injection
            return(services.AddAbp <UploaderWebModule>(options =>
            {
                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                    );
            }));
        }
Example #23
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //Configure DbContext
            services.AddAbpDbContext <MallDbContext>(options =>
            {
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
            });

            services.AddAuthentication(authOpts =>
            {
                //authOpts.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                //authOpts.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                authOpts.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
            }).AddCookie(cookieOpts =>
            {
                //cookieOpts.LoginPath = "/Account/Login/";
            });


            //AuthConfigurer.Configure(services, _appConfiguration);

            services.AddMvc(options =>
            {
                //添加防伪过滤器
                options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
            });



            //添加swagger
            services.AddSwaggerGen(options =>
            {
                options.SwaggerDoc("v1", new Info {
                    Title = "Mall API", Version = "v1"
                });
                options.DocInclusionPredicate((docName, description) => true);
            });

            //Configure Abp and Dependency Injection
            return(services.AddAbp <MallWebModule>(options =>
            {
                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                    );
            }));
        }
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddAbpDbContext <SimpleTaskAppDbContext>(options =>
            {
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
            });

            services.AddMvc();

            //Configure Abp and Dependency Injection
            return(services.AddAbp <SimpleTaskAppWebModule>(options =>
            {
                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseLog4Net().WithConfig("log4net.config")
                    );
            }));
        }
Example #25
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //Configure DbContext
            services.AddAbpDbContext <AbpPerformanceTestAppDbContext>(options =>
            {
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
            });

            services.AddMvc(options =>
            {
                options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
            });

            //Configure Abp and Dependency Injection
            return(services.AddAbp <AbpPerformanceTestAppWebModule>(options =>
            {
                //Configure Log4Net logging
            }));
        }
Example #26
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //Configure DbContext
            services.AddAbpDbContext <JTDbContext>(options =>
            {
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
            });

            services.AddJTIdentity <Tenant, User, Role>()
            .AddJTTenantManager <JTTenantManager <Tenant, User> >()
            .AddJTUserManager <UserManager>()
            .AddJTRoleManager <RoleManager>()
            .AddJTEditionManager <JTEditionManager>()
            .AddJTUserStore <UserStore>()
            .AddJTUserStore <JTUserStore <Role, User> >()
            .AddJTRoleStore <RoleStore>()
            .AddJTLogInManager <JTLogInManager <Tenant, Role, User> >()
            .AddJTSignInManager <JTSignInManager <Tenant, Role, User> >()
            .AddJTSecurityStampValidator <JTSecurityStampValidator <Tenant, Role, User> >()
            .AddJTUserClaimsPrincipalFactory <UserClaimsPrincipalFactory>()
            .AddJTPermissionChecker <PermissionChecker>()
            .AddDefaultTokenProviders();

            CorsConfigurer.Configure(services);
            AuthConfigurer.Configure(services, _appConfiguration);
            MvcConfigurer.Configure(services);
            SwaggerConfigurer.Configure(services, _appConfiguration);

            services.AddControllersWithViews(options =>
            {
                //options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
                options.Filters.Add(new AbpAutoValidateAntiforgeryTokenAttribute());
            }).AddNewtonsoftJson();

            //Configure Abp and Dependency Injection
            return(services.AddAbp <JTWebModule>(options =>
            {
                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                    );
            }));
        }
Example #27
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            // 注册数据库上下文
            services.AddAbpDbContext <IEManageSystemDbContext>(options =>
            {
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
            });

            services.AddMvc(options =>
            {
                // 防止 XSRF/CSRF(跨站请求伪造) 攻击,我们使用 JWT 进行身份验证,不存在 XSRF/CSRF
                // options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
            })
            .AddJsonOptions(options =>
            {
                // 解决循环引用时的序列化
                options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
            });

            // 添加单页
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/build";
            });

            // 添加IEJwtBearer认证
            services.AddIEJwtBearer(
                WebConfiguration.Issuer,
                WebConfiguration.Audience,
                WebConfiguration.SymmetricKey);

            // 添加IE授权
            services.AddIEAuthorization();

            // Configure Abp and Dependency Injection
            return(services.AddAbp <IEManageSystemWebModule>(options =>
            {
                // Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                    );
            }));
        }
Example #28
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddAbpDbContext <ItemsDbContext>(options =>
            {
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, "Data Source=DESKTOP-LE44UH9;Initial Catalog=Amazon;Integrated Security=True");
            });

            services.AddMvc(options =>
            {
                options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
            });
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "Item Api", Version = "v1"
                });
            });
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/build";
            });

            services.AddCors(options =>
            {
                options.AddPolicy(_default,
                                  builder =>
                {
                    builder.WithOrigins("http://localhost:5001",
                                        "http://localhost:8000")
                    .AllowAnyHeader()
                    .AllowAnyMethod();
                });
            });
            services.AddSingleton <IConnectionMultiplexer>(ConnectionMultiplexer.Connect("127.0.0.1:6379,allowAdmin=true"));
            return(services.AddAbp <ItemsWebModule>(options =>
            {
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                    );
            }));
        }
Example #29
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //Configure DbContext
            services.AddAbpDbContext <Api1DbContext>(options =>
            {
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
            });

            services.AddControllersWithViews(options =>
            {
                options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
            }).AddNewtonsoftJson();

            AuthConfigurer.Configure(services, _appConfiguration);

            services.AddSwaggerGen(options =>
            {
                options.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "AbpZeroTemplate API", Version = "v1"
                });
                options.DocInclusionPredicate((docName, description) => true);

                // Define the BearerAuth scheme that's in use
                options.AddSecurityDefinition("bearerAuth", new OpenApiSecurityScheme()
                {
                    Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
                    Name        = "Authorization",
                    In          = ParameterLocation.Header,
                    Type        = SecuritySchemeType.ApiKey
                });
            });

            //Configure Abp and Dependency Injection
            return(services.AddAbp <Api1WebModule>(options =>
            {
                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                    );
            }));
        }
Example #30
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //Configure DbContext
            services.AddAbpDbContext <OfficeBoilerProjectDbContext>(options =>
            {
                DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
            });


            services.AddAuthentication(options =>
            {
                options.DefaultScheme          = "Cookies";
                options.DefaultChallengeScheme = "oidc";
            })
            .AddCookie("Cookies")
            .AddOpenIdConnect("oidc", options =>
            {
                // Identity Server Address
                options.Authority            = "http://localhost:60087";
                options.RequireHttpsMetadata = false;
                options.ClientId             = "officeBoilerProject";
                //options.ClientSecret = "secret";
                options.SaveTokens = true;
            });


            services.AddMvc(options =>
            {
                options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
            });

            //Configure Abp and Dependency Injection
            return(services.AddAbp <OfficeBoilerProjectWebModule>(options =>
            {
                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                    );
            }));
        }