/// <summary> /// Informs the core journal that the user has created an item /// </summary> /// <param name="objEntity"></param> /// <param name="tabId"></param> /// <param name="title"></param> /// <param name="portalId"></param> /// <param name="journalUserId"></param> /// <param name="url"></param> /// <remarks>This may need to be updated based on what you intent to send to the jorunal.</remarks> internal void AddItemToJournal(EntityInfo objEntity, int tabId, string title, int portalId, int journalUserId, string url) { var objectKey = Constants.ContentTypeName + "_" + Constants.JournalSocialModuleTypeName + "_" + string.Format("{0}:{1}", objEntity.Id, portalId); var ji = JournalController.Instance.GetJournalItemByKey(portalId, objectKey); if ((ji != null)) { JournalController.Instance.DeleteJournalItemByKey(portalId, objectKey); } ji = new JournalItem { PortalId = portalId, ProfileId = journalUserId, UserId = journalUserId, //SocialGroupId = objEntity.GroupId, //ContentItemId = objEntity.ContentItemId, Title = title, ItemData = new ItemData { Url = url }, //Summary = objEntity.Details, Body = null, JournalTypeId = GetCreateEventJournalType(portalId), ObjectKey = objectKey, SecuritySet = "E," }; //if (objEntity.GroupId > Null.NullInteger) ji.SocialGroupId = objEntity.GroupId; JournalController.Instance.SaveJournalItem(ji, tabId); }
/// <summary> /// This should only run after the Item exists in the data store. /// </summary> /// <param name="objEntity"></param> /// <param name="tabId"></param> /// <returns></returns> internal ContentItem CreateContentItem(EntityInfo objEntity, 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 { ContentTypeId = contentTypeID, Indexed = false, ContentKey = "view=" + Constants.PageScope.Detail.ToString().ToLower() + "&id=" + objEntity.Id, ModuleID = objEntity.ModuleID, TabID = tabId }; objContent.ContentItemId = Util.GetContentController().AddContentItem(objContent); // Add Terms var cntTerm = new Terms(); cntTerm.ManageQuestionTerms(objEntity, 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 EntityInfo AddItem(EntityInfo objEntity, int tabId) { DotNetNuke.Common.Requires.PropertyNotNegative("portalID", "", objEntity.PortalId); objEntity.Id = _dataProvider.AddItem(objEntity.PortalId); if (objEntity.ContentItemId < 1) { objEntity.ContentItemId = CompleteItemCreation(objEntity, tabId); } //// handle cache clearing //DataCache.RemoveCache(Constants.ModuleCacheKey + Constants.ItemCacheKey + objEntity.ModuleID); return objEntity; }
/// <summary> /// This method will create a new notification message in the data store. /// </summary> /// <param name="objEntity"></param> /// <param name="portalId"></param> /// <param name="tabId"></param> /// <param name="subject"></param> /// <param name="body"></param> /// <remarks>The last part of this method is commented out but was setup to send to a role (based on a group). You can utilize this and/or also pass a list of users.</remarks> internal void ItemNotification(EntityInfo objEntity, int portalId, int tabId, string subject, string body) { var notificationType = NotificationsController.Instance.GetNotificationType(Constants.NotificationSocialModuleTypeName); var notificationKey = string.Format("{0}:{1}:{2}", Constants.ContentTypeName, objEntity.Id, tabId); var objNotification = new Notification { NotificationTypeID = notificationType.NotificationTypeId, Subject = subject, Body = body, IncludeDismissAction = true, SenderUserID = objEntity.CreatedByUserID, Context = notificationKey }; //// invite the members of the group //var colRoles = new List<RoleInfo>(); //var objGroup = TestableRoleController.Instance.GetRole(portalId, r => r.RoleID == objEntity.GroupId); //colRoles.Add(objGroup); //NotificationsController.Instance.SendNotification(objNotification, portalId, colRoles, null); }
/// <summary> /// Handles any content item/taxonomy updates, then deals with cache clearing. /// </summary> /// <param name="objPost"></param> /// <param name="tabId"></param> private static void CompleteItemUpdate(EntityInfo objPost, int tabId) { var cntTaxonomy = new Content(); cntTaxonomy.UpdateContentItem(objPost, tabId); //DataCache.RemoveCache(Constants.ModuleCacheKey + Constants.ItemCacheKey + objPost.ModuleID); }
/// <summary> /// This completes the things necessary for creating a content item in the data store. /// </summary> /// <param name="objPost">The EntityInfo entity we just created in the data store.</param> /// <param name="tabId">The page we will associate with our content item.</param> /// <returns>The ContentItemId primary key created in the Core ContentItems table.</returns> private static int CompleteItemCreation(EntityInfo objPost, int tabId) { var cntTaxonomy = new Content(); var objContentItem = cntTaxonomy.CreateContentItem(objPost, tabId); return objContentItem.ContentItemId; }
public void UpdateItem(EntityInfo objEntity, int tabId) { DotNetNuke.Common.Requires.PropertyNotNegative("Id", "", objEntity.Id); DotNetNuke.Common.Requires.PropertyNotNullOrEmpty("title", "", objEntity.Title); _dataProvider.UpdateItem(objEntity.Id); CompleteItemUpdate(objEntity, tabId); }
/// <summary> /// This is used to update the content in the ContentItems table. Should be called when an item is updated. /// </summary> internal void UpdateContentItem(EntityInfo objEntity, int tabId) { var objContent = Util.GetContentController().GetContentItem(objEntity.ContentItemId); if (objContent == null) return; objContent.TabID = tabId; objContent.ContentKey = "view=" + Constants.PageScope.Detail.ToString().ToLower() + "&id=" + objEntity.Id; Util.GetContentController().UpdateContentItem(objContent); // Update Terms var cntTerm = new Terms(); cntTerm.ManageQuestionTerms(objEntity, objContent); }