/// <summary> /// Refreshes the <see cref="OnlineSites"/> and <see cref="OnlineDlls"/> from the webservice every ten minutes. /// </summary> /// <param name="force">forces the refresh, ignoring the ten minutes refresh interval</param> /// <returns>true when new data was retieved</returns> public static bool GetRemoteOverviews(bool force = false) { if (DateTime.Now - lastOverviewsRetrieved > TimeSpan.FromMinutes(10) || force) // only get overviews every 10 minutes { bool newData = false; OnlineVideosService ws = new OnlineVideosService() { Timeout = 30000, EnableDecompression = true }; try { Log.Info("Updater loading Sites Overview from Webservice"); onlineSites = ws.GetSitesOverview(); newData = true; } catch (Exception ex) { Log.Warn("Error on getting sites overview from server: {0}", ex.ToString()); } try { onlineDlls = ws.GetDllsOverview(); newData = true; } catch (Exception ex) { Log.Warn("Error on getting dlls overview from server: {0}", ex.ToString()); } lastOverviewsRetrieved = DateTime.Now; return(newData); } return(false); }
static bool DownloadDll(string dllName, string localPath) { try { Log.Info("Downloading '{0}.dll'", dllName); OnlineVideosService ws = new OnlineVideosService() { Timeout = 30000, EnableDecompression = true }; byte[] onlineDllData = ws.GetDll(dllName); if (onlineDllData != null && onlineDllData.Length > 0) { File.WriteAllBytes(localPath, onlineDllData); } return(true); } catch (Exception ex) { Log.Warn("Error getting remote DLL '{0}.dll': {1}", dllName, ex.ToString()); return(false); } }
static bool DownloadDll(string dllName, string localPath) { try { Log.Info("Downloading '{0}.dll'", dllName); OnlineVideosService ws = new OnlineVideosService() { Timeout = 30000, EnableDecompression = true }; byte[] onlineDllData = ws.GetDll(dllName); if (onlineDllData != null && onlineDllData.Length > 0) File.WriteAllBytes(localPath, onlineDllData); return true; } catch (Exception ex) { Log.Warn("Error getting remote DLL '{0}.dll': {1}", dllName, ex.ToString()); return false; } }
/// <summary> /// Refreshes the <see cref="OnlineSites"/> and <see cref="OnlineDlls"/> from the webservice every ten minutes. /// </summary> /// <param name="force">forces the refresh, ignoring the ten minutes refresh interval</param> /// <returns>true when new data was retieved</returns> public static bool GetRemoteOverviews(bool force = false) { if (DateTime.Now - lastOverviewsRetrieved > TimeSpan.FromMinutes(10) || force) // only get overviews every 10 minutes { bool newData = false; OnlineVideosService ws = new OnlineVideosService() { Timeout = 30000, EnableDecompression = true }; try { Log.Info("Updater loading Sites Overview from Webservice"); onlineSites = ws.GetSitesOverview(); newData = true; } catch(Exception ex) { Log.Warn("Error on getting sites overview from server: {0}", ex.ToString()); } try { onlineDlls = ws.GetDllsOverview(); newData = true; } catch(Exception ex) { Log.Warn("Error on getting dlls overview from server: {0}", ex.ToString()); } lastOverviewsRetrieved = DateTime.Now; return newData; } return false; }
public static SiteSettings GetRemoteSite(string siteName, OnlineVideos.OnlineVideosWebservice.OnlineVideosService ws = null) { try { if (ws == null) ws = new OnlineVideosService() { Timeout = 30000, EnableDecompression = true }; string siteXml = ws.GetSiteXml(siteName); if (siteXml.Length > 0) { IList<SiteSettings> sitesFromWeb = SerializableSettings.Deserialize(siteXml); if (sitesFromWeb != null && sitesFromWeb.Count > 0) { // Download images try { string iconPath = Path.Combine(OnlineVideoSettings.Instance.ThumbsDir, @"Icons\" + siteName + ".png"); byte[] icon = ws.GetSiteIconIfChanged(siteName, File.Exists(iconPath) ? BitConverter.ToString(md5Service.ComputeHash(File.ReadAllBytes(iconPath))).Replace("-", "").ToLower() : null); if (icon != null && icon.Length > 0) File.WriteAllBytes(iconPath, icon); } catch (Exception ex) { OnlineVideos.OnlineVideoSettings.Instance.Logger.Warn("Error getting Icon for Site '{0}': {1}", siteName, ex.ToString()); } try { string bannerPath = Path.Combine(OnlineVideoSettings.Instance.ThumbsDir, @"Banners\" + siteName + ".png"); byte[] banner = ws.GetSiteBannerIfChanged(siteName, File.Exists(bannerPath) ? BitConverter.ToString(md5Service.ComputeHash(File.ReadAllBytes(bannerPath))).Replace("-", "").ToLower() : null); if (banner != null && banner.Length > 0) File.WriteAllBytes(bannerPath, banner); } catch (Exception ex) { OnlineVideos.OnlineVideoSettings.Instance.Logger.Warn("Error getting Banner for Site '{0}': {1}", siteName, ex.ToString()); } // return the site return sitesFromWeb[0]; } } } catch (Exception ex) { OnlineVideos.OnlineVideoSettings.Instance.Logger.Warn("Error getting remote Site {0}: {1}", siteName, ex.ToString()); } return null; }
public static SiteSettings GetRemoteSite(string siteName, OnlineVideos.OnlineVideosWebservice.OnlineVideosService ws = null) { try { if (ws == null) { ws = new OnlineVideosService() { Timeout = 30000, EnableDecompression = true } } ; string siteXml = ws.GetSiteXml(siteName); if (siteXml.Length > 0) { IList <SiteSettings> sitesFromWeb = SerializableSettings.Deserialize(siteXml); if (sitesFromWeb != null && sitesFromWeb.Count > 0) { // Download images try { string iconPath = Path.Combine(OnlineVideoSettings.Instance.ThumbsDir, @"Icons\" + siteName + ".png"); byte[] icon = ws.GetSiteIconIfChanged(siteName, File.Exists(iconPath) ? BitConverter.ToString(md5Service.ComputeHash(File.ReadAllBytes(iconPath))).Replace("-", "").ToLower() : null); if (icon != null && icon.Length > 0) { File.WriteAllBytes(iconPath, icon); } } catch (Exception ex) { OnlineVideos.OnlineVideoSettings.Instance.Logger.Warn("Error getting Icon for Site '{0}': {1}", siteName, ex.ToString()); } try { string bannerPath = Path.Combine(OnlineVideoSettings.Instance.ThumbsDir, @"Banners\" + siteName + ".png"); byte[] banner = ws.GetSiteBannerIfChanged(siteName, File.Exists(bannerPath) ? BitConverter.ToString(md5Service.ComputeHash(File.ReadAllBytes(bannerPath))).Replace("-", "").ToLower() : null); if (banner != null && banner.Length > 0) { File.WriteAllBytes(bannerPath, banner); } } catch (Exception ex) { OnlineVideos.OnlineVideoSettings.Instance.Logger.Warn("Error getting Banner for Site '{0}': {1}", siteName, ex.ToString()); } // return the site return(sitesFromWeb[0]); } } } catch (Exception ex) { OnlineVideos.OnlineVideoSettings.Instance.Logger.Warn("Error getting remote Site {0}: {1}", siteName, ex.ToString()); } return(null); }