Click or drag to resize
Dwx Import Export

This examples show how to import or export adrchive 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
    {
        static public void ExportDocumentAsDwx(Document selfDoc)
        {
            string fileName = Guid.NewGuid().ToString() + ".dwx";

            using (FileStream fs = new FileStream(fileName, FileMode.OpenOrCreate))
            {
                using (Stream 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
    {
        static public void ExportResultDocumentsAsDwx(Dialog dialog)
        {
            var documents = dialog.Query.PostToDialogExpressionRelationForDocumentsQueryResult(new DialogExpression()
            {
            });

            using (Stream stream = documents.PostToExportDocumentsRelationForStream(new ExportSettings() { ExportTextshots = true, ExportHistory = true }))
            {
                using (FileStream 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
    {
        static public 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
    {
        static public void ImportDocumentAndCheckResult(FileCabinet cabinet)
        {
            FileInfo fileInfo = new FileInfo("FullPath.dwx");

            ImportResult importResult = cabinet.ImportArchive(fileInfo);

            for (int 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