Event Frames from AFSDK using primary referenced element

Discussion created by robert.low on Mar 26, 2014
Latest reply on Mar 27, 2014 by robert.low

I am trying to get programmatic access using the AFSDK to the Event Frames but want to only see particular primary referenced elements. Looking at the help file and vcampus, I don't see many actual .Net examples to do this. I can see the events but never the primaryreferencedelement. I do see the info in PSE and can match the records using visual studio.




here is my code blurb I am using:


Sub test_EF()


        Dim myPISystems As New PISystems


        Dim myDB As AFDatabase = myPISystems("PIServer1").Databases("PIAF")


        Dim myEventFrame As AFEventFrame = New AFEventFrame(myDB, "myEventFrame*")






        Dim myCategory As AFCategory = myDB.ElementCategories.Item("OSIBatch")


        Dim myElemTemplate As AFElementTemplate = myDB.ElementTemplates.Item(1)


        Dim list As AFNamedCollectionList(Of AFEventFrame) = AFEventFrame.FindEventFrames(myDB, myEventFrame, "*", AFSearchField.Name, False, AFSortField.StartTime, AFSortOrder.Ascending, 0, 1000)


        For Each cureventframe As AFEventFrame In list  


             If cureventframe.HasChildEventFrames Then                


                  For Each child In list                    


                    Console.WriteLine("Name: {0}", cureventframe.Name)


                    Console.WriteLine("Start time={0}", child.StartTime.LocalTime.ToString)


                    Console.WriteLine("End Time={0} ", child.EndTime.LocalTime.ToString)


                    Console.WriteLine("AF Unit={0} ", child.PrimaryReferencedElement)


                 Next child


             End If




    End Sub