} // getPercentDone() /// <summary> /// Run the next iteration of this batch operation /// </summary> public void runBatchOp(CswNbtObjClassBatchOp BatchNode) { try { if (BatchNode != null && BatchNode.OpNameValue == CswEnumNbtBatchOpName.SyncLocation) { BatchNode.start(); SyncLocationBatchData BatchData = new SyncLocationBatchData(BatchNode.BatchData.Text); if (BatchData.NodePks.Count > 0) { int NodesProcessedPerIteration = CswConvert.ToInt32(_CswNbtResources.ConfigVbls.getConfigVariableValue(CswEnumConfigurationVariableNames.NodesProcessedPerCycle)); for (int i = 0; i < NodesProcessedPerIteration && BatchData.NodePks.Count > 0; i++) { CswNbtNode Node = _CswNbtResources.Nodes[CswConvert.ToString(BatchData.NodePks[0])]; BatchData.NodePks.RemoveAt(0); bool LocationUpdated = false; if (null != Node) { CswNbtMetaDataNodeType NodeType = Node.getNodeType(); if (null != NodeType) { CswNbtMetaDataNodeTypeProp LocationNTP = NodeType.getLocationProperty(); if (null != LocationNTP) { CswNbtNodePropLocation LocationProp = Node.Properties[LocationNTP]; if (null != LocationProp) { LocationProp.SelectedNodeId = BatchData.LocationId; Node.postChanges(false); LocationUpdated = true; } } } }//if( null != Node ) if (false == LocationUpdated) { BatchNode.appendToLog("Unable to update the location of: " + Node.NodeName + " (" + Node.NodeId.ToString() + ")"); } }//for( int i = 0; i < NodesProcessedPerIteration && BatchData.NodePks.Count > 0; i++ ) } else { BatchNode.finish(); } BatchNode.PercentDone.Value = getPercentDone(BatchNode); BatchNode.BatchData.Text = BatchData.ToString(); BatchNode.postChanges(false); } } catch (Exception ex) { BatchNode.error(ex); } } // runBatchOp()
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); }
}//getLocationListMobile() public Collection <Location> GetLocationsList(string ViewId, string SelectedNodeId = "") { // Only return options if the total number of locations is < the relationshipoptionlimit configuration variable if (CswNbtNodePropLocation.getNumberOfLocationNodes(_CswNbtResources) <= _SearchThreshold) { CswPrimaryKey SelectedLocationId = String.IsNullOrEmpty(SelectedNodeId) ? _CswNbtResources.CurrentNbtUser.DefaultLocationId : CswConvert.ToPrimaryKey(SelectedNodeId); CswNbtView LocationView = _getLocationsView(ViewId); ICswNbtTree tree = _CswNbtResources.Trees.getTreeFromView(LocationView, false, false, false); if (tree.getChildNodeCount() > 0) { _iterateTree(tree, SelectedLocationId); } } return(_LocationCollection); }//GetLocationsList()
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); }
}//searchLocations() private CswNbtView _getLocationsView(string ViewId, string FullPathFilter = "") { CswNbtView Ret = new CswNbtView(); if (string.IsNullOrEmpty(ViewId)) { Ret = CswNbtNodePropLocation.LocationPropertyView(_CswNbtResources, null, ResultMode: CswEnumNbtFilterResultMode.Disabled, FullPathFilter: FullPathFilter); Ret.SaveToCache(false); ViewId = Ret.SessionViewId.ToString(); } CswNbtSessionDataId SessionViewId = new CswNbtSessionDataId(ViewId); if (SessionViewId.isSet()) { Ret = _CswNbtResources.ViewSelect.getSessionView(SessionViewId); CswNbtMetaDataObjectClass LocationOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.LocationClass); CswNbtMetaDataObjectClassProp LocationFullPathOCP = LocationOC.getObjectClassProp(CswNbtObjClassLocation.PropertyName.FullPath); if (false == string.IsNullOrEmpty(FullPathFilter)) { CswNbtViewRoot.forEachProperty forEachPropDelegate = delegate(CswNbtViewProperty ViewProp) { if (ViewProp.ObjectClassPropId == LocationFullPathOCP.PropId) { Ret.AddViewPropertyFilter(ViewProp, Conjunction: CswEnumNbtFilterConjunction.And, FilterMode: CswEnumNbtFilterMode.Contains, SubFieldName: CswEnumNbtSubFieldName.Value, Value: FullPathFilter); } }; Ret.Root.eachRelationship(null, forEachPropDelegate); } } return(Ret); }//_getLocationsView()
public void UpdateNode(CswNbtNode Node, bool ForceUpdate) { // BZ 10240 if ((Node.PendingUpdate || ForceUpdate) && Node.getObjectClass().ObjectClass == CswEnumNbtObjectClass.EquipmentClass) { ((CswNbtObjClassEquipment)Node).SyncEquipmentToAssembly(); } // Case 30126 if (null != Node.getObjectClass().getPropertySet()) { if ((Node.PendingUpdate || ForceUpdate) && Node.getObjectClass().getPropertySet().Name == CswEnumNbtPropertySetName.MaterialSet) { ((CswNbtPropertySetMaterial)Node).onUpdatePropertyValue(); } } // Update all out of date values for a given node foreach (CswNbtNodePropWrapper PropWrapper in Node.Properties) { if (PropWrapper.PendingUpdate || Node.PendingUpdate || ForceUpdate) { switch (PropWrapper.getFieldTypeValue()) { case CswEnumNbtFieldType.Composite: CswNbtNodePropComposite CompositeProp = PropWrapper.AsComposite; CompositeProp.RecalculateCompositeValue(); break; case CswEnumNbtFieldType.Location: CswNbtNodePropLocation LocationProp = PropWrapper.AsLocation; LocationProp.RefreshNodeName(); break; case CswEnumNbtFieldType.LogicalSet: CswNbtNodePropLogicalSet LogicalSetProp = PropWrapper.AsLogicalSet; LogicalSetProp.RefreshStringValue(SetPendingUpdate: false); break; case CswEnumNbtFieldType.NodeTypeSelect: CswNbtNodePropNodeTypeSelect NodeTypeSelectProp = PropWrapper.AsNodeTypeSelect; NodeTypeSelectProp.RefreshSelectedNodeTypeNames(); break; case CswEnumNbtFieldType.PropertyReference: CswNbtNodePropPropertyReference PropertyReferenceProp = PropWrapper.AsPropertyReference; PropertyReferenceProp.RecalculateReferenceValue(); break; case CswEnumNbtFieldType.Quantity: CswNbtNodePropQuantity QuantityProp = PropWrapper.AsQuantity; QuantityProp.RefreshNodeName(); break; case CswEnumNbtFieldType.Relationship: CswNbtNodePropRelationship RelationshipProp = PropWrapper.AsRelationship; RelationshipProp.RefreshNodeName(); break; case CswEnumNbtFieldType.ViewPickList: CswNbtNodePropViewPickList ViewPickListProp = PropWrapper.AsViewPickList; ViewPickListProp.RefreshViewName(); break; case CswEnumNbtFieldType.ViewReference: CswNbtNodePropViewReference ViewReferenceProp = PropWrapper.AsViewReference; ViewReferenceProp.RefreshViewName(); break; case CswEnumNbtFieldType.MTBF: CswNbtNodePropMTBF MTBFProp = PropWrapper.AsMTBF; MTBFProp.RefreshCachedValue(); break; default: if (PropWrapper.PendingUpdate) { PropWrapper.setPendingUpdate(false); } break; } // switch (PropWrapper.FieldType.FieldType) } // if(PropWrapper.PendingUpdate) } // foreach (CswNbtNodePropWrapper PropWrapper in Node.Properties) if (Node.PendingUpdate) { Node.PendingUpdate = false; } } // UpdateNode()