Example #1
0
        /// <summary>
        /// Does the update.
        /// </summary>
        public void Update()
        {
            InProgress = true;

            var i   = 0d;
            var cnt = Database.TVShows.Values.Count(s => s.Airing);
            var ids = Database.TVShows.Values.Where(s => s.Airing).OrderBy(s => s.Title).Select(s => s.ID).ToList();

            foreach (var id in ids)
            {
                UpdateProgressChanged.Fire(this, Database.TVShows[id].Title, ++i / cnt * 100);

                var tv = Database.Update(Database.TVShows[id], (e, s) =>
                {
                    if (e == -1)
                    {
                        UpdateError.Fire(this, s, null, true, false);
                    }
                });

                if (tv != null && tv.Language == "en")
                {
                    UpdateRemoteCache(tv);
                }
            }

            Database.Setting("update", DateTime.Now.ToUnixTimestamp().ToString());
            MainWindow.Active.DataChanged();
            UpdateDone.Fire(this);

            InProgress = false;
        }
Example #2
0
 /// <summary>
 /// Does the update asynchronously.
 /// </summary>
 public void UpdateAsync()
 {
     Task.Factory.StartNew(() =>
     {
         try
         {
             Update();
         }
         catch (Exception ex)
         {
             UpdateError.Fire(this, "The update function has quit with an exception.", ex, false, true);
         }
     });
 }