コード例 #1
0
ファイル: NewsRepository.cs プロジェクト: jimeneza14/R7.News
 public void UpdateNewsEntryText(NewsEntryInfo newsEntry)
 {
     // TODO: More careful handling of empty text including "empty" HTML markup like `<P>&nbsp;</P>`
     if (!string.IsNullOrEmpty(newsEntry.Text))
     {
         var newsEntryText = new NewsEntryText {
             EntryId = newsEntry.EntryId,
             Text    = newsEntry.Text
         };
         if (newsEntry.EntryTextId == null)
         {
             NewsDataProvider.Instance.Add(newsEntryText);
             newsEntry.EntryTextId = newsEntryText.EntryTextId;
             NewsDataProvider.Instance.Update(newsEntry);
         }
         else
         {
             newsEntryText.EntryTextId = newsEntry.EntryTextId.Value;
             NewsDataProvider.Instance.Update(newsEntryText);
         }
     }
     else
     {
         if (newsEntry.EntryTextId != null)
         {
             NewsDataProvider.Instance.Delete <NewsEntryText, int> (newsEntry.EntryTextId.Value);
             newsEntry.EntryTextId = null;
             NewsDataProvider.Instance.Update(newsEntry);
         }
     }
 }
コード例 #2
0
ファイル: NewsRepository.cs プロジェクト: jimeneza14/R7.News
        public int DuplicateNewsEntry(NewsEntryInfo item, int moduleId, int tabId)
        {
            item.EntryId     = 0;
            item.EntryTextId = null;

            if (item.IsPublished(DateTime.Now))
            {
                item.StartDate = null;
                item.EndDate   = DateTime.Today;
            }

            return(AddNewsEntry(item, item.ContentItem.Terms, item.ContentItem.Images, moduleId, tabId));
        }
コード例 #3
0
ファイル: NewsRepository.cs プロジェクト: jimeneza14/R7.News
        internal int AddNewsEntry_Internal(IRepository <NewsEntryInfo> repository, NewsEntryInfo newsEntry,
                                           List <Term> terms,
                                           List <IFileInfo> images,
                                           int moduleId,
                                           int tabId)
        {
            var contentItem = AddContentItem(newsEntry, tabId, moduleId);

            newsEntry.ContentItemId = contentItem.ContentItemId;
            repository.Insert(newsEntry);

            UpdateContentItem(contentItem, newsEntry, terms, images);

            return(newsEntry.EntryId);
        }
コード例 #4
0
        public int AddNewsEntry(NewsEntryInfo newsEntry,
                                List <Term> terms,
                                List <IFileInfo> images,
                                int moduleId,
                                int tabId)
        {
            var contentItem = AddContentItem(newsEntry, tabId, moduleId);

            newsEntry.ContentItemId = contentItem.ContentItemId;
            NewsDataProvider.Instance.Add(newsEntry);

            UpdateContentItem(contentItem, newsEntry, terms, images);

            CacheHelper.RemoveCacheByPrefix(NewsCacheKeyPrefix);

            return(newsEntry.EntryId);
        }
コード例 #5
0
        /// <summary>
        /// Handles Load event for a control
        /// </summary>
        /// <param name="e">Event args.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try {
                if (!IsPostBack)
                {
                    // get news entry
                    NewsEntryInfo newsEntry = null;
                    if (EntryId != null)
                    {
                        newsEntry = NewsRepository.Instance.GetNewsEntry(EntryId.Value, PortalId);
                    }

                    if (newsEntry != null)
                    {
                        ReplacePageTitleAndMeta(newsEntry);

                        var newsEntries = new List <StreamNewsEntryViewModel> ();
                        newsEntries.Add(new StreamNewsEntryViewModel(newsEntry, ViewModelContext));

                        formNewsEntry.DataSource = newsEntries;
                        formNewsEntry.DataBind();
                    }
                    else
                    {
                        if (!IsEditable)
                        {
                            // throw 404 exception, which would result in showing 404 page
                            throw new HttpException((int)HttpStatusCode.NotFound, string.Empty);
                        }

                        // display warning for editors instead
                        this.Message("NewsEntryNotFound.Text", MessageType.Warning, true);
                    }
                }
            }
            catch (HttpException ex) {
                Exceptions.ProcessHttpException(ex);
            }
            catch (Exception ex) {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
コード例 #6
0
ファイル: TabSynchronizer.cs プロジェクト: jspsoft/R7.News
        public INewsEntry AddNewsEntryFromTabData(TabInfo activeTab, int moduleId)
        {
            // add default news entry based on tab data
            var newsEntry = new NewsEntryInfo {
                Title         = activeTab.TabName,
                Description   = HttpUtility.HtmlEncode("<p>" + activeTab.Description + "</p>"),
                AgentModuleId = moduleId,
                PortalId      = activeTab.PortalID,
                StartDate     = (activeTab.StartDate == default(DateTime) || activeTab.StartDate == DateTime.MaxValue) ? null : (DateTime?)activeTab.StartDate,
                // if no end date is set, make news entry expired by default
                EndDate          = (activeTab.EndDate == default(DateTime) || activeTab.EndDate == DateTime.MaxValue) ? DateTime.Today : activeTab.EndDate,
                ThematicWeight   = NewsConfig.Instance.NewsEntry.DefaultThematicWeight,
                StructuralWeight = NewsConfig.Instance.NewsEntry.DefaultStructuralWeight
            };

            // add news entry
            NewsRepository.Instance.AddNewsEntry(newsEntry, activeTab.Terms, new List <IFileInfo> (), moduleId, activeTab.TabID);

            return(newsEntry);
        }
コード例 #7
0
ファイル: ViewAgent.ascx.cs プロジェクト: sundnnstore/R7.News
        private INewsEntry AddFromTabData_Internal()
        {
            var tabController = new TabController();
            var activeTab     = tabController.GetTab(TabId, PortalId);

            // add default news entry based on tab data
            var newsEntry = new NewsEntryInfo {
                Title            = activeTab.TabName,
                Description      = HttpUtility.HtmlEncode("<p>" + activeTab.Description + "</p>"),
                AgentModuleId    = ModuleId,
                EndDate          = DateTime.Today, // expired by default
                ThematicWeight   = NewsConfig.Instance.NewsEntry.DefaultThematicWeight,
                StructuralWeight = NewsConfig.Instance.NewsEntry.DefaultStructuralWeight
            };

            // add news entry
            NewsRepository.Instance.AddNewsEntry(newsEntry, activeTab.Terms, new List <IFileInfo> (), ModuleId, TabId);

            return(newsEntry);
        }
コード例 #8
0
ファイル: NewsRepository.cs プロジェクト: jimeneza14/R7.News
        // TODO: Can use IEnumerable here
        static void UpdateContentItem(ContentItem contentItem, NewsEntryInfo newsEntry, List <Term> terms, List <IFileInfo> images)
        {
            // update content item after EntryId get its value
            // TODO: ContentKey should allow users to view your content item directly based on links provided from the tag search results
            // more info here: http://www.dnnsoftware.com/community-blog/cid/131963/adding-core-taxonomy-to-your-module-part-2-ndash-content-items
            contentItem.ContentKey = newsEntry.EntryId.ToString();
            NewsDataProvider.Instance.ContentController.UpdateContentItem(contentItem);

            // add images to content item
            if (images.Count > 0)
            {
                var attachmentController = new AttachmentController(NewsDataProvider.Instance.ContentController);
                attachmentController.AddImagesToContent(contentItem.ContentItemId, images);
            }

            // add terms to content item
            var termController = new TermController();

            foreach (var term in terms)
            {
                termController.AddTermToContent(term, contentItem);
            }
        }
コード例 #9
0
        public void UpdateNewsEntry(NewsEntryInfo newsEntry, List <Term> terms, int moduleId, int tabId)
        {
            // TODO: Update value of ContentKey
            // update content item
            newsEntry.ContentItem.ContentTitle = newsEntry.Title;
            newsEntry.ContentItem.Content      = newsEntry.Title;
            newsEntry.ContentItem.ModuleID     = newsEntry.AgentModuleId ?? moduleId;
            newsEntry.ContentItem.TabID        = tabId;
            NewsDataProvider.Instance.ContentController.UpdateContentItem(newsEntry.ContentItem);

            NewsDataProvider.Instance.Update <NewsEntryInfo> (newsEntry);

            // update content item terms
            var termController = new TermController();

            termController.RemoveTermsFromContent(newsEntry.ContentItem);
            foreach (var term in terms)
            {
                termController.AddTermToContent(term, newsEntry.ContentItem);
            }

            CacheHelper.RemoveCacheByPrefix(NewsCacheKeyPrefix);
        }
コード例 #10
0
 public XmlNewsEntryInfo(NewsEntryInfo newsEntry)
 {
     @This = newsEntry;
 }
コード例 #11
0
 public XmlNewsEntryInfo()
 {
     @This = new NewsEntryInfo();
 }
コード例 #12
0
        /// <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);
        }
コード例 #13
0
ファイル: NewsRepository.cs プロジェクト: jimeneza14/R7.News
 /// <summary>
 /// Updates the news entry w/o associated entities.
 /// </summary>
 /// <param name="newsEntry">News entry.</param>
 public void UpdateNewsEntry(NewsEntryInfo newsEntry)
 {
     NewsDataProvider.Instance.Update(newsEntry);
     DataCache.ClearCache(NewsCacheKeyPrefix);
 }
コード例 #14
0
 /// <summary>
 /// Updates the news entry w/o associated content item.
 /// </summary>
 /// <param name="newsEntry">News entry.</param>
 public void UpdateNewsEntry(NewsEntryInfo newsEntry)
 {
     NewsDataProvider.Instance.Update(newsEntry);
     CacheHelper.RemoveCacheByPrefix(NewsCacheKeyPrefix);
 }