public override void LoadChildren()
        {
            // Load Definitions
            var definitions = GetFeatureDefinitionIndex().Distinct(new SPFeatureDefinitionComparer());

            // Load Active Features
            Dictionary <Guid, SPFeature> featureIndex = this.FeatureCollection.ToDictionary(p => p.DefinitionId);


            // Unordered List
            var unorderedList = new SerializableList <ISPNode>();

            foreach (var def in definitions)
            {
                SPFeatureNode node = new SPFeatureNode();
                node.Definition = def;
                node.Setup(this);

                if (featureIndex.ContainsKey(def.Id))
                {
                    node.SPObject  = featureIndex[def.Id];
                    node.Activated = true;

                    featureIndex.Remove(def.Id);
                }

                unorderedList.Add(node);
            }

            foreach (var entry in featureIndex)
            {
                SPFeatureNode node = new SPFeatureNode();
                node.Definition = null;
                node.Setup(this);
                node.Text += " (Error: Missing definition)";

                unorderedList.Add(node);
            }


            // Add Inactive Features node from definitions
            this.Children = new SerializableList <ISPNode>(unorderedList.OrderBy(p => p.Text));
        }
Example #2
0
        private async Task <List <PageBarInfo.PanelEntry> > GetPanelsAsync()
        {
            SavedCacheInfo info = GetCache(Module.ModuleGuid);

            if (info == null || info.UserId != Manager.UserId || info.Language != Manager.UserLanguage)
            {
                // We only reload the pages when the user is new (logon/logoff), otherwise we would build this too often
                List <PageBarInfo.PanelEntry> list = new SerializableList <PageBarInfo.PanelEntry>();
                foreach (LocalPage page in Module.PageList)
                {
                    AddPage(list, await YetaWF.Core.Pages.PageDefinition.LoadPageDefinitionByUrlAsync(page.Url), page.Popup);
                }
                if (!string.IsNullOrWhiteSpace(Module.PagePattern))
                {
                    SerializableList <PageBarInfo.PanelEntry> listPattern = new SerializableList <PageBarInfo.PanelEntry>();
                    Regex regPages = new Regex(Module.PagePattern);
                    foreach (PageDefinition.DesignedPage desPage in await YetaWF.Core.Pages.PageDefinition.GetDesignedPagesAsync())
                    {
                        Match m = regPages.Match(desPage.Url);
                        if (m.Success)
                        {
                            if ((from p in Module.PageList where p.Url == desPage.Url select p).FirstOrDefault() == null)
                            {
                                AddPage(listPattern, await YetaWF.Core.Pages.PageDefinition.LoadPageDefinitionAsync(desPage.PageGuid), false);
                            }
                        }
                    }
                    listPattern = new SerializableList <PageBarInfo.PanelEntry>(listPattern.OrderBy((m) => m.Caption.ToString()).ToList());
                    list.AddRange(listPattern);
                }
                info = new SavedCacheInfo {
                    PanelEntries = list,
                    Language     = Manager.UserLanguage,
                    UserId       = Manager.UserId,
                };
                SetCache(Module.ModuleGuid, info);
            }
            return(info.PanelEntries);
        }