public ActionResult Create(OrderViewModel order) { if (ModelState.IsValid) { try { order.Username = User.Identity.Name; order.Save(); OrderHub hub = new OrderHub(); hub.OrderMade(order.Product.Name, order.Quantity); //SendMessage(order); return(RedirectToAction("Index")); } catch (Exception ex) { ModelState.AddModelError("Quantity", ex.Message); return(View(order)); } } else { return(View(order)); } }
//private TTApiService m_TTService; #endregion// members #region Constructors // ***************************************************************** // **** Constructors **** // ***************************************************************** public Form2() { InitializeComponent(); typeof(Ambre.TTServices.Markets.MarketTTAPI).ToString(); // force this needed assembly to load. AppServices appServices = AppServices.GetInstance("AutoStackingTracker", true); // Set application information - do this before hubs are instantiated. appServices.Info.RequestShutdownAddHandler(new EventHandler(this.RequestShutdownHandler)); appServices.LoadServicesFromFile("AutoStackingConfig.txt"); // Creates all services. // Attach event handlers to events this GUI is interested in. foreach (IService service in AppServices.GetInstance().GetServices()) { if (service is OrderHub) { OrderHub hub = (OrderHub)service; hub.BookCreated += new EventHandler(OrderHub_BookCreated); hub.BookChanged += new EventHandler(OrderHub_BookChanged); //hub.BookDeleted += new EventHandler(OrderHub_BookCreated); } } // Can use this to monitor xTrader //System.Diagnostics.Process[] procs2 = System.Diagnostics.Process.GetProcesses(); //System.Diagnostics.Process[] procs = System.Diagnostics.Process.GetProcessesByName("x_trader"); // appServices.Start(); // Start thread hubs. appServices.Connect(); }
public async Task Handle(IOrderProcessedEvent message, IMessageHandlerContext context) { // Here we could write a code with SignalR to notify the page about successful process await Task.Delay(1000); // simulate delay. //orderHub.OrderMessage("Order processed successfully"); OrderHub.SendOrderMessage("Order processed successfully"); }
// // #endregion//Constructors #region no Properties // ***************************************************************** // **** Properties **** // ***************************************************************** // // #endregion//Properties #region Public Methods // ***************************************************************** // **** Public Methods **** // ***************************************************************** // // // // // ********************************************* // **** AddHub() **** // ********************************************* public void AddHub(OrderHub parentOrderHub) { if (m_OrderHub != null) { // Remove the old order hub. } m_OrderHub = parentOrderHub; m_OrderHub.BookChanged += OrderHub_BookChanged; m_OrderHub.BookCreated += OrderHub_BookCreated; m_OrderHub.BookDeleted += OrderHub_BookDeleted; }// AddHub()
public void TestOrderHub() { var context = MockContextFactory.Create(); var getTablesService = new TableService(new MockDataService(context)); var orderService = new OrderService(new MockDataService(context)); var orderPosService = new OrderPosService(new MockDataService(context), orderService); var assignOrderService = new AssignOrderService(new MockDataService(context)); var tabletService = new TabletService(new MockDataService(context)); context.Table.Add(new Database.Models.Table { Id = 12, Name = "Hera", }); context.Tablet.Add(new Database.Models.Tablet { Id = 7, Identifier = "Mira", Mode = Database.Models.Mode.Guest }); context.SaveChanges(); var request = new CreateOrderRequest(); request.TableId = 12; request.TabletIdentifier = "Mira"; var command = new Command <CreateOrderRequest>(); command.RequestId = "123"; command.Arguments = request; var called = false; var hub = new OrderHub(getTablesService, orderService, orderPosService, assignOrderService, tabletService); var responseType = "CreateOrderResponse"; var action = new Action <Command <CreateOrderResponse> >((response) => { Assert.Equal(response.RequestId, command.RequestId); Assert.NotNull(response.Arguments.Order); called = true; }); hub.Clients = MockHubFactory.CreateClients(responseType, action); hub.CreateOrderRequest(command); Assert.True(called); }
}//constructor // // // // **** CreateOrderHubControls **** // private void CreateOrderHubControls() { //foreach (OrderHub hub in AppServices.GetInstance().ServiceOrders.Values) foreach (IService service in AppServices.GetInstance().GetServices()) { if (service is OrderHub) { OrderHub hub = (OrderHub)service; // Create mini viewer this.orderBookViewMini = new Misty.Lib.OrderHubs.FrontEnds.OrderBookViewMini(); this.SuspendLayout(); this.orderBookViewMini.Location = new System.Drawing.Point(0, 0); this.orderBookViewMini.Name = "orderBookViewMini"; System.Drawing.Size size = new System.Drawing.Size(this.ClientSize.Width, this.ClientSize.Height); this.orderBookViewMini.Size = size; this.orderBookViewMini.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top); this.Controls.Add(orderBookViewMini); this.ResumeLayout(); orderBookViewMini.AddHub(hub); } } }// CreateOrderHubControls()
public OrderResponseConsumer(OrderHub orderHub) { _orderHub = orderHub; }
public OrderService(DataContext context, OrderHub orderHub, CustomerOrderHub customerOrderHub) { this.context = context; this.orderHub = orderHub; this.customerHub = customerOrderHub; }