public override BaseActionType[] GetFolderActions(Folder folder, BaseActionType[] proposedActions, EntityActionType[] types)
        {
            BaseActionType action = null;

            OPCServerFolderBehaviorData ext = folder.GetExtensionData <OPCServerFolderBehaviorData>();

            if (!OPCEngine.IsListening(ext.Url, ext.AgentId))
            {
                action = new ConfirmAction("Start Listening", null, "Start Listening", "Are You Sure?", new SimpleDelegate(() =>
                {
                    OPCServerFolderBehaviorData folderExt = folder.GetExtensionData <OPCServerFolderBehaviorData>();

                    var allEvents = Folder.GetEntitiesInFolder <OPCEvent>(folder.FolderID);

                    OpcEventGroup[] eventGroups = allEvents.Where(x => !x.Disabled).Select(x => new OpcEventGroup
                    {
                        Paths      = x.EventValues?.Select(y => y.PathToValue).ToArray() ?? new string[0],
                        EventId    = x.Id,
                        Deadband   = x.Deadband,
                        UpdateRate = x.UpdateRate
                    }).ToArray();

                    OPCEngine.StartListening(folderExt.Url, folderExt.AgentId, eventGroups);
                    OPCEngine.GetInitialData(folderExt.Url, folderExt.AgentId, true);
                }));
            }
            else
            {
                action = new ConfirmAction("Stop Listening", null, "Stop Listening", "Are You Sure?", new SimpleDelegate(() =>
                {
                    OPCServerFolderBehaviorData folderExt = folder.GetExtensionData <OPCServerFolderBehaviorData>();
                    OPCEngine.StopListening(folderExt.Url, folderExt.AgentId);
                }));
            }


            return(new BaseActionType[]
            {
                new AddEntityAction(typeof(OPCEvent), "Add Event", null, "Add OPC Event"),
                new SimpleAction("Rebuild Tag Cache", null, new SimpleDelegate(() =>
                {
                    RebuildTagCache(folder);
                }))
                {
                    DisplayType = ActionDisplayType.Secondary
                },
                action
            }.Concat(proposedActions.Where(a => a is NavigateToFolderAction || a.Name == "Delete Folder")).ToArray());
        }
        private void RebuildTagCache(Folder f)
        {
            ORM <Folder> orm = new ORM <Folder>();

            if (orm.Fetch(f.FolderID + ".tagdata") == null)
            {
                Folder tagf = new Folder();
                tagf.EntityFolderID     = f.FolderID;
                tagf.EntityName         = "Tag Data";
                tagf.FolderBehaviorType = typeof(DefaultFolderBehavior).FullName;
                tagf.FolderID           = f.FolderID + ".tagdata";
                tagf.Store();
            }

            OPCServerFolderBehaviorData folderExt = f.GetExtensionData <OPCServerFolderBehaviorData>();
            var url = folderExt.Url;

            OPCEngine.GetInitialData(url, folderExt.AgentId, false);
        }