8 Replies Latest reply on Mar 25, 2010 10:57 PM by Lonnie Bowling

    How to Create a Notification?

    Lonnie Bowling

      I think this is a basic question, but I can't find any examples of how to create a notification.  I have been using the AF SDK and can create Elements with attributes, but can't seem of figure out how to do the same for notifications.

       

      So far this is what I have:

       

      Dim CurNote As AFNotification = myDB.Notifications.Add("TestNote*")

       

      CurNote.Description = "This is my dest"

       

      myDB.CheckIn(AFCheckedOutMode.ObjectsCheckedOutThisSession)

       

      I need to add a target, add configure and add triggers, set subscriptions, and change email subject lines.

       

      Any help would be appreciated!

       

      Thanks,

       

      Lonnie 

        • Re: How to Create a Notification?
          hanyong

          Hi Lonnie,

           

          There is a sample in the PI Notifications Programmer's Guide, as well as sample C# and VB projects for the same sample in the PI Notifications Developer Tool. 

           

          You can find the PI Notifications Programmer's Guide in the Library section under "vCampus PI Product Kit" -> "Data Access Technologies" -> "PI Notifications Programmer's Guide"

           

          You can download the developer tool in Download Center, under Supporting Files.

            • Re: How to Create a Notification?
              Lonnie Bowling

              Thanks for pointing me in the right direction.  I spent yesterday working through the document and am almost complete.  I'm stuck on getting the content set for email delivery.  I have found exporting a notifcations that I created in PI System Explorer and the SDK, then comparing, them really helps.  This is what my xml exports looks like, I'm only showing the part that concerns email and content, the rest is working and looks good:

               

              SDK XML:  

               

               <AFAttribute>

               

                    <Name>Trigger Input</Name>

               

                    <Type>Object</Type>

               

                  </AFAttribute>

               

                  <AFNotificationContact>

               

                    <Name>Lonnie Bowling_Email</Name>

               

                    <Template>Lonnie Bowling_Email</Template>

               

                    <DeliveryChannel>Email</DeliveryChannel>

               

                    <ConfigString>subject=Alert: BSWBD-A - Breaker Open</ConfigString>

               

                    <AFContactRef id="dbd4923e-df7a-4a23-99a7-290fb26e2077" CanonicalName="DSTControls.local/MyBusiness/Users/SBSUsers/Lonnie Bowling">Lonnie Bowling</AFContactRef>

               

                  </AFNotificationContact>

               

               

               

              And here is what a good notifcation looks like:

               

                 

               

              Created in PI System Explorer
              <
              AFAttribute>

               

                    <Name>Trigger Input</Name>

               

                    <Type>Object</Type>

               

                    <Timestamp>2010-03-24T22:32:10.463Z</Timestamp>

               

                    <Value type="System.Guid">fcd18afe-8b5e-4aa1-9420-dd835806c47c</Value>

               

                    <AFAttributeCategoryRef>Trigger Input</AFAttributeCategoryRef>

               

                  </AFAttribute>

               

                  <AFAttribute>

               

                    <Name>Standard Content</Name>

               

                    <Type>Object</Type>

               

                    <AFAttributeCategoryRef>Standard Content</AFAttributeCategoryRef>

               

                  </AFAttribute>

               

                  <AFNotificationContact>

               

                    <Name>Lonnie Bowling_Email</Name>

               

                    <Template>Lonnie Bowling_Email</Template>

               

                    <DeliveryChannel>Email</DeliveryChannel>

               

                    <AFContactRef id="dbd4923e-df7a-4a23-99a7-290fb26e2077" CanonicalName="DSTControls.local/MyBusiness/Users/SBSUsers/Lonnie Bowling">Lonnie Bowling</AFContactRef>

               

                  </AFNotificationContact>

               

                  <AFNotificationContent>

               

                    <Name>Trigger Input</Name>

               

                    <ContentType>TriggerInput</ContentType>

               

                    <DisplayName>Include Trigger Input</DisplayName>

               

                    <AFNotificationContactRef>Lonnie Bowling_Email</AFNotificationContactRef>

               

                  </AFNotificationContent>

               

                  <AFNotificationContent>

               

                    <Name>Standard Content</Name>

               

                    <ContentType>Standard</ContentType>

               

                    <DisplayName>Include Standard Content</DisplayName>

               

                    <AFNotificationContactRef>Lonnie Bowling_Email</AFNotificationContactRef>

               

                  </AFNotificationContent>

               

                </AFNotification>

               

              Finally here is my code that generated first xml:

               

                          Dim myContactTemplate As AFNotificationContactTemplate = myPISystem.NotificationContactTemplates.Item("Lonnie Bowling_Email")

               

                          Dim myContact = CurNote.NotificationContacts.Add(myContactTemplate)

               

                          myContact.ConfigString = "subject= Alert: " & myNoteName & " - Breaker Open"

               

               

               

                          Dim NewAtt = CurNote.Attributes.Add("Trigger Input")

               

                          'NewAtt.Type = System.Type.GetType("Object")

               

                          myDB.CheckIn(AFCheckedOutMode.ObjectsCheckedOutThisSession)

               

               

               

               

               

              So I'm missing alot of information and have no clue on how to get it populated correctly.  If there is an example somewhere that shows how to work with configuing content that would be helpful.  I have searched all the documentation and can't find anything that explains how to get what I need.

               

              Thanks!

               

              Lonnie