2016-06-17 71 views
1

我在查看Onscreen Reference以查看是否存在查询作业的XML请求。我发现只有客户查询请求CustomerQueryRq,并且也不返回它具有的子作业。查询工作信息

假设这是客户&工作中心的样子:

- Customer 1 
    -- Job 1 
    -- Job 2 
    -- Job 3 

我能够使用CustomerQueryRq并获得详细信息Customer 1,但找不到检索Job 1什么。

所以我的问题是我如何查询一份工作,并得到它的父母客户?我非常感谢任何帮助。

编辑:张贴我QBXML要求:

<?xml version="1.0" encoding="utf-8"?> 
<?qbxml version="13.0"?> 
<QBXML> 
    <QBXMLMsgsRq onError="continueOnError"> 
     <CustomerQueryRq requestID="1"> 
     <FullName>Customer name</FullName> 
     </CustomerQueryRq> 
    </QBXMLMsgsRq> 
</QBXML> 

Customer name有孩子的工作,我想查询这些。

+0

发布您的QBXML请求。 –

+0

感谢您的评论。发布了QBXML请求。 –

回答

1

ICustomerQuery返回作业列表以及客户列表。没有单独的作业查询对象。每个工作都有一个客户作为父母。因此,您也可以检索相关客户的工作。 下面是一个例子:我有一个工作J1与我的公司文件中的客户C1相关联。在下面的C#代码示例中,我创建了一个客户查询对象(使用QB SDK 13.0)并遍历结果。我在顾客列表(C1和J1)中得到两个结果:

using QBXMLRP2Lib; 
using Interop.QBFC13; 

public class SDKApp 
{ 

private QBSessionManager sessionMgr; 

public SDKApp() 
{ 
    // in the class constructor - sessionMgr is a member variable 
    sessionMgr = new QBSessionManager(); 
} 

public void GetData() 
{ 
// open connection and begin session before data fetch - intentionally skipped this code 

// during data fetch 
IMsgSetRequest msgset = sessionMgr.CreateMsgSetRequest("US", 13, 0); 
ICustomerQuery customerQuery = msgset.AppendCustomerQueryRq(); 
IMsgSetResponse msgRes = sessionMgr.DoRequests(msgset); 
IResponseList responseList = msgRes.ResponseList; 
if (responseList.Count > 0) 
{ 
    IResponse response = responseList.GetAt(0); 
    ICustomerRetList customerList = response.Detail as ICustomerRetList; 
    for (int i = 0; i <= customerList.Count - 1; i++) 
    { 
     ICustomerRet qbCustomer = customerList.GetAt(i); 
     string displayName = qbCustomer.Name.GetValue(); 
     string entityType = "Customer"; 
     if (qbCustomer.ParentRef != null) 
     { 
      entityType = "Job of " + qbCustomer.ParentRef.FullName.GetValue(); 
     } 
     Console.WriteLine(displayName + " " + entityType); 
    } 
} 

// end session and close connection after data fetch - intentionally skipped this code 
} 

} 
+0

谢谢纳文!工作很好。 –