public static void ReceiveMaterial(ICswResources CswResources, CswNbtReceivingDefinitionReturn Response, CswNbtReceivingDefinition ReceivingDefiniton) { CswNbtResources NbtResources = (CswNbtResources)CswResources; CswNbtActReceiving ActReceiving = new CswNbtActReceiving(NbtResources, ReceivingDefiniton.MaterialNodeId); JObject ActionData = ActReceiving.receiveMaterial(ReceivingDefiniton); Response.Data.ActionData = ActionData.ToString(); //Create Print Job if (null != ReceivingDefiniton.PrintLabelId && null != ReceivingDefiniton.PrinterNodeId) { CswNbtObjClassContainer InitialContainer = NbtResources.Nodes.GetNode(ReceivingDefiniton.ContainerNodeId); Collection <Dictionary <string, string> > PropVals = new Collection <Dictionary <string, string> >(); foreach (CswNbtAmountsGridQuantity Quant in ReceivingDefiniton.Quantities) { CswNbtObjClassUnitOfMeasure UoMNode = NbtResources.Nodes.GetNode(Quant.UnitNodeId); for (int i = 0; i < Quant.NumContainers; i++) { Dictionary <string, string> vals = InitialContainer.Node.getPropertiesAndValues(); vals[InitialContainer.Barcode.PropName] = Quant.getBarcodes()[i]; vals[InitialContainer.Quantity.PropName] = Quant.Quantity + " " + UoMNode.BaseUnit.Text; PropVals.Add(vals); } } CswNbtWebServicePrintLabels.newPrintJob(CswResources, ReceivingDefiniton.PrinterNodeId, ReceivingDefiniton.PrintLabelId, ReceivingDefiniton.ContainerNodeId, PropVals); } }
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); }