Exemplo n.º 1
0
        public static IdAsset[] GetAllEntries()
        {
            if (cachedEntities != null)
            {
                return(cachedEntities);
            }
            var aerialUrl = "http://a1.phobos.apple.com/us/r1000/000/Features/atv/AutumnResources/videos/entries.json";

#if OFFLINE
            aerialUrl = "http://BOGUS/entries.json";
#endif

            // update anyway
            Caching.StartDelayedCache(aerialUrl);

            string entries = "";
            if (Caching.IsHit(aerialUrl))
            {
                entries = File.ReadAllText(Caching.Get(aerialUrl));
            }
            else
            {
                WebClient webClient = new WebClient();
                entries = webClient.DownloadString(aerialUrl);
            }
            cachedEntities = new JavaScriptSerializer().Deserialize <IdAsset[]>(entries);

            return(cachedEntities);
        }
Exemplo n.º 2
0
        public static IdAsset[] GetAllEntries()
        {
            if (cachedEntities != null)
            {
                return(cachedEntities);
            }

            var settings  = new RegSettings();
            var aerialUrl = settings.JsonURL;

#if OFFLINE
            aerialUrl = "http://BOGUS/entries.json";
#endif

            // update anyway
            Caching.StartDelayedCache(aerialUrl);

            string entries = "";
            if (Caching.IsHit(aerialUrl))
            {
                entries = File.ReadAllText(Caching.Get(aerialUrl));
            }
            else
            {
                WebClient webClient = new WebClient();
                entries = webClient.DownloadString(aerialUrl);
            }
            cachedEntities = new JavaScriptSerializer().Deserialize <IdAsset[]>(entries);

            return(cachedEntities);
        }
Exemplo n.º 3
0
        public static IdAsset[] GetAllEntries()
        {
            if (cachedEntities != null)
            {
                return(cachedEntities);
            }

            var settings  = new RegSettings();
            var aerialUrl = settings.JsonURL;

#if OFFLINE
            aerialUrl = "http://BOGUS/entries.json";
#endif

            //aerialUrl = "https://smukfestmedia.blob.core.windows.net/video/custom-entries.json";
            aerialUrl = "C:\\Users\\ros\\Source\\Repos\\Aerial\\ScreenSaver\\custom-entries.json";

            // update anyway
            Caching.StartDelayedCache(aerialUrl);

            string entries = "";
            if (Caching.IsHit(aerialUrl))
            {
                entries = File.ReadAllText(Caching.Get(aerialUrl));
            }
            else
            {
                WebClient webClient = new WebClient();
                entries = webClient.DownloadString(aerialUrl);
            }

            try
            {
                cachedEntities = new JavaScriptSerializer().Deserialize <IdAsset[]>(entries);
            }
            catch (ArgumentException e)
            {
                //the passed in entities document is invalid.
                return(null);
            }


            return(cachedEntities);
        }
Exemplo n.º 4
0
        private string GetEntries()
        {
            var aerialUrl = "http://a1.phobos.apple.com/us/r1000/000/Features/atv/AutumnResources/videos/entries.json";

#if OFFLINE
            aerialUrl = "http://BOGUS/entries.json";
#endif

            // update anyway
            Caching.StartDelayedCache(aerialUrl);

            if (Caching.IsHit(aerialUrl))
            {
                return(File.ReadAllText(Caching.Get(aerialUrl)));
            }

            WebClient webClient = new WebClient();
            string    entries   = webClient.DownloadString(aerialUrl);
            return(entries);
        }
Exemplo n.º 5
0
        public static IdAsset[] GetAllEntries()
        {
            if (cachedEntities != null)
            {
                return(cachedEntities);
            }

            var settings  = new RegSettings();
            var aerialUrl = settings.JsonURL;

#if OFFLINE
            aerialUrl = "http://BOGUS/entries.json";
#endif

            // update anyway
            Caching.StartDelayedCache(aerialUrl);

            string entries = "";
            if (Caching.IsHit(aerialUrl))
            {
                entries = File.ReadAllText(Caching.Get(aerialUrl));
            }
            else
            {
                WebClient webClient = new WebClient();
                try
                {
                    entries = webClient.DownloadString(aerialUrl);
                }
                catch (Exception ex)
                {
                    ex.ToString();
                    //return null;
                }
            }

            try
            {
                cachedEntities = new JavaScriptSerializer().Deserialize <IdAsset[]>(entries);
            }
            catch (ArgumentException e)
            {
                return(null);
            }
            catch
            {
                //the passed in entities document is invalid.
                try
                {
                    dynamic cached             = ConvertToDynamicObject(entries);
                    var     cachedTempEntities = new List <IdAsset>();
                    var     datas = cached.data;
                    foreach (var data in datas)
                    {
                        var idAsset = new IdAsset();
                        idAsset.id = Guid.NewGuid().ToString();
                        //idAsset.assets = new Asset[data.screensavers.Count];
                        var assets = new List <Asset>();
                        foreach (var screensaver in data.screensavers)
                        {
                            var asset = new Asset();
                            asset.accessibilityLabel = data.name;
                            asset.id        = screensaver.identifier;
                            asset.name      = screensaver.identifier;
                            asset.url       = screensaver.videoURL;//screensaver.urls.h264;
                            asset.timeOfDay = "year";
                            asset.type      = "video";

                            assets.Add(asset);
                        }
                        idAsset.assets = assets.ToArray();
                        cachedTempEntities.Add(idAsset);
                    }
                    cachedEntities = cachedTempEntities.ToArray();
                }
                catch (Exception ex)
                {
                    return(null);
                }
            }


            return(cachedEntities);
        }