public void Handle(Message message)
        {
            if (!Enabled)
            {
                return;
            }
            if (_eventStore == null)
            {
                return;
            }

            var metadata = new Dictionary <string, object>
            {
                { "Bus", _bus.Name },
                { "TimeStamp", DateTime.UtcNow.ToString("yyyy.MM.dd.HH:mm:ss:ffffff") }
            };


            var ed   = GetEventStoreRepository.ToEventData(message.MsgId, message, metadata);
            var data = new List <EventData> {
                ed
            };

            int amPm = (DateTime.UtcNow.Hour > 12) ? 2 : 1;

            _eventStore.AppendToStreamAsync(
                FullStreamName,
                ExpectedVersion.Any,
                data);
        }
Пример #2
0
        public static void Main(string[] args)
        {
            var connection = EventStoreConnection.Create(new IPEndPoint(IPAddress.Loopback, 1113));
            connection.Connect();
            var storage = new ConcurrentDictionary<Guid, List<Event>>();
            
            handlers = new InventoryHandlers(new InMemoryRepository<WarehouseItem>(storage));
            
            var warehouseId = WarehouseListViewModel.Instance.Single().WarehouseId;
            int i = 1000;
            var products = GetAllProducts();
            var tracking = from name in products
                           let sku = name.First() + name.Last() + "-" + ++i
                           let id = Guid.NewGuid()
                           select new TrackItem(id, id, warehouseId, sku, name);
            tracking.ForEachAsync(TrackItemAndDummyUpUsage).Wait();
            var repository = new GetEventStoreRepository<WarehouseItem>(connection, "inventory");

            var items = storage.Values.ToList().Select(events =>
            {
                var item = (WarehouseItem) Activator.CreateInstance(typeof (WarehouseItem), true);
                foreach (var @event in events)
                {
                    item.AsDynamic().ApplyChange(@event);
                }
                return item;
            }).ToList();
            Console.WriteLine("Saving");
            items.ForEach(item => repository.Save(item, Guid.NewGuid()));
        }
Пример #3
0
        public static void Configure(IGeneralBus bus)
        {
            _es = new EventStoreLoader();
            _es.SetupEventStore(new DirectoryInfo(@"C:\Users\rosed18169\source\EventStore-OSS-Win-v3.9.4"));
            _esConnection = _es.Connection;
            _esRepository = new GetEventStoreRepository(_es.Connection);
            Locator.CurrentMutable.RegisterConstant(_esRepository, typeof(IRepository));

            _acctSvc = new AccountSvc(bus, _esRepository);
        }
Пример #4
0
        protected override void Given()
        {
            Repo = new GetEventStoreRepository("UnitTest", _connection);
            // ctor defaults to disabled
            Logging = new EventStoreMessageLogger(Bus,
                                                  _connection,
                                                  StreamName);

            Thread.Sleep(1000);
        }
Пример #5
0
        protected override void Given()
        {
            Repo = new GetEventStoreRepository("UnitTest", _connection);
            // instantiate Logger class that inherits from QueuedSubscriber
            Logging = new EventStoreMessageLogger(Bus,
                                                  _connection,
                                                  StreamName,
                                                  true);

            Thread.Sleep(2000); // needs a bit of time to set up the ES
        }
Пример #6
0
 private void PostToTcpClient(Message message)
 {
     try
     {
         var commitHeaders = new Dictionary <string, object>
         {
             { GetEventStoreRepository.CommitIdHeader, Guid.NewGuid() },
             { GetEventStoreRepository.AggregateClrTypeHeader, message.GetType().AssemblyQualifiedName },
             { "Source", _name }
         };
         var events = new[] { GetEventStoreRepository.ToEventData(message.MsgId, message, commitHeaders) };
         _es.AppendToStreamAsync(_stream, ExpectedVersion, events);
     }
     catch
     {
         //ignore
     }
 }
 public void SetUp()
 {
     _connection = EventStoreConnection.Create(IntegrationTestTcpEndPoint);
     _connection.Connect();
     _repo = new GetEventStoreRepository(_connection);
 }
 public void SetUp()
 {
     _connection = EventStoreConnection.Create(IntegrationTestTcpEndPoint);
     _connection.Connect();
     _repo = new GetEventStoreRepository(_connection);
 }
 public GetEventStoreRepositoryIntegrationTests(EmbeddedEventStoreFixture fixture)
 {
     _connection = fixture.Connection;
     _repo       = new GetEventStoreRepository("UnitTest", _connection);
 }