예제 #1
0
 public ReportingJob(ITracer tracer,
                     ISignInService signInService,
                     IUserImpersonationService userImpersonationService,
                     ITelemetryPublisher telemetry,
                     IConnectionStringSettings connectionStringSettings,
                     IServiceBusMessageReceiverSettings serviceBusMessageReceiverSettings)
     : base(signInService, userImpersonationService, tracer)
 {
     _telemetry = telemetry;
     _serviceBusMessageReceiverSettings = serviceBusMessageReceiverSettings;
     _manager = NamespaceManager.CreateFromConnectionString(connectionStringSettings.GetConnectionString(ServiceBusConnectionStringIdentity.Instance));
     _sqlConnection = new SqlConnection(connectionStringSettings.GetConnectionString(TransportConnectionStringIdentity.Instance));
 }
예제 #2
0
 public ReportingJob(ITracer tracer,
                     ISignInService signInService,
                     IUserImpersonationService userImpersonationService,
                     ITelemetryPublisher telemetry,
                     IConnectionStringSettings connectionStringSettings,
                     IServiceBusMessageReceiverSettings serviceBusMessageReceiverSettings)
     : base(signInService, userImpersonationService, tracer)
 {
     _telemetry = telemetry;
     _serviceBusMessageReceiverSettings = serviceBusMessageReceiverSettings;
     _manager       = NamespaceManager.CreateFromConnectionString(connectionStringSettings.GetConnectionString(ServiceBusConnectionStringIdentity.Instance));
     _sqlConnection = new SqlConnection(connectionStringSettings.GetConnectionString(TransportConnectionStringIdentity.Instance));
 }
        private LinqToDBDomainContext CreateDomainContext(StorageMappingDescriptor storageMappingDescriptor)
        {
            var linqToDbModel = _linqToDbModelFactory.Create(storageMappingDescriptor.EntityContainerName);

            var connections = Connections.GetOrAdd(
                storageMappingDescriptor.ConnectionStringIdentity,
                connectionStringIdentity =>
            {
                var dataProvider     = new SQLiteDataProvider();
                var connectionString = _connectionStringSettings.GetConnectionString(connectionStringIdentity);
                var connection       = (SQLiteConnection)dataProvider.CreateConnection(connectionString);
                connection.Open();

                var dataConnection = new DataConnection(dataProvider, connection)
                {
                    CommandTimeout = linqToDbModel.QueryExecutionTimeout,
                    IsMarsEnabled  = false
                };
                dataConnection.AddMappingSchema(linqToDbModel.MappingSchema);

                return(Tuple.Create(connection, TuneConnection(dataConnection)));
            });

            return(new LinqToDBDomainContext(connections.Item1,
                                             connections.Item2,
                                             new ManagedConnectionStateScopeFactory(),
                                             new WritingStrategyFactory(),
                                             linqToDbModel.TransactionOptions,
                                             new NullPendingChangesHandlingStrategy()));
        }
        private static IUnityContainer ConfigureTracer(
            this IUnityContainer container,
            IEnvironmentSettings environmentSettings,
            IConnectionStringSettings connectionStringSettings)
        {
            var tracerContextEntryProviders =
                    new ITracerContextEntryProvider[]
                    {
                        new TracerContextConstEntryProvider(TracerContextKeys.Required.Environment, environmentSettings.EnvironmentName),
                        new TracerContextConstEntryProvider(TracerContextKeys.Required.EntryPoint, environmentSettings.EntryPointName),
                        new TracerContextConstEntryProvider(TracerContextKeys.Required.EntryPointHost, NetworkInfo.ComputerFQDN),
                        new TracerContextConstEntryProvider(TracerContextKeys.Required.EntryPointInstanceId, Guid.NewGuid().ToString()),
                        new TracerContextSelfHostedEntryProvider(TracerContextKeys.Required.UserAccount) // TODO {all, 08.05.2015}: Если появится авторизация, надо будет доработать логирование
                    };

            var tracerContextManager = new TracerContextManager(tracerContextEntryProviders);
            var tracer = Log4NetTracerBuilder.Use
                                             .ApplicationXmlConfig
                                             .EventLog
                                             .Logstash(new Uri(connectionStringSettings.GetConnectionString(LoggingConnectionStringIdentity.Instance)))
                                             .Build;

            return container.RegisterInstance(tracer)
                            .RegisterInstance(tracerContextManager)
                            .RegisterType<IExceptionLogger, ExceptionTracer>("log4net", Lifetime.Singleton);
        }
예제 #5
0
        public static IUnityContainer ConfigureTracer(
            this IUnityContainer container,
            IEnvironmentSettings environmentSettings,
            IConnectionStringSettings connectionStringSettings)
        {
            var tracerContextEntryProviders =
                new ITracerContextEntryProvider[]
            {
                new TracerContextConstEntryProvider(TracerContextKeys.Required.Environment, environmentSettings.EnvironmentName),
                new TracerContextConstEntryProvider(TracerContextKeys.Required.EntryPoint, environmentSettings.EntryPointName),
                new TracerContextConstEntryProvider(TracerContextKeys.Required.EntryPointHost, NetworkInfo.ComputerFQDN),
                new TracerContextConstEntryProvider(TracerContextKeys.Required.EntryPointInstanceId, Guid.NewGuid().ToString()),
                new TracerContextSelfHostedEntryProvider(TracerContextKeys.Required.UserAccount)         // TODO {all, 08.05.2015}: Если появится авторизация, надо будет доработать логирование
            };

            var tracerContextManager = new TracerContextManager(tracerContextEntryProviders);
            var tracer = Log4NetTracerBuilder.Use
                         .DefaultXmlConfig
                         .EventLog
                         .Logstash(new Uri(connectionStringSettings.GetConnectionString(LoggingConnectionStringIdentity.Instance)))
                         .Build;

            return(container.RegisterInstance(tracer)
                   .RegisterInstance(tracerContextManager));
        }
예제 #6
0
        private DataConnection CreateDataConnection(SchemaInitializationCommand command)
        {
            var connectionString = _connectionStringSettings.GetConnectionString(command.ConnectionStringIdentity);
            var connection       = SqlServerTools.CreateDataConnection(connectionString);

            connection.AddMappingSchema(command.MappingSchema);
            return(connection);
        }
        private DataConnection CreateDataConnection(StorageDescriptor storageDescriptor)
        {
            var connectionString = _connectionStringSettings.GetConnectionString(storageDescriptor.ConnectionStringIdentity);
            var connection       = SqlServerTools.CreateDataConnection(connectionString);

            connection.AddMappingSchema(storageDescriptor.MappingSchema);
            connection.CommandTimeout = (int)storageDescriptor.CommandTimeout.TotalMilliseconds;
            return(connection);
        }
        public DataConnection CreateConnection(StorageDescriptorFeature storageDescriptorFeature)
        {
            var connectionString = _connectionStringSettings.GetConnectionString(storageDescriptorFeature.ConnectionStringName);
            var connection       = SqlServerTools.CreateDataConnection(connectionString);

            connection.AddMappingSchema(storageDescriptorFeature.MappingSchema);
            connection.CommandTimeout = (int)TimeSpan.FromMinutes(30).TotalMilliseconds;
            return(connection);
        }
        private DataConnection CreateDataConnection(IConnectionStringIdentity connectionStringIdentity, MappingSchema mappingSchema)
        {
            var connectionString = _connectionStringSettings.GetConnectionString(connectionStringIdentity);
            var dataConnection   = SqlServerTools.CreateDataConnection(connectionString);

            dataConnection.AddMappingSchema(mappingSchema);
            dataConnection.CommandTimeout = 0;
            return(dataConnection);
        }
예제 #10
0
        private SqlConnection VerifyAndGetConnection()
        {
            var connectionString = _connectionStringSettings.GetConnectionString();

            if (string.IsNullOrWhiteSpace(connectionString))
            {
                throw new ApplicationException("DataAccessProviderError: Set connection string before usage!");
            }

            return(new SqlConnection(connectionString));
        }
예제 #11
0
 public string GetConnectionString(IConnectionStringIdentity identity)
 {
     return(_connectionStringSettings.GetConnectionString(_mapping[identity]));
 }
        private static IUnityContainer ConfigureOperationsProcessing(
            this IUnityContainer container,
            IConnectionStringSettings connectionStringSettings,
            IEnvironmentSettings environmentSettings)
        {
#if DEBUG
            container.RegisterType <ITelemetryPublisher, DebugTelemetryPublisher>(Lifetime.Singleton);
#else
            container.RegisterType <ITelemetryPublisher, CachingTelemetryPublisherDecorator <LogstashTelemetryPublisher> >(Lifetime.Singleton);
#endif

            // primary
            container.RegisterInstance(new EntityTypeMappingRegistryBuilder().Create <ErmSubDomain>(), Lifetime.Singleton)
            .RegisterType <IOperationIdentityRegistry, EmptyOperationIdentityRegistry>(Lifetime.Singleton)
            .RegisterTypeWithDependencies(typeof(ServiceBusMessageReceiverTelemetryDecorator), Lifetime.PerScope, null)
            .RegisterOne2ManyTypesPerTypeUniqueness <IRuntimeTypeModelConfigurator, ProtoBufTypeModelForTrackedUseCaseConfigurator <ErmSubDomain> >(Lifetime.Singleton)
            .RegisterTypeWithDependencies(typeof(BinaryEntireBrokeredMessage2TrackedUseCaseTransformer), Lifetime.Singleton, null)
            .RegisterType <IXmlEventSerializer, XmlEventSerializer>();

            // final
            container.RegisterTypeWithDependencies(typeof(AggregatesFlowHandler), Lifetime.PerResolve, null);

            container.RegisterType <IEventLoggingStrategyProvider, UnityEventLoggingStrategyProvider>()
            .RegisterType <IEvent2BrokeredMessageConverter <IEvent>, Event2BrokeredMessageConverter>()
            .RegisterType <IEventLogger, SequentialEventLogger>()
            .RegisterType <IServiceBusMessageSender, BatchingServiceBusMessageSender>();

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

            // kafka receiver
            container
            .RegisterType <BatchingKafkaReceiverTelemetryDecorator <AmsFactsFlowTelemetryPublisher> >(new InjectionConstructor(new ResolvedParameter <KafkaReceiver>(nameof(AmsFactsFlow)),
                                                                                                                               typeof(AmsFactsFlowTelemetryPublisher)))
            .RegisterType <BatchingKafkaReceiverTelemetryDecorator <RulesetFactsFlowTelemetryPublisher> >(new InjectionConstructor(new ResolvedParameter <KafkaReceiver>(nameof(RulesetFactsFlow)),
                                                                                                                                   typeof(RulesetFactsFlowTelemetryPublisher)))

            .RegisterType <KafkaReceiver>(nameof(AmsFactsFlow), Lifetime.Singleton)
            .RegisterType <KafkaReceiver>(nameof(RulesetFactsFlow), Lifetime.Singleton)
            .RegisterType <IKafkaMessageFlowReceiverFactory, KafkaMessageFlowReceiverFactory>(Lifetime.Singleton)
            .RegisterInstance <IKafkaSettingsFactory>(kafkaSettingsFactory)
            .RegisterType <KafkaMessageFlowInfoProvider>(Lifetime.Singleton);

            return(container.RegisterInstance <IParentContainerUsedRegistrationsContainer>(new ParentContainerUsedRegistrationsContainer(), Lifetime.Singleton)
                   .RegisterType(typeof(ServiceBusMessageFlowReceiver), Lifetime.Singleton)
                   .RegisterType <IServiceBusLockRenewer, NullServiceBusLockRenewer>(Lifetime.Singleton)
                   .RegisterType <IServiceBusSettingsFactory, ServiceBusSettingsFactory>(Lifetime.Singleton)
                   .RegisterType <IServiceBusMessageFlowReceiverFactory, ServiceBusMessageFlowReceiverFactory>(Lifetime.PerScope)
                   .RegisterType <IMessageProcessingStagesFactory, UnityMessageProcessingStagesFactory>(Lifetime.PerScope)
                   .RegisterType <IMessageFlowProcessorFactory, UnityMessageFlowProcessorFactory>(Lifetime.PerScope)
                   .RegisterType <IMessageReceiverFactory, UnityMessageReceiverFactory>(Lifetime.PerScope)

                   .RegisterOne2ManyTypesPerTypeUniqueness <IMessageFlowProcessorResolveStrategy, PrimaryProcessorResolveStrategy>(Lifetime.Singleton)
                   .RegisterOne2ManyTypesPerTypeUniqueness <IMessageFlowProcessorResolveStrategy, FinalProcessorResolveStrategy>(Lifetime.PerScope)

                   .RegisterOne2ManyTypesPerTypeUniqueness <IMessageFlowReceiverResolveStrategy, MessageFlowReceiverResolveStrategy>(Lifetime.PerScope)

                   .RegisterType <IMessageValidatorFactory, UnityMessageValidatorFactory>(Lifetime.PerScope)
                   .RegisterType <IMessageTransformerFactory, UnityMessageTransformerFactory>(Lifetime.PerScope)

                   .RegisterOne2ManyTypesPerTypeUniqueness <IMessageTransformerResolveStrategy, PrimaryMessageTransformerResolveStrategy>(Lifetime.PerScope)
                   .RegisterType <IMessageProcessingHandlerFactory, UnityMessageProcessingHandlerFactory>(Lifetime.PerScope)
                   .RegisterType <IMessageProcessingContextAccumulatorFactory, UnityMessageProcessingContextAccumulatorFactory>(Lifetime.PerScope)

                   .RegisterType <IMessageFlowProcessingObserver, NullMessageFlowProcessingObserver>(Lifetime.Singleton));
        }
예제 #13
0
 public ServiceBusSettingsFactory(IConnectionStringSettings connectionStringSettings)
 {
     _serviceBusConnectionString = connectionStringSettings.GetConnectionString(ServiceBusConnectionStringIdentity.Instance);
 }
 public ServiceBusSettingsFactory(IConnectionStringSettings connectionStringSettings)
 {
     _serviceBusConnectionString = connectionStringSettings.GetConnectionString(ServiceBusConnectionStringIdentity.Instance);
 }
예제 #15
0
        public KafkaSettingsFactory(IConnectionStringSettings connectionStringSettings)
        {
            var kafkaConfig = JsonConvert.DeserializeObject <Dictionary <string, string> >(connectionStringSettings.GetConnectionString(KafkaConnectionStringIdentity.Instance));

            _kafkaConfig = kafkaConfig;
        }