Beispiel #1
0
        private void PreviewPodcatsBtn_Click(object sender, EventArgs e)
        {
            if (podcastUrlTxtBx.Text != "=")
            {
                sPodcastUrl = podcastUrlTxtBx.Text;
            }

            try
            {
                // Récupération du flux RSS
                RssFlow newRss = new RssFlow();
                newRss.create(sPodcastUrl);

                // Gestion des episodes
                Episode oCurrentEpisode;
                List<Episode> aAllEpisodes = new List<Episode>();
                for (int i = 0; i < newRss.items.GetLength(0); i++)
                {
                    if (newRss.items[i, 0] != null)
                    {
                        oCurrentEpisode = new Episode();
                        oCurrentEpisode.iId = 0;
                        oCurrentEpisode.sName = newRss.items[i, 0];
                        oCurrentEpisode.sUrl = newRss.items[i, 2];
                        oCurrentEpisode.sDesc = newRss.items[i, 1];
                        oCurrentEpisode.oDate = Convert.ToDateTime(newRss.items[i, 3]);

                        aAllEpisodes.Add(oCurrentEpisode);
                    }
                }

                // Création de l'objet Podcast
                Podcast oPodcastToDisplay = new Podcast();
                oPodcastToDisplay.initialize(0, newRss.link, newRss.title, newRss.desc, newRss.imageUrl, "", aAllEpisodes);

                //Affichage sur la vue
                pdcstNameTxtBx.Text = oPodcastToDisplay.sName;
                pdcstUrlTxtBx.Text = oPodcastToDisplay.sUrl;
                pdcstDescTxtBx.Text = oPodcastToDisplay.sDesc;
                PodcastEpisodesLstBx.DataSource = oPodcastToDisplay.getEpisodesNames();
                pdcstIconePctex.Image = Image.FromFile(oPodcastToDisplay.sImgPath);
                pdcstIconePctex.SizeMode = PictureBoxSizeMode.StretchImage;

                oCurrentPodcast = oPodcastToDisplay;

                AddPodcatsBtn.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Podcast non trouvé, veuillez verifier l'URL.");
                log.Error("Erreur addPodcast.cs: " + ex.ToString());
            }
        }
Beispiel #2
0
        private void setEpisodes()
        {
            System.Data.SqlClient.SqlConnection conn = getConnectionData();
            List<Episode> aEpisodesList = new List<Episode>();
            String requete = "";

            try
            {
                conn.Open();

                requete = "SELECT EpisodeId, " +
                                "EpisodePodcastId, " +
                                "EpisodeUrl, " +
                                "EpisodeName, " +
                                "EpisodeDesc, " +
                                "EpisodeDate, " +
                                "EpisodeDuration, " +
                                "EpisodePlayed, " +
                                "EpisodeFinished " +
                                "FROM Episodes " +
                                "WHERE EpisodePodcastId=" + iId;

                SqlCommand command = new SqlCommand(requete, conn);
                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    Episode oCurrentEpisode = new Episode();
                    oCurrentEpisode.initialize(Convert.ToInt32(reader["EpisodeId"]),
                                                Convert.ToInt32(reader["EpisodePodcastId"]),
                                                reader["EpisodeUrl"].ToString(),
                                                reader["EpisodeName"].ToString(),
                                                reader["EpisodeDesc"].ToString(),
                                                Convert.ToDateTime(reader["EpisodeDate"]),
                                                Convert.ToInt32(reader["EpisodeDuration"]),
                                                Convert.ToInt32(reader["EpisodePlayed"]),
                                                Convert.ToBoolean(reader["EpisodeFinished"])
                                                );

                    aEpisodesList.Add(oCurrentEpisode);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erreur de connexion à la base de donnée!");
                log.Error("--------------------\n" + "Requete: " + requete + "\n" + ex.ToString());
            }
            finally
            {
                conn.Close();
            }

            aAllEpisodes = aEpisodesList;
        }