示例#1
0
        internal static void OnChanged(object sender, AFChangedEventArgs e)
        {
            //Console.WriteLine(sender);
            //Console.WriteLine(e);

            // Find changes made while application not running.
            List <AFChangeInfo> list = new List <AFChangeInfo>();

            list.AddRange(myPISystem.FindChangedItems(true, int.MaxValue, sysCookie, out sysCookie));
            list.AddRange(monitoredDB.FindChangedItems(true, int.MaxValue, dbCookie, out dbCookie));

            // Refresh objects that have been changed.
            AFChangeInfo.Refresh(myPISystem, list);
            foreach (AFChangeInfo info in list)
            {
                AFChangeInfoAction ac    = info.Action;
                AFObject           myObj = info.FindObject(myPISystem, true);
                AFIdentity         myID  = myObj.Identity;
                if (myID == AFIdentity.EventFrame && ac == AFChangeInfoAction.Added)
                {
                    AFEventFrame myEFinfo = (AFEventFrame)info.FindObject(myPISystem, true);
                    AFNamedCollectionList <AFEventFrame> myEFList = AFEventFrame.FindEventFrames(monitoredDB, null, new AFTime("*"), 0, 5, AFEventFrameSearchMode.BackwardFromEndTime, "", "", null, myEFinfo.Template, true);
                    foreach (AFEventFrame EF in myEFList)
                    {
                        Console.WriteLine(EF.Name);
                    }
                }
            }
        }
        internal void OnChanged(object sender, AFChangedEventArgs e)
        {
            List <AFChangeInfo> changes = new List <AFChangeInfo>();

            changes.AddRange(afdatabase.FindChangedItems(true, int.MaxValue, cookie, out cookie));
            AFChangeInfo.Refresh(afdatabase.PISystem, changes);

            foreach (AFChangeInfo info in changes.FindAll(change => change.Identity == AFIdentity.EventFrame))
            {
                if (info.Action != AFChangeInfoAction.Removed)
                {
                    AFEventFrame lastestEventFrame = (AFEventFrame)info.FindObject(afdatabase.PISystem, true);
                    logger.Debug($"A new event to verify: {lastestEventFrame.Name}");
                    calculation.performAction(lastestEventFrame, info.Action);
                }
            }
        }