13 Replies Latest reply on Oct 2, 2009 5:02 PM by pkaiser

    AN SDK  vs.  AF SDK's Notifications Namespace

      Please note this forum is meant for questions and comments pertaining to the PI Notifications SDK (a.k.a AN SDK). While it is easy to confuse this SDK with the Notifications namepspace of the AF SDK, each serves very distinct purposes. Below is an overview but you can find more information (and coding examples) in the recording of our "AF and Notifications Developer Tools" webinar.

       

      AF SDK (OSIsoft.AF and children namespaces)
      Provides a hierarchical model of objects and collections that AF databases and objects.

       

      AF SDK's Notifications Namespace (OSIsoft.AF.Notifications)
      Provides a set of classes for creating and managing PI Notifications and related objects such as Contacts. Keep in mind the configuration for PI Notifications is stored in AF.
       
      Notifications SDK, AN SDK (OSIsoft.AN)
      Provides a set of classes to run/historize notifications and send events to contacts. Unlike the AF SDK's Notifications namespace, which deals with the configuration of PI Notifications, this set of classes has to do with instances of PI Notifications.

       

      Hope this helps - we hope you'll let us know if you need additional clarifications!

        • Re: AN SDK  vs.  AF SDK's Notifications Namespace
          AAugustine

          I installed AF SDK on my laptop but it doesn't show up in my Visual Studio Add Reference Section. Is there something I need to do to make it show up in the available references ?

            • Re: AN SDK  vs.  AF SDK's Notifications Namespace
              andreas

              Usually not - it should show up in Project>Add References>.NET as a bunch of OSIsoft.AF... Do you see nothing named OSIsoft... or just not the OSIsoft.AF... stuff? What version of Visual Studio?

               

              regards,

                • Re: AN SDK  vs.  AF SDK's Notifications Namespace
                  andreas

                  Another question - does the PI System Explorer work? Can you connect with the PI System Explorer to the AF Database?

                   

                  regards,

                    • Re: AN SDK  vs.  AF SDK's Notifications Namespace
                      AAugustine

                      Cannot connect to server 'gildv04.flowserve.net'. at OSIsoft.AF.Support.AFProxy.Reconnect(Boolean streamed, AFCollectiveMember member, Boolean autoPrompt, AFConnectionPreference preference) in c:\Dev\AF\AF 2.1 Release\Sources\SDK\Support\AFProxy.cs:line 448

                       

                      Any Ideas on why this is happening ?

                       

                      To answer your question above, Yes I can connect to the database from the PI System explorer but not the PI AF explorer due to some reason.

                        • Re: AN SDK  vs.  AF SDK's Notifications Namespace
                          andreas

                          The AF Explorer does not work natively with AF2.x so the only test that counts is the PI System Explorer. That leaves us with the version of Visual Studio and the GAC.

                          • What version of Visual Studio are you using?
                          • Is the OSIsoft.AFSDK in the GAC (C:\WINDOWS\assembly)?
                          • do you have a registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\PI AF Client 2.x ?
                          • Did you install the AF Developer Tools 2.1?
                          • Did you install the AF Client 2.1?
                          • Can you try to uninstall the AF Client and reinstall?

                          regards,

                           

                           

                            • Re: AN SDK  vs.  AF SDK's Notifications Namespace
                              AAugustine

                              Here are answers to your questions -

                               

                              MS Visual Studio Basic 2008 - 9.0

                               

                              OSIsoft.AFSDK  is in the GAC

                               

                              I do have the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\PI AF Client 2.x

                               

                              Yes I have AF Developer 2.1 installed

                               

                              I reinstalled AF Client 2.1 after uninstalling it.

                               

                              I am still getting the same error. Here's the block of code that's throwing the error


                              // Get the Database
                              PISystems myPISystems = new PISystems();
                              PISystem myPISystem = myPISystems.DefaultPISystem;

                              foreach (PISystem system in myPISystems)
                              {
                                 if(system.Name.Equals("gildv04.flowserve.net"))
                                 {
                                    myPISystem = system;
                                 }
                                 output.WriteLine(system.Name);
                              }

                              output.WriteLine("selected PI system " + myPISystem.Name);

                              AFDatabase myPIDB = null;

                              foreach (AFDatabase dataBase in myPISystem.Databases)
                              {
                                 if (dataBase.Name.Equals("Notifications"))
                                 {
                                    myPIDB = dataBase;
                                 }
                              }

                                • Re: AN SDK  vs.  AF SDK's Notifications Namespace
                                  andreas

                                  The code looks o.k. it compiles on my system and runs on my system (after changing database name and server name). I have attached a very small project that uses the UI components to select the AF server, AF Database and browse the elements. Could you extract it, compile it and see what happens if you run it?

                                   

                                  Meanwhile - just because the error message shows this, is this a collective or just a single server?

                                   

                                  regards,

                                    • Re: AN SDK  vs.  AF SDK's Notifications Namespace

                                      Achal: just wondering whether Andreas' answer/code helped solve your problem? Do you require any further assistance on this one?

                                        • Re: AN SDK  vs.  AF SDK's Notifications Namespace
                                          AAugustine

                                          No  unfortunately the code still doesn't work for me yet. What I am trying to do is to build a webpart in C# which can read the acknowlegement database using AF SDK. We are not trying to build a rich client using AF SDK

                                           

                                          We have a collective and the code is executed on a server which has Sharepoint Web Front End and the server is on a different machine.

                                           

                                          Here's the complete code for the webpart:

                                           

                                          using System;
                                          using System.Collections.Generic;
                                          using System.Linq;
                                          using System.Text;
                                          using System.Web;
                                          using System.Web.UI;
                                          using Microsoft.SharePoint;
                                          using System.Xml.Serialization;
                                          using System.IO;
                                          using Microsoft.SharePoint.WebControls;
                                          using OSIsoft.AF;
                                          using OSIsoft.AF.Asset;
                                          using OSIsoft.AF.UI;

                                          namespace AFWebPart
                                          {
                                              publicclassAFWebPart : Microsoft.SharePoint.WebPartPages.WebPart
                                              {
                                                  protectedoverridevoid Render(HtmlTextWriter output) 
                                                  {
                                                      output.WriteLine(" Start -- ");

                                                      try
                                                      {
                                                          // Get the Database
                                                          PISystems myPISystems = new PISystems();
                                                          output.WriteLine(" -- 0 -- ");
                                                          //PISystem myPIsystem = myPISystems.First();
                                                          output.WriteLine(" -- 0.1 -- "); 
                                                          PISystem myPISystem = myPISystems.DefaultPISystem; 
                                                          foreach (PISystem system in myPISystems) 
                                                          {
                                                              output.WriteLine(" -- 0.2-- "); 
                                                              if(system.Name.Equals("gildv04.flowserve.net")) 
                                                              {
                                                                  myPISystem = system;
                                                              }
                                                              output.WriteLine(system.Name);
                                                          }

                                                          output.WriteLine("selected PI system " + myPISystem.Name);

                                                          AFDatabase myPIDB = null;

                                                          foreach (AFDatabase dataBase in myPISystem.Databases) 
                                                          {
                                                              output.WriteLine(" -- 0.3-- " ); 
                                                              if (dataBase.Name.Equals("Notifications" ))
                                                              {
                                                                  myPIDB = dataBase;
                                                              }
                                                          } 
                                                          output.WriteLine(" -- 0.4-- "); 
                                                          AFDatabase myDB = myPISystems.DefaultPISystem.Databases.DefaultDatabase; 
                                                          output.WriteLine(" -- 2 -- " );

                                                          // Search the Elements Collection
                                                          constint MaxCount = 100; 
                                                          AFNamedCollectionList<AFElement> myElements; 
                                                          myElements = AFElement.FindElements(myDB,
                                                                                              null,
                                                                                              "*CU*",
                                                                                              AFSearchField.Name,
                                                                                              false,
                                                                                              AFSortField.Name,
                                                                                              AFSortOrder.Descending,
                                                                                              MaxCount); 
                                                          DisplayElements(myElements, output);
                                                      }
                                                      catch (Exception e) 
                                                      {
                                                          output.WriteLine(e.Message + e.StackTrace);
                                                      }
                                                      output.WriteLine(" End --- " );
                                                  }
                                              }
                                          }

                                           

                                            • Re: AN SDK  vs.  AF SDK's Notifications Namespace
                                              cescamilla

                                              I'll be running this code and see what is going on, rest asure we are taking care of your issue. I'll just add AF to my computer an try it out. :)

                                              • Re: AN SDK  vs.  AF SDK's Notifications Namespace

                                                Note that it could also be a security issue: if SharePoint is configured to impersonate and the AFServer is off-box, then you may be running into a situation where you are attempting a double-hop. If this is the case, you can either configure Kerberos to allow double-hop to the AFServer from the SharePoint Server, or you can modify your code to not use the impersonated account.

                                                  • Re: AN SDK  vs.  AF SDK's Notifications Namespace
                                                    pkaiser

                                                    I've discussed this issue with some of the AF team. We agree with Steve Pilon's suspicion that this issue appears when it does because of a double-hop security issue. It would be helpful to have the rest of the exception error message if available?

                                                     

                                                    Also, though unrelated to the error message, the AF team pointed out that you can retrieve your PI System and Database by name, without having to use for loops:

                                                    PISystem myPISystem = myPISystems[“gildv04.flowserv.net”];

                                                    if (myPISystem != null)

                                                        AFDatabase myPIDB = myPISystem.Databases[“Notifications”];