void CopyContentCustomFieldsFromRemoteToCurrentServer(long contentId, string cultureCode) { string url = GetFullUrl(_serviceUrl.Text, SERVICEURL_CONTENT); AWAPI_ContentService.ContentServiceClient client = new AWAPI.AWAPI_ContentService.ContentServiceClient("basicHttp_ContentService", url); AWAPI_Data.CustomEntities.ContentCustomField[] customFields = client.GetFieldList(contentId); AWAPI_Data.CustomEntities.ContentCustomFieldValueExtended[] values = client.GetFieldValueList(contentId, cultureCode); //Add Fields if (customFields == null || customFields.Length == 0) { return; } ContentCustomFieldLibrary lib = new ContentCustomFieldLibrary(); foreach (AWAPI_Data.CustomEntities.ContentCustomField cf in customFields) { AWAPI_Data.Data.awContentCustomField fld = lib.GetField(cf.customFieldId); if (cf.fieldContentId != contentId) { break; } if (fld == null) { fld = new AWAPI_Data.Data.awContentCustomField(); } fld.contentId = contentId; fld.customFieldId = cf.customFieldId; fld.title = cf.title; fld.description = cf.description; fld.applyToSubContents = cf.applyToSubContents; fld.fieldType = cf.fieldType; fld.maximumLength = cf.maximumLength; fld.maximumValue = cf.maximumValue; fld.minimumValue = cf.minimumValue; fld.defaultValue = cf.defaultValue; fld.regularExpression = cf.regularExpression; fld.sortOrder = cf.sortOrder; fld.isEnabled = cf.isEnabled; fld.lastBuildDate = DateTime.Now; //lib.SaveField(true, fld); } //Add Values if (values != null && values.Length > 0) { foreach (AWAPI_Data.CustomEntities.ContentCustomFieldValueExtended value in values) { lib.UpdateFieldValue(value.contentId, value.customFieldId, App_Code.SessionInfo.CurrentUser.userId, value.fieldValue, ""); } } }
/// <summary> /// /// </summary> /// <param name="siteId"></param> /// <param name="siteTagId"></param> /// <param name="Lineage"></param> /// <param name="deep"></param> void GetList(long siteId, long contentId, string Lineage, int deep, string tags, string cultureCode) { awContent parentContent = GetContent(siteId, contentId, Lineage, deep, cultureCode); if (parentContent == null) { return; } StringBuilder where = new StringBuilder(); where.Append(" parentContentId=" + parentContent.contentId); if (Where.Trim() != "") { where.Append(" AND ( " + Where + " ) "); } IList <awContent> contentList = _contentLib.GetList(true, SiteId, where.ToString(), SortBy, cultureCode).ToList(); if (contentList == null || contentList.Count() == 0) { return; } //FILTER FOR TAGS if (tags.Trim().Length > 0) { IList <awContent> taggedContents = _tagLib.GetTaggedContentList(tags); if (taggedContents == null || taggedContents.Count == 0) { return; } ArrayList arrIds = new ArrayList(); foreach (awContent c in taggedContents) { arrIds.Add(c.contentId); } var taggeds = from t in contentList where arrIds.Contains(t.contentId) select t; if (taggeds == null || taggeds.ToList().Count == 0) { return; } contentList = taggeds.ToList(); } //create syndication items for each blog item AWAPI_BusinessLibrary.library.ContentCustomFieldLibrary custFieldLib = new ContentCustomFieldLibrary(); List <SyndicationItem> items = new List <SyndicationItem>(); int rowNo = 0; int startRowNo = PageIndex * PageSize; foreach (awContent content in contentList.ToList()) { //Check if paging is enabled. if (PageSize > 0) { if (rowNo < startRowNo) { rowNo++; continue; } else if (rowNo >= startRowNo + PageSize) { break; } } SyndicationItem contentItem = CreateContentSyndicationItem(content); AddCustomField(content.contentId, content.parentContentId, cultureCode, ref contentItem); items.Add(contentItem); rowNo++; } _feed.Items = items; }