Ejemplo n.º 1
0
        public void SetCache(Guid moduleGuid, SavedCacheInfo cacheInfo)
        {
            SessionStateIO <SavedCacheInfo> session = new SessionStateIO <SavedCacheInfo> {
                Key  = GetCacheName(moduleGuid),
                Data = cacheInfo,
            };

            session.Save();
        }
Ejemplo n.º 2
0
        public SavedCacheInfo GetCache(Guid moduleGuid)
        {
            SessionStateIO <SavedCacheInfo> session = new SessionStateIO <SavedCacheInfo> {
                Key = GetCacheName(moduleGuid)
            };
            SavedCacheInfo info = session.Load();

            if (info != null && info.Created < DateTime.UtcNow.AddMinutes(-5))
            {
                return(null);
            }
            return(info);
        }
Ejemplo n.º 3
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);
        }