예제 #1
0
        public void FillTVTDatabase(ITVTDatabase database)
        {
            using (var connection = GetConnection())
            {
                var programmes = TVTCommandsV3.Read <TVTProgramme>(connection, TVTCommandsV3.GetProgrammeSQLDefinition(), "master_id, episode_index, fake_title_de, title_de");
                //database.AddProgrammes( programmes.Where( x => (int)x.DataStatus >= (int)TVTDataStatus.OnlyDE ) );
                database.AddProgrammes(programmes);

                var ads = TVTCommandsV3.Read <TVTAdvertising>(connection, TVTCommandsV3.GetAdvertisingSQLDefinition(), "fake_title_de, title_de");
                database.AddAdvertisings(ads);

                var people = TVTCommandsV3.Read <TVTPerson>(connection, TVTCommandsV3.GetPersonSQLDefinition(), "fake_last_name, fake_first_name, last_name");
                database.AddPeople(people);

                var news = TVTCommandsV3.Read <TVTNews>(connection, TVTCommandsV3.GetNewsSQLDefinition(), "title_de");
                database.AddNews(news);

                database.RefreshReferences();
            }
        }
예제 #2
0
        public ITVTDatabase LoadXML(string filename, ITVTDatabase database, TVTDataRoot dataRoot)
        {
            var result = database;
            //int version = 0;
            //DatabaseVersion dbVersion = DatabaseVersion.V2;
            //TVTDataContent defaultType = TVTDataContent.FakeWithRefId;

            var doc = new XmlDocument();

            doc.Load(filename);

            var versionElement = doc.GetElementsByTagName("version");

            if (versionElement[0].HasAttribute("value"))
            {
                var version = versionElement[0].GetAttributeInteger("value");
                if (version != 2)
                {
                    throw new NotSupportedException("Only database version '2' is supported.");
                }
            }

            {
                var movies    = new List <MovieOldV2>();
                var allMovies = doc.GetElementsByTagName("allmovies");

                foreach (XmlNode xmlMovie in allMovies)
                {
                    foreach (XmlNode childNode in xmlMovie.ChildNodes)
                    {
                        switch (childNode.Name)
                        {
                        case "movie":
                            movies.AddRange(LoadMovie(childNode, true));
                            break;

                        default:
                            throw new NotSupportedException("Only 'movie'-tags are supported.");
                        }
                    }
                }
                OldV2Converter.Convert(movies, database, dataRoot);
            }

            {
                var series    = new List <MovieOldV2>();
                var allSeries = doc.GetElementsByTagName("allseries");

                foreach (XmlNode xmlSeries in allSeries)
                {
                    foreach (XmlNode childNode in xmlSeries.ChildNodes)
                    {
                        switch (childNode.Name)
                        {
                        case "serie":
                            series.AddRange(LoadMovie(childNode, true));
                            break;

                        default:
                            throw new NotSupportedException("Only 'serie'-tags are supported.");
                        }
                    }
                }
                OldV2Converter.Convert(series, database, dataRoot);
            }

            {
                var news    = new List <NewsOldV2>();
                var allNews = doc.GetElementsByTagName("allnews");

                foreach (XmlNode xmlNews in allNews)
                {
                    foreach (XmlNode childNode in xmlNews.ChildNodes)
                    {
                        switch (childNode.Name)
                        {
                        case "news":
                            news.AddRange(LoadNews(childNode, true));
                            break;

                        default:
                            throw new NotSupportedException("Only 'news'-tags are supported.");
                        }
                    }
                }
                OldV2Converter.Convert(news, database, dataRoot);
            }

            {
                var ads     = new List <AdvertisingOldV2>();
                var allNews = doc.GetElementsByTagName("allads");

                foreach (XmlNode xmlNews in allNews)
                {
                    foreach (XmlNode childNode in xmlNews.ChildNodes)
                    {
                        switch (childNode.Name)
                        {
                        case "ad":
                            ads.Add(LoadAd(childNode, true));
                            break;

                        default:
                            throw new NotSupportedException("Only 'news'-tags are supported.");
                        }
                    }
                }
                OldV2Converter.Convert(ads, database, dataRoot);
            }

            database.RefreshReferences();

            OldV2Converter.RefreshMovieDescriptions(database);

            return(result);
        }