At first copy / move the document from the basket to the file cabinet (Copy index data + content). Afterwards Clip the documents inside the file cabinet.Example code:
public static void ClipDocuments()
{
// Get documents
Document docBasket = GetDocument("<<fcID>>", <<docID>);
Document docFileCabinet = GetDocument("<<fcID>>", <<docID>>);
// Get file cabinet + basket and copy document
FileCabinet basket = connection.GetFileCabinet(<<BasketID>>).GetFileCabinetFromSelfRelation();
FileCabinet fc = connection.GetFileCabinet("<<FCID>>").GetFileCabinetFromSelfRelation();
int docID = CopyFromBasketToFileCabinet(docBasket, fc);
// Clip the documents
ContentMergeOperationInfo operationInfo = new ContentMergeOperationInfo()
{
Documents = new List<int>() { docFileCabinet.Id, docID },
Force = true,
Operation = ContentMergeOperation.Clip,
};
fc.PutToContentMergeOperationRelationForDocument(operationInfo);
}
private static Document GetDocument(string FCGuid, int docID)
{
return connection.GetFromDocumentForDocumentAsync(docID, FCGuid).Result;
}
private static int CopyFromBasketToFileCabinet(Document docBasket, FileCabinet fc)
{
DialogInfo dialog = fc.GetDialogInfosFromStoresRelation().Dialog.First(d => d.FileCabinetId == fc.Id);
Document docNew = dialog.PostToStoreDocumentRelationForDocument(docBasket);
docNew.PostToSectionsRelationForSection("application/pdf", docBasket.Sections[0].GetSectionFromSelfRelation().GetStreamFromContentRelation());
return docNew.Id;
}