Example #1
0
 private static bool TryLookupUrl(UrlType urlType, out string url)
 {
     url = null;
     // Once the internet has been found missing, don't bother trying it again for the duration of the program.
     if (!_internetAvailable)
     {
         return(false);
     }
     try
     {
         using (var s3Client = new BloomS3Client(null))
         {
             s3Client.Timeout          = TimeSpan.FromMilliseconds(2500.0);
             s3Client.ReadWriteTimeout = TimeSpan.FromMilliseconds(3000.0);
             s3Client.MaxErrorRetry    = 1;
             var  jsonContent = s3Client.DownloadFile(BloomS3Client.BloomDesktopFiles, kUrlLookupFileName);
             Urls urls        = JsonConvert.DeserializeObject <Urls>(jsonContent);
             url = urls.GetUrlById(urlType.ToJsonPropertyString());
             if (!string.IsNullOrWhiteSpace(url))
             {
                 return(true);
             }
             Logger.WriteEvent("Unable to look up URL type " + urlType);
         }
     }
     catch (Exception e)
     {
         _internetAvailable = false;
         Logger.WriteEvent("Exception while attempting look up of URL type " + urlType + ": " + e);
     }
     return(false);
 }
Example #2
0
        private static string LookupFallbackUrl(UrlType urlType)
        {
            Urls urls = JsonConvert.DeserializeObject <Urls>(Resources.CurrentServiceUrls);

            return(urls.GetUrlById(urlType.ToJsonPropertyString()));
        }
Example #3
0
 private static bool TryLookupUrl(UrlType urlType, out string url)
 {
     url = null;
     // Once the internet has been found missing, don't bother trying it again for the duration of the program.
     if (!_internetAvailable)
         return false;
     try
     {
         using (var s3Client = new BloomS3Client(null))
         {
             s3Client.Timeout = TimeSpan.FromMilliseconds(2500.0);
             s3Client.ReadWriteTimeout = TimeSpan.FromMilliseconds(3000.0);
             s3Client.MaxErrorRetry = 1;
             var jsonContent = s3Client.DownloadFile(BloomS3Client.BloomDesktopFiles, kUrlLookupFileName);
             Urls urls = JsonConvert.DeserializeObject<Urls>(jsonContent);
             url = urls.GetUrlById(urlType.ToJsonPropertyString());
             if (!string.IsNullOrWhiteSpace(url))
                 return true;
             Logger.WriteEvent("Unable to look up URL type " + urlType);
         }
     }
     catch (Exception e)
     {
         _internetAvailable = false;
         Logger.WriteEvent("Exception while attempting look up of URL type " + urlType + ": " + e);
     }
     return false;
 }
Example #4
0
 private static string LookupFallbackUrl(UrlType urlType)
 {
     Urls urls = JsonConvert.DeserializeObject<Urls>(Resources.CurrentServiceUrls);
     return urls.GetUrlById(urlType.ToJsonPropertyString());
 }