/// <summary> /// ContentId is required /// Also deep parameter can be used.. /// if deep is 0 then looks for the siteTagId /// If deep is smaller than 0 then it will look for the parents /// if deep is greater than 0 then it will look for childs /// if Lineage is not empty, then first the deep will be found, then the /// Lineage will be checked... /// </summary> /// <param name="?"></param> /// <returns></returns> awContent GetContent(long siteId, long contentId, string contentLineageInAlias, int deep, string cultureCode) { long contentIdToReturn = 0; if (Deep == 0) // returns the current one { contentIdToReturn = contentId; } else { awContent content = _contentLib.Get(contentId, cultureCode, true); if (content == null) { return(null); } if (deep < 0) //look for parents { if (String.IsNullOrEmpty(content.lineage)) { return(null); } string[] parentIds = content.lineage.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries); if (deep == -99 || (-1 * deep) >= parentIds.Length) //get the first one { contentIdToReturn = Convert.ToInt64(parentIds[0]); } else { contentIdToReturn = Convert.ToInt64(parentIds[parentIds.Length + Deep]); } } else if (Deep > 0) //look for childs { //TODO: Complete this. } } awContent contentToReturn = null; if (String.IsNullOrEmpty(contentLineageInAlias)) { contentToReturn = _contentLib.Get(contentIdToReturn, cultureCode, true); } else { contentToReturn = _contentLib.GetByAliasLineage(siteId, contentIdToReturn, contentLineageInAlias, cultureCode); } if (!_contentLib.IsParentsAvailable(true, contentToReturn)) { return(null); } return(contentToReturn); }
/// <summary> /// /// </summary> /// <param name="siteTagId"></param> /// <returns></returns> public AWAPI_Data.CustomEntities.ContentExtended Get(long contentId) { awContent tmp = _contentLibrary.Get(contentId); if (tmp == null) { return(null); } AWAPI_Data.CustomEntities.ContentExtended cont = new AWAPI_Data.CustomEntities.ContentExtended(); cont.contentId = tmp.contentId; cont.alias = tmp.alias; cont.title = tmp.title; cont.description = tmp.description; cont.lineage = tmp.lineage; cont.sortOrder = tmp.sortOrder; cont.pubDate = tmp.pubDate; cont.pubEndDate = tmp.pubEndDate; cont.contentType = tmp.contentType; cont.eventStartDate = tmp.eventStartDate; cont.eventEndDate = tmp.eventEndDate; cont.imageurl = tmp.imageurl; cont.isCommentable = tmp.isCommentable; cont.isEnabled = tmp.isEnabled; cont.link = tmp.link; cont.parentContentId = tmp.parentContentId; cont.lastBuildDate = tmp.lastBuildDate; cont.createDate = tmp.createDate; cont.siteId = tmp.siteId; cont.userId = tmp.userId; return(cont); }
void CopyContentFromRemoteToCurrentServer(long sourceContentId) { //GET FROM THE REMOTE AWAPI_Data.CustomEntities.ContentExtended rmt = (from l in _remoteServerContentListSource where l.contentId.Equals(sourceContentId) select l).FirstOrDefault(); //GET THE CURRENT bool addNew = false; AWAPI_Data.Data.awContent cur = _contentLib.Get(sourceContentId); if (cur == null) { addNew = true; cur = new AWAPI_Data.Data.awContent(); } cur.contentId = rmt.contentId; cur.alias = rmt.alias; cur.siteId = rmt.siteId; cur.description = rmt.description; cur.title = rmt.title; cur.isEnabled = rmt.isEnabled; cur.sortOrder = rmt.sortOrder; cur.link = rmt.link; cur.imageurl = rmt.imageurl; cur.isCommentable = rmt.isCommentable; cur.lineage = rmt.lineage; cur.parentContentId = rmt.parentContentId; cur.pubDate = rmt.pubDate; cur.pubEndDate = rmt.pubEndDate; cur.eventStartDate = rmt.eventStartDate; cur.eventEndDate = rmt.eventEndDate; cur.contentType = rmt.contentType; if (addNew) { _contentLib.Add(cur.contentId, cur.alias, cur.title, cur.description, cur.contentType, cur.siteId, App_Code.SessionInfo.CurrentUser.userId, cur.parentContentId, cur.eventStartDate, cur.eventEndDate, cur.link, cur.imageurl, cur.sortOrder, cur.isEnabled, cur.isCommentable, cur.pubDate, cur.pubEndDate); } else { _contentLib.Update(cur.contentId, cur.alias, cur.title, cur.description, cur.contentType, App_Code.SessionInfo.CurrentUser.userId, cur.parentContentId, cur.eventStartDate, cur.eventEndDate, cur.link, cur.imageurl, cur.sortOrder, cur.isEnabled, cur.isCommentable, cur.pubDate, cur.pubEndDate); } CopyContentCustomFieldsFromRemoteToCurrentServer(cur.contentId, App_Code.SessionInfo.CurrentSite.cultureCode); }