2017-04-27 104 views
0

我正在使用Netsuite API(版本v2016_2)搜索數據。在下面的代碼中,似乎Netsuite花費很多時間來爲查詢提供響應。我正在尋找具有149條MainLine記錄和3941條LineItem(記錄條目)記錄的膝關節週期的GL事務,而Netsuite需要將近22分鐘才能提供這些數據作爲迴應。下面是我用來搜索交易的代碼片段。Netsuite交易搜索性能

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

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

     [email protected] = 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; 
     } 
    } 

我無法知道,如果我很想念我的代碼的東西或者這是一些有關的數據。請爲此建議我一些解決方案。

謝謝。

回答

0

您應該設置_searchPreferences.bodyFieldsOnly = true。它將提高搜索的性能,因爲它不返回相關或子列表數據