public static void Initialize(ICswResources CswResources, CswNbtExplorerReturn Return, CswNbtExplorerRequest Request) { CswNbtResources NbtResources = (CswNbtResources)CswResources; CswPrimaryKey NodeId = CswConvert.ToPrimaryKey(Request.NodeId); if (Request.Depth <= 4 || Request.Depth > 0) //We never want a request higher than 4 and 0 doesn't make sense { MAX_DEPTH = Request.Depth; } FilterVal = new CswCommaDelimitedString(); if (String.IsNullOrEmpty(Request.FilterVal)) { FilterVal.FromString(CswNbtArborGraph._setDefaultFilterVal(NbtResources)); } else { FilterVal.FromString(Request.FilterVal); } StartingNode = NbtResources.Nodes[NodeId]; CswNbtMetaDataNodeType startingNT = StartingNode.getNodeType(); //Add the initial node to the graph _addToGraph(Return, StartingNode.NodeName, string.Empty, NodeId.ToString(), startingNT.IconFileName, 0, "Instance", NodeId.ToString(), startingNT.NodeTypeName, Int32.MinValue); _recurseForRelatingNodes(NbtResources, Return, StartingNode, 1, NodeId.ToString()); _recurseForRelatedNTs(NbtResources, Return, StartingNode.NodeTypeId, 1, NodeId.ToString()); }
} // applyMergeChoices() public void _applyMergeChoicesToNode(MergeInfoData Choices, MergeInfoData.MergeInfoNodePair nodePair, CswNbtNode resultNode) { CswNbtNode Node1 = _CswNbtResources.Nodes[nodePair.Node1Id]; CswNbtNode Node2 = _CswNbtResources.Nodes[nodePair.Node2Id]; if (null != Node1 && null != Node2) { /* * Copy all the values from Node2 into the result and then copy any properties from Node1 into the result that were selected * This is to ensure we copy property values we didn't have to merge. */ resultNode.copyPropertyValuesGeneric(Node2); foreach (MergeInfoData.MergeInfoProperty mergeProp in nodePair.Properties.Where(mergeProp => mergeProp.Choice == 1)) { resultNode.Properties[mergeProp.NodeTypePropId].copyGeneric(Node1.Properties[mergeProp.NodeTypePropId]); } // Set references to new merged node if (Int32.MinValue != nodePair.NodeReferencePropId) { // Find the new nodeid for the value of the reference ICswNbtNodePropNodeReference NodeReferenceProp = resultNode.Properties[nodePair.NodeReferencePropId].AsNodeReference; CswPrimaryKey oldNodeId = NodeReferenceProp.ReferencedNodeId; MergeInfoData.MergeInfoNodePair otherNodePair = Choices.NodePairs.FirstOrDefault(np => np.Node1Id == oldNodeId.ToString() || np.Node2Id == oldNodeId.ToString()); if (null != otherNodePair) { // Set the reference to point to the new merged node NodeReferenceProp.ReferencedNodeId = CswConvert.ToPrimaryKey(otherNodePair.Node2Id); } } // if( Int32.MinValue != nodePair.NodeReferencePropId ) } // if( null != Node1 && null != Node2 ) } // _applyMergeChoicesToNode()
public static void GetSearchImageLink(ICswResources CswResources, CswNbtLayoutDataReturn Ret, string Req) { CswNbtResources NbtResources = (CswNbtResources)CswResources; CswPrimaryKey NodeId = CswConvert.ToPrimaryKey(Req); CswNbtNode Node = NbtResources.Nodes.GetNode(NodeId); CswNbtMetaDataNodeType NodeType = NbtResources.MetaData.getNodeType(Node.NodeTypeId); foreach (CswNbtNodePropWrapper Prop in Node.Properties) { if (CswEnumNbtFieldType.Image == Prop.getFieldTypeValue()) { Ret.Data.ImageLink = CswNbtNodePropImage.getLink(Prop.JctNodePropId, NodeId); } if (CswEnumNbtFieldType.MOL == Prop.getFieldTypeValue()) { Ret.Data.ImageLink = CswNbtNodePropMol.getLink(Prop.JctNodePropId, NodeId); } } if (string.Empty == Ret.Data.ImageLink) { if (NodeType.IconFileName != string.Empty) { Ret.Data.ImageLink = CswNbtMetaDataObjectClass.IconPrefix100 + NodeType.IconFileName; } else { Ret.Data.ImageLink = "Images/icons/300/_placeholder.gif"; } } }
public override void setDBValuesFromRequest(LandingPageData.Request Request) { CswEnumNbtViewType ViewType = (CswEnumNbtViewType)Request.ViewType; if (ViewType == CswEnumNbtViewType.View) { _ItemRow["to_nodeviewid"] = CswConvert.ToDbVal(new CswNbtViewId(Request.PkValue).get()); } else if (ViewType == CswEnumNbtViewType.Action) { _ItemRow["to_actionid"] = CswConvert.ToDbVal(Request.PkValue); } else if (ViewType == CswEnumNbtViewType.Report) { CswPrimaryKey ReportPk = CswConvert.ToPrimaryKey(Request.PkValue); _ItemRow["to_reportid"] = CswConvert.ToDbVal(ReportPk.PrimaryKey); } else if (ViewType == CswEnumNbtViewType.Search) { CswPrimaryKey SearchPk = CswConvert.ToPrimaryKey(Request.PkValue); _ItemRow["to_searchid"] = CswConvert.ToDbVal(SearchPk.PrimaryKey); } else { throw new CswDniException(CswEnumErrorType.Warning, "You must select a view", "No view was selected for new Link LandingPage Item"); } _setCommonDbValuesFromRequest(Request); }
private void _createNotScannedContainerLocation(ContainerData.ReconciliationActions Action, CswEnumNbtContainerLocationTypeOptions Type) { CswNbtMetaDataObjectClass ContLocOc = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.ContainerLocationClass); CswNbtMetaDataNodeType ContLocNt = ContLocOc.FirstNodeType; if (null != ContLocNt) { _CswNbtResources.Nodes.makeNodeFromNodeTypeId(ContLocNt.NodeTypeId, delegate(CswNbtNode NewNode) { CswNbtObjClassContainerLocation ContLocNode = NewNode; ContLocNode.Container.RelatedNodeId = CswConvert.ToPrimaryKey(Action.ContainerId); ContLocNode.Location.SelectedNodeId = CswConvert.ToPrimaryKey(Action.LocationId); ContLocNode.Type.Value = Type.ToString(); ContLocNode.Status.Value = CswEnumNbtContainerLocationStatusOptions.NotScanned.ToString(); ContLocNode.ActionApplied.Checked = CswEnumTristate.False; if (Type == CswEnumNbtContainerLocationTypeOptions.Missing) { ContLocNode.Action.Value = CswEnumNbtContainerLocationActionOptions.MarkMissing.ToString(); } else if (Type == CswEnumNbtContainerLocationTypeOptions.Ignore) { ContLocNode.Action.Value = CswEnumNbtContainerLocationActionOptions.Ignore.ToString(); } ContLocNode.ActionByUser.RelatedNodeId = _CswNbtResources.CurrentNbtUser.UserId; ContLocNode.ScanDate.DateTimeValue = DateTime.Now; ContLocNode.User.RelatedNodeId = _CswNbtResources.CurrentNbtUser.UserId; }); } }
/// <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); }
public void saveContainerActions(ContainerData.ReconciliationRequest Request) { if (null != Request.ContainerActions) { foreach (ContainerData.ReconciliationActions Action in Request.ContainerActions) { if (Action.Action == CswEnumNbtContainerLocationActionOptions.MarkMissing.ToString()) { _createNotScannedContainerLocation(Action, CswEnumNbtContainerLocationTypeOptions.Missing); } else { CswPrimaryKey ContLocNodeId = CswConvert.ToPrimaryKey(Action.ContainerLocationId); if (CswTools.IsPrimaryKey(ContLocNodeId)) { CswNbtObjClassContainerLocation ContLocNode = _CswNbtResources.Nodes.GetNode(ContLocNodeId); ContLocNode.Action.Value = Action.Action; ContLocNode.ActionByUser.RelatedNodeId = _CswNbtResources.CurrentNbtUser.UserId; ContLocNode.postChanges(false); } else if (Action.Action == CswEnumNbtContainerLocationActionOptions.Ignore.ToString()) { _createNotScannedContainerLocation(Action, CswEnumNbtContainerLocationTypeOptions.Ignore); } } } } }
/// <summary> /// Makes a temporary node of the Chemical nodetype. The reason we can't use createMaterial() /// is because we don't have the any properties to provide to the method and tradename, /// material type, and supplier are required. /// </summary> /// <param name="NodeId"></param> /// <returns></returns> public CswPrimaryKey makeTemp(string NodeId) { CswPrimaryKey Ret = new CswPrimaryKey(); CswPrimaryKey NodePk = CswConvert.ToPrimaryKey(NodeId); if (false == CswTools.IsPrimaryKey(NodePk)) //node doesn't exist { CswNbtMetaDataObjectClass ChemicalOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.ChemicalClass); CswNbtMetaDataNodeType ChemicalNT = ChemicalOC.FirstNodeType; if (null != ChemicalNT) { CswNbtPropertySetMaterial NewMaterialTempNode = _CswNbtResources.Nodes.makeNodeFromNodeTypeId(ChemicalNT.NodeTypeId, IsTemp: true); if (null != NewMaterialTempNode) { Ret = NewMaterialTempNode.Node.NodeId; } } } else //node exists { Ret = NodePk; } return(Ret); }
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 override void setItemDataForUI(DataRow LandingPageRow, LandingPageData.Request Request) { Int32 ObjectClassPropId = CswConvert.ToInt32(LandingPageRow["to_objectclasspropid"]); if (ObjectClassPropId != Int32.MinValue) { CswNbtNode RequestNode = _CswNbtResources.Nodes.GetNode(CswConvert.ToPrimaryKey(Request.NodeId)); if (null != RequestNode) { CswNbtMetaDataNodeType NodeType = RequestNode.getNodeType(); if (null != NodeType) { String OCPName = _CswNbtResources.MetaData.getObjectClassPropName(ObjectClassPropId); CswNbtMetaDataNodeTypeProp NodeTypeProp = NodeType.getNodeTypePropByObjectClassProp(OCPName); if (null != NodeTypeProp && false == RequestNode.Properties[NodeTypeProp].AsButton.Hidden) { String DisplayText = LandingPageRow["displaytext"].ToString(); _ItemData.Text = false == String.IsNullOrEmpty(DisplayText) ? DisplayText : "Add New " + NodeTypeProp.PropName; _ItemData.NodeTypePropId = RequestNode.NodeId.ToString() + "_" + NodeTypeProp.PropId.ToString(); _ItemData.ActionName = NodeTypeProp.PropName; _ItemData.ButtonIcon = CswNbtMetaDataObjectClass.IconPrefix100 + NodeType.IconFileName; _setCommonItemDataForUI(LandingPageRow); } } } } }
private void _updateAvailableWorkUnits() { //Case 30817 (Case 30843: moved to here from onBeforeCreate) if (CswTools.IsPrimaryKey(CurrentWorkUnitId) && false == AvailableWorkUnits.CheckValue(CurrentWorkUnitId.ToString())) { AvailableWorkUnits.AddValue(CurrentWorkUnitId.ToString()); CurrentWorkUnitProperty.RelatedNodeId = CurrentWorkUnitId; CurrentWorkUnitProperty.SyncGestalt(); } CswNbtView View = _CswNbtResources.ViewSelect.restoreView(CurrentWorkUnitProperty.NodeTypeProp.ViewId); View.Clear(); View.SetVisibility(CswEnumNbtViewVisibility.Property, null, null); CswNbtMetaDataObjectClass WorkUnitOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.WorkUnitClass); CswNbtViewRelationship WorkUnitParent = View.AddViewRelationship(WorkUnitOC, false); foreach (string WorkUnitNodeId in AvailableWorkUnits.Value) { CswPrimaryKey pk = CswConvert.ToPrimaryKey(WorkUnitNodeId); WorkUnitParent.NodeIdsToFilterIn.Add(pk); } CurrentWorkUnitProperty.OverrideView(View); }
public static void getMolImg(ICswResources CswResources, MolDataReturn Return, MolData ImgData) { string molData = ImgData.molString; string nodeId = ImgData.nodeId; string base64String = ""; CswNbtResources NbtResources = (CswNbtResources)CswResources; if (String.IsNullOrEmpty(molData) && false == String.IsNullOrEmpty(nodeId)) //if we only have a nodeid, get the mol text from the mol property if there is one { CswPrimaryKey pk = CswConvert.ToPrimaryKey(nodeId); CswNbtNode node = NbtResources.Nodes[pk]; CswNbtMetaDataNodeTypeProp molNTP = node.getNodeType().getMolProperty(); if (null != molNTP) { molData = node.Properties[molNTP].AsMol.getMol(); } } if (false == String.IsNullOrEmpty(molData)) { //If the Direct Structure Search module is enabled, use the AcclDirect methods to generate an image. Otherwise, use the legacy code. byte[] bytes = (NbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.DirectStructureSearch) ? NbtResources.AcclDirect.GetImage(molData) : CswStructureSearch.GetImage(molData)); base64String = Convert.ToBase64String(bytes); } ImgData.molImgAsBase64String = base64String; ImgData.molString = molData; Return.Data = ImgData; }
/// <summary> /// Removes the node from the current user's Favorites /// </summary> /// <param name="_CswResources">Resources</param> /// <param name="Response">Empty Repsonse Object</param> /// <param name="NodeId">NodeId to un-Favorite</param> public static void removeFromFavorites(ICswResources _CswResources, CswWebSvcReturn Response, String NodeId) { CswNbtResources _CswNbtResources = (CswNbtResources)_CswResources; CswPrimaryKey NodePK = CswConvert.ToPrimaryKey(NodeId); Int32 UserId = _CswNbtResources.CurrentNbtUser.UserId.PrimaryKey; toggleFavorite(_CswNbtResources, NodePK.PrimaryKey, UserId, CswEnumTristate.False); }
public JObject DeleteNodes(string[] NodePks, string[] NodeKeys) { JObject ret = new JObject(); Collection <CswPrimaryKey> NodePrimaryKeys = new Collection <CswPrimaryKey>(); if (NodeKeys.Length > 0) { foreach (string NodeKey in NodeKeys) { CswNbtNodeKey NbtNodeKey = new CswNbtNodeKey(NodeKey); if (null != NbtNodeKey && null != NbtNodeKey.NodeId && CswTools.IsPrimaryKey(NbtNodeKey.NodeId) && false == NodePrimaryKeys.Contains(NbtNodeKey.NodeId)) { NodePrimaryKeys.Add(NbtNodeKey.NodeId); } } } if (NodePks.Length > 0) { foreach (string NodePk in NodePks) { CswPrimaryKey PrimaryKey = CswConvert.ToPrimaryKey(NodePk); if (CswTools.IsPrimaryKey(PrimaryKey) && false == NodePrimaryKeys.Contains(PrimaryKey)) { NodePrimaryKeys.Add(PrimaryKey); } } } if (NodePrimaryKeys.Count > 0) { if (NodePrimaryKeys.Count < CswNbtBatchManager.getBatchThreshold(_CswNbtResources)) { bool success = true; string DeletedNodes = ""; foreach (CswPrimaryKey Npk in NodePrimaryKeys) { string DeletedNode = ""; success = DeleteNode(Npk, out DeletedNode) && success; if (success) { DeletedNodes += DeletedNode; } } ret["Succeeded"] = success.ToString(); } else { CswNbtBatchOpMultiDelete op = new CswNbtBatchOpMultiDelete(_CswNbtResources); CswNbtObjClassBatchOp BatchNode = op.makeBatchOp(NodePrimaryKeys); ret["batch"] = BatchNode.NodeId.ToString(); } } return(ret); }
public void OnAvailableWorkUnitsChange(CswNbtNodeProp Prop, bool Creating) { _updateAvailableWorkUnits(); if (null == CurrentWorkUnitId || false == AvailableWorkUnits.CheckValue(CurrentWorkUnitId.ToString())) { CswPrimaryKey pk = CswConvert.ToPrimaryKey(AvailableWorkUnits.Value[0]); //we're always guarenteed there's at least one CurrentWorkUnitProperty.RelatedNodeId = pk; CurrentWorkUnitProperty.SyncGestalt(); } }
private JProperty _getNode(string NodePkStr, bool RunProps = true) { JProperty Ret = null; CswPrimaryKey NodePk = CswConvert.ToPrimaryKey(NodePkStr); if (CswTools.IsPrimaryKey(NodePk)) { CswNbtNode ThisNode = _CswNbtResources.Nodes.GetNode(NodePk); Ret = _getNode(ThisNode, RunProps); } return(Ret); }
private IEnumerable <CswPrimaryKey> _getLocationIds(String LocationId) { Collection <CswPrimaryKey> LocationPKs = new Collection <CswPrimaryKey>(); CswPrimaryKey RootLocationId = CswConvert.ToPrimaryKey(LocationId); if (null != RootLocationId) { CswNbtView LocationTreeView = CswNbtNodePropLocation.LocationPropertyView(_CswNbtResources, null); ICswNbtTree LocationTree = _CswNbtResources.Trees.getTreeFromView(LocationTreeView, false, true, false); _addChildLocationIds(RootLocationId, LocationTree, LocationPKs); } return(LocationPKs); }
public JObject initNewTempMaterialNode(Int32 NodeTypeId, string SupplierId, string Suppliername, string Tradename, string PartNo, string NodeId, bool IsConstituent, bool CorporateSupplier) { JObject Ret = new JObject(); //Check if the vendor needs to be created if (false == CswTools.IsPrimaryKey(CswConvert.ToPrimaryKey(SupplierId)) && false == IsConstituent) { CswNbtMetaDataObjectClass VendorOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.VendorClass); if (null != VendorOC) { CswNbtMetaDataNodeType VendorNT = VendorOC.FirstNodeType; if (null != VendorNT) { CswNbtObjClassVendor NewVendorNode = _CswNbtResources.Nodes.makeNodeFromNodeTypeId(VendorNT.NodeTypeId, IsTemp : true, OnAfterMakeNode : delegate(CswNbtNode NewNode) { CswNbtObjClassVendor NodeAsVendor = (CswNbtObjClassVendor)NewNode; NodeAsVendor.VendorName.Text = Suppliername; NodeAsVendor.VendorName.SyncGestalt(); if (CorporateSupplier) { NodeAsVendor.VendorType.Value = CswNbtObjClassVendor.VendorTypes.Corporate; } }); //Set the supplierId to the new vendor node SupplierId = NewVendorNode.NodeId.ToString(); } } } CswPrimaryKey CurrentTempNodePk = CswConvert.ToPrimaryKey(NodeId); if (CswTools.IsPrimaryKey(CurrentTempNodePk)) { CswNbtPropertySetMaterial CurrentTempNode = _CswNbtResources.Nodes.GetNode(CurrentTempNodePk); if (null != CurrentTempNode) { Int32 CurrentNodeTypeId = CurrentTempNode.NodeTypeId; if (NodeTypeId != CurrentNodeTypeId) { // Then we want to just forget about the first temp node created and create a new one with the new nodetype Ret = _tryCreateTempMaterial(NodeTypeId, CswConvert.ToPrimaryKey(SupplierId), Tradename, PartNo, null, IsConstituent); } else { // If the nodetype isn't different then we want to get the props and check if it exsits Ret = _tryCreateTempMaterial(NodeTypeId, CswConvert.ToPrimaryKey(SupplierId), Tradename, PartNo, CurrentTempNodePk.ToString(), IsConstituent); } } } return(Ret); }
private CswNbtView getTabView(string NodeId, string NodeViewId, CswNbtMetaDataNodeType NodeType) { CswNbtView TabView = null; if (false == String.IsNullOrEmpty(NodeViewId)) { CswNbtNode RequestNode = _CswNbtResources.Nodes.GetNode(CswConvert.ToPrimaryKey(NodeId)); if (RequestNode != null && RequestNode.NodeTypeId == NodeType.NodeTypeId) { CswNbtSessionDataId TabViewId = new CswNbtSessionDataId(NodeViewId); TabView = _CswNbtResources.ViewSelect.getSessionView(TabViewId); } } return(TabView); }
public void processReconciliationActions(CswNbtResources _CswNbtResources) { if (_ContainerLocations.Count > 0) { Int32 ContainersProcessedPerIteration = CswConvert.ToInt32(_CswNbtResources.ConfigVbls.getConfigVariableValue(CswEnumConfigurationVariableNames.NodesProcessedPerCycle)); int TotalProcessedThisIteration = 0; while (TotalProcessedThisIteration < ContainersProcessedPerIteration && _ContainerLocations.Count > 0 && (CswEnumScheduleLogicRunStatus.Stopping != _LogicRunStatus)) { CswPrimaryKey ContainerLocationId = CswConvert.ToPrimaryKey(CswConvert.ToString(_ContainerLocations[0])); _executeReconciliationActions(_CswNbtResources, ContainerLocationId); _ContainerLocations.RemoveAt(0); TotalProcessedThisIteration++; } } }
private void _setCommonItemDataForDBImpl(string RoleId, string ActionId, string LinkType, Int32 NewColumn, Int32 NewRow, string Text, string ButtonIcon) { int NumericRoleId = Int32.MinValue; if (RoleId == string.Empty || false == _CswNbtResources.CurrentNbtUser.IsAdministrator()) { RoleId = _CswNbtResources.CurrentNbtUser.RoleId.ToString(); } CswPrimaryKey RolePk = CswConvert.ToPrimaryKey(RoleId); if (null != RolePk) { NumericRoleId = RolePk.PrimaryKey; } if (ButtonIcon == "blank.gif") { ButtonIcon = string.Empty; } if (Int32.MinValue != NumericRoleId) { _ItemRow["for_roleid"] = NumericRoleId; } if (false == String.IsNullOrEmpty(ActionId)) { _ItemRow["for_actionid"] = ActionId; } _ItemRow["componenttype"] = LinkType; if (NewColumn <= 0) { _ItemRow["display_col"] = "1"; } else { _ItemRow["display_col"] = NewColumn; } if (NewRow <= 0) { _ItemRow["display_row"] = _getNextAvailableRowForItem(NumericRoleId, ActionId); } else { _ItemRow["display_row"] = NewRow; } _ItemRow["displaytext"] = Text; _ItemRow["buttonicon"] = ButtonIcon; }
private Int32 _getRoleIdPk(string RoleId) { Int32 RoleIdPk = Int32.MinValue; if (RoleId == string.Empty || false == _CswNbtResources.CurrentNbtUser.IsAdministrator()) { RoleId = _CswNbtResources.CurrentNbtUser.RoleId.ToString(); } CswPrimaryKey RolePk = CswConvert.ToPrimaryKey(RoleId); if (null != RolePk) { RoleIdPk = RolePk.PrimaryKey; } return(RoleIdPk); }
public static JObject getSizeNodeProps(CswNbtResources CswNbtResources, Int32 SizeNodeTypeId, JObject SizeObj, bool WriteNode, out CswNbtNode SizeNode, CswPrimaryKey MaterialId = null) { JObject Ret = new JObject(); SizeNode = CswNbtResources.Nodes.makeNodeFromNodeTypeId(SizeNodeTypeId, OverrideUniqueValidation: true); string UoMId = SizeObj["uom"]["id"].ToString(); // CIS-53182: Preventative measure against the uomid being empty from client if (null != MaterialId && string.IsNullOrEmpty(UoMId) && false == string.IsNullOrEmpty(SizeObj["uom"]["value"].ToString())) { // Try to find the id for the unit of measure CswNbtUnitViewBuilder UnitViewBuilder = new CswNbtUnitViewBuilder(CswNbtResources); CswNbtView UnitsView = UnitViewBuilder.getQuantityUnitOfMeasureView(MaterialId); ICswNbtTree UnitTree = CswNbtResources.Trees.getTreeFromView(UnitsView, false, false, false); for (int i = 0; i < UnitTree.getChildNodeCount(); i++) { UnitTree.goToNthChild(i); if (UnitTree.getNodeNameForCurrentPosition().Equals(SizeObj["uom"]["value"].ToString())) { UoMId = UnitTree.getNodeIdForCurrentPosition().ToString(); } } } CswPrimaryKey UnitIdPK = CswConvert.ToPrimaryKey(UoMId); if (null != UnitIdPK) { SizeNode = CswNbtResources.Nodes.makeNodeFromNodeTypeId(SizeNodeTypeId, delegate(CswNbtNode NewNode) { CswNbtObjClassSize NodeAsSize = (CswNbtObjClassSize)NewNode; NodeAsSize.InitialQuantity.Quantity = CswConvert.ToDouble(SizeObj["quantity"]["value"]); NodeAsSize.InitialQuantity.UnitId = UnitIdPK; NodeAsSize.CatalogNo.Text = SizeObj["catalogNo"]["value"].ToString(); NodeAsSize.QuantityEditable.Checked = CswConvert.ToTristate(SizeObj["quantityEditable"]["value"]); NodeAsSize.Dispensable.Checked = CswConvert.ToTristate(SizeObj["dispensible"]["value"]); NodeAsSize.UnitCount.Value = CswConvert.ToDouble(SizeObj["unitCount"]["value"]); NodeAsSize.Material.RelatedNodeId = MaterialId; }); } else { SizeNode = null; } return(Ret); }
public override CswNbtViewEditorData HandleAction() { CswNbtViewEditorData Return = new CswNbtViewEditorData(); CurrentView.ViewName = Request.NewViewName; CurrentView.Visibility = (CswEnumNbtViewVisibility)Request.NewViewVisibility; CurrentView.VisibilityRoleId = CswConvert.ToPrimaryKey(Request.NewVisibilityRoleId); CurrentView.VisibilityUserId = CswConvert.ToPrimaryKey(Request.NewVisbilityUserId); CurrentView.Category = Request.NewViewCategory; if (Int32.MinValue != Request.NewViewWidth) { CurrentView.Width = Request.NewViewWidth; } base.Finalize(Return); return(Return); }
public static void getPhysicalState(ICswResources CswResources, MaterialResponse Response, string NodeId) { if (null != CswResources) { CswNbtResources NbtResources = (CswNbtResources)CswResources; CswPrimaryKey pk = CswConvert.ToPrimaryKey(NodeId); if (CswTools.IsPrimaryKey(pk)) { Response.Data.PhysicalState = "n/a"; CswNbtPropertySetMaterial MaterialNode = NbtResources.Nodes[pk]; if (MaterialNode.ObjectClass.ObjectClass == CswEnumNbtObjectClass.ChemicalClass) { CswNbtObjClassChemical ChemicalNode = MaterialNode.Node; Response.Data.PhysicalState = ChemicalNode.PhysicalState.Value; } } } }
/// <summary> /// Standard constructor for validating required properties /// </summary> public NewMaterial(CswNbtResources CswNbtResources, Int32 NodeTypeId, string TradeName, CswPrimaryKey SupplierId, bool IsConstituent, string PartNo = "", string NodeId = "") { _NbtResources = CswNbtResources; this.NodeTypeId = NodeTypeId; this.TradeName = TradeName; if (false == IsConstituent) { this.SupplierId = SupplierId; } this.PartNo = PartNo; this.IsConstituent = IsConstituent; //If we are providing an existing material this._MaterialId = CswConvert.ToPrimaryKey(NodeId); if (CswTools.IsPrimaryKey(_MaterialId)) { Node = _NbtResources.Nodes[_MaterialId]; } }
private Collection <CswPrimaryKey> _getLocationIds(ContainerData.ReconciliationRequest Request) { Collection <CswPrimaryKey> LocationIds = new Collection <CswPrimaryKey>(); CswPrimaryKey RootLocationId = CswConvert.ToPrimaryKey(Request.LocationId); if (null != RootLocationId) { if (Request.IncludeChildLocations) { CswNbtView LocationTreeView = CswNbtNodePropLocation.LocationPropertyView(_CswNbtResources, null); ICswNbtTree LocationTree = _CswNbtResources.Trees.getTreeFromView(LocationTreeView, false, true, false); _addChildLocationIds(RootLocationId, LocationTree, LocationIds); } else { LocationIds.Add(RootLocationId); } } return(LocationIds); }
public static void GetRelating(ICswResources CswResources, CswNbtExplorerRelatingReturn RelatingNodes, CswNbtExplorerRequest Req) { CswNbtResources NbtResources = (CswNbtResources)CswResources; CswNbtView view = new CswNbtView(NbtResources); if (Req.RelatingId.StartsWith("OC_")) { int ObjClassId = CswConvert.ToInt32(Req.RelatingId.Substring(Req.RelatingId.LastIndexOf('_') + 1)); CswNbtMetaDataObjectClass ObjClass = NbtResources.MetaData.getObjectClass(ObjClassId); CswNbtMetaDataObjectClassProp objectClassProp = ObjClass.getObjectClassProp(Req.RelatingPropId); CswNbtViewRelationship parent = view.AddViewRelationship(ObjClass, true); CswPrimaryKey pk = CswConvert.ToPrimaryKey(Req.NodeId); view.AddViewPropertyAndFilter(parent, objectClassProp, Value: pk.PrimaryKey.ToString(), SubFieldName: CswEnumNbtSubFieldName.NodeID); } else { int NtId = CswConvert.ToInt32(Req.RelatingId.Substring(Req.RelatingId.LastIndexOf('_') + 1)); CswNbtMetaDataNodeType NodeType = NbtResources.MetaData.getNodeType(NtId); CswNbtMetaDataNodeTypeProp ntp = NodeType.getNodeTypeProp(Req.RelatingPropId); CswNbtViewRelationship parent = view.AddViewRelationship(NodeType, true); CswPrimaryKey pk = CswConvert.ToPrimaryKey(Req.NodeId); view.AddViewPropertyAndFilter(parent, ntp, Value: pk.PrimaryKey.ToString(), SubFieldName: CswEnumNbtSubFieldName.NodeID); } ICswNbtTree tree = NbtResources.Trees.getTreeFromView(view, false, false, false); for (int i = 0; i < tree.getChildNodeCount(); i++) { tree.goToNthChild(i); CswNbtNodeKey nodeKey = tree.getNodeKeyForCurrentPosition(); string nodeName = tree.getNodeNameForCurrentPosition(); CswNbtMetaDataNodeType nodetype = NbtResources.MetaData.getNodeType(nodeKey.NodeTypeId); RelatingNodes.Data.Add(nodeName, nodeKey.NodeId, nodetype.NodeTypeName, string.Empty, string.Empty, string.Empty); tree.goToParentNode(); } }
public static void getSizes(ICswResources CswResources, NodeResponse Response, CswNbtNode.Node Request) { if (null != CswResources) { CswNbtResources NbtResources = (CswNbtResources)CswResources; CswPrimaryKey pk = CswConvert.ToPrimaryKey(Request.NodeId); if (CswTools.IsPrimaryKey(pk)) { CswNbtMetaDataObjectClass sizeOC = NbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.SizeClass); CswNbtMetaDataObjectClassProp materialOCP = sizeOC.getObjectClassProp(CswNbtObjClassSize.PropertyName.Material); CswNbtView sizesView = new CswNbtView(NbtResources); CswNbtViewRelationship parent = sizesView.AddViewRelationship(sizeOC, true); sizesView.AddViewPropertyAndFilter(parent, MetaDataProp: materialOCP, Value: pk.PrimaryKey.ToString(), SubFieldName: CswNbtFieldTypeRuleRelationship.SubFieldName.NodeID, FilterMode: CswEnumNbtFilterMode.Equals); ICswNbtTree tree = NbtResources.Trees.getTreeFromView(sizesView, true, false, false); for (int i = 0; i < tree.getChildNodeCount(); i++) { tree.goToNthChild(i); Response.Data.Nodes.Add(new CswNbtNode.Node(null) { NodeId = tree.getNodeIdForCurrentPosition(), NodeName = tree.getNodeNameForCurrentPosition() }); tree.goToParentNode(); } sizesView.SaveToCache(false, true); Response.Data.ViewId = sizesView.SessionViewId.ToString(); } } }
} // makeContainer() public JObject receiveMaterial(CswNbtReceivingDefinition ReceiptDefinition) { JObject Ret = new JObject(); CswNbtObjClassContainer InitialContainerNode = _CswNbtResources.Nodes[ReceiptDefinition.ContainerNodeId]; if (null != InitialContainerNode && ReceiptDefinition.Quantities.Count > 0) { //Generate the barcodes upfront and treat them as custom barcodes so all Containers in this Receipt Def have similar numbers CswNbtMetaDataNodeTypeProp BarcodeProp = (CswNbtMetaDataNodeTypeProp)InitialContainerNode.NodeType.getBarcodeProperty(); for (int i = 0; i < ReceiptDefinition.Quantities.Count; i++) { CswNbtAmountsGridQuantity quantity = ReceiptDefinition.Quantities[i]; while (quantity.getNumBarcodes() < quantity.NumContainers) { if (quantity.getNumBarcodes() == 0 && i == 0 && false == String.IsNullOrEmpty(InitialContainerNode.Barcode.Barcode)) //special case: the Initial Container node already has a barcode, so insert that one if a user didn't specify a custom barcode { quantity.AddBarcode(InitialContainerNode.Barcode.Barcode); } else { if (null != BarcodeProp.Sequence) { quantity.AddBarcode(BarcodeProp.Sequence.getNext()); } } } } CswNbtNode ReceiptLot = _makeReceiptLot(ReceiptDefinition.MaterialNodeId, ReceiptDefinition, InitialContainerNode.ExpirationDate.DateTimeValue); if (null == ReceiptDefinition.ReceiptLotNodeId) { ReceiptDefinition.ReceiptLotNodeId = ReceiptLot.NodeId; } ReceiptDefinition.Quantities[0].ContainerIds.Add(InitialContainerNode.NodeId.ToString()); int processed = 0; receiveContainers(ReceiptDefinition, ref processed, 1); //process only the first container (the initial one) commitSDSDocNode(ReceiptDefinition.MaterialNodeId, ReceiptDefinition.SDSNodeId, ReceiptDefinition.SDSProps); int TotalContainersToMake = ReceiptDefinition.CountNumberContainersToMake(); int Threshhold = CswConvert.ToInt32(_CswNbtResources.ConfigVbls.getConfigVariableValue("batchthreshold")); bool UseBatchOp = TotalContainersToMake >= Threshhold; Collection <CswPrimaryKey> ContainerIds = null; if (UseBatchOp) { //Containers will be created in a batch op CswNbtBatchOpReceiving ReceivingBatchOp = new CswNbtBatchOpReceiving(_CswNbtResources); ReceivingBatchOp.makeBatchOp(ReceiptDefinition); } else { //Create the containers now int nodesProcessed = 0; CswNbtReceivingDefinition ReceivedContainers = receiveContainers(ReceiptDefinition, ref nodesProcessed, TotalContainersToMake + 1); ContainerIds = new Collection <CswPrimaryKey>(); foreach (CswNbtAmountsGridQuantity Quantity in ReceivedContainers.Quantities) { foreach (string ContainerId in Quantity.ContainerIds) { ContainerIds.Add(CswConvert.ToPrimaryKey(ContainerId)); } } } CswNbtNode MaterialNode = _CswNbtResources.Nodes.GetNode(ReceiptDefinition.MaterialNodeId); Ret = getLandingPageData(_CswNbtResources, MaterialNode, UseBatchOp, ContainerIds); } return(Ret); }