public RunnerConnectionStringSettings()
     : base(ConnectionStrings.For(ErmConnectionStringIdentity.Instance,
                                  FactsConnectionStringIdentity.Instance,
                                  AggregatesConnectionStringIdentity.Instance,
                                  MessagesConnectionStringIdentity.Instance))
 {
 }
        public ReplicationServiceSettings()
        {
            var connectionStrings = ConnectionStrings.For(ErmConnectionStringIdentity.Instance,
                                                          AmsConnectionStringIdentity.Instance,
                                                          RulesetConnectionStringIdentity.Instance,
                                                          FactsConnectionStringIdentity.Instance,
                                                          AggregatesConnectionStringIdentity.Instance,
                                                          MessagesConnectionStringIdentity.Instance,
                                                          ServiceBusConnectionStringIdentity.Instance,
                                                          InfrastructureConnectionStringIdentity.Instance,
                                                          LoggingConnectionStringIdentity.Instance);
            var connectionStringSettings = new ConnectionStringSettingsAspect(connectionStrings);

            var quartzProperties = (NameValueCollection)ConfigurationManager.GetSection(StdSchedulerFactory.ConfigurationSectionName);

            Aspects.Use(connectionStringSettings)
            .Use <BusinessModelSettingsAspect>()
            .Use <ServiceBusMessageLockRenewalSettings>()
            .Use <EnvironmentSettingsAspect>()
            .Use(new QuartzSettingsAspect(connectionStringSettings.GetConnectionString(InfrastructureConnectionStringIdentity.Instance)))
            .Use(new ServiceBusReceiverSettingsAspect(connectionStringSettings.GetConnectionString(ServiceBusConnectionStringIdentity.Instance)))
            .Use <ArchiveVersionsSettings>()
            .Use <LogstashSettingsAspect>()
            .Use <IdentityServiceClientSettingsAspect>()
            .Use(new TaskServiceRemoteControlSettings(quartzProperties));
        }
        public QueryingServiceSettings()
        {
            var connectionString = ConnectionStrings.For(ErmConnectionStringIdentity.Instance,
                                                         AmsConnectionStringIdentity.Instance,
                                                         ValidationRulesConnectionStringIdentity.Instance,
                                                         LoggingConnectionStringIdentity.Instance);

            Aspects.Use(new ConnectionStringSettingsAspect(connectionString))
            .Use <EnvironmentSettingsAspect>();
        }
        public static void Main(string[] args)
        {
            StateInitializationRoot.Instance.PerformTypesMassProcessing(Array.Empty <IMassProcessor>(), true, typeof(object));

            var commands = new List <ICommand>();

            if (args.Contains("-facts"))
            {
                commands.Add(BulkReplicationCommands.ErmToFacts);
                // Надо подумать о лишней обёртке
                commands.Add(new KafkaReplicationCommand(AmsFactsFlow.Instance, BulkReplicationCommands.AmsToFacts));
                commands.Add(new KafkaReplicationCommand(RulesetFactsFlow.Instance, BulkReplicationCommands.RulesetsToFacts));
                commands.Add(SchemaInitializationCommands.WebApp);
                commands.Add(SchemaInitializationCommands.Facts);
            }

            if (args.Contains("-aggregates"))
            {
                commands.Add(BulkReplicationCommands.FactsToAggregates);
                commands.Add(SchemaInitializationCommands.WebApp);
                commands.Add(SchemaInitializationCommands.Aggregates);
            }

            if (args.Contains("-messages"))
            {
                commands.Add(BulkReplicationCommands.AggregatesToMessages);
                commands.Add(SchemaInitializationCommands.WebApp);
                commands.Add(SchemaInitializationCommands.Messages);
            }

            var connectionStrings = ConnectionStrings.For(ErmConnectionStringIdentity.Instance,
                                                          AmsConnectionStringIdentity.Instance,
                                                          FactsConnectionStringIdentity.Instance,
                                                          AggregatesConnectionStringIdentity.Instance,
                                                          MessagesConnectionStringIdentity.Instance,
                                                          RulesetConnectionStringIdentity.Instance);
            var connectionStringSettings = new ConnectionStringSettingsAspect(connectionStrings);
            var environmentSettings      = new EnvironmentSettingsAspect();
            var businessModelSettings    = new BusinessModelSettingsAspect();

            var tracer = CreateTracer(environmentSettings, businessModelSettings);

            var kafkaSettingsFactory =
                new KafkaSettingsFactory(new Dictionary <IMessageFlow, string>
            {
                [AmsFactsFlow.Instance] =
                    connectionStringSettings.GetConnectionString(AmsConnectionStringIdentity.Instance),
                [RulesetFactsFlow.Instance] =
                    connectionStringSettings.GetConnectionString(RulesetConnectionStringIdentity.Instance)
            },
                                         environmentSettings,
                                         Offset.Beginning);

            var kafkaMessageFlowReceiverFactory = new KafkaMessageFlowReceiverFactory(new NullTracer(), kafkaSettingsFactory);

            var dataObjectTypesProviderFactory = new DataObjectTypesProviderFactory();
            var bulkReplicationActor           = new BulkReplicationActor(dataObjectTypesProviderFactory, connectionStringSettings);
            var kafkaReplicationActor          = new KafkaReplicationActor(connectionStringSettings,
                                                                           dataObjectTypesProviderFactory,
                                                                           kafkaMessageFlowReceiverFactory,
                                                                           new KafkaMessageFlowInfoProvider(kafkaSettingsFactory),
                                                                           new IBulkCommandFactory <Message>[]
            {
                new AmsFactsBulkCommandFactory(),
                new RulesetFactsBulkCommandFactory(businessModelSettings)
            },
                                                                           tracer);

            var schemaInitializationActor = new SchemaInitializationActor(connectionStringSettings);

            var sw = Stopwatch.StartNew();

            schemaInitializationActor.ExecuteCommands(commands);
            bulkReplicationActor.ExecuteCommands(commands.Where(x => x == BulkReplicationCommands.ErmToFacts).ToList());
            kafkaReplicationActor.ExecuteCommands(commands);
            bulkReplicationActor.ExecuteCommands(commands.Where(x => x != BulkReplicationCommands.ErmToFacts).ToList());

            Console.WriteLine($"Total time: {sw.ElapsedMilliseconds}ms");
        }