/// <summary> /// /// </summary> public void CopyParameters(ResponseMessage message) { this._operationResult = message.OperationResult; _exception = message.Exception; _operationResultMessage = message.OperationResultMessage; }
protected void Receive(ResponseMessage message) { if (Arbiter == null) { SystemMonitor.OperationWarning("Received message [" + message.GetType().Name + "] while already out of arbiter."); return; } ProxyForwardingSend(message); }
// >> public void OrderOpened(string symbol, int operationID, int orderTicket, decimal openingPrice, int orderOpenTime, bool operationResult, string operationResultMessage) { TracerHelper.Trace(symbol); try { OperationInformation operation = base.GetOperationById(operationID); DateTime? time = GeneralHelper.GenerateDateTimeSecondsFrom1970(orderOpenTime); if (time.HasValue == false) { if (operation != null) { base.CompleteOperation(operationID, new ResponseMessage(false, "Failed to convert time for order.")); } SystemMonitor.Error("Failed to convert time for order."); return; } string orderId = orderTicket.ToString(); if (orderTicket < 0) {// The system needs orderId empty to recognize the result as failure. orderId = string.Empty; operationResult = false; } if (operation != null) { ResponseMessage message = null; lock (this) { if (operation.Request is SubmitOrderMessage) { message = new SubmitOrderResponseMessage(_accountInfo, orderId, true); message.OperationResultMessage = operationResultMessage; message.OperationResult = operationResult; } else if (operation.Request is ExecuteMarketOrderMessage) { OrderInfo info = new OrderInfo(orderId, CreateSymbol(symbol), OrderTypeEnum.UNKNOWN, OrderStateEnum.Executed, int.MinValue); info.OpenTime = time; info.OpenPrice = openingPrice; message = new ExecuteMarketOrderResponseMessage(_accountInfo, info, operationResult); message.OperationResultMessage = operationResultMessage; } else { SystemMonitor.Error("Failed to establish placed order request type."); message = new ResponseMessage(false); } } base.CompleteOperation(operationID, message); } if (string.IsNullOrEmpty(orderId) == false) { // Do an update of this order. lock (this) { _pendingOrdersInformations.Add(orderId); } } } catch (Exception ex) {// Make sure we handle any possible unexpected exceptions, as otherwise // they bring the entire package (MT4 included) down with a bad error. SystemMonitor.Error(ex.Message); } }