Quickbooks API-.NET-QBD-V2-有人在C#中有如何删除或恢复错误对象的工作示例吗

本文关键字:恢复 错误 对象 工作 删除 NET-QBD-V2- API- 何删除 Quickbooks | 更新日期: 2023-09-27 18:29:35

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

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

最近,我显然向Intuit推送了一张发票,它已经确定是"坏的"。

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

谢谢!!

Quickbooks API-.NET-QBD-V2-有人在C#中有如何删除或恢复错误对象的工作示例吗

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:

感谢