コード例 #1
0
        public static IEnumerable <DataRow> CopyVirtualContents(int sourceSiteId, int destinationSiteId)
        {
            var newContents   = ContentRepository.CopyVirtualContents(sourceSiteId, destinationSiteId).ToList();
            var newContentIds = string.Join(",", newContents.Select(r => r.Field <int>("content_id_new")));

            FieldRepository.CopyContentsAttributes(sourceSiteId, destinationSiteId, newContentIds, true);

            var relBetweenAttributes = FieldRepository.GetRelationsBetweenAttributesXml(sourceSiteId, destinationSiteId, string.Empty, null, true);

            if (string.IsNullOrEmpty(newContentIds))
            {
                newContentIds = "0";
            }

            FieldRepository.UpdateAttributes(sourceSiteId, destinationSiteId, relBetweenAttributes, newContentIds);
            ContentRepository.CopyUnionContents(sourceSiteId, destinationSiteId, newContentIds);
            ContentRepository.UpdateVirtualContentAttributes(sourceSiteId, destinationSiteId);

            FieldRepository.UpdateAttributesOrder(destinationSiteId, relBetweenAttributes, newContentIds);

            ContentRepository.CopyContentsGroups(sourceSiteId, destinationSiteId);
            ContentRepository.UpdateContentGroupIds(sourceSiteId, destinationSiteId);

            var relBetweenContents = ContentRepository.GetRelationsBetweenContentsXml(sourceSiteId, destinationSiteId, string.Empty);

            ContentRepository.CopyUserQueryContents(relBetweenContents);

            ContentRepository.CopyUserQueryAttributes(relBetweenContents, relBetweenAttributes);

            return(newContents);
        }