1 Reply Latest reply on Jan 24, 2012 3:05 PM by mhamel

    Editing Escalation Team members from my own form

    andrewnorth

      Ive got a win form using, amongst other things, the notification viewer control. Id like to be able have a button on my form which will allow the user to edit an escalation team by adding and/or deleting contacts from the escalation team. Are all the controls available to replicate this facility which is in the pi explorer?

        • Re: Editing Escalation Team members from my own form
          mhamel

          To answer your questions, all the controls used for the PI System Explorer (PSE) tool are available in the AN SDK assemblies. The OSIsoft.PIAnalytics.Common and OSIsoft.PIAnalytics.SDK contain both UI elements you can utilize within your project. These controls are the base of PI AF clients. In your case, the EscalationViewControl control is the object giving you the possibility to edit an escalation team object as shown in the figure below. This control already handles add and remove functionalities of contacts within the escalation team. You only need to take the reference to the object at the end of your operation.

           

          14547-_2D00_-PI-Escalation-Team-Control.png

           

          Figure 1

           

          You will need to reference in your project the following assemblies: OSIsoft.AF.Security.UI, OSIsoft.AF.UI, OSIsoft.AFSDK and OSIsoft.PIAnalytics.Common. You will need to add in your Visual Studio Toolbox the controls from the OSIsoft.PIAnalytics.Common assembly.

           

          I gave you an example of how you could load a specific contact template, save or cancel the changes after in the excerpt of code below. The SelectedContactTemplate property of the EscalationViewControl is the input and output here. You assign your object to "load" the definition and you read it at the end to grab the changes. Afterward you can call the CheckIn or UndoCheckOut to save or cancel the changes.

           
          Imports OSIsoft.AF
          Imports OSIsoft.AF.Notification
          Imports OSIsoft.AN.UI
          
          Public Class Form1
          
              Private _AFServers As PISystems
              Private _AFServer As PISystem
              Private _AFDB As AFDatabase
              Private _Contact As AFNotificationContactTemplate
          
              Private Sub uxSaveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles uxSaveButton.Click
                  'Trigger the CheckIn method of the current AFNotificationContactTemplate object to save the changes.
                  _Contact.CheckIn()
              End Sub
          
              Private Sub uxCancelButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles uxCancelButton.Click
                  'Trigger the UndoCheckOut method of the current AFNotificationContactTemplate object to cancel your changes.
                  _Contact.UndoCheckOut(False)
              End Sub
          
              Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
                  'Objects.
                  Dim MyList As AFNamedCollectionList(Of AFNotificationContactTemplate)
          
                  'Get references on collection of PI AF Servers, the right server and the
                  'proper database.
                  _AFServers = New PISystems
                  _AFServer = _AFServers("blizzard")
                  _AFDB = _AFServer.Databases("SM1")
          
                  'Get the contact template you want to modify
                  MyList = AFNotificationContactTemplate.FindNotificationContactTemplates(_AFServer, "OCS Escalation", AFSearchField.Name, AFSortField.Name, AFSortOrder.Ascending, 1)
          
                  'Get a reference on the contact itself and persist it into the class.
                  _Contact = MyList.Item(0)
          
                  'Assign the first template to the EscalationViewControl control to visualize the configuration.
                  EscalationViewControl1.SelectedContactTemplate = _Contact
                  'By default this control is not visible on the form, so you need to make it visible.
                  EscalationViewControl1.Visible = True
              End Sub
          
              
          End Class
          

           

           

          Let me know if this solution helped you.