/// <summary> /// Revises the aggregate configuration. /// </summary> /// <param name="context"></param> /// <param name="item"></param> /// <param name="configurationToUse"></param> private void ReviseAggregateConfiguration( ServerSystemContext context, ArchiveItemState item, AggregateConfiguration configurationToUse) { // set configuration from defaults. if (configurationToUse.UseServerCapabilitiesDefaults) { AggregateConfiguration configuration = item.ArchiveItem.AggregateConfiguration; if (configuration == null || configuration.UseServerCapabilitiesDefaults) { configuration = Server.AggregateManager.GetDefaultConfiguration(null); } configurationToUse.UseSlopedExtrapolation = configuration.UseSlopedExtrapolation; configurationToUse.TreatUncertainAsBad = configuration.TreatUncertainAsBad; configurationToUse.PercentDataBad = configuration.PercentDataBad; configurationToUse.PercentDataGood = configuration.PercentDataGood; } // override configuration when it does not make sense for the item. configurationToUse.UseServerCapabilitiesDefaults = false; if (item.ArchiveItem.Stepped) { configurationToUse.UseSlopedExtrapolation = false; } }
/// <summary> /// Returns the next child. /// </summary> private IReference NextChild() { UnderlyingSystem system = (UnderlyingSystem)this.SystemContext.SystemHandle; NodeId targetId = null; // check if a specific browse name is requested. if (!QualifiedName.IsNull(base.BrowseName)) { // check if match found previously. if (m_position == Int32.MaxValue) { return(null); } // browse name must be qualified by the correct namespace. if (m_source.BrowseName.NamespaceIndex != base.BrowseName.NamespaceIndex) { return(null); } // look for matching folder. if (m_stage == Stage.Folders && m_folders != null) { for (int ii = 0; ii < m_folders.Length; ii++) { if (base.BrowseName.Name == m_folders[ii].Name) { targetId = ArchiveFolderState.ConstructId(m_folders[ii].UniquePath, m_source.NodeId.NamespaceIndex); break; } } } // look for matching item. else if (m_stage == Stage.Items && m_items != null) { for (int ii = 0; ii < m_items.Length; ii++) { if (base.BrowseName.Name == m_items[ii].Name) { targetId = ArchiveItemState.ConstructId(m_items[ii].UniquePath, m_source.NodeId.NamespaceIndex); break; } } } // look for matching parent. else if (m_stage == Stage.Parents) { ArchiveFolder parent = m_source.ArchiveFolder.GetParentFolder(); if (base.BrowseName.Name == parent.Name) { targetId = ArchiveFolderState.ConstructId(parent.UniquePath, m_source.NodeId.NamespaceIndex); } } m_position = Int32.MaxValue; } // return the child at the next position. else { // look for next folder. if (m_stage == Stage.Folders && m_folders != null) { if (m_position >= m_folders.Length) { return(null); } targetId = ArchiveFolderState.ConstructId(m_folders[m_position++].UniquePath, m_source.NodeId.NamespaceIndex); } // look for next item. else if (m_stage == Stage.Items && m_items != null) { if (m_position >= m_items.Length) { return(null); } targetId = ArchiveItemState.ConstructId(m_items[m_position++].UniquePath, m_source.NodeId.NamespaceIndex); } // look for matching parent. else if (m_stage == Stage.Parents) { ArchiveFolder parent = m_source.ArchiveFolder.GetParentFolder(); if (parent != null) { targetId = ArchiveFolderState.ConstructId(parent.UniquePath, m_source.NodeId.NamespaceIndex); } } } // create reference. if (targetId != null) { return(new NodeStateReference(ReferenceTypeIds.Organizes, false, targetId)); } return(null); }
/// <summary> /// Creates items from embedded resources. /// </summary> private void CreateFolderFromResources(NodeState root, string folderName) { FolderState dataFolder = new FolderState(root); dataFolder.ReferenceTypeId = ReferenceTypeIds.Organizes; dataFolder.TypeDefinitionId = ObjectTypeIds.FolderType; dataFolder.NodeId = new NodeId(folderName, NamespaceIndex); dataFolder.BrowseName = new QualifiedName(folderName, NamespaceIndex); dataFolder.DisplayName = dataFolder.BrowseName.Name; dataFolder.WriteMask = AttributeWriteMask.None; dataFolder.UserWriteMask = AttributeWriteMask.None; dataFolder.EventNotifier = EventNotifiers.None; root.AddChild(dataFolder); AddPredefinedNode(SystemContext, root); foreach (string resourcePath in Assembly.GetExecutingAssembly().GetManifestResourceNames()) { if (!resourcePath.StartsWith("Quickstarts.HistoricalAccessServer.Data." + folderName)) { continue; } ArchiveItem item = new ArchiveItem(resourcePath, Assembly.GetExecutingAssembly(), resourcePath); ArchiveItemState node = new ArchiveItemState(SystemContext, item, NamespaceIndex); node.ReloadFromSource(SystemContext); dataFolder.AddReference(ReferenceTypeIds.Organizes, false, node.NodeId); node.AddReference(ReferenceTypeIds.Organizes, true, dataFolder.NodeId); AddPredefinedNode(SystemContext, node); } }