/// <summary>
        /// Updates the default Expiration Date on containers to receive based on Receipt Lot's Manufactured Date
        /// </summary>
        public ContainerData.ReceivingData updateExpirationDate(ContainerData.ReceiptLotRequest Request)
        {
            ContainerData.ReceivingData ReceiveData = new ContainerData.ReceivingData();
            JObject ReceiptLotPropsObj = CswConvert.ToJObject(Request.ReceiptLotProps);

            if (ReceiptLotPropsObj.HasValues)
            {
                CswPrimaryKey ReceiptLotId = CswConvert.ToPrimaryKey(Request.ReceiptLotId);
                if (CswTools.IsPrimaryKey(ReceiptLotId))
                {
                    CswNbtObjClassReceiptLot ReceiptLot = _CswNbtResources.Nodes.GetNode(ReceiptLotId);
                    _CswNbtSdTabsAndProps.saveNodeProps(ReceiptLot.Node, ReceiptLotPropsObj);
                    CswPrimaryKey ContainerId = CswConvert.ToPrimaryKey(Request.ContainerId);
                    if (CswTools.IsPrimaryKey(ContainerId) &&
                        ReceiptLot.ManufacturedDate.DateTimeValue != DateTime.MinValue)
                    {
                        CswNbtObjClassContainer   Container = _CswNbtResources.Nodes.GetNode(ContainerId);
                        CswNbtPropertySetMaterial Material  = _CswNbtResources.Nodes.GetNode(Container.Material.RelatedNodeId);
                        Container.ExpirationDate.DateTimeValue = Material.getDefaultExpirationDate(ReceiptLot.ManufacturedDate.DateTimeValue);
                        Container.postChanges(false);
                        JObject ContainerProps = getContainerAddProps(Container);
                        ReceiveData.ContainerProps = ContainerProps.ToString();
                    }
                }
            }
            return(ReceiveData);
        }
Beispiel #2
0
        public static void saveMaterialProps(ICswResources CswResources, MaterialResponse Response, string PropDefinition)
        {
            if (null != CswResources)
            {
                CswNbtResources         NbtResources         = (CswNbtResources)CswResources;
                CswNbtActCreateMaterial CreateMaterialAction = new CswNbtActCreateMaterial(NbtResources);

                // Convert PropDefintion to JObject
                JObject PropsObj = CswConvert.ToJObject(PropDefinition);

                if (PropsObj.HasValues)
                {
                    // Convert the nodeid to a primary key
                    CswPrimaryKey NodePk = CswConvert.ToPrimaryKey(CswConvert.ToString(PropsObj["NodeId"]));

                    // Convert the Nodetypeid to an Int32
                    Int32 NodeTypeId = CswConvert.ToInt32(CswConvert.ToString(PropsObj["NodeTypeId"]));

                    // Properties only
                    JObject Properties = CswConvert.ToJObject(PropsObj["Properties"]);

                    // Save the properties
                    JObject PropValues = CreateMaterialAction.saveMaterialProps(NodePk, Properties, NodeTypeId);

                    // Set the return object
                    if (PropValues.HasValues)
                    {
                        if (null != PropValues.Property("PhysicalState"))
                        {
                            Response.Data.Properties.PhysicalState = CswConvert.ToString(PropValues["PhysicalState"]);
                        }
                    }
                }//if( PropsObj.HasValues )
            }
        }
        public static JObject getSizeNodeProps(CswNbtResources CswNbtResources, Int32 SizeNodeTypeId, string SizeDefinition, bool WriteNode)
        {
            JObject    SizeObj = CswConvert.ToJObject(SizeDefinition, true, "size");
            CswNbtNode SizeNode;

            return(getSizeNodeProps(CswNbtResources, SizeNodeTypeId, SizeObj, WriteNode, out SizeNode));
        }
        /// <summary>
        /// Finalize the new Material
        /// </summary>
        public JObject commitMaterial(string MaterialDefinition)
        {
            JObject RetObj = new JObject();

            JObject MaterialObj = CswConvert.ToJObject(MaterialDefinition);

            if (MaterialObj.HasValues)
            {
                JArray        SizesArray = CswConvert.ToJArray(MaterialObj["sizeNodes"]);
                CswPrimaryKey MaterialId = new CswPrimaryKey();
                MaterialId.FromString(CswConvert.ToString(MaterialObj["materialId"]));
                if (CswTools.IsPrimaryKey(MaterialId))
                {
                    CswNbtNode MaterialNode = _CswNbtResources.Nodes[MaterialId];
                    if (null != MaterialNode)
                    {
                        /* 1. Validate the new material and get its properties */
                        MaterialNode = _commitMaterialNode(MaterialObj);
                        RetObj["createdmaterial"] = true;

                        /* 2. Add the sizes */
                        if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.Containers))
                        {
                            SizesArray = _removeDuplicateSizes(SizesArray);
                            _addMaterialSizes(SizesArray, MaterialNode);
                            RetObj["sizescount"] = SizesArray.Count;
                        }

                        /* 3. Add landingpage data */
                        RetObj["landingpagedata"] = _getLandingPageData(MaterialNode);
                    }
                }
            }
            return(RetObj);
        }
Beispiel #5
0
        public JObject ConvertWcfPropertyData(CswNbtWcfProperty Prop)
        {
            JObject ret = new JObject();

            ret["id"]      = Prop.PropId;
            ret["name"]    = Prop.PropName;
            ret["ocpname"] = Prop.OriginalPropName;
            JObject values = new JObject();

            foreach (string subFieldStr in Prop.values.Keys)
            {
                string  subFieldStrOrig = subFieldStr.Replace('_', ' ');
                object  subFieldVal     = Prop.values[subFieldStr];
                JObject subFieldObj     = CswConvert.ToJObject(subFieldVal.ToString());
                if (subFieldObj.HasValues)
                {
                    //Some out our subfield values are actually JObjects and must be added as such.
                    values.Add(subFieldStrOrig, subFieldObj);
                }
                else
                {
                    values.Add(subFieldStrOrig, subFieldVal.ToString());
                }
            }
            ret["values"] = values;

            return(ret);
        }
Beispiel #6
0
        /// <summary>
        /// After the Object Class Button Click Event is triggered, determine whether any properties were part of the request. If so, return the updated properties for the provided tabs, if any.
        /// </summary>
        private void _onAfterButtonClickSaveProps(string TabId, NbtButtonData ButtonData)
        {
            Int32   TabIdAsInt  = CswConvert.ToInt32(TabId);
            JObject SelectedTab = null;

            if (null != ButtonData.PropsToSave && ButtonData.PropsToSave.HasValues)
            {
                SelectedTab = CswConvert.ToJObject(ButtonData.PropsToSave[TabId]);
            }
            if (TabIdAsInt > 0 || (null != SelectedTab && SelectedTab.HasValues))
            {
                CswNbtSdTabsAndProps Sd = new CswNbtSdTabsAndProps(_CswNbtResources);
                ButtonData.PropsToReturn = Sd.getProps(NodeId.ToString(), null, TabId, NodeTypeId, null, null, ForceReadOnly: false);
            }
        }
Beispiel #7
0
 /// <summary>
 /// Create a new node
 /// </summary>
 public void addNodeProps(CswNbtNode Node, JObject PropsObj, CswNbtMetaDataNodeTypeTab Tab)
 {
     if (Node != null && null != PropsObj && PropsObj.HasValues)
     {
         foreach (JObject PropObj in
                  from PropJProp
                  in PropsObj.Properties()
                  where null != PropJProp.Value
                  select CswConvert.ToJObject(PropJProp.Value)
                  into PropObj
                  where PropObj.HasValues
                  select PropObj)
         {
             addSingleNodeProp(Node, PropObj, Tab);
         }
     }
 }
Beispiel #8
0
        /// <summary>
        /// Save any properties before the Object Class Button Click Event is triggered
        /// </summary>
        private void _onBeforeButtonClickSaveProps(string TabId, NbtButtonData ButtonData)
        {
            Int32   TabIdAsInt  = CswConvert.ToInt32(TabId);
            JObject SelectedTab = null;

            if (null != ButtonData.PropsToSave && ButtonData.PropsToSave.HasValues)
            {
                SelectedTab = CswConvert.ToJObject(ButtonData.PropsToSave[TabId]);
            }
            if (TabIdAsInt > 0 || (null != SelectedTab && SelectedTab.HasValues))
            {
                if (canSave(TabId))
                {
                    CswNbtSdTabsAndProps Sd = new CswNbtSdTabsAndProps(_CswNbtResources);
                    ButtonData.Action = CswEnumNbtButtonAction.refresh;
                    Sd.saveProps(this.NodeId, TabIdAsInt, SelectedTab, this.NodeTypeId, null, false);
                }
            }
        }
        private CswNbtNode _commitMaterialNode(JObject MaterialObj)
        {
            CswNbtNode Ret = null;

            Int32 MaterialNodeTypeId = CswConvert.ToInt32(MaterialObj["materialnodetypeid"]);

            if (Int32.MinValue != MaterialNodeTypeId)
            {
                CswNbtMetaDataNodeType MaterialNt = _CswNbtResources.MetaData.getNodeType(MaterialNodeTypeId);
                if (null != MaterialNt)
                {
                    Ret = _CswNbtResources.Nodes[CswConvert.ToString(MaterialObj["materialId"])];
                    if (null != Ret)
                    {
                        // Set the Vendor node property isTemp = false if necessary
                        bool          IsConstituent = CswConvert.ToBoolean(MaterialObj["isConstituent"]);
                        CswPrimaryKey VendorNodePk  = CswConvert.ToPrimaryKey(CswConvert.ToString(MaterialObj["supplierid"]));
                        if (CswTools.IsPrimaryKey(VendorNodePk) && false == IsConstituent)
                        {
                            CswNbtObjClassVendor VendorNode = _CswNbtResources.Nodes.GetNode(VendorNodePk);
                            if (null != VendorNode && VendorNode.IsTemp)
                            {
                                VendorNode.PromoteTempToReal();
                            }
                        }

                        //Ret.IsTemp = false;
                        JObject MaterialProperties          = (JObject)MaterialObj["properties"];
                        CswNbtSdTabsAndProps SdTabsAndProps = new CswNbtSdTabsAndProps(_CswNbtResources);
                        SdTabsAndProps.saveProps(Ret.NodeId, Int32.MinValue, MaterialProperties, Ret.NodeTypeId, null, IsIdentityTab: false, setIsTempToFalse: false);

                        NewMaterial FinalMaterial = new NewMaterial(_CswNbtResources, Ret);
                        FinalMaterial.TradeName = CswConvert.ToString(MaterialObj["tradename"]);
                        if (false == IsConstituent)
                        {
                            FinalMaterial.SupplierId = CswConvert.ToPrimaryKey(CswConvert.ToString(MaterialObj["supplierid"]));
                            FinalMaterial.PartNo     = CswConvert.ToString(MaterialObj["partno"]);
                        }

                        CswNbtPropertySetMaterial NodeAsMaterial = FinalMaterial.commit();
                        NodeAsMaterial.Save.setHidden(value: false, SaveToDb: true);

                        JObject RequestObj = CswConvert.ToJObject(MaterialObj["request"]);
                        if (RequestObj.HasValues)
                        {
                            _processRequest(CswConvert.ToString(RequestObj["requestitemid"]), NodeAsMaterial);
                        }
                        CswNbtActReceiving Receiving = new CswNbtActReceiving(_CswNbtResources);

                        CswPrimaryKey SDSNodeId = new CswPrimaryKey();
                        if (null != MaterialObj["sdsDocId"])
                        {
                            SDSNodeId.FromString(MaterialObj["sdsDocId"].ToString());
                            JObject SDSProps = CswConvert.ToJObject(MaterialObj["sdsDocProperties"]);
                            Receiving.commitSDSDocNode(NodeAsMaterial.NodeId, SDSNodeId, SDSProps);
                        }
                        Ret.PromoteTempToReal();
                    }
                }

                if (null == Ret)
                {
                    throw new CswDniException(CswEnumErrorType.Error,
                                              "Failed to create new material.",
                                              "Attempted to call _commitMaterialNode failed.");
                }
            }
            return(Ret);
        }
        public CswNbtActDispenseContainer(CswNbtResources CswNbtResources, string SourceContainerNodeId, string DispenseTransactionId = null, string DispenseTransactionProperties = null)
        {
            _CswNbtResources      = CswNbtResources;
            _CswNbtSdTabsAndProps = new CswNbtSdTabsAndProps(_CswNbtResources);

            if (false == String.IsNullOrEmpty(SourceContainerNodeId))
            {
                CswPrimaryKey SourceContainerPK = new CswPrimaryKey();
                SourceContainerPK.FromString(SourceContainerNodeId);
                _SourceContainer = _CswNbtResources.Nodes.GetNode(SourceContainerPK);
                if (false == String.IsNullOrEmpty(DispenseTransactionId))
                {
                    CswPrimaryKey ContainerDispenseTransactionId = new CswPrimaryKey();
                    ContainerDispenseTransactionId.FromString(DispenseTransactionId);
                    _TempDispenseTransaction = _CswNbtResources.Nodes.GetNode(ContainerDispenseTransactionId);
                    if (null != _TempDispenseTransaction)
                    {
                        _CswNbtSdTabsAndProps.saveProps(_TempDispenseTransaction.NodeId, Int32.MinValue, CswConvert.ToJObject(DispenseTransactionProperties), _TempDispenseTransaction.NodeTypeId, null, IsIdentityTab: false, setIsTempToFalse: false);
                    }
                    _SourceContainer.Dispenser = new CswNbtContainerDispenser(_CswNbtResources, new CswNbtContainerDispenseTransactionBuilder(_CswNbtResources, _TempDispenseTransaction), _SourceContainer);
                }
            }
            else
            {
                throw new CswDniException(CswEnumErrorType.Error, "Cannot execute dispense contianer action with an undefined Source Container.", "Attempted to constuct CswNbtActDispenseContainer without a valid Source Container.");
            }
            if (false == _CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.CISPro))
            {
                throw new CswDniException(CswEnumErrorType.Error, "Cannot use the Dispense action without the required module.", "Attempted to constuct CswNbtActSubmitRequest without the required module.");
            }
        }