如何使用 Quickbooks QBFC (8.0 SDK) 获取客户、工作和员工列表
我接到了一项艰巨的任务:编写一个 C# 应用程序,以将单独数据库中的员工时间条目与 Quickbooks 同步。 由于我是 QB 编程的新手,因此我正在尝试执行基本任务,例如获取客户列表,然后为每个客户分配工作,然后为员工分配工作。 我一直在阅读 SDK 文档,但我对细节仍然有点模糊,因为我找到的示例目前对我来说有点太先进了:-P
为了让事情简单,我想问一下获取一个代码片段,为我提供了初学者的客户列表。 这是我得到的代码:
QBSessionManager SessionManager = new QBSessionManager();
IMsgSetRequest customerSet = SessionManager.CreateMsgSetRequest("US", 8, 0);
//
// Code to get list of customers here.
//
SessionManager.OpenConnection2("", "New App", ENConnectionType.ctLocalQBD);
SessionManager.BeginSession(string.Empty, ENOpenMode.omDontCare);
IMsgSetResponse Resp = SessionManager.DoRequests(customerSet);
MessageBox.Show(Resp.ToXMLString());
SessionManager.EndSession();
SessionManager.CloseConnection();
任何人都可以帮我填写“获取客户列表的代码”吗? 预先非常感谢您!
胜利者
I have been given the painful task of writing a C# application to sync up employee time entries in a separate database with Quickbooks. Since I'm brand new to QB programming, I'm trying to peform basic tasks, such as getting a list of customers, then jobs for each customer, then employees. I've been reading the SDK documentation, but I'm still a little fuzzy on the details because the examples I'm finding are a little too advanced for me at the moment :-P
To keep things simple, I would like to ask for a code snippet that gives me the list of customers for starters. Here's the code I've got:
QBSessionManager SessionManager = new QBSessionManager();
IMsgSetRequest customerSet = SessionManager.CreateMsgSetRequest("US", 8, 0);
//
// Code to get list of customers here.
//
SessionManager.OpenConnection2("", "New App", ENConnectionType.ctLocalQBD);
SessionManager.BeginSession(string.Empty, ENOpenMode.omDontCare);
IMsgSetResponse Resp = SessionManager.DoRequests(customerSet);
MessageBox.Show(Resp.ToXMLString());
SessionManager.EndSession();
SessionManager.CloseConnection();
Can anyone fill in the "code to get list of customers here" for me? Thank you very much in advance!
Victor
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
添加到 Victors、Chili 和 Hassan 的答案中。 很高兴偶然发现这个问题,因为我自己也在为 QBFC 的例子而苦苦挣扎。
这是一套完整的代码,可能会对以后的人有所帮助。 如果与此同时有人可以向我指出一些有用的文档……那就太好了。
Adding to Victors, Chili and Hassan's answer. Glad to have stumbled on this question as I myself was struggling with the QBFC examples.
Here is a full set of code that might just help someone down the road. If in the meantime someone could just point me in the direction of some useful documentation...that would be great.
好吧,看来我找到了缺失的部分:
这会生成与每个客户相关的所有数据,这是向前迈出的一步。 为客户解析 XML 应该非常简单,但是为每个客户解析单独的任务/作业将很费力,因为每个任务没有子节点 - 基本上您会得到重复的 XML 块,其中包含所有基本客户信息(地址、账单)地址、送货地址等),然后是一个名为“FullName”的属性,它将一个冒号附加到客户名称后面,后跟任务标题(其本身可以后跟另一个带有子任务标题的冒号等)。 我想知道是否可以对请求查询做一些聪明的事情来获得更好的 xml 响应(例如,指定我想要返回的属性,并且可能强制为给定客户的每个任务创建子节点)...感谢评论。
Ok, seems like I found the missing piece:
This produces all the data related to each customer, which is a step forward. Parsing the XML for customers should be pretty straightforward, but parsing the individual tasks/jobs for each customer will be laborious, because there are no subnodes for each task - basically you get repeating chunks of XML with all the basic customer info (address, billing address, shipping address, etc.), then this one property called "FullName" which appends a colon to the customer name, followed by the task title (which itself can be followed by another colon with a subtask title, etc.). I'm wondering if there's something clever I can do with the request query to get a better xml response (for instance, specify what properties I want returned, and maybe enforce the creation of subnodes for each task for a given customer)...comments are appreciated.
只有上面列表中指定的字段才会从 QuickBooks 返回 - 在正确的情况下使用正确的字符串非常重要 - 如果出现问题,不会产生错误消息。 您不能指定子字段(例如,地址块中的城市;您必须获取整个地址块)。 对于自定义字段,您还必须指定 OwnerID(对于非应用程序私有的自定义字段使用 0)
Only the fields specified in the above list will be returned from QuickBooks - it is very important to use the correct strings in the correct case - no error messages will result if something is wrong. You cannot specify sub-fields (eg, City within an Address block; you must get the entire Address block). For custom fields, you also must specify the OwnerID (use 0 for custom fields that are not private to an application)