private void SetupTestData( out IReadOnlyCollection<Break> breaksBeingSmoothed, out SmoothBreak theSmoothBreak, out IReadOnlyCollection<Programme> scheduleProgrammes, out List<Spot> spotsForBreak, out SalesArea salesArea, out IReadOnlyDictionary<string, Clash> clashesByExternalRef, out IReadOnlyDictionary<Guid, SpotInfo> spotInfos, out ProductClashRules productClashRule, out SmoothResources smoothResources, out IClashExposureCountService clashExposureCountService, out SponsorshipRestrictionService sponsorshipRestrictionsService) { breaksBeingSmoothed = _repositoryWrapper.LoadAllTestBreaks().ToList(); theSmoothBreak = new SmoothBreak(breaksBeingSmoothed.First(), 1); scheduleProgrammes = _repositoryWrapper.LoadAllProgrammes().ToList(); spotsForBreak = new List<Spot>() { _spot }; salesArea = _repositoryWrapper.LoadAllSalesArea().First(); clashesByExternalRef = _repositoryWrapper.LoadAllClashes().ToDictionary(c => c.Externalref); spotInfos = SpotInfo.Factory( spotsForBreak, _repositoryWrapper.LoadAllProducts().ToDictionary(p => p.Externalidentifier), clashesByExternalRef ); productClashRule = ProductClashRules.LimitOnExposureCount; smoothResources = new SmoothResources(); clashExposureCountService = ClashExposureCountService.Create(); sponsorshipRestrictionsService = SponsorshipRestrictionService.Factory( spotInfos, new SponsorshipRestrictionFilterService(ImmutableList.Create<Sponsorship>()), new SmoothSponsorshipTimelineManager(new List<SmoothSponsorshipTimeline>()), scheduleProgrammes.First(), DebugLogger); }
private static IClashExposureCountService CreateEffectiveClashExposureCountService( IRepositoryScope scope) { TenantSettings tenantSettings = GetTenantSettings(scope); if (String.IsNullOrWhiteSpace(tenantSettings.PeakStartTime)) { return(ClashExposureCountService.Create()); } return(ClashExposureCountService.Create( (tenantSettings.PeakStartTime, tenantSettings.PeakEndTime) )); }
protected override void Load(ContainerBuilder builder) { _ = builder.RegisterInstance(new RootFolder(_rootFolder)).AsSelf(); _ = builder.Register(context => { return(new FeatureManager( context.Resolve <TenantIdentifier>(), context.Resolve <IFeatureSettingsProvider>())); }).As <IFeatureManager>().InstancePerLifetimeScope(); _ = builder.RegisterType <KPIResolver>().As <IKPIResolver>().InstancePerLifetimeScope(); _ = builder.RegisterType <KPICalculationManager>().As <IKPICalculationManager>().InstancePerLifetimeScope(); _ = builder.RegisterType <KPICalculationScopeFactory>().As <IKPICalculationScopeFactory>(); _ = builder.RegisterType <ScenarioCampaignMetricsProcessor>().As <IScenarioCampaignMetricsProcessor>(); _ = builder.RegisterType <AnalysisGroupKPIsCalculator>().As <IAnalysisGroupKPIsCalculator>(); builder.RegisterKPICalculators(); // Synchronization service _ = builder.RegisterType <SynchronizationService>().AsSelf().InstancePerLifetimeScope(); _ = builder .Register(x => x.Resolve <IFeatureManager>().IsEnabled(nameof(ProductFeature.IntegrationSynchronization)) ? (ISynchronizationService)x.Resolve <SynchronizationService>() : new EmptySynchronizationService()) .As <ISynchronizationService>() .InstancePerLifetimeScope(); _ = builder.RegisterInstance(new SynchronizationServicesConfiguration() .Add(SynchronizedServiceType.RunExecution) .Add(SynchronizedServiceType.DataSynchronization, maxConcurrencyLevel: 1)); _ = builder.Register(context => EmailUtilities.GetEmailConnection(context.Resolve <IConfiguration>())) .As <IEmailConnection>().InstancePerLifetimeScope(); _ = builder.Register( x => { var tenantSettingsRepository = x.Resolve <ITenantSettingsRepository>(); if (tenantSettingsRepository is null) { return(ClashExposureCountService.Create()); } TenantSettings tenantSettings = tenantSettingsRepository.Get(); if (tenantSettings is null) { return(ClashExposureCountService.Create()); } var peakStartAndEnd = (tenantSettings.PeakStartTime, tenantSettings.PeakEndTime); return(ClashExposureCountService.Create(peakStartAndEnd)); }) .As <IClashExposureCountService>() .InstancePerLifetimeScope(); _ = builder.RegisterType <DataChangeValidator>().As <IDataChangeValidator>().InstancePerLifetimeScope(); _ = builder.RegisterType <RepositoryFactory>().As <IRepositoryFactory>().InstancePerLifetimeScope(); _ = builder.Register(context => { var nc = new NotificationCollection(); nc.Add(new HTTPTNotification()); return(nc); }) .As <INotificationCollection>() .InstancePerLifetimeScope(); _ = builder.RegisterType <OptimiserInputFiles>().InstancePerLifetimeScope(); _ = builder.RegisterType <DataManipulator>().As <IDataManipulator>().InstancePerLifetimeScope(); _ = builder.RegisterType <ModelLoaders>().As <IModelLoaders>().InstancePerLifetimeScope(); // Register Smooth processor _ = builder.RegisterType <SmoothEngine>().AsSelf(); _ = builder.RegisterType <SmoothProcessor>().As <ISmoothProcessor>(); // Register FeatureManager _ = builder.RegisterType <TenantSettingsFeatureManager>().As <ITenantSettingsFeatureManager>(); _ = builder.RegisterType <AutoBookInputHandler>().As <IAutoBookInputHandler>(); _ = builder.RegisterType <AutoBookOutputHandler>().As <IAutoBookOutputHandler>(); _ = builder.RegisterType <BRSIndicatorManager>().As <IBRSIndicatorManager>().InstancePerDependency(); _ = builder.RegisterType <BRSCalculator>().As <IBRSCalculator>().InstancePerDependency(); // Register RunCleaner _ = builder.RegisterType <RunCleaner>().As <IRunCleaner>().InstancePerLifetimeScope(); // Register RunManager _ = builder.RegisterType <RunManager>().As <IRunManager>().InstancePerDependency(); //Register RecalculateBreakAvailabilityService _ = builder.RegisterType <RecalculateBreakAvailabilityService>().As <IRecalculateBreakAvailabilityService>().InstancePerDependency(); _ = builder.RegisterType <SystemLogicalDateService>().As <ISystemLogicalDateService>(); _ = builder.Register(context => LoggerFactory.Create(config => config.AddDebug())) .Named <ILoggerFactory>("Debug") .SingleInstance(); _ = builder.Register(context => context.ResolveNamed <ILoggerFactory>("Debug").CreateLogger <IRecalculateBreakAvailabilityService>()) .As <ILogger <IRecalculateBreakAvailabilityService> >() .InstancePerDependency(); _ = builder.RegisterType <ScenarioSnapshotGenerator>().AsSelf(); _ = builder.RegisterType <RunCompletionNotifier>().AsSelf().InstancePerLifetimeScope(); _ = builder.RegisterType <RunInstanceCreator>().AsSelf().InstancePerLifetimeScope(); _ = builder.RegisterType <RunScenarioTask>().AsSelf().InstancePerLifetimeScope(); _ = builder.RegisterType <RunScenarioTaskExecutor>().AsSelf().InstancePerLifetimeScope(); _ = builder.Register <ISystemMessageRepository>(x => new SystemMessageRepository()); _ = builder.RegisterType <IdentityGeneratorResolver>() .As <IIdentityGeneratorResolver>() .InstancePerLifetimeScope(); _ = builder.RegisterType <ProductAdvertiserValidator>().As <IProductAdvertiserValidator>() .InstancePerLifetimeScope(); _ = builder.RegisterType <ClashExceptionSerializer>().As <IClashExceptionSerializer>().InstancePerLifetimeScope(); _ = builder.RegisterType <CampaignSerializer>().As <ICampaignSerializer>().InstancePerLifetimeScope(); _ = builder.RegisterType <BreakSerializer>().As <IBreakSerializer>().InstancePerLifetimeScope(); _ = builder.RegisterType <CampaignFlattener>().As <ICampaignFlattener>().InstancePerLifetimeScope(); _ = builder.RegisterType <CampaignPassPrioritiesService>().As <ICampaignPassPrioritiesService>().InstancePerLifetimeScope(); _ = builder.RegisterType <PassInspectorService>().As <IPassInspectorService>().InstancePerLifetimeScope(); _ = builder.RegisterType <AnalysisGroupCampaignQuery>().As <IAnalysisGroupCampaignQuery>().InstancePerLifetimeScope(); _ = builder.RegisterType <RecommendationAggregator>().As <IRecommendationAggregator>().InstancePerLifetimeScope(); _ = builder.RegisterType <ScenarioCampaignResultReportCreator>().As <IScenarioCampaignResultReportCreator>() .InstancePerLifetimeScope(); _ = builder.RegisterType <RecommendationsResultReportCreator>().As <IRecommendationsResultReportCreator>() .InstancePerLifetimeScope(); _ = builder.RegisterType <SpotModelCreator>().As <ISpotModelCreator>() .InstancePerLifetimeScope(); _ = builder.RegisterType <ProgTxDetailSerializer>().As <IProgTxDetailSerializer>().InstancePerLifetimeScope(); _ = builder.Register(x => MemoryCache.Default).As <MemoryCache>().SingleInstance(); _ = builder.RegisterType <CampaignCleaner>().As <ICampaignCleaner>().InstancePerLifetimeScope(); }