Netsuite交易搜索性能

时间:2017-04-27 12:15:57

标签: netsuite

我正在使用Netsuite API(版本v2016_2)来搜索数据。使用下面的代码,似乎Netsuite花了很多时间来回答查询。我正在搜索具有149 MainLine记录和3941 LineItem(日记条目)记录的周期时间的GL交易,并且Netsuite花费将近22分钟来响应该数据。以下是我用于搜索交易的代码段。

public void GetTransactionData()
{
        DataTable dtData = new DataTable();
        string errorMsg = "";
        LoginToService(ref errorMsg);

        TransactionSearch objTransSearch = new TransactionSearch();
        TransactionSearchBasic objTransSearchBasic = new TransactionSearchBasic();
        SearchEnumMultiSelectField semsf = new SearchEnumMultiSelectField();

        semsf.@operator = SearchEnumMultiSelectFieldOperator.anyOf;
        semsf.operatorSpecified = true;
        semsf.searchValue = new string[] { "Journal" };
        objTransSearchBasic.type = semsf;


        objTransSearchBasic.postingPeriod = new RecordRef() { internalId = "43" };

        objTransSearch.basic = objTransSearchBasic;


        //Set Search Preferences
        SearchPreferences _searchPreferences = new SearchPreferences();
        Preferences _prefs = new Preferences();
        _serviceInstance.preferences = _prefs;
        _serviceInstance.searchPreferences = _searchPreferences;
        _searchPreferences.pageSize = 1000;
        _searchPreferences.pageSizeSpecified = true;
        _searchPreferences.bodyFieldsOnly = false;

        //Set Search Preferences

        try
        {
            SearchResult result = _serviceInstance.search(objTransSearch);
    /*
    Above line taking almost 22 minutes for below record count 
    result.recordList.Length = 149
    Total JournalEntryLine = 3941
    */


            List<JournalEntry> lstJEntry = new List<JournalEntry>();
            List<JournalEntryLine> lstLineItems = new List<JournalEntryLine>();

            if (result.status.isSuccess)
            {
                for (int i = 0; i <= result.recordList.Length - 1; i += 1)
                {

                    JournalEntry JEntry = (JournalEntry)result.recordList[i];
                    lstJEntry.Add((JournalEntry)result.recordList[i]);

                    if (JEntry.lineList != null)
                    {

                        foreach (JournalEntryLine line in JEntry.lineList.line)
                        {
                            lstLineItems.Add(line);
                        }
                    }
                }
            }


            try
            {
                _serviceInstance.logout();
            }
            catch (Exception ex)
            {

            }
        }

        catch (Exception ex)
        {
            throw ex;
        }
    }

我无法知道如果我在代码中遗漏了某些内容,或者这是关于数据的内容。请为我建议一些解决方案。

感谢。

2 个答案:

答案 0 :(得分:0)

您应该设置_searchPreferences.bodyFieldsOnly = true。它将通过搜索提高性能,因为它不会返回相关或子列表数据

答案 1 :(得分:0)

我认为您是从Netsuite外部进行此搜索以获取日记帐分录数据或行。不要在外部进行直接搜索,而要在NETSUITE中维护RESTLET并调用该RESTLET。在RESTLET中,执行所需的搜索并返回结果。在NETSUITE中,搜索性能可以提供快速的结果。