Show / Hide Table of Contents

    Delete a Document

    To delete a document you just need to call the document endpoint with a DELETE request which is represented in the platform client through the method DeleteSelfRelation.
    Following the examples.

    Delete Example

    public static string DeleteDocumentById(FileCabinet fileCabinet, string id)
    {
        Dialog search = fileCabinet.GetDialogFromCustomSearchRelation();
    
        Document documentToDelete = search.GetDialogFromSelfRelation().GetDocumentsResult(new DialogExpression()
        {
            Start = 0,
            Count = 1,
            Condition = new List<DialogExpressionCondition>(new List<DialogExpressionCondition>
            {
                new DialogExpressionCondition
                {
                    Value = new List<string>() {id},
                    DBName = "DWDOCID"
                }
            }),
            Operation = DialogExpressionOperation.And
        }).Items.FirstOrDefault() ?? throw new InvalidOperationException();
    
        return documentToDelete.DeleteSelfRelation();
    }
    

    Trash Bin Examples

    Since DocuWare Version 7.8, it isn't possible to delete a document directly.
    Every document first gets placed into the trash bin.

    List Documents which are in the Trash Bin

    public static TrashBinDocumentsTableResult GetTrashBinDocumentsTableResult(Organization org)
    {
        TrashBin trashBin = org.GetTrashBinFromTrashBinRelation();
    
        TrashBinQuery trashBinQuery = new TrashBinQuery
            { 
                Start = 0, 
                Count = 10
            };
    
        return trashBin.PostToQueryDocumentsRelationForTrashBinDocumentsTableResult(trashBinQuery);
    }
    

    Delete a Document from the Trash Bin

    public static void DeleteOneDocument(Organization org)
    {
        TrashBin trashBin = org.GetTrashBinFromTrashBinRelation();
    
        trashBin.PostToBatchDeleteRelationForBatchDeleteResult(
            new BatchDeleteDocumentsSource()
            {
                Id = new List<string>()
                {
                    "tr_00000000-0000-0000-0000-000000000000-1"
                }
            });
    }
    

    Delete first 100 Documents from the Trash Bin

    public static void BatchDelete(Organization org)
    {
        TrashBin trashBin = org.GetTrashBinFromTrashBinRelation();
    
        TrashBinDocumentsTableResult trashBinTableResult = trashBin.PostToQueryDocumentsRelationForTrashBinDocumentsTableResult(new TrashBinQuery { Count = 100 });
    
        trashBin.PostToBatchDeleteRelationForBatchDeleteResult(
            new BatchDeleteDocumentsSource()
            {
                Id = trashBinTableResult.Rows.Select(r => r.Id.ToString()).ToList()
            });
    }
    

    Delete all Documents from the Trash Bin

    public static void DeleteAllByBatches(Organization org)
    {
        TrashBin trashBin = org.GetTrashBinFromTrashBinRelation();
    
        TrashBinDocumentsTableResult trashBinTableResult;
    
        do
        {
            trashBinTableResult = trashBin.PostToQueryDocumentsRelationForTrashBinDocumentsTableResult(new TrashBinQuery { Count = 100 });
    
            trashBin.PostToBatchDeleteRelationForBatchDeleteResult(
                new BatchDeleteDocumentsSource()
                {
                    Id = trashBinTableResult.Rows.Select(r => r.Id.ToString()).ToList()
                });
        } while (trashBinTableResult.NextRelationLink != null);
    }
    

    Restore a Document from the Trash Bin

    public static void RestoreOneDocument(Organization org)
    {
        TrashBin trashBin = org.GetTrashBinFromTrashBinRelation();
    
        trashBin.PostToBatchRestoreRelationForBatchRestoreResult(
            new BatchDeleteDocumentsSource()
            {
                Id = new List<string>()
                {
                    "tr_00000000-0000-0000-0000-000000000000-1"
                }
            });
    }
    

    Restore first 100 Documents from the Trash Bin

    public static void BatchRestore(Organization org)
    {
        TrashBin trashBin = org.GetTrashBinFromTrashBinRelation();
    
        TrashBinDocumentsTableResult trashBinTableResult = trashBin.PostToQueryDocumentsRelationForTrashBinDocumentsTableResult(new TrashBinQuery { Count = 100 });
    
        trashBin.PostToBatchRestoreRelationForBatchRestoreResult(
            new BatchRestoreDocumentsSource()
            {
                Id = trashBinTableResult.Rows.Select(r => r.Id.ToString()).ToList()
            });
    }
    

    Restore all Documents from the Trash Bin

    public static void RestoreAllByBatches(Organization org)
    {
        TrashBin trashBin = org.GetTrashBinFromTrashBinRelation();
    
        TrashBinDocumentsTableResult trashBinTableResult;
    
        do
        {
            trashBinTableResult = trashBin.PostToQueryDocumentsRelationForTrashBinDocumentsTableResult(new TrashBinQuery { Count = 100 });
    
            trashBin.PostToBatchRestoreRelationForBatchRestoreResult(
                new BatchRestoreDocumentsSource()
                {
                    Id = trashBinTableResult.Rows.Select(r => r.Id.ToString()).ToList()
                });
        } while (trashBinTableResult.NextRelationLink != null);
    }
    
    About Us Contact Imprint Terms Data privacy
    © 2024 DocuWare Corporation powered by DocFX Back to top