Example #1
0
        /// <summary>
        /// This should only run after the Article exists in the data store. 
        /// </summary>
        /// <returns>The newly created ContentItemID from the data store.</returns>
        public ContentItem CreateContentItem(Article objArticle, int tabId)
        {
            var typeController = new ContentTypeController();
            var colContentTypes = (from t in typeController.GetContentTypes() where t.ContentType == ContentTypeName select t);
            int contentTypeId;

            if (colContentTypes.Count() > 0)
            {
                var contentType = colContentTypes.Single();
                contentTypeId = contentType == null ? CreateContentType() : contentType.ContentTypeId;
            }
            else
            {
                contentTypeId = CreateContentType();
            }

            var objContent = new ContentItem
            {
                Content = objArticle.Title + " " + HttpUtility.HtmlDecode(objArticle.Description),
                ContentTypeId = contentTypeId,
                Indexed = false,
                ContentKey = "aid=" + objArticle.ArticleId,
                ModuleID = objArticle.ModuleId,
                TabID = tabId
            };

            objContent.ContentItemId = Util.GetContentController().AddContentItem(objContent);

            // Add Terms
            var cntTerm = new Terms();
            cntTerm.ManageArticleTerms(objArticle, objContent);

            return objContent;
        }
Example #2
0
        /// <summary>
        /// This should only run after the Post exists in the data store. 
        /// </summary>
        /// <returns>The newly created ContentItemID from the data store.</returns>
        /// <remarks>This is for the first question in the thread. Not for replies or items with ParentID > 0.</remarks>
        internal ContentItem CreateContentItem(JournalItem objJournalItem, int tabId) {
            var typeController = new ContentTypeController();
            string contentTypeName = "DNNCorp_JournalProfile";
            if (objJournalItem.SocialGroupId > 0) {
                contentTypeName = "DNNCorp_JournalGroup";
            }
            var colContentTypes = (from t in typeController.GetContentTypes() where t.ContentType == contentTypeName select t);
            int contentTypeID;

            if (colContentTypes.Count() > 0) {
                var contentType = colContentTypes.Single();
                contentTypeID = contentType == null ? CreateContentType(contentTypeName) : contentType.ContentTypeId;
            } else {
                contentTypeID = CreateContentType(contentTypeName);
            }
            
            var objContent = new ContentItem {
                Content = GetContentBody(objJournalItem),                
                ContentTypeId = contentTypeID,
                Indexed = false,
                ContentKey = "journalid=" + objJournalItem.JournalId,
                ModuleID = -1,
                TabID = tabId
            };

            objContent.ContentItemId = Util.GetContentController().AddContentItem(objContent);

            // Add Terms
            //var cntTerm = new Terms();
            //cntTerm.ManageQuestionTerms(objPost, objContent);

            return objContent;
        }
        /// <summary>
        /// This should run only after the item has been added/updated in data store and the ContentItem exists.
        /// </summary>
        /// <param name="objPost">The content item we are associating categories with.</param>
        /// <param name="objContent"></param>
        internal void ManageQuestionTerms(EntityInfo objPost, ContentItem objContent)
        {
            RemoveQuestionTerms(objContent);

            foreach (var term in objPost.Terms) {
                Util.GetTermController().AddTermToContent(term, objContent);
            }
        }
        public void DeleteContentItem(ContentItem contentItem)
        {
            //Argument Contract
            Requires.NotNull("contentItem", contentItem);
            Requires.PropertyNotNegative("contentItem", "ContentItemId", contentItem.ContentItemId);

            _dataService.DeleteContentItem(contentItem.ContentItemId);
        }
Example #5
0
		/// <summary>
		/// This should run only after a thread has been added/updated in data store and the ContentItem exists.
		/// </summary>
		/// <param name="objTopic">The content item we are associating categories with. In this module, it will always be a thread.</param>
		/// <param name="objContent"></param>
		internal void ManageThreadTerms(TopicInfo objTopic, ContentItem objContent)
		{
			RemoveThreadTerms(objContent);

			foreach (var term in objTopic.Terms) {
				Util.GetTermController().AddTermToContent(term, objContent);
			}
		}
Example #6
0
        ///<summary>
        /// This should run only after the Article has been added/updated in data store and the ContentItem exists.
        ///</summary>
        ///<param name="objArticle"></param>
        ///<param name="objContent"></param>
        public void ManageArticleTerms(Article objArticle, ContentItem objContent)
        {
            RemoveArticleTerms(objContent);

            foreach (var term in objArticle.Terms)
            {
                Util.GetTermController().AddTermToContent(term, objContent);
            }
        }
Example #7
0
        /// <summary>
        /// This should run only after the post has been added/updated in data store and the ContentItem exists.
        /// </summary>
        /// <param name="objPost">The content item we are associating categories with. In this module, it will always be a question (first post).</param>
        /// <param name="objContent"></param>
        internal void ManageQuestionTerms(AlbumInfo objAlbum, ContentItem objContent)
        {
            RemoveQuestionTerms(objContent);

            var terms = Util.GetContentController().GetContentItem(objAlbum.AlbumID).Terms;

            foreach (var term in terms) {
                Util.GetTermController().AddTermToContent(term, objContent);
            }
        }
 internal static ContentItem CreateValidContentItem()
 {
     ContentItem content = new ContentItem
                               {
                                   Content = Constants.CONTENT_ValidContent,
                                   ContentKey = Constants.CONTENT_ValidContentKey,
                                   Indexed = Constants.CONTENT_IndexedFalse
                               };
     return content;
 }
	    public int AddContentItem(ContentItem contentItem)
        {
            //Argument Contract
            Requires.NotNull("contentItem", contentItem);

            contentItem.ContentItemId = _dataService.AddContentItem(contentItem, UserController.GetCurrentUserInfo().UserID);

            SaveMetadataDelta(contentItem);

            return contentItem.ContentItemId;
        }
Example #10
0
 /// <summary>
 /// This should run only after the post has been added/updated in data store and the ContentItem exists.
 /// </summary>
 /// <param name="objPost">The content item we are associating categories with. In this module, it will always be a question (first post).</param>
 /// <param name="objContent"></param>
 public void ManageQuestionTerms(AlbumInfo objAlbum, ContentItem objContent)
 {
     RemoveQuestionTerms(objContent);
     if (Util.GetContentController().GetContentItem(objAlbum.TabID).Terms != null)
     {
         var terms = Util.GetContentController().GetContentItem(objAlbum.TabID).Terms;
         foreach (var term in terms)
         {
             Util.GetTermController().AddTermToContent(term, objContent);
         }
     }
 }
        public void DeleteContentItem(ContentItem contentItem)
        {
            //Argument Contract
            Requires.NotNull("contentItem", contentItem);
            Requires.PropertyNotNegative("contentItem", "ContentItemId", contentItem.ContentItemId);

            var searrchDoc = new SearchDocumentToDelete
            {
                UniqueKey = contentItem.ContentItemId.ToString("D"),
                ModuleId = contentItem.ModuleID,
                TabId = contentItem.TabID,
                SearchTypeId = SearchHelper.Instance.GetSearchTypeByName("module").SearchTypeId
            };
            DotNetNuke.Data.DataProvider.Instance().AddSearchDeletedItems(searrchDoc);

            _dataService.DeleteContentItem(contentItem.ContentItemId);
        }
Example #12
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="objTopic"></param>
		/// <param name="tabId"></param>
		/// <returns>The newly created ContentItemID from the data store.</returns>
		/// <remarks>This should only run once a topic is in the data store.</remarks>
		internal ContentItem CreateContentItem(TopicInfo objTopic, int tabId)
		{
			var objContent = new ContentItem
								{
									//Content = objTopic.Description,
									ContentTypeId = GetContentTypeID(),
									Indexed = false,
									//ContentKey = "view=" + Constants.PageScope.ProjectDetail + "&project=" + objTopic.Title,
									ModuleID = objTopic.ModuleID,
									TabID = tabId
								};

			objContent.ContentItemId = Util.GetContentController().AddContentItem(objContent);

			//// Add Terms
			//var cntTerm = new Terms();
			//cntTerm.ManageThreadTerms(objTopic, objContent);

			return objContent;
		}
        public void AddAnnouncement(AnnouncementInfo announcement)
        {
            using (IDataContext context = DataContext.Instance())
            {
                var repository = context.GetRepository<AnnouncementInfo>();

                var objContentItem = new ContentItem
                {
                    Content = announcement.Description,
                    ContentTitle = announcement.Title,
                    Indexed = false,
                    ModuleID = announcement.ModuleID,
                    TabID = Null.NullInteger,
                    ContentKey = null,
                    ContentTypeId = 4
                };

                announcement.ContentItemID = new ContentController().AddContentItem(objContentItem);
                repository.Insert(announcement);
                }
        }
Example #14
0
        private static ContentItem CreateFileContentItem()
        {
            var typeController = new ContentTypeController();
            var contentTypeFile = (from t in typeController.GetContentTypes() where t.ContentType == "File" select t).SingleOrDefault();

            if (contentTypeFile == null)
            {
                contentTypeFile = new ContentType { ContentType = "File" };
                contentTypeFile.ContentTypeId = typeController.AddContentType(contentTypeFile);
            }

            var objContent = new ContentItem
            {
                ContentTypeId = contentTypeFile.ContentTypeId,
                Indexed = false,
            };

            objContent.ContentItemId = Util.GetContentController().AddContentItem(objContent);

            return objContent;
        }
Example #15
0
		/// <summary>
		/// Removes terms associated w/ a specific ContentItem.
		/// </summary>
		/// <param name="objContent"></param>
		internal void RemoveThreadTerms(ContentItem objContent)
		{
			Util.GetTermController().RemoveTermsFromContent(objContent);
		}
Example #16
0
 public void AddMetaData(ContentItem contentItem, string name, string value)
 {
     //do nothing
 }
        public void ContentController_UpdateContentItem_Throws_On_Negative_ContentItemId()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            ContentController controller = new ContentController(mockDataService.Object);

            ContentItem content = new ContentItem();
            content.ContentItemId = Null.NullInteger;

            Assert.Throws<ArgumentException>(() => controller.UpdateContentItem(content));
        }
        public void UpdateContentItem(ContentItem contentItem)
        {
            //Argument Contract
            Requires.NotNull("contentItem", contentItem);
            Requires.PropertyNotNegative("contentItem", "ContentItemId", contentItem.ContentItemId);
            
            AttachmentController.SerializeAttachmentMetadata(contentItem);

            SaveMetadataDelta(contentItem);
            
            _dataService.UpdateContentItem(contentItem, UserController.GetCurrentUserInfo().UserID);
        }
        private void SaveMetadataDelta(ContentItem contentItem)
        {
            var persisted = GetMetaData(contentItem.ContentItemId);

            var lh = persisted.AllKeys.ToDictionary(x => x, x => persisted[x]);

            var rh = contentItem.Metadata.AllKeys.ToDictionary(x => x, x => contentItem.Metadata[x]);

            if (!MetaDataChanged(lh, rh))
            {
                return;
            }

            // Items in the database but missing from the parameter (have been deleted).
            var deleted = lh.Except(rh).ToArray();

            // Items included in the object but missing from the database (newly added).
            var added = rh.Except(lh).ToArray();

            _dataService.SynchronizeMetaData(contentItem, added, deleted);
        }
        /// <summary>
        /// Parse the content item content to populate a DNN Hangout object
        /// </summary>
        /// <param name="contentItem"></param>
        /// <returns></returns>
        private HangoutInfo ParseContentItemForHangout(ContentItem contentItem)
        {
            var hangout = new HangoutInfo();
            if (contentItem != null && !string.IsNullOrEmpty(contentItem.Content))
            {
                hangout = contentItem.Content.FromJson<HangoutInfo>();
            }

            return hangout;
        }
        public void DeleteMetaData(ContentItem contentItem, string name, string value)
        {
            //Argument Contract
            Requires.NotNull("contentItem", contentItem);
            Requires.PropertyNotNegative("contentItem", "ContentItemId", contentItem.ContentItemId);
            Requires.NotNullOrEmpty("name", name);

            _dataService.DeleteMetaData(contentItem, name, value);
        }
        /// <summary>
        /// This method creates new DNN Hangout entries in the content item data store
        /// </summary>
        /// <param name="tabId"></param>
        /// <param name="moduleId"></param>
        /// <param name="bookmark"></param>
        /// <returns></returns>
        public int CreateContentItem(int tabId, int moduleId, HangoutInfo hangout)
        {
            // create a new content item
            var objContent = new ContentItem
            {
                Content = JsonExtensionsWeb.ToJsonString(hangout),
                ContentTypeId = DNNHangoutContentTypeId,
                Indexed = false,
                ModuleID = moduleId,
                TabID = tabId
            };

            // save the content item to the database
            objContent.ContentItemId = Util.GetContentController().AddContentItem(objContent);

            // update the objects with the new content item id retrieved in the line above
            hangout.ContentItemId = objContent.ContentItemId;

            // update the content item properties with proper content
            objContent.Content = JsonExtensionsWeb.ToJsonString(hangout);
            objContent.ContentKey = string.Format(CONTENT_KEY_FORMAT, hangout.ContentItemId);

            // update the content item again since we now have a contentItemId for the properties
            Util.GetContentController().UpdateContentItem(objContent);

            // return the content item id
            return objContent.ContentItemId;
        }
Example #23
0
        /// <summary>
        /// This should only run after the Post exists in the data store. 
        /// </summary>
        /// <returns>The newly created ContentItemID from the data store.</returns>
        /// <remarks>This is for the first question in the thread. Not for replies or items with ParentID > 0.</remarks>
        internal ContentItem CreateContentItem(AlbumInfo objPost, int tabId)
        {
            var typeController = new ContentTypeController();
            var colContentTypes = (from t in typeController.GetContentTypes() where t.ContentType == Constants.ContentTypeName select t);
            int contentTypeID;

            if (colContentTypes.Count() > 0)
            {
                var contentType = colContentTypes.Single();
                contentTypeID = contentType == null ? CreateContentType() : contentType.ContentTypeId;
            }
            else
            {
                contentTypeID = CreateContentType();
            }

            var objContent = new ContentItem
                                {
                                    Content = objPost.ShortContent,
                                    ContentTypeId = contentTypeID,
                                    Indexed = false,
                                    ContentKey = "view=" + Constants.PageScope.Question.ToString().ToLower() + "&id=" + objPost.AlbumID,
                                    ModuleID = objPost.ModuleID,
                                    TabID = tabId
                                };

            objContent.ContentItemId = Util.GetContentController().AddContentItem(objContent);

            // Add Terms
            var cntTerm = new Terms();
            cntTerm.ManageQuestionTerms(objPost, objContent);

            return objContent;
        }
Example #24
0
		protected void Clone(ContentItem cloneItem, ContentItem originalItem)
		{
			CloneBaseProperties(cloneItem, originalItem);

			cloneItem.ContentItemId = originalItem.ContentItemId;
			cloneItem.Content = originalItem.Content;
			cloneItem.ContentTypeId = originalItem.ContentTypeId;
			cloneItem.TabID = originalItem.TabID;
			cloneItem.ModuleID = originalItem.ModuleID;
			cloneItem.ContentKey = originalItem.ContentKey;
            cloneItem.Indexed = originalItem.Indexed;
            cloneItem.StateID = originalItem.StateID;
		}
Example #25
0
 public int InsertStory(StoryInfo story, string language, int moduleId, int tabId)
 {
     using (IDataContext ctx = DataContext.Instance())
     {
         var rep = ctx.GetRepository<StoryInfo>();
         rep.Insert(story);
         StoryLangInfo lang = new StoryLangInfo
                              {
                                  StoryId = story.StoryId,
                                  Language = language,
                                  Story = story.Story,
                                  Title = story.Title
                              };
         InsertStoryLang(lang, tabId);
         var contentItem = new ContentItem()
         {
             Content = GetStoryContent(story.StoryId),
             ContentTypeId = ContentTypeId,
             Indexed = false,
             ContentKey = "#view/" + story.StoryId.ToString(),
             ModuleID = moduleId,
             TabID = tabId
         };
         story.ContentItemID = Util.GetContentController().AddContentItem(contentItem);
         rep.Update(story);
         return story.StoryId;
     }
 }
 private void InitializeWorkflow(ContentItem contentItem)
 {
     contentItem.StateID = Null.NullInteger;
 }
 internal static void SerializeAttachmentMetadata(ContentItem contentItem)
 {
     SerializeToMetadata(contentItem.Files, contentItem.Metadata, FilesKey);
     SerializeToMetadata(contentItem.Videos, contentItem.Metadata, VideoKey);
     SerializeToMetadata(contentItem.Images, contentItem.Metadata, ImageKey);
 }
 internal static void SerializeAttachmentMetadata(ContentItem contentItem)
 {
     SerializeToMetadata(contentItem.Files, contentItem.Metadata, FilesKey);
     SerializeToMetadata(contentItem.Videos, contentItem.Metadata, VideoKey);
     SerializeToMetadata(contentItem.Images, contentItem.Metadata, ImageKey);
 }
 /// <summary>
 /// This method deletes a content item
 /// </summary>
 /// <param name="contentItem"></param>
 public void DeleteContentItem(ContentItem contentItem)
 {
     // execute the deletion
     Util.GetContentController().DeleteContentItem(contentItem);
 }
Example #30
0
 /// <summary>
 /// Removes terms associated w/ a specific ContentItem.
 /// </summary>
 /// <param name="objContent"></param>
 public void RemoveArticleTerms(ContentItem objContent)
 {
     Util.GetTermController().RemoveTermsFromContent(objContent);
 }
 public void DeleteMetaData(ContentItem contentItem, string name)
 {
     if (contentItem.Metadata.AllKeys.Contains(name))
     {
         DeleteMetaData(contentItem, name, contentItem.Metadata[name]);
     }
 }