} // getPercentDone() /// <summary> /// Run the next iteration of this batch operation /// </summary> public void runBatchOp(CswNbtObjClassBatchOp BatchNode) { try { if (BatchNode.OpNameValue == CswEnumNbtBatchOpName.Receiving) { _CswNbtSdTabsAndProps = new CswNbtSdTabsAndProps(_CswNbtResources); BatchNode.start(); ReceivingBatchData BatchData = new ReceivingBatchData(BatchNode.BatchData.Text); CswNbtActReceiving ActReceiving = new CswNbtActReceiving(_CswNbtResources); CswNbtReceivingDefinition UpdatedReceiptDef = ActReceiving.receiveContainers(BatchData.ReceiptDef, ref _NodesProcessed, _MaxNodeProcessed); ReceivingBatchData UpdatedBatchData = new ReceivingBatchData(UpdatedReceiptDef); BatchNode.BatchData.Text = UpdatedBatchData.ToString(); if (0 == BatchData.CountNumberContainersToCreate() || 0 == _NodesProcessed) { BatchNode.finish(); } _NodesProcessed = 0; //reset this for Unit Test purposes BatchNode.PercentDone.Value = getPercentDone(BatchNode); BatchNode.BatchData.Text = BatchData.ToString(); BatchNode.postChanges(false); } } catch (Exception ex) { BatchNode.error(ex); } } // runBatchOp()
} // makeBatchOp() public Double getPercentDone(CswNbtObjClassBatchOp BatchNode) { Double ret = 100; if (BatchNode != null && BatchNode.OpNameValue == CswEnumNbtBatchOpName.Receiving) { ReceivingBatchData BatchData = new ReceivingBatchData(BatchNode.BatchData.Text); int containersLeft = BatchData.CountNumberContainersToCreate(); int totalContainers = BatchData.CountTotalContainers(); ret = Math.Round((Double)(totalContainers - containersLeft) / totalContainers * 100, 0); } return(ret); } // getPercentDone()