// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddMvc(); // Configuring Swagger SwaggerConfiguration.ConfigureSwagger(services); }
public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddMvc(); // Configuring Business services.AddScoped <IUserBusiness, UserBusiness>(); services.AddStackExchangeRedisCache(options => { options.Configuration = Configuration.GetConnectionString("Redis"); options.InstanceName = string.Empty; }); var scheduler = CreateScheduler(); var massTransitBuilder = new RabbitMqSchedulerMassTransitBuilder(scheduler) { Options = o => o.Bind(Configuration.GetSection("MassTransit:RabbitMq")) }; services .AddElsa() .AddElsaDashboard() .AddHttpActivities() .AddTimerActivities(options => options.Configure(x => x.SweepInterval = Duration.FromSeconds(10))) .AddEmailActivities(options => options.Bind(Configuration.GetSection("Smtp"))) .AddMassTransitSchedulingActivities(massTransitBuilder, options => options.Bind(Configuration.GetSection("MassTransit:RabbitMq:MessageSchedule"))) .AddActivity <RequestCredentials>() .AddUserActivities() .AddWorkflow <UserTrackingWorkflow>() .AddScoped <IUsersService, UsersServiceService>() .AddSingleton(scheduler) .AddSingleton <IHostedService, QuartzHostedService>(); // Add a hosted service to stat and stop the quartz scheduler IScheduler CreateScheduler() { LogProvider.SetCurrentLogProvider(new QuartzConsoleLogProvider()); ISchedulerFactory schedulerFactory = new StdSchedulerFactory(new NameValueCollection() { { "quartz.scheduler.instanceName", "Sample-QuartzScheduler" }, { "quartz.scheduler.instanceId", "AUTO" }, { "quartz.threadPool.type", "Quartz.Simpl.SimpleThreadPool, Quartz" }, { "quartz.threadPool.threadCount", "4" }, { "quartz.jobStore.misfireThreshold", "60000" }, { "quartz.jobStore.type", "Quartz.Simpl.RAMJobStore, Quartz" }, }); var scheduler = schedulerFactory.GetScheduler().GetAwaiter().GetResult(); return(scheduler); } // Configuring Swagger SwaggerConfiguration.ConfigureSwagger(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddMvc(); // Configuring Business services.AddScoped <IUserBusiness, UserBusiness>(); // Configuring Elsa ElsaConfiguration.ConfigureElsa(services, Configuration); // Configuring Swagger SwaggerConfiguration.ConfigureSwagger(services); }
// 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.AddControllersWithViews() .AddJsonOptions(options => ConfigureJsonSerializer(options.JsonSerializerOptions));; services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp"; }); services.AddTransient <ApplicationUserManager>(); services.AddTransient <ApplicationSignInManager>(); services.AddDbContext <ChatDbContext>(options => { options.UseSqlServer( Configuration.GetConnectionString(ChatDbContext.ConnectionString)); }); // register it services.AddScoped <IUserClaimsPrincipalFactory <ApplicationUser>, AppClaimsPrincipalFactory>(); services.AddIdentity <ApplicationUser, ApplicationRole>(opts => { opts.Password.RequiredLength = 5; opts.Password.RequireNonAlphanumeric = false; opts.Password.RequireLowercase = false; opts.Password.RequireUppercase = false; opts.Password.RequireDigit = false; }).AddEntityFrameworkStores <ChatDbContext>() .AddDefaultTokenProviders(); SwaggerConfiguration.ConfigureSwagger(services, new List <string> { }); services.AddSignalR().AddJsonProtocol(options => { ConfigureJsonSerializer(options.PayloadSerializerOptions); }); services.AddHangfire(x => x.UseSqlServerStorage(Configuration.GetConnectionString(ChatDbContext.ConnectionString))); //Установка приложения Croco.SetCrocoApplication(services); }
// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddMemoryCache(); services.AddDbContext <PgsKanbanContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); IdentityConfiguration.AddIdentity(services); SwaggerConfiguration.ConfigureSwagger(services); SignalRConfiguration.AddSignalR(services); MvcConfiguration.AddMvc(services); IdentityConfiguration.ConfigureIdentity(services); CorsConfiguration.AddCors(services); OptionsRegistration.Configure(Configuration, services); services.AddSingleton <IMapper>(sp => AutoMapperConfig.Initialize()); JwtConfiguration.AddJwtAuthorization(Configuration, services); return(DependencyRegistration.Register(Configuration, services)); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews().AddRazorRuntimeCompilation(); services.Configure <FormOptions>(options => { options.MultipartBodyLengthLimit = int.MaxValue; // In case of multipart options.ValueCountLimit = 200; // 200 items max options.ValueLengthLimit = 1024 * 1024 * 100; // 100MB max len form data }); services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddTransient <ApplicationUserManager>(); services.AddTransient <ApplicationSignInManager>(); services.AddDbContext <XdocDbContext>(options => { options.UseSqlServer( Configuration.GetConnectionString(XdocDbContext.ConnectionString)); }); // register it services.AddScoped <IUserClaimsPrincipalFactory <ApplicationUser>, AppClaimsPrincipalFactory>(); services.AddIdentity <ApplicationUser, ApplicationRole>(opts => { opts.Password.RequiredLength = 5; opts.Password.RequireNonAlphanumeric = false; opts.Password.RequireLowercase = false; opts.Password.RequireUppercase = false; opts.Password.RequireDigit = false; }).AddEntityFrameworkStores <XdocDbContext>() .AddDefaultTokenProviders(); SwaggerConfiguration.ConfigureSwagger(services, new List <string> { }); services.ConfigureApplicationCookie(options => { options.ExpireTimeSpan = TimeSpan.FromDays(5); options.Cookie.HttpOnly = true; options.SlidingExpiration = true; options.LoginPath = "/Account/Login"; options.LogoutPath = "/Account/Logout"; }); services.AddControllersWithViews().AddJsonOptions(options => ConfigureJsonSerializer(options.JsonSerializerOptions)); services.AddRazorPages(); services.AddSignalR().AddJsonProtocol(options => { ConfigureJsonSerializer(options.PayloadSerializerOptions); }); services.AddHttpContextAccessor(); services.TryAddSingleton <IActionContextAccessor, ActionContextAccessor>(); services.AddHangfire(x => x.UseSqlServerStorage(Configuration.GetConnectionString(XdocDbContext.ConnectionString))); //Установка приложения Croco.SetCrocoApplication(services); }