November Happy Hour will be moved to Thursday December 5th.

Class DataImporter

Import pages from binary format

Inheritance
System.Object
DataImporter
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Enterprise
Assembly: EPiServer.Enterprise.dll
Version: 9.12.2
Syntax
[ServiceConfiguration(typeof(IDataImporter), Lifecycle = ServiceInstanceScope.Transient)]
public class DataImporter : ExportImportBase, ITransferContext, IContentTransferContext, ITransferHandlerContext, IDataImporter
Examples

An example that demonstrates how to import a package that has been exported with the DataExporter class. The package is imported directly under the root page in the destination site.

Constructors

DataImporter()

Initializes a new instance of the DataImporter class

Declaration
public DataImporter()

DataImporter(PropertyContentReferenceListTransform, PropertyJsonTransform)

Declaration
[Obsolete("Use alternative constructor")]
public DataImporter(PropertyContentReferenceListTransform propertyContentReferenceListTransform, PropertyJsonTransform propertyJsonTransform)
Parameters
Type Name Description
PropertyContentReferenceListTransform propertyContentReferenceListTransform
PropertyJsonTransform propertyJsonTransform

DataImporter(PropertyContentReferenceListTransform, PropertyJsonTransform, IContentCacheRemover)

Declaration
[Obsolete("Use alternative constructor")]
public DataImporter(PropertyContentReferenceListTransform propertyContentReferenceListTransform, PropertyJsonTransform propertyJsonTransform, IContentCacheRemover contentCacheRemover)
Parameters
Type Name Description
PropertyContentReferenceListTransform propertyContentReferenceListTransform
PropertyJsonTransform propertyJsonTransform
IContentCacheRemover contentCacheRemover

DataImporter(PropertyContentReferenceListTransform, PropertyJsonTransform, IContentCacheRemover, IPrincipalAccessor)

Declaration
[Obsolete("Use alternative constructor")]
public DataImporter(PropertyContentReferenceListTransform propertyContentReferenceListTransform, PropertyJsonTransform propertyJsonTransform, IContentCacheRemover contentCacheRemover, IPrincipalAccessor principalAccessor)
Parameters
Type Name Description
PropertyContentReferenceListTransform propertyContentReferenceListTransform
PropertyJsonTransform propertyJsonTransform
IContentCacheRemover contentCacheRemover
IPrincipalAccessor principalAccessor

DataImporter(IContentCacheRemover, IPrincipalAccessor, IDataImportEvents, IDataImportEventsRaiser, IContentRepository, IPermanentLinkMapper, IContentTypeRepository, ContentTypeAvailabilityService, IAvailableSettingsRepository, IContentTransfer, IContentTransferValidator)

Declaration
public DataImporter(IContentCacheRemover contentCacheRemover, IPrincipalAccessor principalAccessor, IDataImportEvents dataImportEvents, IDataImportEventsRaiser eventRaiser, IContentRepository contentRepository, IPermanentLinkMapper permanentLinkMapper, IContentTypeRepository contentTypeRepository, ContentTypeAvailabilityService contentTypeAvailabilityService, IAvailableSettingsRepository availableSettingsRepository, IContentTransfer contentTransfer, IContentTransferValidator contentTransferValidator)
Parameters
Type Name Description
IContentCacheRemover contentCacheRemover
IPrincipalAccessor principalAccessor
IDataImportEvents dataImportEvents
IDataImportEventsRaiser eventRaiser
IContentRepository contentRepository
IPermanentLinkMapper permanentLinkMapper
IContentTypeRepository contentTypeRepository
ContentTypeAvailabilityService contentTypeAvailabilityService
IAvailableSettingsRepository availableSettingsRepository
IContentTransfer contentTransfer
IContentTransferValidator contentTransferValidator

Properties

AutoDetectCulture

Gets or sets a value indicating whether [auto detect culture].

Declaration
public bool AutoDetectCulture { get; set; }
Property Value
Type Description
System.Boolean

true if [auto detect culture]; otherwise, false.

IgnoreDynamicProperties

If dynamic properties in import packages should be ignored

Declaration
public bool? IgnoreDynamicProperties { get; set; }
Property Value
Type Description
System.Nullable<System.Boolean>

If value is not set the default value will be based on if dynamic properties are enabled or not in configuration

ImportedVppFiles

Gets or sets a value indicating whether the importer imported vpp based files.

Declaration
public bool ImportedVppFiles { get; set; }
Property Value
Type Description
System.Boolean

true if vpp based files where imported; otherwise, false.

NumberOfPagesToImport

Gets or sets the all the pages to import.

Declaration
public int NumberOfPagesToImport { get; }
Property Value
Type Description
System.Int32

The number of pages to import.

NumberOfVisitorGroupToImport

Gets or sets the number of visitor group to import.

Declaration
public int NumberOfVisitorGroupToImport { get; }
Property Value
Type Description
System.Int32

The number of visitor group to import.

Status

Contains continuosly updates of the import process

Declaration
public IImportStatus Status { get; }
Property Value
Type Description
IImportStatus

Methods

ExsistLegacyFileInThePackage()

Declaration
public virtual bool ExsistLegacyFileInThePackage()
Returns
Type Description
System.Boolean

Import()

Execute the import.

Declaration
public virtual void Import()

Import(Stream, ContentReference, ImportOptions)

Imports the import packages specified by System.IO.Stream

Declaration
public ITransferLog Import(Stream stream, ContentReference destinationRoot, ImportOptions options)
Parameters
Type Name Description
System.IO.Stream stream

The stream to the import package

ContentReference destinationRoot

The root where content items will be imported under

ImportOptions options

Options that specify settings for the import

Returns
Type Description
ITransferLog

A logger with result

Remarks

Potential errors and warnings are logged to returned logger

Continuous progress can be retreieved from Status.

ImportFile(IFileTransferObject, ZipPackage)

Declaration
protected void ImportFile(IFileTransferObject metaData, ZipPackage package)
Parameters
Type Name Description
IFileTransferObject metaData
System.IO.Packaging.ZipPackage package

InternalImportLive(IFileTransferObject, ZipPackage)

Declaration
protected void InternalImportLive(IFileTransferObject metaData, ZipPackage package)
Parameters
Type Name Description
IFileTransferObject metaData
System.IO.Packaging.ZipPackage package

OnImportProperty(TransformPropertyEventArgs)

Raises the ImportPropertyEvent event.

Declaration
public override void OnImportProperty(TransformPropertyEventArgs e)
Parameters
Type Name Description
TransformPropertyEventArgs e

The TransformPropertyEventArgs instance containing the event data to import a property.

Overrides

OnResolveFileTransferType(ResolveFileTransferTypeArgs)

Raises the ResolveFileTransferType event.

Declaration
protected virtual void OnResolveFileTransferType(ResolveFileTransferTypeArgs e)
Parameters
Type Name Description
ResolveFileTransferTypeArgs e

The e.

Events

ContentImported

Occurs after a page has been imported

Declaration
[Obsolete("Use IDataImporterEvents to register to event handlers")]
public static event ContentImportedEventHandler ContentImported
Event Type
Type Description
ContentImportedEventHandler

ContentImporting

Occurs before a content item is imported

Declaration
[Obsolete("Use IDataImporterEvents to register to event handlers")]
public static event ContentImportingEventHandler ContentImporting
Event Type
Type Description
ContentImportingEventHandler

FileImported

Occurs after a file has been imported

Declaration
[Obsolete("Use IDataImporterEvents to register to event handlers")]
public static event FileImportedEventHandler FileImported
Event Type
Type Description
FileImportedEventHandler

FileImporting

Occurs before a file is imported

Declaration
[Obsolete("Use IDataImporterEvents to register to event handlers")]
public static event FileImportingEventHandler FileImporting
Event Type
Type Description
FileImportingEventHandler

Imported

Occurs after an export package has been imported.

Declaration
[Obsolete("Use IDataImporterEvents to register to event handlers")]
public static event EventHandler Imported
Event Type
Type Description
System.EventHandler
Remarks

The source of the event is the actual DataImporter used for the event which provides more information.

Importing

Occurs before an export package will be imported.

Declaration
[Obsolete("Use IDataImporterEvents to register to event handlers")]
public static event EventHandler Importing
Event Type
Type Description
System.EventHandler

ImportingPages

Occurs after the pages to be imported have been determined, but before they are populated with information and published.

Declaration
[Obsolete("Use IDataImporterEvents to register to event handlers")]
public static event EventHandler ImportingPages
Event Type
Type Description
System.EventHandler
Remarks

The source of the event is the actual DataImporter used for the event which provides more information.

ImportPropertyEvent

Event to handle the import of properties. To add an import transformation for for a property you have to add a event handler for it:

ImportPropertyEvent += new EventHandler<TransformPropertyEventArgs>(MyProperty.ExportEventHandler);
public static void ExportEventHandler(object sender, TransformPropertyEventArgs e)

{ IContentTransferContext transferContext = sender as IContentTransferContext; if (transferContext == null // The transfer context should not be null || e == null // The event args shuld exists
|| e.IsHandled // and not be handled by another handler || e.PropertySource == null // and the property type should be the correct type. || e.PropertySource.TypeName == null || e.PropertySource.TypeName.CompareTo("Development.MyProperty") != 0) { return; }

//TODO: Write import transformation code for MyProperty

e.IsHandled = true; // Signal that its handled to all other Export event handlers. }

Declaration
[Obsolete("Use IDataImporterEvents to register to event handlers")]
public static event EventHandler<TransformPropertyEventArgs> ImportPropertyEvent
Event Type
Type Description
System.EventHandler<TransformPropertyEventArgs>

PageImported

Occurs after a page has been imported

Declaration
[Obsolete("Use ContentImported instead")]
public static event PageImportedEventHandler PageImported
Event Type
Type Description
PageImportedEventHandler

PageImporting

Occurs before a page is imported

Declaration
[Obsolete("Use ContentImporting instead")]
public static event PageImportingEventHandler PageImporting
Event Type
Type Description
PageImportingEventHandler

ResolveFileTransferType

Occurs to resolve a IFileTransferObject implementation during deserialize of a file.

Declaration
public static event EventHandler<ResolveFileTransferTypeArgs> ResolveFileTransferType
Event Type
Type Description
System.EventHandler<ResolveFileTransferTypeArgs>

Implements

Extension Methods