Click or drag to resize
Transfer Documents

These examples show how you can transfer documents between document trays and cabinets and between two different file cabinets.

In order to transfer documents, you must specify the source file cabinet or basket and the destination file cabinet or basket. Further you must specify the documents with the index data to transfer.

The two examples show how you copy documents keeping the index data of the source documents and how to copy documents while specifying new indexdata. Both operations can be executed synchronously and asynchronously.

Transfer Documents from a Document Tray to a File Cabinet

This example shows how you can transfer documents from a document tray to a file cabinet (or to an other document tray). There should be at least one field in the source document that exists in the destination cabinet.

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DocuWare.Platform.ServerClient;

namespace DocuWare.PlatformClientExamples
{
    static partial class Examples
    {
        static public DocumentsQueryResult TransferFromBasketToFileCabinet(
            List<int> documentIds, 
            string basketId, 
            FileCabinet fileCabinet)
        {
            var transferInfo = new FileCabinetTransferInfo()
            {
                KeepSource = true,
                SourceDocId = documentIds,
                SourceFileCabinetId = basketId,
            };

            return fileCabinet.PostToTransferRelationForDocumentsQueryResult(transferInfo);
        }

    }
}
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DocuWare.Platform.ServerClient;

namespace DocuWare.PlatformClientExamples
{
    static partial class ExamplesAsync
    {
        static async public Task<DocumentsQueryResult> TransferFromBasketToFileCabinet(
            List<int> documentIds, 
            string basketId, 
            FileCabinet fileCabinet)
        {
            var transferInfo = new FileCabinetTransferInfo()
            {
                KeepSource = true,
                SourceDocId = documentIds,
                SourceFileCabinetId = basketId,
            };

            return await fileCabinet.PostToTransferRelationForDocumentsQueryResultAsync(transferInfo);
        }

    }
}
Transfer a Document from a Document Tray to a File Cabinet

This example shows how you can transfer documents from one file cabinet to another file cabinet specifing the index data.

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DocuWare.Platform.ServerClient;

namespace DocuWare.PlatformClientExamples
{
    static partial class Examples
    {
        static public DocumentsQueryResult TransferBetweenCabinetsWithFields(
            Document sourceDocument, 
            string sourceCabinetId, 
            FileCabinet destCabinet)
        {
            //Create Document with fields from the destination cabinet.
            var transferInfo = new DocumentsTransferInfo()
            {
                Documents = new List<Document>() { sourceDocument },
                KeepSource = false,
                SourceFileCabinetId = sourceCabinetId
            };

            return destCabinet.PostToTransferRelationForDocumentsQueryResult(transferInfo);
        }


        static public DocumentsQueryResult TransferBetweenCabinetsWithFields(
            int sourceDocId, 
            string sourceCabinetId, 
            FileCabinet destCabinet)
        {
            //Create Document with fields from the destination cabinet.
            var sourceDocument = new Document
            {
                Id = sourceDocId,
                Fields = new List<DocumentIndexField> 
                { 
                    DocumentIndexField.Create("COMPANY", "My Company"), 
                    DocumentIndexField.Create("SUBJECT", "Holiday hotel booking")
                }
            };

            var transferInfo = new DocumentsTransferInfo()
            {
                Documents = new List<Document>() { sourceDocument },
                KeepSource = false,
                SourceFileCabinetId = sourceCabinetId
            };

            return destCabinet.PostToTransferRelationForDocumentsQueryResult(transferInfo);
        }
    }
}
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DocuWare.Platform.ServerClient;

namespace DocuWare.PlatformClientExamples
{
    static partial class ExamplesAsync
    {
        static public async Task<DocumentsQueryResult> TransferBetweenCabinetsWithFieldsAsync(
            Document sourceDocument, 
            string sourceCabinetId, 
            FileCabinet destCabinet)
        {
            // In case the file cabinets have the same field names, we can just start copying the documents.
            var transferInfo = new DocumentsTransferInfo()
            {
                Documents = new List<Document>() { sourceDocument },
                KeepSource = false,
                SourceFileCabinetId = sourceCabinetId
            };

            return await destCabinet.PostToTransferRelationForDocumentsQueryResultAsync(transferInfo);            
        }


        static async public Task<DocumentsQueryResult> TransferBetweenCabinetsWithFieldsAsync(
            int sourceDocId, 
            string sourceCabinetId, 
            FileCabinet destCabinet)
        {
            //Create Document with fields from the destination cabinet.
            var sourceDocument = new Document
            {
                Id = sourceDocId,
                Fields = new List<DocumentIndexField> 
                { 
                    DocumentIndexField.Create("COMPANY", "My Company"), 
                    DocumentIndexField.Create("SUBJECT", "Holiday hotel booking")
                }
            };

            var transferInfo = new DocumentsTransferInfo()
            {
                Documents = new List<Document>() { sourceDocument },
                KeepSource = false,
                SourceFileCabinetId = sourceCabinetId
            };

            return await destCabinet.PostToTransferRelationForDocumentsQueryResultAsync(transferInfo);
        }
    }
}