コード例 #1
0
 public static void GetAndStoreHtmlBlobs(HtmlBlobType htmlBlobType, Dictionary <Uri, string> items, [Optional] bool forceOverwrite)
 {
     foreach (Uri uri in items.Keys)
     {
         HtmlBlob.GetAndStoreHtmlBlob(htmlBlobType, items[uri], uri, forceOverwrite);
     }
 }
コード例 #2
0
        public static string RetrieveBlob(HtmlBlobType htmlBlobType, string htmlBlobId, Uri uri, bool getIfNotExists = false)
        {
            // Get the blob if it doesn't exist
            if (getIfNotExists == true)
            {
                // This method will not do anything if the blob already exists
                HtmlBlob.GetAndStoreHtmlBlob(htmlBlobType, htmlBlobId, uri);
            }

            string         blobName       = HtmlBlob.ConstructBlobName(htmlBlobType, htmlBlobId, uri);
            CloudBlockBlob cloudBlockBlob = HtmlBlob.CloudBlobContainer.GetBlockBlobReference(blobName);

            string result = null;

            try
            {
                result = cloudBlockBlob.DownloadText();
            }
            catch (System.AggregateException e)
            {
                HtmlBlob.PrintGetHtmlPageException(cloudBlockBlob.SnapshotQualifiedUri, e);

                bool is404Exception = e.InnerExceptions.Where(ie =>
                                                              ie.GetType() == typeof(HttpRequestException) &&
                                                              ie.Message.IndexOf("404 (Not Found).", StringComparison.InvariantCultureIgnoreCase) >= 0).Any();

                if (!is404Exception)
                {
                    //throw;
                }
            }
            catch (Exception e)
            {
                HtmlBlob.PrintGetHtmlPageException(cloudBlockBlob.SnapshotQualifiedUri, e);
                //throw;
            }

            return(result);
        }