public override void DeleteItems(List <DataCompareItem> items, IDataSynchronizationStatus status) { if (items != null && items.Count > 0) { int currentItem = 0; foreach (var item in items) { if (!status.ContinueProcessing) { break; } var itemInvariant = new DataCompareItemInvariant(item); // Get the item ID from the Target Identifier Store var item_id = itemInvariant.GetTargetIdentifier <string>(); try { //Call the Automation BeforeDeleteItem (Optional only required if your supporting Automation Item Events) Automation?.BeforeDeleteItem(this, itemInvariant, item_id); if (itemInvariant.Sync) { #region Delete Item var result = WebRequestHelper.DeleteRequestAsJson(null, $"{ListServiceUrl}/{DataSourceReader.ListId}/members/{item_id}"); #endregion //Call the Automation AfterDeleteItem Automation?.AfterDeleteItem(this, itemInvariant, item_id); } ClearSyncStatus(item); //Clear the Sync Flag on Processed Rows } catch (WebException e) { Automation?.ErrorItem(this, itemInvariant, item_id, e); HandleError(status, e); } catch (SystemException e) { Automation?.ErrorItem(this, itemInvariant, item_id, e); HandleError(status, e); } finally { status.Progress(items.Count, ++currentItem); //Update the Sync Progress } } } }
public override void DeleteItems(List<DataCompareItem> items, IDataSynchronizationStatus status) { if (items != null && items.Count > 0) { int currentItem = 0; //Pass an array of ints to DataCompareItemInvariant to identify identifier fields to copy foreach (var item in items.Select(p => new DataCompareItemInvariant(p))) { if (!status.ContinueProcessing) break; try { //Example: Get the item ID from the Target Identifier Store var item_id = item.GetTargetIdentifier<int>(); //Call the Automation BeforeDeleteItem if (Automation != null) Automation.BeforeDeleteItem(this, item, item_id); if (item.Sync) { #region Delete Item //TODO: Delete the Item in the Target #endregion //Call the Automation AfterDeleteItem if (Automation != null) Automation.AfterDeleteItem(this, item, item_id); } } catch (Exception) { //TODO: Handle Error if (status.FailOnError) throw; } finally { status.Progress(items.Count, ++currentItem); } } } }
public override void DeleteItems(List <DataCompareItem> items, IDataSynchronizationStatus status) { if (items != null && items.Count > 0) { int currentItem = 0; foreach (var item in items) { if (!status.ContinueProcessing) { break; } try { var itemInvariant = new DataCompareItemInvariant(item); var filename = itemInvariant.GetTargetIdentifier <string>(); Automation?.BeforeDeleteItem(this, itemInvariant, filename); if (itemInvariant.Sync) { try { Session.RemoveFile(filename); Automation?.AfterDeleteItem(this, itemInvariant, filename); } catch (Exception e) { Automation?.ErrorItem(this, itemInvariant, filename, e); throw; } } ClearSyncStatus(item); //Clear the Sync Flag on Processed Rows } catch (SystemException e) { HandleError(status, e); } finally { status.Progress(items.Count, ++currentItem); //Update the Sync Progress } } } }