예제 #1
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()));
        }
예제 #2
0
        private void RegisterInventoryHandlers()
        {
            var handler = new InventoryHandlers(new GetEventStoreRepository<WarehouseItem>(
                                                    EventStoreConnection, "inventory"));

            Register<TrackItem>(handler);
            Register<PickItem>(handler);
            Register<StartCycleCount>(handler);
            Register<CompleteCycleCount>(handler);
            Register<AdjustItemQuantity>(handler);
            Register<LiquidateItem>(handler);
            Register<ReceiveItem>(handler);
        }