Пример #1
0
        public void StartTimer(Podcast podcast)
        {
            Timer updateTimer = new Timer();

            podcast.updateTimer = updateTimer;
            updateTimer.Stop();
            updateTimer.Start();

            updateTimer.Elapsed  += (sender, e) => TimerElapsedHandler(sender, e, podcast);
            updateTimer.Interval  = Int32.Parse(podcast.UpdateFrequency) * 6000;
            updateTimer.Enabled   = true;
            updateTimer.AutoReset = true;
        }
Пример #2
0
        public static async void LaddaPodcastTillXML(string url, string kategori, int updateInterval)
        {
            List <Podcast> pLista = new List <Podcast>();
            Serializer     seri   = new Serializer();

            var task = new Task <Podcast>(() => {
                Podcast podcast        = new Podcast(updateInterval, url);
                List <Episode> epLista = new List <Episode>();


                if (System.IO.File.Exists("Podcast3.xml"))
                {
                    pLista = seri.deserializepodcast();
                }
                XmlReader reader     = XmlReader.Create(url);
                SyndicationFeed feed = SyndicationFeed.Load(reader);
                reader.Close();

                foreach (SyndicationItem item in feed.Items)
                {
                    var episode = new Episode()
                    {
                        title       = item.Title.Text,
                        description = item.Summary.Text,
                        pubDate     = item.PublishDate.ToString(),
                        link        = item.Links[1].Uri.ToString(),
                        spelad      = false,
                    };
                    epLista.Add(episode);
                }

                podcast.title       = feed.Title.Text;
                podcast.url         = url;
                podcast.kategori    = kategori;
                podcast.episodeList = epLista;
                podcast.interval    = 10;

                return(podcast);
            });

            task.Start();
            var p = await task;

            pLista.Add(p);

            seri.serialize(pLista);
        }
Пример #3
0
 public void ChangePodcastFromList(string podcastName, string url, string freq, string category)
 {
     try
     {
         pDB.Podcasts = deserializedPodcasts;
         Podcast podcastChanged = pDB.Podcasts.FirstOrDefault(a => a.Title == podcastName);
         podcastChanged.Url             = url;
         podcastChanged.UpdateFrequency = freq;
         podcastChanged.categories      = cDB.AddCategory(category);
         serializer.Serialize(@"C:\podFeeds\poddar.txt", pDB.Podcasts);
         deserializeList(filenameForJson);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
Пример #4
0
        public async Task addPodcast(string url, string selectedCategory, string timer)
        {
            Podcast result = await Task.Run(() => GetPodcastFeed(url, selectedCategory, timer));

            if (validate.IfFileExists(@"C:\podFeeds\poddar.txt"))
            {
                pDB.Podcasts = deserializedPodcasts;
                pDB.AddPodcast(result);
                serializer.Serialize <Podcast>(@"C:\podFeeds\poddar.txt", pDB.Podcasts);
                deserializeList(filenameForJson);
            }
            else
            {
                pDB.AddPodcast(result);
                serializer.Serialize <Podcast>(@"C:\podFeeds\poddar.txt", pDB.Podcasts);
                deserializeList(filenameForJson);
            }
        }
Пример #5
0
        public Podcast RemovePodcastFromList(string podcastName)
        {
            Podcast podcastRemoved = new Podcast();

            try
            {
                pDB.Podcasts   = deserializedPodcasts;
                podcastRemoved = pDB.Podcasts.FirstOrDefault(a => a.Title == podcastName);
                pDB.RemoveFromList(podcastRemoved);
                serializer.Serialize(@"C:\podFeeds\poddar.txt", pDB.Podcasts);
                deserializeList(filenameForJson);
                return(podcastRemoved);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(podcastRemoved);
            }
        }
Пример #6
0
        public async Task <bool> kollaOmNyttAvsnittFinns(string kategori, string podcast)
        {
            return(await Task.Run(() =>
            {
                bool finns = false;
                Podcast podcastelm = new Podcast();
                List <string> allaGamlaAvsnitt = hamtaAvsnitt(podcast, kategori);
                laddaNerNyaAvsnitt(kategori, podcast);
                List <string> allaNyaAvsnitt = hamtaAvsnitt(podcast, "xmlFiler");
                var path = Directory.GetCurrentDirectory() + @"\xmlFiler\" + podcast + ".xml";
                var pathGammal = Directory.GetCurrentDirectory() + @"\" + kategori + @"\" + podcast + ".xml";

                if (allaGamlaAvsnitt.Count == allaNyaAvsnitt.Count)
                {
                    File.Delete(path);
                }
                else
                {
                    finns = true;
                }
                return finns;
            }));
        }
Пример #7
0
 public void PodInfo(string name, string url, string category, int interval)
 {
     try
     {
         AddPod pod = new AddPod();
         timer          = new System.Timers.Timer(interval);
         timer.Elapsed += (timerSender, timerEvent) => UpdaterRemove(timerSender, timerEvent, name, url, category, interval);
         timer.Stop();
         var poddis = new Podcast()
         {
             Name     = name,
             Url      = url,
             Category = category,
             Interval = interval,
         };
         pod.AddNewPod(name, category, url, interval);
         pods.Add(poddis);
         timer.Start();
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
Пример #8
0
 public void addToCatList(Podcast pod)
 {
     podCasts.Add(pod);
 }
Пример #9
0
        public void nyPodcast(string url, string kategori, string frekvens)
        {
            Podcast nyPodcast = new Podcast(url, kategori, frekvens);

            addNyPodcastToList(nyPodcast);
        }
Пример #10
0
 private void addNyPodcastToList(Podcast nyPodcast)
 {
     allaPodcasts.Add(nyPodcast);
 }
Пример #11
0
 public void StartFeedTimer(Podcast podcast)
 {
     StopTimer(podcast);
     StartTimer(podcast);
 }
Пример #12
0
        public void StopTimer(Podcast podcast)
        {
            Timer timer = podcast.updateTimer;

            timer.Stop();
        }