AnsweredAssumed Answered

How to get value of attributes from an event frame

Question asked by mikespath on Jun 22, 2017
Latest reply on Jun 29, 2017 by Guilherme Ferreira

I'm trying to find a way via the AF SDK to get the value of the referenced elements associated with a found event frame. I thought the code below was the answer but it does not give the value that triggered the event but it just gives me the current attribute value of the referenced element.

 

            AFEventFrameSearch search = new AFEventFrameSearch(db, "search", query);

            //use new mehotd to GetTotalCount() without bringing back all EF headers. Fast and lower memory footprint 
            MessageBox.Show(string.Format("Total EF match critiera: {0} ", search.GetTotalCount()));


            //now actually bring back EF and full load- much more expensive call. 
            IEnumerable<AFEventFrame> eventFameResults = search.FindEventFrames(0, true, int.MaxValue);
            foreach(AFEventFrame ef in eventFameResults)
            {
                //ef.CaptureValues();


                if (ef.CanBeAcknowledged && /*!ef.IsAcknowledged && */ ef.Name.Contains("DO"))
                {
                    MessageBox.Show(ef.Name);
                    ef.Acknowledge();

                    // now get more details from the even from the referenced elements
                    foreach (AFElement elem in ef.ReferencedElements)
                    {
                        foreach (AFAttribute attrib in elem.Attributes)
                        {
                            if (attrib.Name.Contains("DO"))
                            {
                                AFValue myValue = attrib.GetValue();
                                MessageBox.Show(string.Format("DO:{0}",myValue.Value.ToString()));
                            }
                        }
                    }


                }

Outcomes