// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddOptions(); var opts = new HarvesterOptions(); Configuration.Bind("Harvester", opts); services.AddSingleton(opts); var opts2 = new SonicElasticStoreOptions(); Configuration.Bind("SonicElasticStore", opts2); services.AddSingleton(opts2); var opts3 = new DataOptions(); Configuration.Bind("Data", opts3); services.AddSingleton(opts3); var opts4 = new TaskRunnerDelays(); Configuration.Bind("ReindexDelays", opts4); services.AddSingleton(opts4); services.AddSingleton(new PolicyRegistry()); services.Configure <IntegrationProperties>(Configuration.GetSection("Integration")); // Add framework services. services.AddMvc(options => { options.EnableEndpointRouting = false; options.Filters.Add(typeof(ProcessCustomerCodeAttribute)); }).AddNewtonsoftJson(options => { options.SerializerSettings.ContractResolver = new DefaultContractResolver(); }); services.AddMemoryCache(); services.AddHttpClient(); var containerBuilder = new ContainerBuilder(); containerBuilder.RegisterModule(new DefaultModule() { Configuration = Configuration }); containerBuilder.Populate(services); var container = containerBuilder.Build(); return(new AutofacServiceProvider(container)); }
private CustomerCodeTaskInstance GetCustomerCodeTaskInstance( IIdentityProvider provider, string customerCode, Func <ITask> reindexAllTaskAccessor, TaskRunnerDelays delays ) { CustomerCodeTaskInstance result = null; if (customerCode == null || _taskList.TryGetValue(customerCode, out result)) { return(result); } lock (Locker) { if (!_taskList.TryGetValue(customerCode, out result)) { result = new CustomerCodeTaskInstance(provider, reindexAllTaskAccessor(), delays, _consolidationFactory); _taskList.Add(customerCode, result); } } return(result); }
public ActionsServiceProperties() { EnableScheduleProcess = true; NumberOfThreads = 4; Delays = new TaskRunnerDelays(); }
public CustomerCodeInstanceCollection(ILogger logger, TaskRunnerDelays delays, IFactory consolidationFactory) { _logger = logger; _delays = delays; _consolidationFactory = consolidationFactory; }
public CustomerCodeTaskInstance(IIdentityProvider provider, ITask reindexAllTask, TaskRunnerDelays delays, IFactory consolidationFactory) { ReindexAllTask = reindexAllTask; ReindexAllTaskAccessor = (s, i) => s == "ReindexAllTask" ? ReindexAllTask : null; TaskService = new InmemoryTaskService(); TaskServiceAccessor = () => TaskService; TasksRunner = new TasksRunner(ReindexAllTaskAccessor, TaskServiceAccessor, provider, delays, consolidationFactory); var actionRunnerThread = new Thread(TasksRunner.Run); actionRunnerThread.Start(provider.Identity.CustomerCode); }