/// <summary> /// We have been added to a spreadsheet cell. /// </summary> /// <param name="topicID"></param> /// <param name="parameters"> /// We are expecting one (1) parameter that represents the UserOrderID and OrderDate /// </param> /// <param name="getNewValues"></param> /// <returns></returns> object IRtdServer.ConnectData(int topicID, ref Array parameters, ref bool getNewValues) { try { getNewValues = true; // over-write any saved values in the spreadsheet var queryStr = (parameters.GetValue(0)).ToString(); var queryParts = MessageUtil.ExtractRecord(queryStr); var queryOrder = new Order(queryParts); if (!queryOrder.CanCalculateCompositOrderId) { return("#Error: UserOrderId/OrderDate do not meet requirements"); } lock (nmsClient) { var cacheKey = queryOrder.CacheKey; orderToTopicMapping[cacheKey] = topicID; var order = nmsClient.GetOrderByKey(cacheKey); if (order == null) { // Give us a chance to connect, but don't waste too much time if (!nmsClient.Connected()) { Thread.Sleep(1000); } if (nmsClient.Connected()) { // query the system for the order nmsClient.QueryOrder(queryOrder.userOrderId, (DateTime)queryOrder.orderDate); return("Unknown order - sent query"); } return("#Warn: Not connected to broker, try again"); } return(GetErrorOrStatus(order)); } } catch (Exception e) { //log.Error(e); return("#Error looking up order status:" + e.Message); } }