/// <summary> /// Checks permission and disposes a container (does not post changes!) /// </summary> public void Dispose(bool OverridePermissions = false) { if (OverridePermissions || CswNbtObjClassContainer.canContainer(_CswNbtResources, _CswNbtResources.Actions[CswEnumNbtActionName.DisposeContainer], _Container.getPermissionGroupId())) { _ContainerDispenseTransactionBuilder.create(CswEnumNbtContainerDispenseType.Dispose, -_Container.Quantity.Quantity, _Container.Quantity.UnitId, SrcContainer: _Container); _Container.Quantity.Quantity = 0; _Container.Disposed.Checked = CswEnumTristate.True; _Container.CreateContainerLocationNode(CswEnumNbtContainerLocationTypeOptions.Dispose); _Container.Node.IconFileNameOverride = "x.png"; _Container.Node.Searchable = false; } }
}//_dispense() private void _reconcile(string operation, string barcode, JObject update, CswNbtObjClassBatchOp BatchNode) { try { string newLocationBarcode = update["location"].ToString(); CswNbtObjClassContainer containerNode = _getNodeFromBarcode(barcode, CswEnumNbtObjectClass.ContainerClass, CswNbtObjClassContainer.PropertyName.Barcode, false); if (null != containerNode) { containerNode.CreateContainerLocationNode(CswEnumNbtContainerLocationTypeOptions.ReconcileScans, newLocationBarcode, barcode); containerNode.Location.RefreshNodeName(); containerNode.postChanges(false); } else { string msg = _generateErrorMessage(operation, barcode, null, "A container with barcode " + barcode + " does not exist."); _storeError(BatchNode, msg); } } catch (Exception e) { string msg = "The reconcile operation failed for the container barcode " + barcode + "with exception: " + e; _storeError(BatchNode, msg); } }//_reconcile()
/// <summary> /// Dispense out of this container. /// </summary> /// <param name="DispenseType"></param> /// <param name="QuantityToDeduct">Positive quantity to subtract</param> /// <param name="UnitId"></param> /// <param name="RequestItemId"></param> /// <param name="DestinationContainer"></param> public void DispenseOut(CswEnumNbtContainerDispenseType DispenseType, double QuantityToDeduct, CswPrimaryKey UnitId, CswPrimaryKey RequestItemId = null, CswNbtObjClassContainer DestinationContainer = null, bool RecordTransaction = true) { double RealQuantityToDeduct = _getDispenseAmountInProperUnits(QuantityToDeduct, UnitId, _Container.Quantity.UnitId); double CurrentQuantity = 0; if (CswTools.IsDouble(_Container.Quantity.Quantity)) { CurrentQuantity = _Container.Quantity.Quantity; } _Container.Quantity.Quantity = CurrentQuantity - RealQuantityToDeduct; if (DestinationContainer != null) { DestinationContainer.DispenseIn(DispenseType, QuantityToDeduct, UnitId, RequestItemId, _Container, false); // false, because we do not want another duplicate transaction record } if (RecordTransaction) { _ContainerDispenseTransactionBuilder.create(DispenseType, -RealQuantityToDeduct, _Container.Quantity.UnitId, RequestItemId, _Container, DestinationContainer); } _Container.CreateContainerLocationNode(CswEnumNbtContainerLocationTypeOptions.Dispense); } // DispenseOut()