public void ValidateCache()
        {
            var enabledDataServices = DataServiceFactory.GetCurrentDataService();

            foreach (IDataService dataService in enabledDataServices)
            {
                var fileStore = Mvx.Resolve <IMvxFileStore>();

                Assert.IsTrue(fileStore.Exists("CachedItems-" + dataService.GetType().ToString()));
                Assert.IsTrue(fileStore.Exists("LastRefresh-" + dataService.GetType().ToString()));
            }
        }
Exemplo n.º 2
0
        public ItemsShowcaseViewModel()
        {
            EnabledDataServices = DataServiceFactory.GetCurrentDataService();

            if (EnabledDataServices.Count == 0)
            {
                ServiceLocator.MessageService.ShowErrorAsync("No DataServices Enabled", "Application Error");
            }
            else
            {
                LoadItems();
            }
        }
Exemplo n.º 3
0
        public ItemsShowcaseViewModel()
        {
            EnabledDataServices = DataServiceFactory.GetCurrentDataService();

            if (EnabledDataServices.Count == 0)
            {
                ServiceLocator.MessageService.ShowErrorAsync("No DataServices Enabled", "Application Error");
            }
            else
            {
                // If we are running in the debugger, tell LoadItems() to ignore the cache in case we modified
                //  the RSS feeds or other content elements.  This way we are sure to see the desired content
                //  when iterating program changes in the debugger.
                LoadItems(Debugger.IsAttached);
            }
        }
        public void ValidateRefresh()
        {
            var fileStore = Mvx.Resolve <IMvxFileStore>();

            Dictionary <string, DateTime> initialRefreshTimes = new Dictionary <string, DateTime>();
            var enabledDataServices = DataServiceFactory.GetCurrentDataService();

            //Obtain Cached refresh times if available
            foreach (IDataService dataService in enabledDataServices)
            {
                string initialRefreshText;
                if (fileStore.TryReadTextFile("LastRefresh-" + dataService.GetType().ToString(), out initialRefreshText))
                {
                    var initialRefreshTime = DateTime.Parse(initialRefreshText);
                    initialRefreshTimes.Add(dataService.GetType().ToString(), initialRefreshTime);
                }
            }

            //Initiate Delay
            Thread.Sleep(500);

            //Ensure the method is called without error
            itemsShowcaseViewModel.RefreshCommand.Execute(null);
            MonitorLoadingItems();
            Debug.WriteLine("DataSources Refreshed " + DateTime.Now.ToString());

            //If Cached refreshtimes exist, validate them
            if (initialRefreshTimes.Count > 0)
            {
                foreach (IDataService dataService in enabledDataServices)
                {
                    string lastRefreshText;
                    fileStore.TryReadTextFile("LastRefresh-" + dataService.GetType().ToString(), out lastRefreshText);
                    var lastRefreshTime = DateTime.Parse(lastRefreshText);
                    Assert.IsTrue(lastRefreshTime > initialRefreshTimes[dataService.GetType().ToString()]);
                }

                Debug.WriteLine("Verfied Cache Updated after Refresh");
            }
            else
            {
                Assert.Fail("Cache Data was not found or unitialized");
            }
        }
        /// <summary>
        /// Loads Items from our DataServices and sort into grouped enumerable
        /// </summary>
        private async void LoadItems(bool overrideCache = false)
        {
            IsBusy = true;

            if (AppSettings.EnableRemoteAppSettings)
            {
                RemoteAppSettingsService remoteAppSettingsService = new RemoteAppSettingsService();
                await remoteAppSettingsService.LoadRemoteAppSettings(overrideCache);
            }

            //Name may change after RemoteSettings enabled
            ApplicationName = AppSettings.ApplicationName;

            if (AppSettings.EnableRemoteUrlSourceService)
            {
                await RemoteUrlSourceService.GetRemoteUrlSources();
            }

            EnabledDataServices = DataServiceFactory.GetCurrentDataService();

            if (EnabledDataServices.Count == 0)
            {
                ServiceLocator.MessageService.ShowErrorAsync("No DataServices Enabled", "Application Error");
                return;
            }

            items = new List <Item>();
            await DoFetchDataServices(EnabledDataServices, overrideCache);

            ItemGroups = new List <Group <Item> >(from item in items
                                                  group item by item.Group into grp
                                                  orderby grp.GetOrderPreference()
                                                  select new Group <Item>(grp.Key, grp)).ToList();

            IsBusy = false;

            if (LoadCompleted != null)
            {
                LoadCompleted(this, EventArgs.Empty);
            }
        }