QuickBooks Retrieve of Customers Fails

試著忘記壹切 提交于 2019-12-11 17:46:09

问题


I have this code:

protected readonly IMsgSetRequest RequestMsgSet = null;
protected IMsgSetResponse ResponseMsgSet = null;

public string GetAllCustomer(bool IsActiveOnly = true)
{

    RequestMsgSet.ClearRequests();
    ICustomerQuery CustomerQueryRq = RequestMsgSet.AppendCustomerQueryRq();

    if (IsActiveOnly)
    {
        if (CustomerQueryRq != null)
            CustomerQueryRq.ORCustomerListQuery.CustomerListFilter.ActiveStatus.SetValue(
                ENActiveStatus.asActiveOnly);
    }
    else {
        CustomerQueryRq.ORCustomerListQuery.CustomerListFilter.ActiveStatus.SetValue(ENActiveStatus.asAll);
    }
    ResponseMsgSet = SessionManager.DoRequests(RequestMsgSet);
    return(ResponseMsgSet.ToXMLString());
}

Console.WriteLine(GetAllCustomer());

It returns this:

<?xml version="1.0" ?>
<QBXML>
<QBXMLMsgsRs>
<CustomerQueryRs requestID="0" statusCode="1000" statusSeverity="Error" statusMessage="There has been an internal error when processing the request." />
</QBXMLMsgsRs>
</QBXML>

I suspect that the DoRequests runs out of memory as I have 110,000 customers.

How can I confirm that DoRequests is running out of memory?

How can I rewrite this code to use less memory?


回答1:


Have a look at ICustomerQuery

You can get data with filtering's such as: name range (a-i, j-r than s-z) filter, date range filter, name starts with filter and other some filters as well.

Also this can be used to get only the things you want like: FullName and AccountNumber.

In this way you may consume less memory usage. Have a look at below sample code:

public IList<CustomerModelQB> GetAllCustomer(string fromName = "a", string toName = "z", bool IsActiveOnly = true)
    {
        RequestMsgSet.ClearRequests();
        ICustomerQuery CustomerQueryRq = RequestMsgSet.AppendCustomerQueryRq();

        if (IsActiveOnly)
        {
            if (CustomerQueryRq != null)
                CustomerQueryRq.ORCustomerListQuery.CustomerListFilter.ActiveStatus.SetValue(
                    ENActiveStatus.asActiveOnly);
        }
        else
            CustomerQueryRq.ORCustomerListQuery.CustomerListFilter.ActiveStatus.SetValue(ENActiveStatus.asAll);

        //CustomerQueryRq.ORCustomerListQuery.CustomerListFilter.MaxReturned.SetValue(3);

        //Set field value for FromName
        CustomerQueryRq.ORCustomerListQuery.CustomerListFilter.ORNameFilter.NameRangeFilter.FromName.SetValue(fromName);
        //Set field value for ToName
        CustomerQueryRq.ORCustomerListQuery.CustomerListFilter.ORNameFilter.NameRangeFilter.ToName.SetValue(toName);

        CustomerQueryRq.IncludeRetElementList.Add("FullName");
        CustomerQueryRq.IncludeRetElementList.Add("AccountNumber");
        ResponseMsgSet = SessionManager.DoRequests(RequestMsgSet);
        return WalkCustomerQuery(ResponseMsgSet);
    }

Further you may refer to this question for alphabetical breakout of things.



来源:https://stackoverflow.com/questions/53018684/quickbooks-retrieve-of-customers-fails

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!