Ejemplo n.º 1
0
        private int ProcessFile(string path)
        {
            string replaySerialNumber = System.IO.Path.GetFileNameWithoutExtension(path);

            ZoggrData.ShowsDB db = new ZoggrData.ShowsDB();

            int ShowCount = 0;

            using (TransactionScope transactions = new TransactionScope())
            {
                // Delete Existing Shows
                db.ClearShows(replaySerialNumber);

                // Add New Shows
                XmlDocument document = new XmlDocument();
                document.Load(path);

                foreach (XmlNode node in document.SelectNodes("/result/channel-list/channel/show"))
                {
                    XmlElement ShowNode = node as XmlElement;
                    if ((ShowNode != null))
                    {
                        XmlElement ChannelNode = ShowNode.ParentNode as XmlElement;

                        var show = new ZoggrData.Show();
                        show.ReplaySerialNumber = replaySerialNumber;
                        show.TabId               = ChannelNode.GetAttribute("categoryID");
                        show.TabName             = ChannelNode.GetAttribute("categoryName");
                        show.ChannelId           = ChannelNode.GetAttribute("channelID");
                        show.ChannelType         = ChannelNode.GetAttribute("channelType");
                        show.ChannelTitle        = ChannelNode.GetAttribute("title");
                        show.ShowTitle           = ShowNode.GetAttribute("title");
                        show.EpisodeId           = ShowNode.GetAttribute("showID");
                        show.EpisodeDescription  = ShowNode.GetAttribute("description");
                        show.EpisodeTitle        = ShowNode.GetAttribute("episodeTitle");
                        show.EpisodeStartTimeGMT = Convert.ToDateTime(ShowNode.GetAttribute("startTimeGMT"));
                        show.EpisodeDuration     = Convert.ToInt32(ShowNode.GetAttribute("durationInMinutes"));
                        show.EpisodeQuality      = ShowNode.GetAttribute("quality");

                        db.AddShow(show);
                        ShowCount += 1;
                    }
                }
                db.SubmitChanges();
                transactions.Complete();
            }
            return(ShowCount);
        }
Ejemplo n.º 2
0
        private int ProcessFile(string path)
        {
            string replaySerialNumber = System.IO.Path.GetFileNameWithoutExtension(path);
            ZoggrData.ShowsDB db = new ZoggrData.ShowsDB();

            int ShowCount = 0;
            using (TransactionScope transactions = new TransactionScope())
            {
                // Delete Existing Shows
                db.ClearShows(replaySerialNumber);

                // Add New Shows
                XmlDocument document = new XmlDocument();
                document.Load(path);

                foreach (XmlNode node in document.SelectNodes("/result/channel-list/channel/show"))
                {
                    XmlElement ShowNode = node as XmlElement;
                    if ((ShowNode != null))
                    {
                        XmlElement ChannelNode = ShowNode.ParentNode as XmlElement;

                        var show = new ZoggrData.Show();
                        show.ReplaySerialNumber = replaySerialNumber;
                        show.TabId = ChannelNode.GetAttribute("categoryID");
                        show.TabName = ChannelNode.GetAttribute("categoryName");
                        show.ChannelId = ChannelNode.GetAttribute("channelID");
                        show.ChannelType = ChannelNode.GetAttribute("channelType");
                        show.ChannelTitle = ChannelNode.GetAttribute("title");
                        show.ShowTitle = ShowNode.GetAttribute("title");
                        show.EpisodeId = ShowNode.GetAttribute("showID");
                        show.EpisodeDescription = ShowNode.GetAttribute("description");
                        show.EpisodeTitle = ShowNode.GetAttribute("episodeTitle");
                        show.EpisodeStartTimeGMT = Convert.ToDateTime(ShowNode.GetAttribute("startTimeGMT"));
                        show.EpisodeDuration = Convert.ToInt32(ShowNode.GetAttribute("durationInMinutes"));
                        show.EpisodeQuality = ShowNode.GetAttribute("quality");

                        db.AddShow(show);
                        ShowCount += 1;
                    }
                }
                db.SubmitChanges();
                transactions.Complete();
            }
            return ShowCount;
        }