Exemple #1
0
        //Aktualizuje wszystkie zaznaczone seriale i tworzy log z procesu
        private void getEpisodes()
        {
            Application.Current.Dispatcher.Invoke(new Action(() => main.clearLog()));
            foreach (Series s in main.seriesList)
            {
                if (s._update)
                {
                    List <Episode>   ep = new List <Episode>();
                    ReadFromDataBase RD = new ReadFromDataBase();
                    UpdateDataBase   UD = new UpdateDataBase();
                    AddToDataBase    AD = new AddToDataBase();

                    Application.Current.Dispatcher.Invoke(new Action(() => main.addToLog("Pobieram " + s._seriesName)));

                    ep = new DownloadEpisodes().getEpisodes(s._id);

                    Application.Current.Dispatcher.Invoke(new Action(() => main.addToLog("Aktualizuję " + s._seriesName)));

                    int update = 0, added = 0;

                    foreach (Episode e in ep)
                    {
                        if (RD.EpisodeExist(e._id))
                        {
                            if (RD.EpisodeLastUpdate(e._id) < e._lastUpdate)
                            {
                                UD.UpdateEpisode(e);
                                update++;
                            }
                        }
                        else
                        {
                            AD.addEpisode(s._id, e);
                            added++;
                        }
                    }

                    Application.Current.Dispatcher.Invoke(new Action(() => main.addToLog("      Zaktualizowałem " + update + " odcinków")));
                    Application.Current.Dispatcher.Invoke(new Action(() => main.addToLog("      Dodałem " + added + " odcinków")));
                }
                else
                {
                    Application.Current.Dispatcher.Invoke(new Action(() => main.addToLog("Pomijam " + s._seriesName)));
                }
            }


            Application.Current.Dispatcher.Invoke(new Action(() => main.LoadingScreen = Visibility.Hidden));
        }
Exemple #2
0
        private void clear()
        {
            Application.Current.Dispatcher.Invoke(new Action(() => main.clearLog()));

            foreach (Series s in main.seriesList)
            {
                if (s._update)
                {
                    AddToDataBase  AD   = new AddToDataBase();
                    List <Episode> ep   = new List <Episode>();
                    Episode        last = new ReadFromDataBase().GetLastEpisode(s._id);

                    Application.Current.Dispatcher.Invoke(new Action(() => main.addToLog("Pobieram " + s._seriesName)));
                    ep = new DownloadEpisodes().getEpisodes(s._id);

                    Application.Current.Dispatcher.Invoke(new Action(() => main.addToLog("Aktualizuję " + s._seriesName)));

                    new DeleteFromDataBase().deleteEpisodes(s._id);

                    foreach (Episode e in ep)
                    {
                        AD.addEpisode(s._id, e);
                    }

                    if (last != null)
                    {
                        new UpdateDataBase().AllBelowWatched(s._id, last._episodeNumber, last._seasonNumber, true);
                        new UpdateDataBase().AllAboveUnwatched(s._id, last._episodeNumber, last._seasonNumber, false);
                    }
                    else
                    {
                        new UpdateDataBase().AllWatched(s._id, true);
                        new UpdateDataBase().AllNotAiredUnwatched(s._id);
                    }
                }
                else
                {
                    Application.Current.Dispatcher.Invoke(new Action(() => main.addToLog("Pomijam " + s._seriesName)));
                }
            }

            Application.Current.Dispatcher.Invoke(new Action(() => main.LoadingScreen = Visibility.Hidden));
        }