Click or drag to resize
Get all Documents of a Basket or File Cabinet

This example shows you how you can access all documents of a basket or a file cabinet. This is basically the same operation, because a basket and a file cabinet are very similar structures.

In order to get all documents of a basket or file cabinet, you can use the GetFromDocumentsForDocumentsQueryResultAsync extension method. You can provide optional parameters where you can set the number of documents to be returned or which fields you want to have.

In the following example we use only the count parameter in order to specify that we want to get all documents of a file cabinet.

Note Note

You should not try to get all items of a file cabinet in a production environment. Rather specify a reasonable value for the count parameter, e.g. count: 1000.

List all documents of a File Cabinet or Web Basket
C#
using System;
using System.Collections.Generic;
using System.Linq;
using DocuWare.Platform.ServerClient;

namespace DocuWare.PlatformClientExamples
{
    static partial class Examples
    {
        public static DocumentsQueryResult ListAllDocuments(ServiceConnection conn, string fileCabinetId, int? count = int.MaxValue)
        {
            DocumentsQueryResult queryResult = conn.GetFromDocumentsForDocumentsQueryResultAsync(
                fileCabinetId,
                count: count).Result;
            foreach (var document in queryResult.Items)
            {
                Console.WriteLine("Document {0} created at {1}", document.Id, document.CreatedAt);
            }
            return queryResult;
        }
    }
}
List all documents of a File Cabinet or Web Basket asynchronously
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DocuWare.Platform.ServerClient;

namespace DocuWare.PlatformClientExamples
{
    static partial class ExamplesAsync
    {
        public static async Task<DocumentsQueryResult> ListAllDocumentsAsync(ServiceConnection conn, string fileCabinetId, int? count = int.MaxValue)
        {
            DocumentsQueryResult queryResult = await conn.GetFromDocumentsForDocumentsQueryResultAsync(
                fileCabinetId,
                count: count);
            foreach (var document in queryResult.Items)
            {
                Console.WriteLine("Document {0} created at {1}", document.Id, document.CreatedAt);
            }
            return queryResult;
        }
    }
}