private object Pub(string orderString, string messageType)
        {
            // We are public (well, we are common code to the public API) API called from Excel, ensure we catch all exceptions
            try {
                log.Info(orderString);
                // turn the string into an order so that we can do some validation on it.
                var orderFields = MessageUtil.ExtractRecord(orderString, true);
                if (orderFields.Count == 0)
                {
                    return("#Warn: did not receive a proper order string. " + orderString);
                }
                // To work with Bloomberg EMSX we require the OrderDate and UserOrderId
                // ClientOrderId is nolonger valid
                if (orderFields.ContainsKey("CLIENTORDERID"))
                {
                    return("#Error: Specify UserOrderId and OrderDate instead of ClientOrderId");
                }

                var order = new Order(orderFields);
                if (order.ModifiedUserOrderId)
                {
                    return("#Error: UserOrderID does not meet requirements.  Must be 6 or less, without spaces and %");
                }
                if (!order.CanCalculateCompositOrderId)
                {
                    return("#Error: Missing OrderDate");
                }

                lock (nmsClient) {
                    if (nmsClient.Connected())
                    {
                        var cachedOrder = nmsClient.GetOrderByKey(order.CacheKey);
                        // what kind of order are we?
                        switch (messageType)
                        {
                        case "NEW":
                            if (cachedOrder != null && cachedOrder.Status != "INVALID" && cachedOrder.Status != "UNKNOWN")
                            {
                                return("#Error - order already sent '" + order.CacheKey + "'");
                            }
                            nmsClient.SendOrder(order);
                            break;

                        case "CANCEL":
                            nmsClient.SendCancel(order);
                            break;

                        case "REPLACE":
                            order.FixMessageType = "G";
                            nmsClient.SendReplace(order);
                            break;

                        default:
                            return("#Error:  Unable to determine type of message to send.  '" + messageType + "'");
                        }
                        log.Info("Sent order:" + order.ToSting());
                    }
                    else
                    {
                        nmsClient.Start();
                        return("#Warn: Not connected to broker, try again");
                    }
                }
                return("Published " + GenerateExcelTimestamp());
            } catch (Exception e) {
                Console.WriteLine("Unable to publish" + e.Message);
                return("#Error: Unable to Publish: " + e.Message);
            }
        }