public GetAnnotationsIBMResponse GetAnnotationsIBM(GetAnnotationsIBMRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            // Must have the documentId you'd like to add annotations to.
            // If you only have the document cache URI, DocumentFactory.LoadFromUri needs to be called.
            if (string.IsNullOrEmpty(request.DocumentId))
            {
                throw new ArgumentNullException("documentId");
            }

            // The IBM annotations will be stored here (key: GUID, value: XML string).
            Dictionary <AnnHistoryItemState, Dictionary <string, string> > ibmObjects = null;

            var cache = ServiceHelper.Cache;

            using (var document = DocumentFactory.LoadFromCache(cache, request.DocumentId))
            {
                // Ensure we have the document.
                DocumentHelper.CheckLoadFromCache(document);

                // Use the history to return all added, modified, and deleted IBM annotations.
                ibmObjects = ProcessAnnotationsHistory(document);
            }

            // Here (if defined) we send the converted annotations to disk as an example.
            if (ibmObjects != null && _processToDiskRoot != null)
            {
                try
                {
                    string dir = _processToDiskRoot + "/" + request.DocumentId;
                    ProcessToDisk(dir, ibmObjects);
                }
                catch (Exception e)
                {
                    Trace.WriteLine(string.Format("Failed to process converted annotations to disk: {0}", e.Message));
                }
            }

            GetAnnotationsIBMResponse response = new GetAnnotationsIBMResponse();

            if (ibmObjects != null)
            {
                // See #REF IBM_Annotations_Support
                if (ibmObjects.ContainsKey(AnnHistoryItemState.Added))
                {
                    response.Added = ibmObjects[AnnHistoryItemState.Added];
                }
                if (ibmObjects.ContainsKey(AnnHistoryItemState.Modified))
                {
                    response.Modified = ibmObjects[AnnHistoryItemState.Modified];
                }
                if (ibmObjects.ContainsKey(AnnHistoryItemState.Deleted))
                {
                    response.Deleted = ibmObjects[AnnHistoryItemState.Deleted];
                }
            }

            return(response);
        }
예제 #2
0
            public async Task <Result <GetAnnotationsIBMResponse> > GetAnnotationsIBM(GetAnnotationsIBMRequest request)
            {
                const string api    = "api/Annotations/GetAnnotationsIBM";
                var          result = await _owner.PostAsync <GetAnnotationsIBMRequest, GetAnnotationsIBMResponse>(api, request);

                return(result);
            }