Transfer Documents
These examples show how you can copy documents between document trays and cabinets and how to move them between two different file cabinets.
In order to perform these operations, 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.
The two examples show how you copy documents keeping the index data of the source documents and how to move documents while specifying new index data. Both operations can be executed synchronously and asynchronously.
Copy Documents from a Document Tray to a File Cabinet
This example shows how you can copy documents from a document tray to a file cabinet (or to another document tray). There should be at least one field in the source document that exists in the destination file 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
{
public static 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
{
public static async 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).ConfigureAwait(false);
}
}
}
Move a Document from a File Cabinet to a File Cabinet
This example shows how you can move documents from one file cabinet to another file cabinet specifying 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
{
public static 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);
}
public static 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
{
public static 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).ConfigureAwait(false);
}
public static async 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).ConfigureAwait(false);
}
}
}