Example #1
0
        }//_updateOwner()

        private void _transfer(string operation, string barcode, JObject update, CswNbtObjClassBatchOp BatchNode)
        {
            try
            {
                string     newOwnerBarcode = update["user"].ToString();
                CswNbtNode newOwnerNode    = _getNodeFromBarcode(newOwnerBarcode, CswEnumNbtObjectClass.UserClass, CswNbtObjClassUser.PropertyName.Barcode);
                if (null != newOwnerNode)
                {
                    CswPrimaryKey newOwnerNodeId = newOwnerNode.NodeId;

                    CswNbtObjClassContainer containerNode = _getNodeFromBarcode(barcode, CswEnumNbtObjectClass.ContainerClass, CswNbtObjClassContainer.PropertyName.Barcode);
                    if (null != containerNode)
                    {
                        containerNode.TransferContainer(newOwnerNodeId);
                        containerNode.postChanges(false);
                    }
                    else
                    {
                        string msg = _generateErrorMessage(operation,
                                                           barcode,
                                                           new Dictionary <string, string>
                        {
                            { "New Owner", newOwnerBarcode },
                            { "New Location", update["location"].ToString() }
                        },
                                                           "A container with barcode " + barcode + " does not exist.");
                        _storeError(BatchNode, msg);
                    }
                }
                else
                {
                    string msg = _generateErrorMessage(operation,
                                                       barcode,
                                                       new Dictionary <string, string>
                    {
                        { "New Owner", newOwnerBarcode },
                        { "New Location", update["location"].ToString() }
                    },
                                                       "The User barcode, " + newOwnerBarcode + ", does not exist");
                    _storeError(BatchNode, msg);
                }
            }
            catch (Exception e)
            {
                string msg = "The transfer operation failed for the container barcode " + barcode + "with exception: " + e;
                _storeError(BatchNode, msg);
            }
        }//_transfer()