Beispiel #1
0
        /// <summary>
        /// Gets the contribution metadata that is stored within Azure storage using the hyperlink ID as the key; returns null when not found
        /// </summary>
        /// <param name="hyperlinkID">Unique identifier of the storage blob result; key used to locate the results in storage</param>
        /// <returns>Contribution data from storage; NULL when not found</returns>
        public static async Task <ResultStorage> GetContributionResultAsync(string hyperlinkID)
        {
            //- Check Parameters
            if (string.IsNullOrEmpty(hyperlinkID) == true)
            {
                throw new ArgumentNullException("hyperlinkID");
            }

            //- Get Value
            ResultFromStorage storageResult = await GetFromStorageAsync(GetContributionBlobKey(hyperlinkID));

            //- Deserialize Result
            ResultStorage result = null;

            if (storageResult.HasResult == true)
            {
                result = JsonConvert.DeserializeObject <ResultStorage>(storageResult.SerializedResult);
            }

            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// Loads the object into Azure Storage
        /// </summary>
        /// <param name="sourceResult">Metadata to be stored within the Azure storage</param>
        /// <returns>Nothing, async task</returns>
        public static async Task StoreStorageBlobAsync(ResultStorage sourceResult)
        {
            //- Check Parameters
            if (sourceResult == null)
            {
                throw new ArgumentNullException("sourceResult");
            }

            if (string.IsNullOrEmpty(sourceResult.HyperlinkID) == true)
            {
                throw new Exception("Unable to load storage result; missing hyperlink ID");
            }

            //- Check Manager
            CheckIfAvailable();

            //- Serialize
            string sourceResultSerialized = JsonConvert.SerializeObject(sourceResult);

            //- Insert Blob
            CloudBlockBlob blob = _instance._blobContainer.GetBlockBlobReference(GetContributionBlobKey(sourceResult.HyperlinkID));

            await blob.UploadTextAsync(sourceResultSerialized);
        }