Click or drag to resize
Application Properties

This sample shows hot to store, update and delete application properties.

Some DocuWare client applications may need to store additional information. This could be achieved by storing that information in as application properties on document level.

Store, Update and Delete Application Properties
C#
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DocuWare.Platform.ServerClient;

namespace DocuWare.PlatformClientExamples
{
    static partial class Examples
    {
        /// <summary>
        /// Stores, updates and deletes application properties.
        /// </summary>
        public static void ApplicationProperties(Document newDocument, FileCabinet cabinet)
        {
            FileInfo[] filesInfo = new FileInfo[] { new FileInfo("2Pages.pdf"), new FileInfo("2Pages.pdf")};

            // add application properties on upload
            newDocument.ApplicationProperties = new List<DocumentApplicationProperty>();
            newDocument.ApplicationProperties.Add(new DocumentApplicationProperty() { Name = "key1", Value = "Best Value" });
            newDocument.ApplicationProperties.Add(new DocumentApplicationProperty() { Name = "key2", Value = "For Delete" });

            // upload the document and retrieve it
            newDocument = cabinet.UploadDocument(newDocument, filesInfo);
            newDocument = newDocument.GetDocumentFromSelfRelation();

            DocumentApplicationProperties properties = new DocumentApplicationProperties();
            properties.DocumentApplicationProperty = new List<DocumentApplicationProperty>();

            // update application properties
            properties.DocumentApplicationProperty.Add(new DocumentApplicationProperty() { Name = "key1", Value = "UpdatedValue" });
            properties.DocumentApplicationProperty.Add(new DocumentApplicationProperty() { Name = "key3", Value = "NewValue" });

            // delete existing application property
            properties.DocumentApplicationProperty.Add(new DocumentApplicationProperty() { Name = "key2", Value = null });

            // update application properties
            newDocument.PostToAppPropertiesRelationForDocumentApplicationProperties(properties);
        }
    }
}