예제 #1
0
        public static bool BlobExists(HtmlBlobType htmlBlobType, string htmlBlobId, Uri uri)
        {
            string         blobName       = HtmlBlob.ConstructBlobName(htmlBlobType, htmlBlobId, uri);
            CloudBlockBlob cloudBlockBlob = HtmlBlob.CloudBlobContainer.GetBlockBlobReference(blobName);

            return(cloudBlockBlob.Exists());
        }
예제 #2
0
        public static void SaveBlob(HtmlBlobType htmlBlobType, string htmlBlobId, Uri uri, string html)
        {
            string         blobName       = HtmlBlob.ConstructBlobName(htmlBlobType, htmlBlobId, uri);
            CloudBlockBlob cloudBlockBlob = HtmlBlob.CloudBlobContainer.GetBlockBlobReference(blobName);

            cloudBlockBlob.UploadText(html);
        }
예제 #3
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);
     }
 }
예제 #4
0
        public static void GetAndStoreHtmlBlob(HtmlBlobType htmlBlobType, string htmlBlobId, Uri uri, [Optional] bool forceOverwrite)
        {
            if (forceOverwrite == false && HtmlBlob.BlobExists(htmlBlobType, htmlBlobId, uri))
            {
                // Blob exists and we don't want to force an overwrite so do nothing
                return;
            }

            string htmlBlob = HtmlBlob.GetHtmlPage(uri);

            if (!String.IsNullOrWhiteSpace(htmlBlob))
            {
                HtmlBlob.SaveBlob(htmlBlobType, htmlBlobId, uri, htmlBlob);
            }
        }
예제 #5
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);
        }
예제 #6
0
 private static string ConstructBlobName(HtmlBlobType htmlBlobType, string htmlBlobId, Uri uri)
 {
     string blobName = String.Join("/", HtmlBlob.nhlBlobNamePrefix, htmlBlobType.ToString(), htmlBlobId, uri.RemoveHttpFromUri());
     return blobName;
 }
예제 #7
0
 public static void SaveBlob(HtmlBlobType htmlBlobType, string htmlBlobId, Uri uri, string html)
 {
     string blobName = HtmlBlob.ConstructBlobName(htmlBlobType, htmlBlobId, uri);
     CloudBlockBlob cloudBlockBlob = HtmlBlob.CloudBlobContainer.GetBlockBlobReference(blobName);
     cloudBlockBlob.UploadText(html);
 }
예제 #8
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;
        }
예제 #9
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);
     }
 }
예제 #10
0
        public static void GetAndStoreHtmlBlob(HtmlBlobType htmlBlobType, string htmlBlobId, Uri uri, [Optional] bool forceOverwrite)
        {
            if (forceOverwrite == false && HtmlBlob.BlobExists(htmlBlobType, htmlBlobId, uri))
            {
                // Blob exists and we don't want to force an overwrite so do nothing
                return;
            }

            string htmlBlob = HtmlBlob.GetHtmlPage(uri);

            if (!String.IsNullOrWhiteSpace(htmlBlob))
            {
                HtmlBlob.SaveBlob(htmlBlobType, htmlBlobId, uri, htmlBlob);
            }
        }
예제 #11
0
 public static bool BlobExists(HtmlBlobType htmlBlobType, string htmlBlobId, Uri uri)
 {
     string blobName = HtmlBlob.ConstructBlobName(htmlBlobType, htmlBlobId, uri);
     CloudBlockBlob cloudBlockBlob = HtmlBlob.CloudBlobContainer.GetBlockBlobReference(blobName);
     return cloudBlockBlob.Exists();
 }
예제 #12
0
        private static string ConstructBlobName(HtmlBlobType htmlBlobType, string htmlBlobId, Uri uri)
        {
            string blobName = String.Join("/", HtmlBlob.nhlBlobNamePrefix, htmlBlobType.ToString(), htmlBlobId, uri.RemoveHttpFromUri());

            return(blobName);
        }