public override void Run() { // This is a sample worker implementation. Replace with your logic. Trace.TraceInformation("BeeHive.Demo.Worker entry point called", "Information"); while (true) { Thread.Sleep(10000); Trace.TraceInformation("Working", "Information"); var order = new Order() { CustomerId = Guid.NewGuid().ToString("N"), Id = Guid.NewGuid().ToString("N"), PaymentMethod = "Card/Visa/4444333322221111/123", ShippingAddress = "Jabolsa", TotalPrice = 223, ProductQuantities = new Dictionary<string, int>() { {Guid.NewGuid().ToString("N"), 1}, {Guid.NewGuid().ToString("N"), 2}, {Guid.NewGuid().ToString("N"), 3}, } }; var customer = new Customer() { Address = "2, Korat Jingala", Email = "*****@*****.**", Id = order.CustomerId, Name = "Natsak Birat" }; _customerStore.InsertAsync(customer).Wait(); _orderStore.InsertAsync(order).Wait(); var ev = new Event(new OrderAccepted() { OrderId = order.Id }) { EventType = "OrderAccepted" }; _queueOperator.PushAsync(ev).Wait(); } }
private static void Main(string[] args) { try { Trace.Listeners.Clear(); Trace.Listeners.Add(new ColourfulConsoleTraceListener()); IWindsorContainer container = new WindsorContainer(); ConfigureDI(container); var orchestrator = container.Resolve<Orchestrator>(); ConsoleWriteLine(ConsoleColor.Green, "Started the processing. Enter <n> to create a message or press <ENTER> to end"); orchestrator.SetupAsync().Wait(); orchestrator.Start(); var queueOperator = container.Resolve<IEventQueueOperator>(); var orderStore = container.Resolve<ICollectionStore<Order>>(); var customerStore = container.Resolve<ICollectionStore<Customer>>(); while (true) { var line = Console.ReadLine(); if (line == "n") { var order = new Order() { CustomerId = Guid.NewGuid().ToString("N"), Id = Guid.NewGuid().ToString("N"), PaymentMethod = "Card/Visa/4444333322221111/123", ShippingAddress = "Jabolsa", TotalPrice = 223, ProductQuantities = new Dictionary<string, int>() { {Guid.NewGuid().ToString("N"), 1}, {Guid.NewGuid().ToString("N"), 2}, {Guid.NewGuid().ToString("N"), 3}, } }; var customer = new Customer() { Address = "2, Korat Jingala", Email = "*****@*****.**", Id = order.CustomerId, Name = "Natsak Birat" }; customerStore.InsertAsync(customer).Wait(); orderStore.InsertAsync(order).Wait(); queueOperator.PushAsync(new Event(new OrderAccepted() { OrderId = order.Id }) { EventType = "OrderAccepted" }).Wait(); } else break; } ConsoleWriteLine(ConsoleColor.DarkCyan, "Stopped"); } catch (Exception e) { ConsoleWriteLine(ConsoleColor.Red, e.ToString()); Console.ReadLine(); } }