0

有没有人在 C# 中有一个工作示例,说明如何删除或恢复被同步过程标记为错误的对象?

我正在创建一个使用 QuickBooks API V2 将发票推送到 Intuit 的 .Net 应用程序。

最近,我显然向 Intuit 推送了一张已确定为“坏”的发票。

当我寻找类似的问题时,我看到了一些我需要恢复或删除这些的答案,但找不到任何如何这样做的示例。

谢谢!!

4

1 回答 1

0

PFB .net 代码片段。

用于查询错误对象

Intuit.Ipp.Data.Qbd.CustomerQuery qbdCustomerQueryErroredObjects =  new Intuit.Ipp.Data.Qbd.CustomerQuery();
qbdCustomerQueryErroredObjects.ErroredObjectsOnly = true;
IEnumerable<Intuit.Ipp.Data.Qbd.Customer> qbdCustomers = qbdCustomerQueryErroredObjects.ExecuteQuery<Intuit.Ipp.Data.Qbd.Customer>(context) as IEnumerable<Intuit.Ipp.Data.Qbd.Customer>;

查询对象的同步状态

Intuit.Ipp.Data.Qbd.SyncStatusRequest syncSt1 = new Intuit.Ipp.Data.Qbd.SyncStatusRequest();
syncSt1.ErroredObjectsOnly = true;
syncSt1.OfferingIdSpecified = true;
syncSt1.OfferingId = Intuit.Ipp.Data.Qbd.offeringId.ipp;
syncSt1.NgIdSet = new Intuit.Ipp.Data.Qbd.NgIdSet[1];
syncSt1.NgIdSet[0] = new Intuit.Ipp.Data.Qbd.NgIdSet();
syncSt1.NgIdSet[0].NgId = "949162";
syncSt1.NgIdSet[0].NgObjectType = Intuit.Ipp.Data.Qbd.objectName.Customer;

//Optional Params
//syncSt1.StartCreatedTMS = DateTime.Now.AddDays(-90);
//syncSt1.StartCreatedTMSSpecified = true;
//syncSt1.EndCreatedTMS = DateTime.Now;
//syncSt1.EndCreatedTMSSpecified = true;
IEnumerable<Intuit.Ipp.Data.Qbd.SyncStatusResponse> syncResultCustomers = commonService.GetSyncStatus(syncSt1);

删除错误对象

Intuit.Ipp.Data.Qbd.Customer customerToDelete = new Intuit.Ipp.Data.Qbd.Customer();
customerToDelete.Id = new Intuit.Ipp.Data.Qbd.IdType() { idDomain = Intuit.Ipp.Data.Qbd.idDomainEnum.NG, Value = "949162" };
customerToDelete.SyncToken = "1";
commonService.Delete(customerToDelete);

您也可以使用 ApiExplorer 完成所有这些操作。

您可以通过执行查询并设置 ErroredObjectsOnly=true 来检查。

http://docs.developer.intuit.com/0025_Intuit_Anywhere/0050_Data_Services/v2/0500_QuickBooks_Windows/0100_Calling_Data_Services/0015_Retrieving_Objects#Objects_in_Error_State

如果实体处于错误状态,您可以使用 SyncStatus API 查询具体原因:

http://docs.developer.intuit.com/0025_Intuit_Anywhere/0050_Data_Services/v2/0500_QuickBooks_Windows/0600_Object_Reference/SyncStatus

从那里,您将需要删除或恢复处于错误状态的对象,具体取决于是否发生了同步。

删除(未发生同步):

http://docs.developer.intuit.com/0025_Intuit_Anywhere/0050_Data_Services/v2/0500_QuickBooks_Windows/0100_Calling_Data_Services/Deleting_an_Object

如果实体至少发生了一次成功的同步,但随后更新将其推入错误状态,您将需要执行 Revert:

谢谢

于 2013-08-29T06:45:12.297 回答