protected virtual void ExportContentWithVerion(XmlTextWriter xml , ContentReference contentToExport , IContentTransferContext context , ITransferContentData transferContent , Action <XmlTextWriter, ContentReference, IContentTransferContext, ITransferContentData> callBackAction) { var rawContentInfo = _rawContentRetiever.CreateRawContentInfo(contentToExport, string.Empty); ContentVersion latestPublishedMasterVersion; var versions = GetContentVersions(contentToExport , rawContentInfo , out latestPublishedMasterVersion).ToList(); var rawContentRetieverEx = _rawContentRetiever as IRawContentRetrieverEx; if (versions == null || versions.Any() == false || latestPublishedMasterVersion == null) { callBackAction.Invoke(xml, contentToExport, context, transferContent); return; } foreach (var version in versions) { var versionTransferData = BuildRawTransferContent(context , null , rawContentRetieverEx , version); new XmlSerializer(typeof(TransferContentData)).Serialize(xml, versionTransferData, null); } }
protected virtual TransferContentData BuildRawTransferContent(IContentTransferContext context , List <ContentLanguageSetting> contentLanguageSettings , IRawContentRetrieverEx rawContentRetieverEx, IContent version) { var transferVersionContent = new TransferContentData() { RawContentData = rawContentRetieverEx.CreateRawContent(version) }; if (contentLanguageSettings != null) { transferVersionContent.ContentLanguageSettings = contentLanguageSettings; } PropertyExportContext propertyExportContext = new PropertyExportContext { TransferContext = context, TransferOptions = Options, Output = transferVersionContent.RawContentData, Source = version }; _propertyExporter.ExportProperties(version , transferVersionContent.RawContentData.Property , propertyExportContext); return(transferVersionContent); }
protected override void ExportContent(XmlTextWriter xml , ContentReference contentToExport , IContentTransferContext context , ITransferContentData transferContent) { if (_transferExportOptionsEx.ExportVersion) { ExportContentWithVerion(xml, contentToExport, context, transferContent, base.ExportContent); } else { base.ExportContent(xml, contentToExport, context, transferContent); } }
public ContentAreaTransform(IContentMap contentMap, ContentFragmentBuilder contentFragmentBuilder, IContentTransferContext transferContext) { _contentMap = contentMap; _contentFragmentBuilder = contentFragmentBuilder; _transferContext = transferContext; }
public ExportLinkResolver(IContentTransferContext transferContext) { _transferContext = transferContext; }
public ContentScanEventArgs(ITransferContentData transferContentData, IContentTransferContext transferContext) { _transferContentData = transferContentData; _transferContext = transferContext; }
public ExportLinkResolver(IContentTransferContext transferContext) { _transferContext = transferContext; }
public ContentAreaTransform(IContentMap contentMap, ContentFragmentBuilder contentFragmentBuilder, IContentTransferContext transferContext) { _contentMap = contentMap; _contentFragmentBuilder = contentFragmentBuilder; _transferContext = transferContext; }
public ContentScanEventArgs(ITransferContentData transferContentData, IContentTransferContext transferContext) { _transferContentData = transferContentData; _transferContext = transferContext; }
private static ContentAreaTransform CreateSubject(IContentMap contentMap = null, IContentTransferContext transferContext = null, ContentFragmentBuilder fragmentBuilder = null) { if (contentMap == null) { var mock = new Mock<IContentMap>(); mock.Setup(x => x.GetContentFunctions(It.IsAny<Guid>(), It.IsAny<string>())).Returns(EmptyContentFunctionLookup); contentMap = mock.Object; } transferContext = transferContext ?? new Mock<IContentTransferContext>().Object; fragmentBuilder = fragmentBuilder ?? new Mock<ContentFragmentBuilder>(null, null).Object; return new ContentAreaTransform(contentMap, fragmentBuilder, transferContext); }
private static ContentAreaTransform CreateSubject(IContentMap contentMap = null, IContentTransferContext transferContext = null, ContentFragmentBuilder fragmentBuilder = null) { if (contentMap == null) { var mock = new Mock <IContentMap>(); mock.Setup(x => x.GetContentFunctions(It.IsAny <Guid>(), It.IsAny <string>())).Returns(EmptyContentFunctionLookup); contentMap = mock.Object; } transferContext = transferContext ?? new Mock <IContentTransferContext>().Object; fragmentBuilder = fragmentBuilder ?? new Mock <ContentFragmentBuilder>(null, null).Object; return(new ContentAreaTransform(contentMap, fragmentBuilder, transferContext)); }
protected override IContent Import(ImportedContentData importedContentData , AccessLevel requiredDestinationAccess, IContentTransferContext context , TransferImportOptions options, out Guid importedPageGuid) { if (options.TransferType != TypeOfTransfer.Importing) { return(base.Import(importedContentData , requiredDestinationAccess , context, options, out importedPageGuid)); } CultureInfo originalSelectedLanguage = null; if (importedContentData.SelectedLanguage != null) { originalSelectedLanguage = CultureInfo.GetCultureInfo(importedContentData.SelectedLanguage.Name); } var selectedLanguageAction = importedContentData.GetType().GetProperty("SelectedLanguage"); var contentLanguage = importedContentData.GetLanguageBranch(); if (!string.IsNullOrEmpty(contentLanguage)) { selectedLanguageAction.SetValue(importedContentData, CultureInfo.GetCultureInfo(contentLanguage)); } var status = importedContentData.GetStatus(); var propSaveAction = context.GetType().GetProperty("SaveAction"); SaveAction originalSaveActions = SaveAction.Publish | SaveAction.SkipValidation; if (!string.IsNullOrEmpty(status) && int.Parse(status) < (int)VersionStatus.Published) { propSaveAction.SetValue(context, SaveAction.CheckOut | SaveAction.ForceNewVersion | SaveAction.SkipValidation); } var orgPageSaveDBChangeBy = ContextCache.Current["PageSaveDB:ChangedBy"]; var orgPageSaveDBPageSaved = ContextCache.Current["PageSaveDB:PageSaved"]; ContextCache.Current["PageSaveDB:ChangedBy"] = string.Empty; ContextCache.Current["PageSaveDB:PageSaved"] = string.Empty; try { var importedContentGuid = new Guid(importedContentData.GetContentGuid()); var handleContentGuidMethod = defaultContentImporter.GetType() .GetMethod("HandleContentGuid", BindingFlags.NonPublic | BindingFlags.Instance); var guid = (Guid)handleContentGuidMethod.Invoke( defaultContentImporter , new object[] { importedContentGuid, context }); PermanentLinkMap permanentLinkMap = permanentLinkMapper.Find(guid); var baseContent = base.Import(importedContentData , requiredDestinationAccess , context, options, out importedPageGuid); if (permanentLinkMap != null && (context.SaveAction & SaveAction.Publish) != SaveAction.Publish) { contentRepository.Save(baseContent, context.SaveAction, requiredDestinationAccess); } return(baseContent); } catch (Exception ex) { Logger.Error(ex); throw; } finally { selectedLanguageAction.SetValue(importedContentData, originalSelectedLanguage); propSaveAction.SetValue(context, originalSaveActions); ContextCache.Current["PageSaveDB:ChangedBy"] = orgPageSaveDBChangeBy; ContextCache.Current["PageSaveDB:PageSaved"] = orgPageSaveDBPageSaved; } }