// TODO: Pass parameters via specific node, remove it after processing? public List <MenuNode> ManipulateNodes(List <MenuNode> nodes, PortalSettings portalSettings) { try { var config = NewsConfig.GetInstance(portalSettings.PortalId).NodeManipulator; var parentNode = FindNodeByTabId(nodes, config.ParentNodeTabId); if (parentNode != null) { var streamModule = ModuleController.Instance.GetModule(config.StreamModuleId, config.StreamModuleTabId, false); if (streamModule != null) { var settingsRepository = new StreamSettingsRepository(); var settings = settingsRepository.GetSettings(streamModule); var newsEntries = GetNewsEntries(settings, settings.PageSize, portalSettings.PortalId); foreach (var newsEntry in newsEntries) { parentNode.Children.Add(CreateMenuNode(newsEntry, parentNode, streamModule)); } } else { LogAdminAlert($"Could not find Stream module with ModuleID={config.StreamModuleId} on page with TabID={config.StreamModuleTabId}.", portalSettings.PortalId); } } else { LogAdminAlert($"Could not find parent node with TabID={config.ParentNodeTabId}.", portalSettings.PortalId); } } catch (Exception ex) { Exceptions.LogException(ex); } return(nodes); }
public IEnumerable <NewsEntryInfo> GetNewsEntriesByAgent(int moduleId, int portalId) { var cacheKey = NewsCacheKeyPrefix + "AgentModuleId=" + moduleId; return(DataCache.GetCachedData <IEnumerable <NewsEntryInfo> > ( new CacheItemArgs(cacheKey, NewsConfig.GetInstance(portalId).DataCacheTime, CacheItemPriority.Normal), c => GetNewsEntriesByAgentInternal(moduleId) )); }
protected IEnumerable <INewsEntry> GetNewsEntries_Cached(int moduleId, int portalId, StreamSettings settings) { // TODO: Reuse cached data from StreamViewModel or (better) move caching to repository var cacheKey = "//" + Const.Prefix + "/NodeManipulator?ModuleId=" + moduleId; return(DataCache.GetCachedData <IEnumerable <INewsEntry> > ( new CacheItemArgs(cacheKey, NewsConfig.GetInstance(portalId).DataCacheTime, CacheItemPriority.Normal), c => GetNewsEntries(portalId, settings) )); }
public IEnumerable <NewsEntryInfo> GetAllNewsEntries(int moduleId, int portalId, WeightRange thematicWeights, WeightRange structuralWeights) { var cacheKey = NewsCacheKeyPrefix + "ModuleId=" + moduleId; return(DataCache.GetCachedData <IEnumerable <NewsEntryInfo> > ( new CacheItemArgs(cacheKey, NewsConfig.GetInstance(portalId).DataCacheTime, CacheItemPriority.Normal), c => GetAllNewsEntriesInternal(portalId, thematicWeights, structuralWeights) )); }
/// <summary> /// Imports news from AnnoView modules to R7.News /// </summary> /// <param name="sleepTimeout">Sleep timeout.</param> protected int Import(int sleepTimeout) { var itemsImported = 0; var itemsImportedDiv10 = 0; var announcements = NewsDataProvider.Instance.GetObjects <AnnouncementInfo> (); if (announcements != null) { var moduleController = new ModuleController(); var tabController = new TabController(); var termController = new TermController(); using (var dc = DataContext.Instance()) { var repository = dc.GetRepository <NewsEntryInfo> (); foreach (var announcement in announcements) { var module = moduleController.GetModule(announcement.ModuleId); if (module != null) { try { // fill news entry var newsEntry = new NewsEntryInfo { Title = announcement.Title, Description = announcement.Description, StartDate = announcement.PublishDate, EndDate = announcement.ExpireDate, Url = announcement.Url, PortalId = module.PortalID, ThematicWeight = (announcement.Export) ? NewsConfig.GetInstance(module.PortalID).NewsEntry.MaxWeight : 0, StructuralWeight = (announcement.Export) ? NewsConfig.GetInstance(module.PortalID).NewsEntry.MaxWeight : 0 }; // add news entry NewsRepository.Instance.AddNewsEntry_Internal( repository, newsEntry, GetTerms(announcement, module, tabController, termController), GetImages(announcement), module.ModuleID, module.TabID ); // count number of items imported, // invoke Progressing method each 10 items itemsImported++; if (itemsImported / 10 > itemsImportedDiv10) { itemsImportedDiv10++; Progressing(); } Thread.Sleep(sleepTimeout); } catch (Exception ex) { // log error on importing current announcement ScheduleHistoryItem.AddLogNote("Announcement.ItemId:" + announcement.ItemId + "; Exception:" + ex); Exceptions.LogException(ex); } } } } } return(itemsImported); }