Table of Contents

Class ImportExportFacility

Namespace
ArcanaDevelopment.adTempus.Client
Assembly
ArcanaDevelopment.adTempus.Client.dll

Provides import and export facilities.

public sealed class ImportExportFacility
Inheritance
object
ImportExportFacility

Remarks

To create an ImportExportFacility, use GetImportExportFacility

Note

Only one ImportExportFacility should be active within a Scheduler session, because each call to SetSource... will destroy the cached data on the server for any other export or import operations that are in progress.

Importing Data

Importing data requires these steps:

Fields

ObjectPageSize

public int ObjectPageSize

Field Value

int

Properties

DataContext

The DataContext this object belongs to.

public DataContext DataContext { get; }

Property Value

DataContext

ImportedObjects

[CanBeNull]
public IReadOnlyList<ImportedObject> ImportedObjects { get; }

Property Value

IReadOnlyList<ImportedObject>

Messages

Gets messages returned by the most recent operation.

[NotNull]
public MessageCollection Messages { get; }

Property Value

MessageCollection

ObjectComparisonReports

Gets the ObjectComparison reports returned by ImportData if the ReturnComparisonReport is specified.

[CanBeNull]
public IReadOnlyList<ObjectComparison> ObjectComparisonReports { get; }

Property Value

IReadOnlyList<ObjectComparison>

Remarks

This member will be null if ReturnComparisonReport is not specified, or if errors occur during import.

The ObjectComparisonReportGenerator can be used to create a report based on the ObjectComparisons.

Methods

ExportData(ExportOptions, out string)

Exports data to an XML document and returns the document.

public bool ExportData(ExportOptions options, out string exportedData)

Parameters

NameTypeDescription
options ExportOptions

Options controlling the export behavior

exportedData string

Returns the export data, or null if an error occurs

Returns

bool

Remarks

This method returns the entire export document in memory. For large amounts of data, use ExportDataToFile(ExportOptions, string, CancellationToken) or ExportDataToStream(ExportOptions, Stream, CancellationToken) instead.

This method cannot be used if ExportOptions.CompressExport is true. Use ExportDataToFile(ExportOptions, string, CancellationToken) or ExportDataToStream(ExportOptions, Stream, CancellationToken) instead.

ExportDataToFile(ExportOptions, string)

Exports data and writes the results directly to a local file.

public bool ExportDataToFile(ExportOptions options, string targetFileName)

Parameters

NameTypeDescription
options ExportOptions

Options controlling the export behavior

targetFileName string

The name of the file to write the data to. This file will be created locally (on the client computer), not on the server.

Returns

bool

ExportDataToFile(ExportOptions, string, CancellationToken)

Exports data and writes the results directly to a local file.

[RequiredVersion(4, 1, 14216, 1042)]
public bool ExportDataToFile(ExportOptions options, string targetFileName, CancellationToken cancellationToken)

Parameters

NameTypeDescription
options ExportOptions

Options controlling the export behavior

targetFileName string

The name of the file to write the data to. This file will be created locally (on the client computer), not on the server.

cancellationToken CancellationToken

Cancellation Token used to cancel the export. See Remarks.

Returns

bool

Remarks

<p>Prior to version 6, the <code class="paramref">cancellationToken</code> may not produce immediate cancellation. In those versions there is no mechanism for sending a cancellation
request to the server, so the full export will always complete on the server side. Cancellation only affects the serialization of the data to the client, which can be cancelled
before it is completed.</p>
<p>Beginning with version 6, the cancellation request is sent to the server to terminate the export process.</p>

ExportDataToStream(ExportOptions, Stream)

Exports data and writes the results to a stream.

public bool ExportDataToStream(ExportOptions options, Stream targetStream)

Parameters

NameTypeDescription
options ExportOptions

Options controlling the export behavior

targetStream Stream

The stream to write the data to

Returns

bool

ExportDataToStream(ExportOptions, Stream, CancellationToken)

Exports data and writes the results to a stream.

[RequiredVersion(4, 1, 14216, 1042)]
public bool ExportDataToStream(ExportOptions options, Stream targetStream, CancellationToken cancellationToken)

Parameters

NameTypeDescription
options ExportOptions

Options controlling the export behavior

targetStream Stream

The stream to write the data to

cancellationToken CancellationToken

Cancellation Token used to cancel the export. See Remarks.

Returns

bool

Remarks

<p>Prior to version 6, the <code class="paramref">cancellationToken</code> may not produce immediate cancellation. In those versions there is no mechanism for sending a cancellation
request to the server, so the full export will always complete on the server side. Cancellation only affects the serialization of the data to the client, which can be cancelled
before it is completed.</p>
<p>Beginning with version 6, the cancellation request is sent to the server to terminate the export process.</p>

ImportData(ImportOptions, out IReadOnlyList<ImportedObject>)

Performs the import.

public ImportResult ImportData(ImportOptions options, out IReadOnlyList<ImportedObject> importedObjects)

Parameters

NameTypeDescription
options ImportOptions

Options to control the import process.

importedObjects IReadOnlyList<ImportedObject>

A collection of ImportedObject objects with information about each object imported from the source.

Returns

ImportResult

An ImportResult giving the overall result of the operation. Refer to the ImportResult for individual items in the importedObjects collection for information about the state of each object.

Remarks

You must set the import source using one of the SetSource... methods before calling ImportData.

Calling ParseImportData before importing is optional, but you must either set ImportOptions.ImportSelectionsOnly=false or include ObjectImportParameters for each object you want to import, to tell adTempus which objects to import.

If ImportOptions.ReturnComparisonReport is True, the ObjectComparisonReports collection will be set after a successful import.

ImportData(ImportOptions, CancellationToken)

Performs the import.

public ImportResult ImportData(ImportOptions options, CancellationToken cancellationToken)

Parameters

NameTypeDescription
options ImportOptions

Options to control the import process.

cancellationToken CancellationToken

Cancellation token that can be used to cancel the import. This parameter is ignored for server versions older than 6.0.

Returns

ImportResult

An ImportResult giving the overall result of the operation. Refer to the ImportResult for individual items in the ImportedObjects collection for information about the state of each object.

Remarks

You must set the import source using one of the SetSource... methods before calling ImportData.

Calling ParseImportData before importing is optional, but you must either set ImportOptions.ImportSelectionsOnly=false or include ObjectImportParameters for each object you want to import, to tell adTempus which objects to import.

If ImportOptions.ReturnComparisonReport is True, the ObjectComparisonReports collection will be set after a successful import.

ParseImportData(ImportOptions, out ImportFileInformation)

Parses the import source and returns information about its contents.

public bool ParseImportData(ImportOptions options, out ImportFileInformation fileInformation)

Parameters

NameTypeDescription
options ImportOptions

Options to control the parsing and import process.

fileInformation ImportFileInformation

On return, contains information about the import source and its contents.

Returns

bool

True if parsing was successful, or False if errors were found. Refer to the Messages collection for error information if the method returns False.

Remarks

Use this method to get information about the objects in the import source, which can then be used to set options for each object before performing the import using ImportData.

Calling ParseImportData is optional. See Remarks in ImportData.

SetSource(string)

Sets the import source from a string.

public void SetSource(string data)

Parameters

NameTypeDescription
data string

The contents of an adTempus export file.

SetSourceFromFile(string)

Sets the import source from a local file.

public void SetSourceFromFile(string fileName)

Parameters

NameTypeDescription
fileName string

The name of the file to use.

Remarks

This is the name of a file on the client. The contents of the file are streamed to the server.

SetSourceFromSnapshot(ObjectChangeLog)

Sets the source from an object snapshot.

public void SetSourceFromSnapshot(ObjectChangeLog source)

Parameters

NameTypeDescription
source ObjectChangeLog

The ObjectChangeLog representing the snapshot to use.

SetSourceFromStream(Stream)

Streams data to the server and sets the fileID to use to reference the data in subsequent calls.

public void SetSourceFromStream(Stream data)

Parameters

NameTypeDescription
data Stream

Stream containing the source data

Events

ProgressReported

public event EventHandler<ImportEventArgs> ProgressReported

Event Type

EventHandler<ImportEventArgs>