0

QBWC(QBXML) :如何更新 QuickBooks 中的库存/非库存项目(如果它已经存在)。

我正在使用 WCF 服务。这里是 sendrequestxml 和 receiveResponseXML 函数。

public string sendRequestXML(string ticket, string strHCPResponse, string strCompanyFileName,
        string qbXMLCountry, int qbXMLMajorVers, int qbXMLMinorVers)
    {

        if (System.Web.HttpContext.Current.Session["counter"] == null)
        {
            System.Web.HttpContext.Current.Session["counter"] = 0;
        }
        string evLogTxt = "WebMethod: sendRequestXML() has been called by QBWebconnector" + "\r\n\r\n";
        evLogTxt = evLogTxt + "Parameters received:\r\n";
        evLogTxt = evLogTxt + "string ticket = " + ticket + "\r\n";
        evLogTxt = evLogTxt + "string strHCPResponse = " + strHCPResponse + "\r\n";
        evLogTxt = evLogTxt + "string strCompanyFileName = " + strCompanyFileName + "\r\n";
        evLogTxt = evLogTxt + "string qbXMLCountry = " + qbXMLCountry + "\r\n";
        evLogTxt = evLogTxt + "int qbXMLMajorVers = " + qbXMLMajorVers.ToString() + "\r\n";
        evLogTxt = evLogTxt + "int qbXMLMinorVers = " + qbXMLMinorVers.ToString() + "\r\n";
        evLogTxt = evLogTxt + "\r\n";

        req = (ArrayList)System.Web.HttpContext.Current.Session["RequestList"];

        if (req == null)
        {
            req = buildRequest(ticket);
            System.Web.HttpContext.Current.Session["RequestList"] = req;
        }
        string request = "";
        int total = req.Count;
        count = Convert.ToInt32(System.Web.HttpContext.Current.Session["counter"]);

        if (count < total)
        {
            request = req[count].ToString();
            evLogTxt = evLogTxt + "sending request no = " + (count + 1) + "\r\n";
            System.Web.HttpContext.Current.Session["counter"] = ((int)System.Web.HttpContext.Current.Session["counter"]) + 1;
        }
        else
        {
            count = 0;
            System.Web.HttpContext.Current.Session["counter"] = 0;
            request = "";
        }
        evLogTxt = evLogTxt + "\r\n";
        evLogTxt = evLogTxt + "Return values: " + "\r\n";
        evLogTxt = evLogTxt + "string request = " + request + "\r\n";
        logEvent(evLogTxt);
        return request;
    }

 public int receiveResponseXML(string ticket, string response, string hresult, string message)
    {
        string evLogTxt = "WebMethod: receiveResponseXML() has been called by QBWebconnector" + "\r\n\r\n";
        evLogTxt = evLogTxt + "Parameters received:\r\n";
        evLogTxt = evLogTxt + "string ticket = " + ticket + "\r\n";
        evLogTxt = evLogTxt + "string response = " + response + "\r\n";
        evLogTxt = evLogTxt + "string hresult = " + hresult + "\r\n";
        evLogTxt = evLogTxt + "string message = " + message + "\r\n";
        evLogTxt = evLogTxt + "\r\n";

        int retVal = 0;
        if (!hresult.ToString().Equals(""))
        {
            // if there is an error with response received, web service could also return a -ve int     
            evLogTxt = evLogTxt + "HRESULT = " + hresult + "\r\n";
            evLogTxt = evLogTxt + "Message = " + message + "\r\n";
            retVal = -101;
        }
        else
        {
            evLogTxt = evLogTxt + "Length of response received = " + response.Length + "\r\n";
            req = (ArrayList)System.Web.HttpContext.Current.Session["RequestList"];
            if (req == null)
            {
                req = buildRequest(ticket);
            }
            int total = req.Count;
            int count = Convert.ToInt32(System.Web.HttpContext.Current.Session["counter"]);

            int percentage = (count * 100) / total;
            if (count == 60)
            {
                if (percentage >= 100)
                {
                    count = 0;
                    System.Web.HttpContext.Current.Session["counter"] = 0;
                }
            }
            retVal = percentage;
        }
        evLogTxt = evLogTxt + "\r\n";
        evLogTxt = evLogTxt + "Return values: " + "\r\n";
        evLogTxt = evLogTxt + "int retVal= " + retVal.ToString() + "\r\n";
        logEvent(evLogTxt);
        return retVal;
    }

我熟悉 QB 错误代码。如果项目已经存在,那么它会给您类似项目已经存在的错误,但是如何处理该错误并生成另一个新请求以更新该项目。

谁能指导我如何更新 QuickBooks 中的项目?

4

0 回答 0