Dwx Import Export
This examples show how to import or export archive packages through the Platform.
Export a document as archive
C#
using DocuWare.Platform.ServerClient;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DocuWare.PlatformClientExamples
{
static partial class Examples
{
public static void ExportDocumentAsDwx(Document selfDoc)
{
string fileName = Guid.NewGuid().ToString() + ".dwx";
using (var fs = new FileStream(fileName, FileMode.OpenOrCreate))
{
using (var download = selfDoc.PostToDownloadAsArchiveRelationForStream(new ExportSettings() { ExportTextshots = true }))
{
download.CopyTo(fs);
}
}
}
}
}
Export Result Documents
C#
using DocuWare.Platform.ServerClient;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DocuWare.PlatformClientExamples
{
static partial class Examples
{
public static void ExportResultDocumentsAsDwx(Dialog dialog)
{
var documents = dialog.Query.PostToDialogExpressionRelationForDocumentsQueryResult(new DialogExpression()
{
});
using (var stream = documents.PostToExportDocumentsRelationForStream(new ExportSettings() { ExportTextshots = true, ExportHistory = true }))
{
using (var fileStream = new FileStream("c:\\TextExport.dwx", FileMode.Create))
{
stream.CopyTo(fileStream);
}
}
}
}
}
Import an archive
C#
using DocuWare.Platform.ServerClient;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DocuWare.PlatformClientExamples
{
static partial class Examples
{
public static void ImportDocument(FileCabinet cabinet)
{
FileInfo fileInfo = new FileInfo("FullPath.dwx");
ImportResult importResult = cabinet.ImportArchive(fileInfo);
}
}
}
Import an archive and check the result
C#
using DocuWare.Platform.ServerClient;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DocuWare.PlatformClientExamples
{
static partial class Examples
{
public static void ImportDocumentAndCheckResult(FileCabinet cabinet)
{
var fileInfo = new FileInfo("FullPath.dwx");
ImportResult importResult = cabinet.ImportArchive(fileInfo);
for (var i = 0; i < importResult.Results.Count; i++)
{
ImportResultEntry resultEntry = importResult.Results[i];
switch (resultEntry.Status)
{
case ImportEntryStatus.Succeeded:
{
// do something with the imported documents
// it is a list of all versions imported
List<ImportEntryVersion> importedDocumentsIds = resultEntry.EntryVersions;
break;
}
case ImportEntryStatus.Failed:
{
string msg = resultEntry.ErrorMessage;
int documentPosition = i; // this is the original document position from the package
// check the error message or store it
break;
}
}
}
}
}
}
See Also
Reference
ExportSettings ImportResult ImportResultEntry ImportEntryStatus