Example #1
0
 public OrderReport GetOrderReport(OrderResponse response, ReportReturnType returnType)
 {
     CheckInitialized();
     var trans = GetTransactionReport(response, returnType);
     return new OrderReport()
         {
             OrderID = trans.OrderID,
             OrderType = trans.OrderType,
             RequestResult = trans.RequestResult,
             RequestErrorMessage = trans.RequestErrorMessage,
             OrderStatus = trans.OrderStatus,
             ReportData = trans.ReportData
         };
 }
Example #2
0
        public TransactionReport GetTransactionReport(OrderResponse response, ReportReturnType returnType)
        {
            CheckInitialized();
            var error = "unknown";
            var requestResult = RequestResultType.Error;
            var reportData = "";
            var orderStatus = "";

            OrderType type = response.OrderType;

            if (TestMode)
            {
                reportData = "This is a test order report. Order ID: ( " + response.OrderID + " ) Type: ( " + type.ToString() + " )";
                requestResult = RequestResultType.TestMode;
                orderStatus = "Test Mode.";
                error = "none";
            }
            else
            {
                try
                {
                    var location = new StringBuilder(_url);

                    if (type == OrderType.FaxMessage) // test for FaxMessage/TL since it's url doesn't follow the convention
                    {
                        location.Append(@"/");
                        location.Append(OrderTypeUtil.GetCode(type));
                        location.Append("ReportByUnqid.aspx?");
                    }
                    else
                    {
                        location.Append(@"/");
                        location.Append(OrderTypeUtil.GetCode(type));
                        location.Append("report.aspx?");
                    }

                    location.Append("UserName="******"&UserPassword="******"&ReturnType=");
                    location.Append(returnType.ToString());

                    if (type == OrderType.EmailMessage || type == OrderType.SMSMessage ||
                        type == OrderType.VoiceMessage || type == OrderType.FaxMessage)
                    {
                        location.Append("&Unqid=");
                        location.Append(response.Unqid);
                    }

                    location.Append("&OrderID=");
                    location.Append(response.OrderID);

                    reportData = webClientProxy.UploadString(location.ToString(), "");

                    requestResult = RequestResultType.Success;
                    error = "none";

                    var xmlDoc = new XmlDocument();
                    xmlDoc.LoadXml(reportData);
                    //assumes there is only one of this kind of tag
                    var xnList = xmlDoc.SelectNodes("/PostAPIResponse/SaveTransactionalOrderResult");
                    foreach (XmlNode xn in xnList)
                    {
                        try
                        {
                            orderStatus = xn["status"].InnerText;
                        }
                        catch (NullReferenceException)
                        {
                            requestResult = RequestResultType.Error;
                            error = xn["Exception"].InnerText;
                        }
                    }
                }
                catch (Exception ex)
                {
                    requestResult = RequestResultType.Error;
                    error = "An error occurred while requesting the order report. " + ex.ToString();
                }
            }

            return new TransactionReport()
            {
                OrderID = response.OrderID,
                Unqid = response.Unqid,
                OrderType = response.OrderType,
                RequestResult = requestResult,
                RequestErrorMessage = error,
                OrderStatus = orderStatus,
                ReportData = reportData,
            };
        }
Example #3
0
 /// <summary>
 /// Cancels an order. All broadcasts and messages are orders.
 /// </summary>
 public string CancelOrder(OrderResponse response)
 {
     CheckInitialized();
     return CancelOrder(response.OrderID, response.OrderType);
 }