コード例 #1
0
            public async Task <Result <LoadFromCacheResponse> > LoadFromCache(LoadFromCacheRequest request)
            {
                const string api      = "api/Factory/LoadFromCache";
                var          response = await _owner.PostAsync <LoadFromCacheRequest, LoadFromCacheResponse>(api, request);

                return(response);
            }
コード例 #2
0
        public LoadFromCacheResponse LoadFromCache(LoadFromCacheRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            var cache = ServiceHelper.Cache;

            using (var document = DocumentFactory.LoadFromCache(cache, request.DocumentId))
            {
                // Return null if the document does not exist in the cache
                // If you want to throw an error then call:
                // DocumentHelper.CheckLoadFromCache(document);

                if (document != null && document.CacheStatus == DocumentCacheStatus.NotSynced)
                {
                    // This means this document was uploaded and never loaded, make sure it does not delete itself after we dispose it and perform the same action as if
                    // a document was loaded from a URI
                    CacheController.TrySetCacheUri(document);

                    if (ServiceHelper.AutoUpdateHistory)
                    {
                        document.History.AutoUpdate = true;
                    }

                    ServiceHelper.SetRasterCodecsOptions(document.RasterCodecs, (int)document.Pages.DefaultResolution);
                    document.AutoDeleteFromCache  = false;
                    document.AutoDisposeDocuments = true;
                    document.AutoSaveToCache      = false;
                    document.SaveToCache();
                }

                return(new LoadFromCacheResponse {
                    Document = document
                });
            }
        }