예제 #1
0
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterEventStore(context =>
            {
                var configuration = context.Resolve <IConfiguration>();
                var eventStoreConnectionString = configuration.GetValue <string>("CoreEventStore:EventStoreConfig:ConnectionString");
                var init = new InitializationConfiguration()
                {
                    EventStoreConnectionString = eventStoreConnectionString,
                };
                return(init);
            })
            .SubscribeRead(subscriptionConfiguration =>
            {
                subscriptionConfiguration.AddEvent <CustomerCreatedForEfCore>(nameof(CustomerCreatedForEfCore));
            }, new CustomProjectorInvoker())
            .UseeEfCore(context =>
            {
                var configuration = context.Resolve <IConfiguration>();

                var efCoreConfiguration = new EfCoreConfiguration();
                efCoreConfiguration.ConnectionString = configuration.GetValue <string>("CoreEventStore:SqlServerConfig:ConnectionString");
                efCoreConfiguration.DefaultSchema    = configuration.GetValue <string>("CoreEventStore:SqlServerConfig:DefaultSchema");

                return(efCoreConfiguration);
            })
            .KeepPositionInEfCore()
            .KeepIdempotenceInEfCore();
        }
예제 #2
0
            public FactsBase()
            {
                _jobState      = new Mock <IRevalidationJobStateService>();
                _packageState  = new Mock <IPackageRevalidationStateService>();
                _packageFinder = new Mock <IPackageFinder>();
                _scopeFactory  = new Mock <IServiceScopeFactory>();

                var scope           = new Mock <IServiceScope>();
                var serviceProvider = new Mock <IServiceProvider>();

                serviceProvider.Setup(p => p.GetService(typeof(IRevalidationJobStateService))).Returns(_jobState.Object);
                serviceProvider.Setup(p => p.GetService(typeof(IPackageRevalidationStateService))).Returns(_packageState.Object);
                serviceProvider.Setup(p => p.GetService(typeof(IPackageFinder))).Returns(_packageFinder.Object);
                serviceProvider.Setup(p => p.GetService(typeof(IServiceScopeFactory))).Returns(_scopeFactory.Object);

                scope.Setup(s => s.ServiceProvider).Returns(serviceProvider.Object);
                _scopeFactory.Setup(s => s.CreateScope()).Returns(scope.Object);

                _config = new InitializationConfiguration();

                _target = new InitializationManager(
                    _jobState.Object,
                    _packageState.Object,
                    _packageFinder.Object,
                    _scopeFactory.Object,
                    _config,
                    Mock.Of <ILogger <InitializationManager> >());
            }
예제 #3
0
        public static ContainerBuilder RegisterEventStore(this ContainerBuilder containerBuilder, Func <IComponentContext, InitializationConfiguration> initializationConfiguration)
        {
            InitializationConfiguration configuration = null;

            containerBuilder.Register <IEventStoreConnection>((Func <IComponentContext, IEventStoreConnection>)(context =>
            {
                configuration = initializationConfiguration(context);
                containerBuilder.RegisterInstance(configuration).As <InitializationConfiguration>().IfNotRegistered(typeof(InitializationConfiguration)).SingleInstance();


                IEventStoreConnection eventStoreConnection = EventStoreConnectionBuilder.Build(configuration);
                return(eventStoreConnection);
            })).As <IEventStoreConnection>().SingleInstance();


            //containerBuilder.RegisterInstance(configuration).As<InitializationConfiguration>().IfNotRegistered(typeof(InitializationConfiguration)).SingleInstance();

            //InitializationConfiguration configuration = new InitializationConfiguration();
            //initializationConfiguration.Invoke(configuration);
            //IEventStoreConnection EventStoreConnection = EventStoreConnectionBuilder.Build(configuration);
            //containerBuilder.RegisterInstance(EventStoreConnection).As<IEventStoreConnection>().SingleInstance();


            containerBuilder.RegisterType <EventStoreConnectionManager>().As <IEventStoreConnectionManager>().SingleInstance();
            containerBuilder.RegisterType <PersistentSubscriptionClient>().As <IPersistentSubscriptionClient>().SingleInstance();//.PreserveExistingDefaults();
            containerBuilder.RegisterType <EventStoreDbContext>().As <IEventStoreDbContext>().SingleInstance();
            containerBuilder.RegisterType <EventStoreReader>().As <IEventStoreReader>().SingleInstance();


            return(containerBuilder);
        }
예제 #4
0
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterEventStore(initializationConfiguration =>
            {
                var configuration = initializationConfiguration.Resolve <IConfiguration>();
                var eventStoreConnectionString = configuration.GetValue <string>("CoreEventStore:EventStoreConfig:ConnectionString");
                var init = new InitializationConfiguration()
                {
                    EventStoreConnectionString = eventStoreConnectionString,
                };
                return(init);
            })
            .SubscribeRead(subscriptionConfiguration =>
            {
                subscriptionConfiguration.AddEvent <CustomerCreatedForMySql>(nameof(CustomerCreatedForMySql));
                subscriptionConfiguration.AddEvent <CustomerModified>(nameof(CustomerModified));
            }, new CustomProjectorInvoker())
            .UseeMySql(context =>
            {
                var configuration         = context.Resolve <IConfiguration>();
                var mySqlConnectionString = configuration.GetValue <string>("CoreEventStore:MySqlConfig:ConnectionString");

                var mySqlConfiguration = new MySqlConfiguration();
                mySqlConfiguration.ConnectionString = mySqlConnectionString;
                return(mySqlConfiguration);
            })
            .KeepPositionInMySql()
            .KeepIdempotenceInMySql();
        }
예제 #5
0
        protected override void Load(ContainerBuilder builder)
        {
            IConfiguration configuration = null;

            builder.RegisterEventStore(initializationConfiguration =>
            {
                configuration = initializationConfiguration.Resolve <IConfiguration>();
                var eventStoreConnectionString = configuration.GetValue <string>("CoreEventStore:EventStoreConfig:ConnectionString");
                var init = new InitializationConfiguration()
                {
                    EventStoreConnectionString = eventStoreConnectionString,
                };
                return(init);
            })
            .SubscribeRead(subscriptionConfiguration =>
            {
                subscriptionConfiguration.AddEvent <CustomerCreated>(nameof(CustomerCreated));
                subscriptionConfiguration.AddEvent <CustomerModified>(nameof(CustomerModified));
            }, new CustomProjectorInvoker())
            .KeepPositionInMongo(configuration =>
            {
                configuration.ConnectionString = "mongodb://127.0.0.1";
                configuration.DatabaseName     = "TestDB";
            })
            .KeepIdempotenceInMongo();
        }
예제 #6
0
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterEventStore(initializationConfiguration =>
            {
                var configuration = initializationConfiguration.Resolve <IConfiguration>();
                var eventStoreConnectionString = configuration.GetValue <string>("CoreEventStore:EventStoreConfig:ConnectionString");
                var init = new InitializationConfiguration()
                {
                    EventStoreConnectionString = eventStoreConnectionString,
                };
                return(init);
            });

            // builder.RegisterEventStore(initializationConfiguration =>
            // {
            //     initializationConfiguration.Username = "******";
            //     initializationConfiguration.Password = "******";
            //     initializationConfiguration.DefaultPort = 1113;
            //     //initializationConfiguration.IsDockerized = true;
            //     //initializationConfiguration.DockerContainerName = "eventstore";
            //
            //     initializationConfiguration.IsDockerized = false;
            //     initializationConfiguration.ConnectionUri = "127.0.0.1";
            // });
        }
        protected override void Load(ContainerBuilder builder)
        {
            IConfiguration configuration = null;

            builder.RegisterEventStore(initializationConfiguration =>
            {
                configuration = initializationConfiguration.Resolve <IConfiguration>();
                var eventStoreConnectionString = configuration.GetValue <string>("CoreEventStore:EventStoreConfig:ConnectionString");
                var init = new InitializationConfiguration()
                {
                    EventStoreConnectionString = eventStoreConnectionString,
                };
                return(init);
            })
            .SubscribeRead(subscriptionConfiguration =>
            {
                subscriptionConfiguration.AddEvent <CustomerCreatedForPostgres>(nameof(CustomerCreatedForPostgres));
                subscriptionConfiguration.AddEvent <CustomerModified>(nameof(CustomerModified));
            }, new CustomProjectorInvoker())
            .UseePostgreSQL(configuration =>
            {
                configuration.ConnectionString = "Host=localhost;Port=5432;Database=eventstoredb;Username=postgres;password=TTTttt456";
                //configuration.DefaultSchema = "essch";
            })
            .KeepPositionInPostgreSQL()
            .KeepIdempotenceInPostgreSQL();
        }
예제 #8
0
 public WeeklySummaryNotificationTask(
     InitializationConfiguration configuration,
     Func <Task <SqlConnection> > openSupportRequestSqlConnectionAsync,
     ILoggerFactory loggerFactory)
     : base(configuration, openSupportRequestSqlConnectionAsync, loggerFactory)
 {
     _targetEmailAddress = configuration.TargetEmailAddress;
 }
 protected override void Load(ContainerBuilder builder)
 {
     builder.RegisterEventStore(initializationConfiguration =>
     {
         var configuration = initializationConfiguration.Resolve <IConfiguration>();
         var eventStoreConnectionString = configuration.GetValue <string>("CoreEventStore:EventStoreConfig:ConnectionString");
         var init = new InitializationConfiguration()
         {
             EventStoreConnectionString = eventStoreConnectionString,
         };
         return(init);
     });
 }
        public OnCallDailyNotificationTask(
            InitializationConfiguration configuration,
            Func <Task <SqlConnection> > openSupportRequestSqlConnectionAsync,
            ILoggerFactory loggerFactory)
            : base(configuration, openSupportRequestSqlConnectionAsync, loggerFactory)
        {
            var pagerDutyConfiguration = new PagerDutyConfiguration(
                configuration.PagerDutyAccountName,
                configuration.PagerDutyApiKey
                );

            _pagerDutyClient = new PagerDutyClient(pagerDutyConfiguration);
        }
예제 #11
0
            public FactsBase()
            {
                _context      = new Mock <IEntitiesContext>();
                _scopeFactory = new Mock <IServiceScopeFactory>();
                _config       = new InitializationConfiguration();

                var scope           = new Mock <IServiceScope>();
                var serviceProvider = new Mock <IServiceProvider>();

                _scopeFactory.Setup(s => s.CreateScope()).Returns(scope.Object);
                scope.Setup(s => s.ServiceProvider).Returns(serviceProvider.Object);
                serviceProvider.Setup(p => p.GetService(typeof(IEntitiesContext))).Returns(_context.Object);

                _target = new PackageFinder(
                    _context.Object,
                    _scopeFactory.Object,
                    _config,
                    Mock.Of <ILogger <PackageFinder> >());
            }
예제 #12
0
        protected SupportRequestsNotificationScheduledTask(
            InitializationConfiguration configuration,
            Func <Task <SqlConnection> > openSupportRequestSqlConnectionAsync,
            ILoggerFactory loggerFactory)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            _messagingService = new MessagingService(loggerFactory, configuration.SmtpUri);

            _supportRequestRepository = new SupportRequestRepository(loggerFactory, openSupportRequestSqlConnectionAsync);
        }
            public void Succeeds(bool areCredentialsExpired)
            {
                var config   = new InitializationConfiguration();
                var sender   = new MailAddress("*****@*****.**");
                var username = "******";
                var list     = CreateValidList();
                var runTime  = new DateTimeOffset(2018, 10, 31, 12, 10, 31, TimeSpan.Zero);

                var result = new CredentialExpirationEmailBuilder(
                    config, sender, username, list, runTime, areCredentialsExpired);

                Assert.Equal(config, result.InitializationConfiguration);
                Assert.Equal(sender, result.Sender);
                Assert.Equal(username, result.Username);
                Assert.Equal(username, result.UserAddress.DisplayName);
                Assert.Equal(list.First().EmailAddress, result.UserAddress.Address);
                Assert.Equal(list, result.Credentials);
                Assert.Equal(runTime, result.JobRunTime);
                Assert.Equal(areCredentialsExpired, result.AreCredentialsExpired);
            }
예제 #14
0
        protected override void Load(ContainerBuilder builder)
        {
            IConfiguration configuration = null;

            builder.RegisterEventStore(initializationConfiguration =>
            {
                configuration = initializationConfiguration.Resolve <IConfiguration>();
                var eventStoreConnectionString = configuration.GetValue <string>("CoreEventStore:EventStoreConfig:ConnectionString");
                var init = new InitializationConfiguration()
                {
                    EventStoreConnectionString = eventStoreConnectionString,
                };
                return(init);
            })
            .SubscribeRead(subscriptionConfiguration =>
            {
                subscriptionConfiguration.AddEvent <CustomerCreated>(nameof(CustomerCreated));
                subscriptionConfiguration.AddEvent <CustomerModified>(nameof(CustomerModified));
            }, new CustomProjectorInvoker());
        }
        public static IEventStoreConnection Build(InitializationConfiguration initializationConfiguration)
        {
            //return EventStoreConnection.Create("connectto=tcp://admin:changeit@eventstore:1113");
            // StringBuilder connectionString = new StringBuilder("connectto=tcp://");
            //
            // if (!string.IsNullOrWhiteSpace(initializationConfiguration.Username) || string.IsNullOrWhiteSpace(initializationConfiguration.Password))
            //     connectionString.Append($"{initializationConfiguration.Username}:{initializationConfiguration.Password}@");
            //
            // if (initializationConfiguration.IsDockerized)
            //     connectionString.Append(initializationConfiguration.DockerContainerName);
            // else
            //     connectionString.Append(initializationConfiguration.ConnectionUri);
            //
            // connectionString.Append(":" + initializationConfiguration.DefaultPort);
            // initializationConfiguration.ReadonlyConnectionString = connectionString.ToString();

            var con = EventStoreConnection.Create(initializationConfiguration.EventStoreConnectionString);

            con.ConnectAsync().Wait();

            return(con);
        }
예제 #16
0
        private static void UpdateConfig(tSNE tsne, string conf, Dictionary <string, object> param)
        {
            Console.WriteLine("\n{0}Configuration:", conf);
            switch (conf)
            {
            case "Initialization":
                InitializationConfiguration ic = tsne.InitializationConfig;
                ic.SmartInit           = Convert.ToBoolean(UpdateField(param, "SmartInit", ic.SmartInit));
                ic.InitialSolutionSeed = Convert.ToInt32(UpdateField(param, "InitialSolutionSeed", ic.InitialSolutionSeed));
                if (ic.InitialSolutionSeed == -1)
                {
                    Console.WriteLine("\tInitialSolutionSeed set to -1 - using random seed.");
                }
                break;

            case "Affinities":
                AffinitiesConfiguration ac = tsne.AffinitiesConfig;
                ac.Perplexity  = Convert.ToDouble(UpdateField(param, "Perplexity", ac.Perplexity));
                ac.EntropyTol  = Convert.ToDouble(UpdateField(param, "EntropyTol", ac.EntropyTol));
                ac.EntropyIter = Convert.ToInt32(UpdateField(param, "EntropyIter", ac.EntropyIter));
                break;

            case "LSHF":
                LSHFConfiguration lc = tsne.LSHFConfig;
                lc.LSHForestTrees = Convert.ToInt32(UpdateField(param, "LSHForestTrees", lc.LSHForestTrees));
                lc.LSHTreeC       = Convert.ToInt32(UpdateField(param, "LSHTreeC", lc.LSHTreeC));
                lc.LSHHashDims    = Convert.ToInt32(UpdateField(param, "LSHHashDims", lc.LSHHashDims));
                lc.LSHSeed        = Convert.ToInt32(UpdateField(param, "LSHSeed", lc.LSHSeed));
                if (lc.LSHSeed == -1)
                {
                    Console.WriteLine("\tLSHSeed set to -1 - using random seed.");
                }
                break;

            case "Gradient":
                GradientConfiguration gc = tsne.GradientConfig;
                gc.Iterations      = Convert.ToInt32(UpdateField(param, "Iterations", gc.Iterations));
                gc.GradMinGain     = Convert.ToDouble(UpdateField(param, "GradMinGain", gc.GradMinGain));
                gc.RepulsionMethod = UpdateRepulsionMethod(param, gc.RepulsionMethod);
                gc.Exaggeration    = UpdateFunctionField(param, "Exaggeration", gc.Exaggeration);
                gc.Momentum        = UpdateFunctionField(param, "Momentum", gc.Momentum);
                gc.LearningRate    = UpdateFunctionField(param, "LearningRate", gc.LearningRate);
                break;

            case "BarnesHut":
                BarnesHutConfiguration bc = tsne.BarnesHutConfig;
                bc.BarnesHutCondition = Convert.ToDouble(UpdateField(param, "BarnesHutCondition", bc.BarnesHutCondition));
                bc.Presort            = Convert.ToBoolean(UpdateField(param, "Presort", bc.Presort));
                break;

            case "PI":
                PIConfiguration pc = tsne.PIConfig;
                pc.min_num_intervals      = Convert.ToInt32(UpdateField(param, "min_num_intervals", pc.min_num_intervals));
                pc.intervals_per_integer  = Convert.ToDouble(UpdateField(param, "intervals_per_integer", pc.intervals_per_integer));
                pc.n_interpolation_points = Convert.ToInt32(UpdateField(param, "n_interpolation_points", pc.n_interpolation_points));
                break;

            default:
                Console.WriteLine("\tConfiguration type {0} unknown.", conf);
                break;
            }
            if (param.Count > 0)
            {
                Console.WriteLine("\tUnknown {0}Configuration parameters: {1}!", conf, string.Join(", ", param.Keys));
            }
        }
        protected SupportRequestsNotificationScheduledTask(
            InitializationConfiguration configuration,
            Func <Task <SqlConnection> > openSupportRequestSqlConnectionAsync,
            ILoggerFactory loggerFactory)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            var serializer     = new ServiceBusMessageSerializer();
            var topicClient    = new TopicClientWrapper(configuration.EmailPublisherConnectionString, configuration.EmailPublisherTopicName);
            var enqueuer       = new EmailMessageEnqueuer(topicClient, serializer, loggerFactory.CreateLogger <EmailMessageEnqueuer>());
            var messageService = new AsynchronousEmailMessageService(
                enqueuer,
                loggerFactory.CreateLogger <AsynchronousEmailMessageService>(),
                configuration);

            _messagingService = new MessagingService(messageService, loggerFactory.CreateLogger <MessagingService>());

            _supportRequestRepository = new SupportRequestRepository(loggerFactory, openSupportRequestSqlConnectionAsync);
        }