/// <summary> /// Run the next iteration of this batch operation /// </summary> public void runBatchOp(CswNbtObjClassBatchOp BatchNode) { try { if (BatchNode != null && BatchNode.OpNameValue == CswEnumNbtBatchOpName.MultiDelete) { BatchNode.start(); MultiDeleteBatchData BatchData = new MultiDeleteBatchData(BatchNode.BatchData.Text); if (BatchData.DeleteNodeIds.Count > 0) { string NodeIdStr = BatchData.DeleteNodeIds.First.ToString(); _deleteNode(NodeIdStr); // Setup for next iteration BatchData.DeleteNodeIds.RemoveAt(0); BatchNode.BatchData.Text = BatchData.ToString(); BatchNode.PercentDone.Value = getPercentDone(BatchNode); } else { BatchNode.finish(); } BatchNode.postChanges(false); } } catch (Exception ex) { BatchNode.error(ex); } }
/// <summary> /// Create a new batch operation to handle a deleteNodes/multi edit operation /// </summary> /// <param name="DeleteNodeIds"></param> public CswNbtObjClassBatchOp makeBatchOp(Collection <CswPrimaryKey> DeleteNodeIds) { CswNbtObjClassBatchOp BatchNode = null; MultiDeleteBatchData BatchData = new MultiDeleteBatchData(string.Empty); BatchData.DeleteNodeIds = _pkArrayToJArray(DeleteNodeIds); BatchData.StartingCount = DeleteNodeIds.Count(); BatchNode = CswNbtBatchManager.makeNew(_CswNbtResources, _BatchOpName, BatchData.ToString()); return(BatchNode); }
public Double getPercentDone(CswNbtObjClassBatchOp BatchNode) { Double ret = 100; if (BatchNode != null && BatchNode.OpNameValue == CswEnumNbtBatchOpName.MultiDelete) { MultiDeleteBatchData BatchData = new MultiDeleteBatchData(BatchNode.BatchData.Text); if (BatchData.StartingCount > 0) { ret = Math.Round((Double)(BatchData.StartingCount - BatchData.DeleteNodeIds.Count()) / BatchData.StartingCount * 100, 0); } } return(ret); }