/// <summary> /// Gets the teletext site. /// </summary> /// <param name="number">The number.</param> /// <returns></returns> public string GetTeletextSite(int number) { string Url = string.Empty; try { // Check first if URL with 00 does exists Url = UrlFormatter.FormatTeletextUrl(number, 0); if (!Helper.CheckIfURLExists(new Uri(Url))) { // Get the Image Url = UrlFormatter.FormatTeletextUrl(number, 1); } string value; using (var cache = new SerializableSiteCache<string, string>(EnvironmentHelper.ExecutionDirectory + ConfigurationHelper.SerializedSiteCacheFile)) { // Is image in cache and not expired? if (cache.ContainsKey(Url)) return cache.Get(Url); byte[] image = Helper.GetImageFromURL(Url); value = Helper.GetBase64DataURI(ConfigurationHelper.ImageMimeType, image); // Add to cache cache.Insert(Url, value); } return value; } catch (Exception ex) { FaultContract fault = new FaultContract(); throw new FaultException<FaultContract>(fault, new FaultReason(string.Format("Teletext Site could not be found, {0}", Url))); } }
/// <summary> /// Gets the teletext sub site. /// </summary> /// <param name="SiteNumber">The site number.</param> /// <param name="subSiteNumber">The sub site number.</param> /// <returns></returns> public string GetTeletextSubSite(int SiteNumber, int subSiteNumber) { try { // Get the Image string Url = UrlFormatter.FormatTeletextUrl(SiteNumber, subSiteNumber); string value; using (var cache = new SerializableSiteCache<string, string>(EnvironmentHelper.ExecutionDirectory + ConfigurationHelper.SerializedSiteCacheFile)) { // Is image in cache and not expired? if (cache.ContainsKey(Url)) return cache.Get(Url); byte[] image = Helper.GetImageFromURL(Url); value = Helper.GetBase64DataURI(ConfigurationManager.AppSettings["ImageMimeType"], image); // Add to cache cache.Insert(Url, value); } return value; } catch (Exception ex) { FaultContract fault = new FaultContract(); throw new FaultException<FaultContract>(fault, new FaultReason("Teletext Site couldn't be found")); } }