public JObject saveMaterialProps(CswPrimaryKey NodePk, JObject PropsObj, Int32 NodeTypeId)
        {
            JObject Ret = new JObject();

            if (CswTools.IsPrimaryKey(NodePk))
            {
                CswNbtPropertySetMaterial MaterialNode = _CswNbtResources.Nodes.GetNode(NodePk);

                CswNbtSdTabsAndProps SdTabsAndProps = new CswNbtSdTabsAndProps(_CswNbtResources);
                SdTabsAndProps.saveNodeProps(MaterialNode.Node, PropsObj);

                switch (MaterialNode.ObjectClass.ObjectClass)
                {
                case CswEnumNbtObjectClass.ChemicalClass:
                    CswNbtObjClassChemical ChemicalNode = MaterialNode.Node;
                    Ret["PhysicalState"] = ChemicalNode.PhysicalState.Value;

                    // Add more properties here if you want.

                    break;

                case CswEnumNbtObjectClass.NonChemicalClass:
                    Ret["PhysicalState"] = CswNbtPropertySetMaterial.CswEnumPhysicalState.NA;

                    // Add properties here!
                    break;

                case CswEnumNbtObjectClass.BiologicalClass:
                    CswNbtObjClassBiological BioNode = MaterialNode.Node;
                    Ret["PhysicalState"] = BioNode.PhysicalState.Value;
                    break;
                }
            }

            return(Ret);
        }
Esempio n. 2
0
        public CswNbtReceivingDefinition receiveContainers(CswNbtReceivingDefinition ReceiptDef, ref int NodesProcessed, int MaxProcessed)
        {
            CswNbtMetaDataNodeType ContainerNt = _CswNbtResources.MetaData.getNodeType(ReceiptDef.ContainerNodeTypeId);

            foreach (CswNbtAmountsGridQuantity QuantityDef in ReceiptDef.Quantities)
            {
                CswNbtObjClassSize  AsSize  = _CswNbtResources.Nodes.GetNode(QuantityDef.SizeNodeId);
                string              Barcode = string.Empty;
                Action <CswNbtNode> After   = delegate(CswNbtNode NewNode)
                {
                    CswNbtObjClassContainer thisContainer = NewNode;
                    if (QuantityDef.getNumBarcodes() <= QuantityDef.NumContainers && false == string.IsNullOrEmpty(Barcode))
                    {
                        thisContainer.Barcode.setBarcodeValueOverride(Barcode, false);
                    }
                    thisContainer.Size.RelatedNodeId     = QuantityDef.SizeNodeId;
                    thisContainer.Material.RelatedNodeId = ReceiptDef.MaterialNodeId;
                    if (AsSize.QuantityEditable.Checked != CswEnumTristate.True)
                    {
                        QuantityDef.Quantity   = AsSize.InitialQuantity.Quantity;
                        QuantityDef.UnitNodeId = AsSize.InitialQuantity.UnitId;
                    }
                    if (null == thisContainer.Quantity.UnitId || Int32.MinValue == thisContainer.Quantity.UnitId.PrimaryKey)
                    {
                        thisContainer.Quantity.UnitId = QuantityDef.UnitNodeId;
                    }
                    thisContainer.DispenseIn(CswEnumNbtContainerDispenseType.Receive, QuantityDef.Quantity, QuantityDef.UnitNodeId, ReceiptDef.RequestItemtNodeId);
                    thisContainer.Disposed.Checked         = CswEnumTristate.False;
                    thisContainer.ReceiptLot.RelatedNodeId = ReceiptDef.ReceiptLotNodeId;
                };

                for (Int32 C = 0; C < QuantityDef.NumContainers; C += 1)
                {
                    if (NodesProcessed < MaxProcessed)
                    {
                        //we promote the first container before the batch op starts, so there should always be at least one container id in the first set of quantities
                        CswPrimaryKey ContainerId = null;
                        if (C < QuantityDef.ContainerIds.Count)
                        {
                            ContainerId = CswConvert.ToPrimaryKey(QuantityDef.ContainerIds[C]);
                        }
                        CswCommaDelimitedString Barcodes = QuantityDef.getBarcodes();
                        Barcode = (QuantityDef.getNumBarcodes() > C ? Barcodes[C] : string.Empty);

                        if (null == ContainerId)  //only create a container if we haven't already
                        {
                            CswNbtNodeKey           ContainerNodeKey;
                            CswNbtObjClassContainer Container = _CswNbtSdTabsAndProps.addNode(ContainerNt, ReceiptDef.ContainerProps, out ContainerNodeKey, After);
                            QuantityDef.ContainerIds.Add(Container.NodeId.ToString());
                            NodesProcessed++;
                        }
                        else
                        {
                            CswNbtNode InitialContainerNode = _CswNbtResources.Nodes.GetNode(ContainerId);
                            if (null != InitialContainerNode && InitialContainerNode.IsTemp)
                            {
                                _CswNbtSdTabsAndProps.saveNodeProps(InitialContainerNode, ReceiptDef.ContainerProps);
                                After(InitialContainerNode);
                                InitialContainerNode.PromoteTempToReal();
                                NodesProcessed++;
                            }
                        }
                    }
                } //for( Int32 C = 0; C < NoContainers; C += 1 )
            }

            return(ReceiptDef);
        }