internal void OnModifyOrderCommand_WhenNoOrderExists_DoesNotSendToGateway() { // Arrange var order = new StubOrderBuilder().EntryOrder("O-123456").BuildMarketOrder(); var traderId = TraderId.FromString("TESTER-000"); var accountId = AccountId.FromString("NAUTILUS-000-SIMULATED"); var modify = new ModifyOrder( traderId, accountId, order.Id, order.Quantity, Price.Create(1.00010m, 5), Guid.NewGuid(), StubZonedDateTime.UnixEpoch()); // Act this.engine.Endpoint.SendAsync(modify); Task.Delay(100).Wait(); // Buffer to avoid intermittent tests // Assert Assert.Null(this.engine.UnhandledMessages.FirstOrDefault()); Assert.Equal(2, this.engine.ProcessedCount); Assert.Equal(1, this.engine.CommandCount); Assert.Equal(0, this.engine.EventCount); Assert.Empty(this.tradingGateway.CalledMethods); Assert.Empty(this.tradingGateway.ReceivedObjects); Assert.Empty(this.receiver.Messages); }
private void OnMessage(ModifyOrder command) { this.CommandCount++; this.Logger.LogInformation(LogId.Trading, $"{Received}{Command} {command}."); var order = this.database.GetOrder(command.OrderId); if (order is null) { this.Logger.LogError(LogId.Database, $"Cannot execute command {command} (order was not found in the memory cache)."); return; } if (!order.IsWorking) { this.bufferModify[command.OrderId] = command; this.Logger.LogWarning(LogId.Trading, $"Buffering command {command} (order not yet working)."); return; } if (this.bufferModify.ContainsKey(command.OrderId)) { this.bufferModify[command.OrderId] = command; this.Logger.LogDebug(LogId.Trading, $"Buffering command {command} (order already being modified)."); return; } // Buffer the command to check in later processing this.bufferModify[command.OrderId] = command; this.gateway.ModifyOrder( order, command.ModifiedQuantity, command.ModifiedPrice); }
internal void OnModifyOrderCommand_WhenOrderAlreadyBeingModified_DoesNotSendToGateway() { // Arrange var order = new StubOrderBuilder().EntryOrder("O-123456").BuildStopMarketOrder(); var traderId = TraderId.FromString("TESTER-000"); var accountId = AccountId.FromString("NAUTILUS-000-SIMULATED"); var positionId = new PositionId("P-123456"); var strategyId = new StrategyId("SCALPER", "001"); var submit = new SubmitOrder( traderId, accountId, strategyId, positionId, order, Guid.NewGuid(), StubZonedDateTime.UnixEpoch()); var modify1 = new ModifyOrder( traderId, accountId, order.Id, order.Quantity, Price.Create(1.00010m, 5), Guid.NewGuid(), StubZonedDateTime.UnixEpoch()); var modify2 = new ModifyOrder( traderId, accountId, order.Id, order.Quantity, Price.Create(1.00010m, 5), Guid.NewGuid(), StubZonedDateTime.UnixEpoch()); // Act this.engine.Endpoint.SendAsync(submit).Wait(); this.engine.Endpoint.SendAsync(StubEventMessageProvider.OrderAcceptedEvent(order)).Wait(); this.engine.Endpoint.SendAsync(StubEventMessageProvider.OrderWorkingEvent(order)).Wait(); this.engine.Endpoint.SendAsync(modify1).Wait(); this.engine.Endpoint.SendAsync(modify2).Wait(); Task.Delay(100).Wait(); // Buffer to avoid intermittent tests // Assert Assert.Null(this.engine.UnhandledMessages.FirstOrDefault()); Assert.Equal(6, this.engine.ProcessedCount); Assert.Equal(3, this.engine.CommandCount); Assert.Equal(2, this.engine.EventCount); Assert.Equal(2, this.tradingGateway.CalledMethods.Count); Assert.Equal(2, this.tradingGateway.ReceivedObjects.Count); Assert.Equal("SubmitOrder", this.tradingGateway.CalledMethods[0]); Assert.Equal("ModifyOrder", this.tradingGateway.CalledMethods[1]); Assert.Equal(3, this.receiver.Messages.Count); }
// Use this for initialization void Start() { _shipping = transform.Find("Upgrade Shipping").gameObject.GetComponent <Button>(); _wine = transform.Find("Wine & Dine").gameObject.GetComponent <Button>(); _kissUp = transform.Find("Kiss up").gameObject.GetComponent <Button>(); _info = transform.Find("Info").gameObject.GetComponent <Button>(); _whm = GameObject.Find("Main Camera").GetComponent <WarehouseManager>(); _wineCorn = _wine.transform.Find("Corn").gameObject.GetComponent <Button>(); _wineSquash = _wine.transform.Find("Squash").gameObject.GetComponent <Button>(); _wineBeets = _wine.transform.Find("Beets").gameObject.GetComponent <Button>(); _wineCorn.gameObject.transform.localScale = new Vector3(0, 0, 0); _wineSquash.gameObject.transform.localScale = new Vector3(0, 0, 0); _wineBeets.gameObject.transform.localScale = new Vector3(0, 0, 0); _panels = FindObjectOfType <Panels>(); _kissUp.onClick.AddListener(KissUp); _wine.onClick.AddListener(WineAndDine); _info.onClick.AddListener(Info); _wineCorn.onClick.AddListener(WineCorn); _wineBeets.onClick.AddListener(WineBeets); _wineSquash.onClick.AddListener(WineSquash); _shipping.onClick.AddListener(UpgradeShipping); _modifyOrder = FindObjectOfType <ModifyOrder>(); _originalWineText = _wine.transform.Find("Text").GetComponent <Text>().text; _wine.transform.Find("Text").GetComponent <Text>().text = _originalWineText + " ($" + _wineAndDinePrice + ")"; _originalShippingText = _shipping.transform.Find("Text").GetComponent <Text>().text; _shipping.transform.Find("Text").GetComponent <Text>().text = _originalShippingText + " ($" + _upgradeShippingPrice + ")"; _originalKissUpText = _kissUp.transform.Find("Text").GetComponent <Text>().text; _kissUp.transform.Find("Text").GetComponent <Text>().text = _originalKissUpText + " ($" + _kissUpPrice + ")"; HideUpgradeMenu(); }
internal void CanSerializeAndDeserialize_ModifyOrderCommands() { // Arrange var order = new StubOrderBuilder().BuildMarketOrder(); var command = new ModifyOrder( new TraderId("TESTER", "000"), new AccountId("FXCM", "028999999", "SIMULATED"), new OrderId("O-123456"), order.Quantity, Price.Create(1.50000m, 5), Guid.NewGuid(), StubZonedDateTime.UnixEpoch()); // Act var packed = this.serializer.Serialize(command); var unpacked = (ModifyOrder)this.serializer.Deserialize(packed); // Assert Assert.Equal(command, unpacked); this.Output.WriteLine(Convert.ToBase64String(packed)); this.Output.WriteLine(Encoding.UTF8.GetString(packed)); }
private void gvChildGV_RowCellClick(object sender, RowCellClickEventArgs e) { GridView gv = (sender as GridView).GridControl.GetViewAt(e.Location) as GridView; if (gv != null) { GridHitInfo hi = gv.CalcHitInfo(e.Location); if (hi.Column != null && hi.InRowCell) { //记录当前焦点所在的OrderRow DataRow currentMatch = gv.GetDataRow(hi.RowHandle); #region 点击种类 如果是组合商品 下面显示 if (currentMatch["ItemType"].ToString() == ItemType.ConbineProduct.ToString()) { detailAessemble.PageVisible = true; tabsTradeDetail.SelectedTabPage = detailAessemble; } else { detailAessemble.PageVisible = false; } #endregion #region 如果不是连续点击 则绑定数据 //防止同一重复事件多次加载 if (_currentOrderRow != currentMatch) { //记录当前焦点所在的OrderRow _currentOrderRow = currentMatch; //记录当前订单的父Trade行 _currentTradeRow = currentMatch.GetParentRow(Alading.Taobao.Constants.TRADE_ORDER_RELATION); //绑定TradeDetail信息 SetTradeDetailMessages(_currentTradeRow); //绑定商品信息到面板 ShowItemPropValue(currentMatch["iid"].ToString(), currentMatch["sku_properties_name"].ToString()); } #endregion #region 如果选中列为’修改订单‘,则执行处理代码 if (hi.Column.ColumnHandle == 0)// { //如果是未建立库存 则不作处理 if (_currentOrderRow[1].ToString() == LackProductOrNot.NotBuildStock) { XtraMessageBox.Show("当前订单未关联库存,不能修改订单信息"); return; } //取得当前选中订单的数据库真实值 View_TradeStock focusedOrder = View_TradeStockService.GetView_TradeStock(p => p.TradeOrderCode == _currentOrderRow["TradeOrderCode"].ToString()).FirstOrDefault(); if (focusedOrder == null) { return; } if (focusedOrder.LocalStatus != LocalTradeStatus.HasNotSummit) { XtraMessageBox.Show("该订单的交易状态已经改变,不能换货!"); return; } #region 利用时间戳来防止并发 DialogResult result = DialogResult.Yes; if (!SystemHelper.CompareTimeStamp(_currentOrderRow["OrderTimeStamp"] as byte[], focusedOrder.OrderTimeStamp)) { //如果订单信息已经被改,询问是否继续修改 result = XtraMessageBox.Show("订单信息已被修改,继续修改(YES)/查看流程信息(NO)", "订单修改", MessageBoxButtons.YesNo); if (result == DialogResult.No)//如果选择为NO,则查看流程信息,并返回 { tabsTradeDetail.SelectedTabPage = detailTabFlowMsg; return; } } if (result == DialogResult.Yes)//如果result=YES,则继续修改 { //传入时间戳,只有在最后修改提交前验证才能保证不并发 ModifyOrder modifyOrder = new ModifyOrder(focusedOrder, _currentOrderRow["OrderTimeStamp"] as byte[]);//转入修改订单页面 modifyOrder.ShowDialog(); switch (modifyOrder.DialogResult) { case DialogResult.Ignore: return; case DialogResult.OK: InitSelectTab(); break; case DialogResult.Cancel: tabsTradeDetail.SelectedTabPage = detailTabFlowMsg; break; } } else//否则,直接返回 { return; } #endregion } #endregion } } }
private void OnMessage(ModifyOrder command) { this.commandThrottler.Endpoint.Send(command); this.SendReceived(command); }
public static ResponseModifyOrder ToResponseModifySaleOrder(this ModifyOrder p) { return(Mapper.Map <ModifyOrder, ResponseModifyOrder>(p)); }