Exemple #1
0
    /// <summary>
    /// 
    /// </summary>
    private void AddSessions()
    {
      Browser browser = new Browser(m_Session);
      browser.MaxReferencesReturned = 0;
      browser.BrowseDirection   = BrowseDirection.Forward;
      browser.IncludeSubtypes   = true;
      browser.NodeClassMask     = (int)NodeClass.Object;
      browser.ContinueUntilDone = true;
      NodeId browseid = new NodeId(Objects.Server_ServerDiagnostics_SessionsDiagnosticsSummary);
      browser.ReferenceTypeId =  null;
      ReferenceDescriptionCollection refs = browser.Browse(browseid);

      foreach(ReferenceDescription rf in refs)
      {
        if(m_Session.TypeTree.IsTypeOf(new ExpandedNodeId(rf.TypeDefinition), new ExpandedNodeId(ObjectTypes.SessionDiagnosticsObjectType)))
        {
          if(listView1.Items.IndexOfKey(rf.NodeId.ToString()) == -1)
          {
            ListViewItem lvi = listView1.Items.Add(rf.NodeId.ToString(), rf.DisplayName.Text.ToString(), -1);
            lvi.Tag = rf.NodeId;
            lvi.IndentCount = 0;

            string SessionID = "SessionDiagnostics.SessionId";
            string ClientName = "SessionDiagnostics.ClientName";
            string ClientConnectionTime = "SessionDiagnostics.ClientConnectionTime";

            ListViewItem.ListViewSubItem SessionIDSubItem = lvi.SubItems.Add("");
            SessionIDSubItem.Name = rf.NodeId.Identifier.ToString() + "." + SessionID;
            ListViewItem.ListViewSubItem ClientNameSubItem = lvi.SubItems.Add("");
            ClientNameSubItem.Name = rf.NodeId.Identifier.ToString() + "." + ClientName;
            ListViewItem.ListViewSubItem ClientConnectionTimeSubItem = lvi.SubItems.Add("");
            ClientConnectionTimeSubItem.Name = rf.NodeId.Identifier.ToString() + "." + ClientConnectionTime;

            MonitoredItem sessionItem = new MonitoredItem(m_Subscription.DefaultItem);
            sessionItem.StartNodeId = (NodeId)rf.NodeId;
            sessionItem.RelativePath = SessionID;
            sessionItem.NodeClass = NodeClass.Object;
            sessionItem.AttributeId = Attributes.Value;
            m_Subscription.AddItem(sessionItem);
            sessionItem.Notification += m_ItemNotification;


            INode node = m_Session.NodeCache.Find(rf.NodeId);

            TypedMonitoredItem SessionIDItem = new TypedMonitoredItem(m_Subscription.DefaultItem);
            SessionIDItem.StartNodeId = (NodeId)rf.NodeId;
            SessionIDItem.RelativePath = SessionID;
            SessionIDItem.NodeClass = NodeClass.Variable;
            SessionIDItem.AttributeId = Attributes.Value;
            m_Subscription.AddItem(SessionIDItem);
            SessionIDItem.Notification += m_ItemNotification;
            SessionIDSubItem.Tag = SessionIDItem;
            Utils.Trace("Adding: {0}, {1} as subitem in AddSessions()", SessionIDItem.StartNodeId.ToString(), SessionIDItem.RelativePath.ToString());


            TypedMonitoredItem ClientNameItem = new TypedMonitoredItem(m_Subscription.DefaultItem);
            ClientNameItem.StartNodeId = (NodeId)rf.NodeId;
            ClientNameItem.RelativePath = ClientName;
            ClientNameItem.NodeClass = NodeClass.Variable;
            ClientNameItem.AttributeId = Attributes.Value;
            m_Subscription.AddItem(ClientNameItem);
            ClientNameItem.Notification += m_ItemNotification;
            ClientNameSubItem.Tag = ClientNameItem;
            Utils.Trace("Adding: {0}, {1} as subitem in AddSessions()", ClientNameItem.StartNodeId.ToString(), ClientNameItem.RelativePath.ToString());

            DateTimeMonitoredItem ClientConnectionTimeItem = new DateTimeMonitoredItem(m_Subscription.DefaultItem);
            ClientConnectionTimeItem.StartNodeId = (NodeId)rf.NodeId;
            ClientConnectionTimeItem.RelativePath = ClientConnectionTime;
            ClientConnectionTimeItem.NodeClass = NodeClass.Variable;
            ClientConnectionTimeItem.AttributeId = Attributes.Value;
            m_Subscription.AddItem(ClientConnectionTimeItem);
            ClientConnectionTimeItem.Notification += m_ItemNotification;
            ClientConnectionTimeSubItem.Tag = ClientConnectionTimeItem;
            Utils.Trace("Adding: {0}, {1} as subitem in AddSessions()", ClientConnectionTimeItem.StartNodeId.ToString(), ClientConnectionTimeItem.RelativePath.ToString());
          }
          else
          {
            Utils.Trace("Key already exists in listview. rf.BrowseName: {0},rf.NodeId: {1}, rf.TypeDefinition: {2}", rf.BrowseName.ToString(), rf.NodeId.ToString(), rf.TypeDefinition.ToString());
          }
        }
        else
        {
          Utils.Trace("Unknown Object rf.BrowseName: {0},rf.NodeId: {1}, rf.TypeDefinition: {2}", rf.BrowseName.ToString(), rf.NodeId.ToString(), rf.TypeDefinition.ToString());
        }
      }
    }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        private void AddSessions()
        {
            Browser browser = new Browser(m_Session);

            browser.MaxReferencesReturned = 0;
            browser.BrowseDirection       = BrowseDirection.Forward;
            browser.IncludeSubtypes       = true;
            browser.NodeClassMask         = (int)NodeClass.Object;
            browser.ContinueUntilDone     = true;
            NodeId browseid = new NodeId(Objects.Server_ServerDiagnostics_SessionsDiagnosticsSummary);

            browser.ReferenceTypeId = null;
            ReferenceDescriptionCollection refs = browser.Browse(browseid);

            foreach (ReferenceDescription rf in refs)
            {
                if (m_Session.TypeTree.IsTypeOf(new ExpandedNodeId(rf.TypeDefinition), new ExpandedNodeId(ObjectTypes.SessionDiagnosticsObjectType)))
                {
                    if (listView1.Items.IndexOfKey(rf.NodeId.ToString()) == -1)
                    {
                        ListViewItem lvi = listView1.Items.Add(rf.NodeId.ToString(), rf.DisplayName.Text.ToString(), -1);
                        lvi.Tag         = rf.NodeId;
                        lvi.IndentCount = 0;

                        string SessionID            = "SessionDiagnostics.SessionId";
                        string ClientName           = "SessionDiagnostics.ClientName";
                        string ClientConnectionTime = "SessionDiagnostics.ClientConnectionTime";

                        ListViewItem.ListViewSubItem SessionIDSubItem = lvi.SubItems.Add("");
                        SessionIDSubItem.Name = rf.NodeId.Identifier.ToString() + "." + SessionID;
                        ListViewItem.ListViewSubItem ClientNameSubItem = lvi.SubItems.Add("");
                        ClientNameSubItem.Name = rf.NodeId.Identifier.ToString() + "." + ClientName;
                        ListViewItem.ListViewSubItem ClientConnectionTimeSubItem = lvi.SubItems.Add("");
                        ClientConnectionTimeSubItem.Name = rf.NodeId.Identifier.ToString() + "." + ClientConnectionTime;

                        MonitoredItem sessionItem = new MonitoredItem(m_Subscription.DefaultItem);
                        sessionItem.StartNodeId  = (NodeId)rf.NodeId;
                        sessionItem.RelativePath = SessionID;
                        sessionItem.NodeClass    = NodeClass.Object;
                        sessionItem.AttributeId  = Attributes.Value;
                        m_Subscription.AddItem(sessionItem);
                        sessionItem.Notification += m_ItemNotification;


                        INode node = m_Session.NodeCache.Find(rf.NodeId);

                        TypedMonitoredItem SessionIDItem = new TypedMonitoredItem(m_Subscription.DefaultItem);
                        SessionIDItem.StartNodeId  = (NodeId)rf.NodeId;
                        SessionIDItem.RelativePath = SessionID;
                        SessionIDItem.NodeClass    = NodeClass.Variable;
                        SessionIDItem.AttributeId  = Attributes.Value;
                        m_Subscription.AddItem(SessionIDItem);
                        SessionIDItem.Notification += m_ItemNotification;
                        SessionIDSubItem.Tag        = SessionIDItem;
                        Utils.Trace("Adding: {0}, {1} as subitem in AddSessions()", SessionIDItem.StartNodeId.ToString(), SessionIDItem.RelativePath.ToString());


                        TypedMonitoredItem ClientNameItem = new TypedMonitoredItem(m_Subscription.DefaultItem);
                        ClientNameItem.StartNodeId  = (NodeId)rf.NodeId;
                        ClientNameItem.RelativePath = ClientName;
                        ClientNameItem.NodeClass    = NodeClass.Variable;
                        ClientNameItem.AttributeId  = Attributes.Value;
                        m_Subscription.AddItem(ClientNameItem);
                        ClientNameItem.Notification += m_ItemNotification;
                        ClientNameSubItem.Tag        = ClientNameItem;
                        Utils.Trace("Adding: {0}, {1} as subitem in AddSessions()", ClientNameItem.StartNodeId.ToString(), ClientNameItem.RelativePath.ToString());

                        DateTimeMonitoredItem ClientConnectionTimeItem = new DateTimeMonitoredItem(m_Subscription.DefaultItem);
                        ClientConnectionTimeItem.StartNodeId  = (NodeId)rf.NodeId;
                        ClientConnectionTimeItem.RelativePath = ClientConnectionTime;
                        ClientConnectionTimeItem.NodeClass    = NodeClass.Variable;
                        ClientConnectionTimeItem.AttributeId  = Attributes.Value;
                        m_Subscription.AddItem(ClientConnectionTimeItem);
                        ClientConnectionTimeItem.Notification += m_ItemNotification;
                        ClientConnectionTimeSubItem.Tag        = ClientConnectionTimeItem;
                        Utils.Trace("Adding: {0}, {1} as subitem in AddSessions()", ClientConnectionTimeItem.StartNodeId.ToString(), ClientConnectionTimeItem.RelativePath.ToString());
                    }
                    else
                    {
                        Utils.Trace("Key already exists in listview. rf.BrowseName: {0},rf.NodeId: {1}, rf.TypeDefinition: {2}", rf.BrowseName.ToString(), rf.NodeId.ToString(), rf.TypeDefinition.ToString());
                    }
                }
                else
                {
                    Utils.Trace("Unknown Object rf.BrowseName: {0},rf.NodeId: {1}, rf.TypeDefinition: {2}", rf.BrowseName.ToString(), rf.NodeId.ToString(), rf.TypeDefinition.ToString());
                }
            }
        }