Example #1
0
        private RefreshResults RefreshRecentlyAdded()
        {
            var list = Browser.GetRecentlyAddedVideos();

            List <Video> added      = new List <Video>();
            List <Video> duplicates = new List <Video>();
            List <Video> failedIds  = new List <Video>();

            DateTime runTime = DateTime.Now;


            foreach (Video v in list)
            {
                var existing = DataStore.GetExistingVideo(v.Type, v.AmazonId, v.Title);

                if (existing == null)
                {
                    v.Created = v.Updated = runTime;
                    v.AddTag(TagRecord.Create(-1, TagType.New));

                    if ((from i in added
                         where i.AmazonId == v.AmazonId || i.Title == v.Title
                         select i).FirstOrDefault() == null)
                    {
                        try
                        {
                            DataStore.InsertVideo(v);
                            added.Add(v);
                        }
                        catch (Exception e)
                        {
                            failedIds.Add(v);
                        }
                    }
                    else
                    {
                        duplicates.Add(v);
                    }
                }
                else
                {
                    existing.Updated = runTime;
                    DataStore.UpdateVideo(existing);
                }
            }

            RefreshResults result = new RefreshResults(added, failedIds);

            return(result);
        }
Example #2
0
 private void ShowRefreshStatus(RefreshResults result, string title = "Refreshed")
 {
     MessageBoxFactory.ShowInfo(mainWindow, result.GetSummary(), title);
 }