QBWC QBXML:如果QuickBooks中已存在库存项目,如何更新库存项目

时间:2013-10-29 12:33:00

标签: qbxml qbwc

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中的项目吗?

0 个答案:

没有答案