/// <summary> /// Persist the SDS Document /// </summary> public void commitSDSDocNode(CswPrimaryKey MaterialId, CswPrimaryKey SDSNodeId, JObject SDSProps) { CswNbtObjClassSDSDocument SDSDoc = _CswNbtResources.Nodes.GetNode(SDSNodeId); if (null != SDSDoc) { _CswNbtSdTabsAndProps.saveProps(SDSDoc.NodeId, Int32.MinValue, SDSProps, SDSDoc.NodeTypeId, null, IsIdentityTab: false, setIsTempToFalse: false); if ((SDSDoc.FileType.Value == CswNbtPropertySetDocument.CswEnumDocumentFileTypes.File && false == string.IsNullOrEmpty(SDSDoc.File.FileName)) || (SDSDoc.FileType.Value == CswNbtPropertySetDocument.CswEnumDocumentFileTypes.Link && false == string.IsNullOrEmpty(SDSDoc.Link.Href))) { SDSDoc.Owner.RelatedNodeId = MaterialId; SDSDoc.PromoteTempToReal(); } } }
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."); } }
/// <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 JObject saveProps(CswPrimaryKey NodePk, Int32 TabId, JObject NewPropsJson, Int32 NodeTypeId, CswNbtView View, bool IsIdentityTab, bool RemoveTempStatus) { return(_TabsPropsSd.saveProps(NodePk, TabId, NewPropsJson, NodeTypeId, View, IsIdentityTab, RemoveTempStatus)); } // saveProps()