protected void Application_Start() { var cs = ConnectionSettings.Create(); var endpoint = new IPEndPoint(IPAddress.Loopback, 1113); var con = EventStoreConnection.Create(endpoint); con.ConnectAsync(); var credentials = new EventStore.ClientAPI.SystemData.UserCredentials("admin", "changeit"); var adapter = new EventStoreAdapter(endpoint, credentials); ProjectionManager = new ProjectionManager(endpoint, credentials, adapter); ProjectionManager.Run(); CommandManager = new CommandManager(con); //var binder = new DefaultModelBinder(); //ModelBinders.Binders.Add(typeof(DateTime), binder); //ModelBinders.Binders.Add(typeof(DateTime?), binder); AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); }
protected override async Task Given() { _credentials = new EventStore.ClientAPI.SystemData.UserCredentials("admin", "changeit"); _onDeleteStreamCompleted = () => { _resetEvent.Set(); }; await base.Given(); var sub = await _conn.SubscribeToStreamAsync(_projectionNamesBuilder.GetEmittedStreamsName(), true, (s, evnt) => { _eventAppeared.Set(); return(Task.CompletedTask); }, userCredentials : _credentials); _emittedStreamsTracker.TrackEmittedStream(new EmittedEvent[] { new EmittedDataEvent( _testStreamName, Guid.NewGuid(), "type1", true, "data", null, CheckpointTag.FromPosition(0, 100, 50), null), }); if (!_eventAppeared.WaitOne(TimeSpan.FromSeconds(5))) { Assert.Fail("Timed out waiting for emitted stream event"); } sub.Unsubscribe(); var emittedStreamResult = await _conn.ReadStreamEventsForwardAsync(_projectionNamesBuilder.GetEmittedStreamsName(), 0, 1, false, _credentials); Assert.AreEqual(1, emittedStreamResult.Events.Length); Assert.AreEqual(SliceReadStatus.Success, emittedStreamResult.Status); }
public StreamStoreConnectionFixture() { AdminCredentials = new UserCredentials("admin", "changeit"); #if LIVE_ES_CONNECTION //Connection = new EventStoreConnectionWrapper( // EventStoreConnection.Create("ConnectTo=tcp://admin:changeit@localhost:1113; HeartBeatTimeout=500")); string esUser = "******"; string esPwd = "changeit"; var creds = new ES.SystemData.UserCredentials(esUser, esPwd); string esIpAddress = "127.0.0.1"; int esPort = 1113; var tcpEndpoint = new IPEndPoint(IPAddress.Parse(esIpAddress), esPort); var settings = ES.ConnectionSettings.Create() .SetDefaultUserCredentials(creds) .KeepReconnecting() .KeepRetrying() .UseConsoleLogger() .DisableTls() .DisableServerCertificateValidation() .WithConnectionTimeoutOf(TimeSpan.FromSeconds(15)) .Build(); Connection = new EventStoreConnectionWrapper(ES.EventStoreConnection.Create(settings, tcpEndpoint, Guid.NewGuid().ToString())); Connection.Connect(); #else Connection = new ReactiveDomain.Testing.EventStore.MockStreamStoreConnection("Test Fixture"); Connection.Connect(); #endif }
object CreateInstance(Type handlerType) { if (_factories == null) { var endpoint = new IPEndPoint(IPAddress.Loopback, 1113); var credentials = new EventStore.ClientAPI.SystemData.UserCredentials("admin", "changeit"); var adapter = new MyBudget.Infrastructure.EventStoreAdapter(endpoint, credentials); var es = new MyBudget.Infrastructure.EventStore(endpoint, credentials, adapter); var repository = new GetEventStoreRepositoryAdapter(_connection, endpoint, adapter); _factories = new Dictionary <Type, Func <object> >(); _factories[typeof(MyBudget.Commands.BudgetHandlers)] = () => new MyBudget.Commands.BudgetHandlers(repository, es); _factories[typeof(MyBudget.Commands.LinesHandlers)] = () => new MyBudget.Commands.LinesHandlers(repository); _factories[typeof(MyBudget.Commands.UserHandlers)] = () => new MyBudget.Commands.UserHandlers(repository); } //var endpoint = new IPEndPoint(IPAddress.Loopback, 1113); //var credentials = new EventStore.ClientAPI.SystemData.UserCredentials("admin", "changeit"); //var adapter = new MyBudget.Infrastructure.EventStoreAdapter(endpoint, credentials); //var es = new MyBudget.Infrastructure.EventStore(endpoint,credentials, adapter); //var repository = new GetEventStoreRepositoryAdapter(_connection, endpoint, adapter ); return(_factories[handlerType]()); //return Activator.CreateInstance(handlerType, Get_EventStoreRepository(), es); }
protected override void Given() { _credentials = new EventStore.ClientAPI.SystemData.UserCredentials("admin", "changeit"); _eventAppeared = new CountdownEvent(_numberOfTrackedEvents); _onDeleteStreamCompleted = () => { _resetEvent.Set(); }; base.Given(); var sub = _conn.SubscribeToStreamAsync(_projectionNamesBuilder.GetEmittedStreamsName(), true, (s, evnt) => { _eventAppeared.Signal(); return(Task.CompletedTask); }, userCredentials: _credentials).Result; for (int i = 0; i < _numberOfTrackedEvents; i++) { _conn.AppendToStreamAsync(String.Format(_testStreamFormat, i), ExpectedVersion.Any, new EventData(Guid.NewGuid(), "type1", true, Helper.UTF8NoBom.GetBytes("data"), null)); _emittedStreamsTracker.TrackEmittedStream(new EmittedEvent[] { new EmittedDataEvent( String.Format(_testStreamFormat, i), Guid.NewGuid(), "type1", true, "data", null, CheckpointTag.FromPosition(0, 100, 50), null), }); } if (!_eventAppeared.Wait(TimeSpan.FromSeconds(10))) { Assert.Fail("Timed out waiting for emitted streams"); } var emittedStreamResult = _conn.ReadStreamEventsForwardAsync(_projectionNamesBuilder.GetEmittedStreamsName(), 0, _numberOfTrackedEvents, false, _credentials).Result; Assert.AreEqual(_numberOfTrackedEvents, emittedStreamResult.Events.Length); Assert.AreEqual(SliceReadStatus.Success, emittedStreamResult.Status); }
IRepository Get_EventStoreRepository() { var endpoint = new IPEndPoint(IPAddress.Loopback, 1113); var credentials = new EventStore.ClientAPI.SystemData.UserCredentials("admin", "changeit"); var adapter = new MyBudget.Infrastructure.EventStoreAdapter(endpoint, credentials); return(new GetEventStoreRepositoryAdapter(_connection, endpoint, adapter)); }
public EventStoreDataFactory(string connectionString, string username, string password) { this.Username = username; this.Password = password; connection = EventStoreConnection.Create(connectionString); //EventStoreConnection.Create(new IPEndPoint(IPAddress.Loopback, 1113)); // Don't forget to tell the connection to connect! connection.ConnectAsync().Wait(); //Should be run ONLY once actually. try { EventStore.ClientAPI.SystemData.UserCredentials credentials = new EventStore.ClientAPI.SystemData.UserCredentials(username, password); PersistentSubscriptionSettings settings = PersistentSubscriptionSettings.Create().DoNotResolveLinkTos().StartFromCurrent(); connection.CreatePersistentSubscriptionAsync("fingrid.messaging.smsrequest", "fingrid.messaging.smsrequest.group", settings, credentials).Wait(); } catch { } }
static void Main(string[] args) { Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("it-IT"); var endpoint = new IPEndPoint(IPAddress.Loopback, 1113); var esCon = EventStoreConnection.Create(endpoint); esCon.Connect(); var credentials = new EventStore.ClientAPI.SystemData.UserCredentials("admin", "changeit"); var cm = new CommandManager(esCon); var pm = new MyBudget.Projections.ProjectionManager(endpoint, credentials, new MyBudget.Infrastructure.EventStoreAdapter(endpoint, credentials)); pm.Run(); var tu = pm.GetUsersList().AllUsers(); tu.Wait(); userId = tu.Result.Select(s => s.Id).FirstOrDefault(); budgetId = pm.GetBudgetsList().GetBudgetsUserCanView(new MyBudget.Domain.Users.UserId(userId)).Select(s => s.Id).FirstOrDefault(); using (var con = new System.Data.SqlClient.SqlConnection(_cs)) { con.Open(); var movements = LoadMovements(con); foreach (var anno in movements.GroupBy(g => g.DateTime.Year)) { var str = ServiceStack.Text.CsvSerializer.SerializeToCsv(anno.OrderBy(d => d.DateTime)); System.IO.File.WriteAllText(@"c:\temp\Year_" + anno.Key + ".csv", str); } var importer = new ImportManager(cm, pm); importer.ImportCategoriesByName(movements.Select(s => s.Category), budgetId, userId); var categories = pm.GetCategories().GetBudgetsCategories(budgetId); var handler = cm.Create <CreateLine>(); foreach (var m in movements) { handler(m.ToCreateLine(new BudgetId(budgetId), userId, categories)); } } }
public SmsRequestProcessor(IEventStoreDataFactory dataFactory, ISmsDao smsDao, ISmsServiceProvider smsServiceFactory) { if (dataFactory == null) { throw new ArgumentNullException("dataFactory"); } if (smsDao == null) { throw new ArgumentNullException("smsDao"); } if (smsServiceFactory == null) { throw new ArgumentNullException("smsServiceFactory"); } this.userCred = new EventStore.ClientAPI.SystemData.UserCredentials(dataFactory.Username, dataFactory.Password); this.smsDao = smsDao; this.dataFactory = dataFactory; this.smsServiceFactory = smsServiceFactory; }
static void Main(string[] args) { Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("it-IT"); var endpoint = new IPEndPoint(IPAddress.Loopback, 1113); var esCon = EventStoreConnection.Create(endpoint); esCon.Connect(); var credentials = new EventStore.ClientAPI.SystemData.UserCredentials("admin", "changeit"); var cm = new CommandManager(esCon); var pm = new MyBudget.Projections.ProjectionManager(endpoint, credentials, new MyBudget.Infrastructure.EventStoreAdapter(endpoint, credentials)); pm.Run(); var tu = pm.GetUsersList().AllUsers(); tu.Wait(); userId = tu.Result.Select(s => s.Id).FirstOrDefault(); budgetId = pm.GetBudgetsList().GetBudgetsUserCanView(new MyBudget.Domain.Users.UserId(userId)).Select(s => s.Id).FirstOrDefault(); using (var con = new System.Data.SqlClient.SqlConnection(_cs)) { con.Open(); var movements = LoadMovements(con); foreach (var anno in movements.GroupBy(g=> g.DateTime.Year)) { var str = ServiceStack.Text.CsvSerializer.SerializeToCsv(anno.OrderBy(d=> d.DateTime)); System.IO.File.WriteAllText(@"c:\temp\Year_"+anno.Key + ".csv", str); } var importer = new ImportManager(cm, pm); importer.ImportCategoriesByName(movements.Select(s => s.Category), budgetId, userId); var categories = pm.GetCategories().GetBudgetsCategories(budgetId); var handler = cm.Create<CreateLine>(); foreach (var m in movements) handler(m.ToCreateLine(new BudgetId(budgetId), userId, categories)); } }