Пример #1
0
 public void TestCustomerResponse()
 {
     ProcessAddRs.ProcessCustomerAdd(XDocument.Parse("<?xml version=\"1.0\" ?> <QBXML> <QBXMLMsgsRs> <InvoiceAddRs requestID=\"1297\" statusCode=\"3070\" statusSeverity=\"Error\" statusMessage=\"The string &quot;Graham-Lees Hall 334, Washington and Lee University&quot; in the field &quot;Addr2&quot; is too long.\" /> </QBXMLMsgsRs> </QBXML> "), "0d4f37ec-96f8-425e-8534-c7733ed0c0e8");
 }
Пример #2
0
        /// <summary>
        /// WebMethod# 5 - receiveResponseXML()
        /// Signature: public int receiveResponseXML(string ticket, string response, string hresult, string message)
        ///
        /// IN:
        /// string ticket
        /// string response
        /// string hresult
        /// string message
        ///
        /// OUT:
        /// int retVal
        /// Greater than zero  = There are more request to send
        /// 100 = Done. no more request to send
        /// Less than zero  = Custom Error codes
        /// </summary>
        public int receiveResponseXML(string ticket, string response, string hresult, string message)
        {
            var user = rep.GetUser(WebSecurity.CurrentUserId);

            rep.Add(new ResponseXML()
            {
                Date     = DateTime.Now,
                Guid     = ticket,
                Hresult  = hresult,
                Message  = message,
                Response = response,
                ClientID = user.ClientID ?? 0
            });
            rep.Save();


            string responseType      = "";
            bool   updatingInventory = false;
            var    trans             = rep.GetTransaction(ticket);

            int retVal = 0;

            if (!hresult.ToString().Equals(""))
            {
                // if there is an error with response received, web service could also return a -ve int
                retVal = -101;
            }
            else
            {
                if (response.IndexOf("QBXMLMsgsRs") > 0)
                {
                    var doc = XDocument.Parse(response);
                    responseType = doc.Document.Root.Descendants("QBXMLMsgsRs").FirstOrDefault().Descendants().FirstOrDefault().Name.LocalName;
                    switch (responseType)
                    {
                    case "CustomerAddRs":
                        ProcessAddRs.ProcessCustomerAdd(doc, ticket);
                        break;

                    case "ItemQueryRs":
                        ProcessQueryRs.InventoryQuery(response);
                        break;

                    case "InvoiceAddRs":
                        ProcessAddRs.ProcessInvoiceAddRs(response, hresult, message);
                        break;

                    case "ItemSalesTaxQueryRs":
                        ProcessQueryRs.ItemSalesTaxQueryRs(response);
                        break;

                    case "ItemSalesTaxAddRs":
                        ProcessAddRs.ProcessSalesTaxAdd(response);
                        break;

                    case "ItemSalesTaxGroupQueryRs":
                        ProcessQueryRs.ItemSalesTaxGroupQueryRs(response);
                        break;

                    case "ItemInventoryQueryRs":
                        updatingInventory = true;
                        ProcessQueryRs.ItemInventoryQueryRs(response);
                        break;

                    case "ItemNonInventoryQueryRs":
                        ProcessQueryRs.ItemNonInventoryQueryRs(response);
                        break;

                    default:
                        break;
                    }
                }

                //Total Items to be processed for this transaction.
                int total = rep.GetOrdersByTransaction(trans.TransactionID).Count() + rep.GetCustomersByTransaction(trans.TransactionID).Count();

                //Remaining Items needing Processed
                int count = rep.GetUnprocessedOrdersByTransaction(ticket).Count() + rep.GetUnprocessedCustomersByTransaction(ticket).Count();

                decimal percentage = 100;
                if (total != 0)
                {
                    percentage = 100 * ((total - count)) / total;

                    if (percentage >= 100)
                    {
                        count = 0;
                    }
                }
                retVal = Convert.ToInt32(percentage.ToString("N0"));
            }
            if (WebSecurity.IsAuthenticated)
            {
                return(updatingInventory ? 0 : retVal);
            }

            return(100);
        }