Ejemplo n.º 1
0
        public static TVTPerson GetPersonByNameOrCreate(ITVTDatabase database, string name, TVTDataType defaultType, bool isFakeName, TVTPersonFunction functionForNew = TVTPersonFunction.Unknown)
        {
            if (!string.IsNullOrEmpty(name))
            {
                var tempName = name.Split(',')[0];
                var person   = database.GetPersonByName(tempName);

                if (person == null)
                {
                    person = new TVTPerson();
                    person.GenerateGuid();
                    person.DataType = defaultType;
                    if (isFakeName)
                    {
                        PersonConverter.ConvertFakeFullname(person, tempName);
                    }
                    else
                    {
                        PersonConverter.ConvertFullname(person, tempName);
                    }

                    person.Functions.Add(functionForNew);
                    person.PriceMod = 1;
                    database.AddPerson(person);
                }
                return(person);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
 public override void RefreshReferences(ITVTDatabase database)
 {
     if (SeriesMaster != null && SeriesMaster.IsAlive)
     {
         SeriesId = SeriesMaster.TargetGeneric.Id;
     }
 }
Ejemplo n.º 3
0
        public static void Convert(List <AdvertisingOldV2> adsOldV2, ITVTDatabase database, TVTDataRoot dataRoot)
        {
            foreach (var adSrc in adsOldV2)
            {
                var ad = new TVTAdvertising();
                ad.DataRoot = dataRoot;

                ConvertCommonMinimal(adSrc, ad, database);
                ad.DescriptionDE = adSrc.description;
                ad.DescriptionEN = adSrc.descriptionEnglish;

                ad.CreatorId    = adSrc.creatorID;
                ad.EditorId     = adSrc.editorID;
                ad.LastModified = new DateTime(2004, 1, 1);

                ad.FixPrice    = (adSrc.fixedProfit > 0);
                ad.MinAudience = ConvertOldToNewValueFloat(adSrc.minAudience);
                ad.MinImage    = ConvertOldToNewValue(adSrc.minImage);
                ad.Repetitions = adSrc.repetitions;
                ad.Duration    = adSrc.duration;
                ad.Profit      = ConvertProfitPenalty(adSrc.profit, adSrc.fixedProfit > 0, adSrc.fixedProfit);
                ad.Penalty     = ConvertProfitPenalty(adSrc.penalty, adSrc.fixedPenalty > 0, adSrc.fixedPenalty);

                ad.TargetGroup = ConvertTargetGroup(adSrc.targetgroup);

                ad.Approved = adSrc.approved;

                database.AddAdvertising(ad);
            }
        }
Ejemplo n.º 4
0
        public override void Load(XmlNode xmlNode, T episode, ITVTDatabase database)
        {
            base.Load(xmlNode, episode, database);

            //foreach (var movieChild in xmlNode.ChildNodes)
            //{
            //    if (movieChild is XmlLinkedNode)
            //    {
            //        var linkedNode = (XmlLinkedNode)movieChild;

            //        LoadNames(linkedNode, episode, dbVersion, dataStructure);

            //        switch (linkedNode.Name)
            //        {
            //            case "data":
            //                episode.BettyBonus = linkedNode.GetAttributeInteger("betty");
            //                episode.PriceMod = linkedNode.GetAttributeInteger("price");
            //                episode.CriticsRate = linkedNode.GetAttributeInteger("critics");
            //                episode.ViewersRate = linkedNode.GetAttributeInteger("speed");
            //                episode.BoxOfficeRate = linkedNode.GetAttributeInteger("outcome");
            //                break;
            //        }
            //    }
            //}
        }
Ejemplo n.º 5
0
        public override void RefreshReferences(ITVTDatabase database)
        {
            base.RefreshReferences(database);

            if (!string.IsNullOrEmpty(NewsThreadId))
            {
                NewsThreadInitial = database.GetNewsThreadInitial(NewsThreadId);
            }
        }
Ejemplo n.º 6
0
        public void WriteChangesToDatabase(ITVTDatabase database)
        {
            using (var connection = GetConnection())
            {
                {
                    var newProgrammes = database.GetAllProgrammes(true, true).Where(x => x.IsNew);
                    TVTCommandsV3.Insert <TVTProgramme>(connection, TVTCommandsV3.GetProgrammeSQLDefinition(), newProgrammes);
                    newProgrammes.ToList().ForEach(x => { x.IsNew = false; x.IsChanged = false; });

                    var changedProgrammes = database.GetAllProgrammes(true, true).Where(x => x.IsChanged);
                    TVTCommandsV3.Update <TVTProgramme>(connection, TVTCommandsV3.GetProgrammeSQLDefinition(), changedProgrammes);
                    changedProgrammes.ToList().ForEach(x => { x.IsChanged = false; });
                }

                {
                    var newNews = database.GetAllNews().Where(x => x.IsNew);
                    TVTCommandsV3.Insert <TVTNews>(connection, TVTCommandsV3.GetNewsSQLDefinition(), newNews);
                    newNews.ToList().ForEach(x => { x.IsNew = false; x.IsChanged = false; });

                    var changedNews = database.GetAllNews().Where(x => x.IsChanged);
                    TVTCommandsV3.Update <TVTNews>(connection, TVTCommandsV3.GetNewsSQLDefinition(), changedNews);
                    changedNews.ToList().ForEach(x => { x.IsChanged = false; });
                }

                {
                    var newAds = database.GetAllAdvertisings().Where(x => x.IsNew);
                    TVTCommandsV3.Insert <TVTAdvertising>(connection, TVTCommandsV3.GetAdvertisingSQLDefinition(), newAds);
                    newAds.ToList().ForEach(x => { x.IsNew = false; x.IsChanged = false; });

                    var changedAds = database.GetAllAdvertisings().Where(x => x.IsChanged);
                    TVTCommandsV3.Update <TVTAdvertising>(connection, TVTCommandsV3.GetAdvertisingSQLDefinition(), changedAds);
                    changedAds.ToList().ForEach(x => { x.IsChanged = false; });
                }

                {
                    var newPeople = database.GetAllPeople().Where(x => x.IsNew);
                    TVTCommandsV3.Insert <TVTPerson>(connection, TVTCommandsV3.GetPersonSQLDefinition(), newPeople);
                    newPeople.ToList().ForEach(x => { x.IsNew = false; x.IsChanged = false; });

                    var changedPeople = database.GetAllPeople().Where(x => x.IsChanged);
                    TVTCommandsV3.Update <TVTPerson>(connection, TVTCommandsV3.GetPersonSQLDefinition(), changedPeople);
                    changedPeople.ToList().ForEach(x => { x.IsChanged = false; });
                }
            }
        }
Ejemplo n.º 7
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();
            }
        }
Ejemplo n.º 8
0
        public static List <TVTPerson> GetPersonsByNameOrCreate(ITVTDatabase database, string names, TVTDataType defaultType, bool isFakeName, TVTPersonFunction functionForNew = TVTPersonFunction.Unknown)
        {
            var result = new List <TVTPerson>();

            if (!string.IsNullOrEmpty(names))
            {
                var array = names.Split(',');
                foreach (var aValue in array)
                {
                    var personName = aValue.Trim();

                    var person = GetPersonByNameOrCreate(database, personName, defaultType, isFakeName, functionForNew);
                    if (person != null)
                    {
                        result.Add(person);
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 9
0
        private static void ConvertCommon(CommonOldV2 common, ITVTNames names, ITVTDatabase database, bool flipFake = false)
        {
            ConvertCommonMinimal(common, names, database);
            if (flipFake)
            {
                names.FakeTitleDE = common.title != null?common.title.Trim() : null;

                names.FakeTitleEN = common.titleEnglish != null?common.titleEnglish.Trim() : null;

                names.TitleDE = common.titleFake != null?common.titleFake.Trim() : null;

                names.TitleEN = common.titleEnglishFake != null?common.titleEnglishFake.Trim() : null;
            }
            else
            {
                names.FakeTitleDE = common.titleFake != null?common.titleFake.Trim() : null;

                names.FakeTitleEN = common.titleEnglishFake != null?common.titleEnglishFake.Trim() : null;
            }
        }
Ejemplo n.º 10
0
        public override void RefreshReferences(ITVTDatabase database)
        {
            if (ProductType == TVTProductType.Episode)
            {
                if (!string.IsNullOrEmpty(MasterId))
                {
                    if (SeriesMaster == null)
                    {
                        var master = database.GetProgrammeById(MasterId);
                        if (master != null)
                        {
                            SeriesMaster = new WeakReference <TVTProgramme>(master);
                        }
                    }
                }
                else if (SeriesMaster != null && SeriesMaster.IsAlive)
                {
                    MasterId = SeriesMaster.TargetGeneric.Id.ToString();
                }
            }
            else if (this.ProductType == TVTProductType.Series)
            {
                Children = database.GetEpisodesOfSeries(this.Id).OrderBy(x => x.EpisodeIndex).ToList <TVTProgramme>();
                MasterId = Id.ToString();
            }

            foreach (var member in Staff)
            {
                if (member.Person != null)
                {
                    if (member.Person.OnlyReference)
                    {
                        member.Person = database.GetPersonById(member.Person.Id);
                    }
                }
            }
        }
Ejemplo n.º 11
0
 public virtual void RefreshReferences(ITVTDatabase database)
 {
 }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
0
 public virtual void Load(XmlNode xmlNode, T entity, ITVTDatabase database)
 {
 }
Ejemplo n.º 14
0
 private static void ConvertCommonMinimal(CommonOldV2 common, ITVTNamesBasic names, ITVTDatabase database)
 {
     names.GenerateGuid();
     names.OldId         = common.id.ToString();
     names.TitleDE       = HttpUtility.HtmlDecode(common.title);;
     names.TitleEN       = common.titleEnglish;
     names.DescriptionDE = common.description;
     names.DescriptionEN = common.descriptionEnglish;
 }
Ejemplo n.º 15
0
        public static void RefreshMovieDescriptions(ITVTDatabase database)
        {
            var programme = new List <ITVTProgrammeCore>();

            programme.AddRange(database.GetAllProgrammes(true));
            programme.AddRange(database.GetAllEpisodes());

            foreach (var person in database.GetAllPeople())
            {
                var foundProgrammes = programme.Where(x => x.Staff.FirstOrDefault(y => y.Person == person) != null);
                foreach (var foundProgramme in foundProgrammes)
                {
                    var index = foundProgramme.Staff.FirstOrDefault(y => y.Person == person).Index;

                    if (!string.IsNullOrEmpty(foundProgramme.DescriptionDE))
                    {
                        if (person.FullName != " " && foundProgramme.DescriptionDE.Contains(person.FullName))
                        {
                            foundProgramme.DescriptionDE = foundProgramme.DescriptionDE.Replace(person.FullName, string.Format("[{0}|Full]", index));
                        }

                        if (!string.IsNullOrEmpty(person.FirstName) && foundProgramme.DescriptionDE.Contains(person.FirstName))
                        {
                            foundProgramme.DescriptionDE = foundProgramme.DescriptionDE.Replace(person.FirstName, string.Format("[{0}|First]", index));
                        }

                        if (!string.IsNullOrEmpty(person.LastName) && foundProgramme.DescriptionDE.Contains(person.LastName))
                        {
                            foundProgramme.DescriptionDE = foundProgramme.DescriptionDE.Replace(person.LastName, string.Format("[{0}|Last]", index));
                        }

                        if (!string.IsNullOrEmpty(person.NickName) && foundProgramme.DescriptionDE.Contains(person.NickName))
                        {
                            foundProgramme.DescriptionDE = foundProgramme.DescriptionDE.Replace(person.NickName, string.Format("[{0}|Nick]", index));
                        }
                    }


                    if (!string.IsNullOrEmpty(foundProgramme.DescriptionEN))
                    {
                        if (person.FullName != " " && foundProgramme.DescriptionEN.Contains(person.FullName))
                        {
                            foundProgramme.DescriptionEN = foundProgramme.DescriptionEN.Replace(person.FullName, string.Format("[{0}|Full]", index));
                        }

                        if (!string.IsNullOrEmpty(person.FirstName) && foundProgramme.DescriptionEN.Contains(person.FirstName))
                        {
                            foundProgramme.DescriptionEN = foundProgramme.DescriptionEN.Replace(person.FirstName, string.Format("[{0}|First]", index));
                        }

                        if (!string.IsNullOrEmpty(person.LastName) && foundProgramme.DescriptionEN.Contains(person.LastName))
                        {
                            foundProgramme.DescriptionEN = foundProgramme.DescriptionEN.Replace(person.LastName, string.Format("[{0}|Last]", index));
                        }

                        if (!string.IsNullOrEmpty(person.NickName) && foundProgramme.DescriptionEN.Contains(person.NickName))
                        {
                            foundProgramme.DescriptionEN = foundProgramme.DescriptionEN.Replace(person.NickName, string.Format("[{0}|Nick]", index));
                        }
                    }



                    if (!string.IsNullOrEmpty(foundProgramme.DescriptionDE))
                    {
                        if (person.FakeFullName != " " && foundProgramme.DescriptionDE.Contains(person.FakeFullName))
                        {
                            foundProgramme.DescriptionDE = foundProgramme.DescriptionDE.Replace(person.FakeFullName, string.Format("[{0}|Full]", index));
                        }

                        if (!string.IsNullOrEmpty(person.FakeFirstName) && foundProgramme.DescriptionDE.Contains(person.FakeFirstName))
                        {
                            foundProgramme.DescriptionDE = foundProgramme.DescriptionDE.Replace(person.FakeFirstName, string.Format("[{0}|First]", index));
                        }

                        if (!string.IsNullOrEmpty(person.FakeLastName) && foundProgramme.DescriptionDE.Contains(person.FakeLastName))
                        {
                            foundProgramme.DescriptionDE = foundProgramme.DescriptionDE.Replace(person.FakeLastName, string.Format("[{0}|Last]", index));
                        }

                        if (!string.IsNullOrEmpty(person.FakeNickName) && foundProgramme.DescriptionDE.Contains(person.FakeNickName))
                        {
                            foundProgramme.DescriptionDE = foundProgramme.DescriptionDE.Replace(person.FakeNickName, string.Format("[{0}|Nick]", index));
                        }
                    }

                    if (!string.IsNullOrEmpty(foundProgramme.DescriptionEN))
                    {
                        if (person.FakeFullName != " " && foundProgramme.DescriptionEN.Contains(person.FakeFullName))
                        {
                            foundProgramme.DescriptionEN = foundProgramme.DescriptionEN.Replace(person.FakeFullName, string.Format("[{0}|Full]", index));
                        }

                        if (!string.IsNullOrEmpty(person.FakeFirstName) && foundProgramme.DescriptionEN.Contains(person.FakeFirstName))
                        {
                            foundProgramme.DescriptionEN = foundProgramme.DescriptionEN.Replace(person.FakeFirstName, string.Format("[{0}|First]", index));
                        }

                        if (!string.IsNullOrEmpty(person.FakeLastName) && foundProgramme.DescriptionEN.Contains(person.FakeLastName))
                        {
                            foundProgramme.DescriptionEN = foundProgramme.DescriptionEN.Replace(person.FakeLastName, string.Format("[{0}|Last]", index));
                        }

                        if (!string.IsNullOrEmpty(person.FakeNickName) && foundProgramme.DescriptionEN.Contains(person.FakeNickName))
                        {
                            foundProgramme.DescriptionEN = foundProgramme.DescriptionEN.Replace(person.FakeNickName, string.Format("[{0}|Nick]", index));
                        }
                    }
                }
            }
        }
Ejemplo n.º 16
0
        public static void Convert(List <NewsOldV2> newsOldV2, ITVTDatabase database, TVTDataRoot dataRoot)
        {
            foreach (var newsSrc in newsOldV2)
            {
                var news = new TVTNews();
                news.DataRoot = dataRoot;

                ConvertCommonMinimal(newsSrc, news, database);

                if (newsSrc.parentID == 0)
                {
                    news.NewsType     = TVTNewsType.InitialNews;
                    news.NewsThreadId = newsSrc.id.ToString();
                    news.Tag          = -1;
                }
                else
                {
                    news.NewsType     = TVTNewsType.FollowingNews;
                    news.NewsThreadId = newsSrc.parentID.ToString();
                    news.Tag          = newsSrc.episode;
                }

                //PossibleFollower - erst später ermitteln;
                news.Genre = (TVTNewsGenre)newsSrc.genre;

                news.AvailableAfterDays       = -1;
                news.YearRangeFrom            = -1;
                news.YearRangeTo              = -1;
                news.MinHoursAfterPredecessor = -1;
                news.TimeRangeFrom            = -1;
                news.TimeRangeTo              = -1;

                news.Price   = ConvertOldToNewValue(newsSrc.price);
                news.Quality = ConvertOldToNewValue(newsSrc.topicality);

                news.Resource1Type = null;
                news.Resource2Type = null;
                news.Resource3Type = null;
                news.Resource4Type = null;

                database.AddNews(news);
            }

            var allNews = database.GetAllNews();

            List <string> threadsDone = new List <string>();

            //Episoden-ID fixen
            foreach (var news in allNews)
            {
                if (!threadsDone.Contains(news.NewsThreadId))
                {
                    var newsThread = allNews.Where(x => x.NewsThreadId == news.NewsThreadId);

                    var start = newsThread.FirstOrDefault(x => (int)x.Tag == -1);
                    start.Tag = 0;

                    var rest = newsThread.ToList();
                    rest.Remove(start);

                    var episode = 1;
                    foreach (var restNews in rest.OrderBy(x => x.Tag).ToList())
                    {
                        restNews.Tag = episode;
                        episode++;
                    }

                    threadsDone.Add(news.NewsThreadId);
                }
            }

            foreach (var news in allNews)
            {
                var episode = (int)news.Tag;

                TVTNews follower = allNews.FirstOrDefault(x => x.NewsThreadId == news.NewsThreadId && (int)x.Tag == episode + 1);
                if (follower != null)
                {
                    follower.NewsType = TVTNewsType.FollowingNews;
                    news.Effects.Add(new TVTNewsEffect(TVTNewsEffectType.TriggerNews, follower.Id.ToString()));
                }
                else
                {
                    if (news.NewsThreadId == news.OldId)
                    {
                        news.NewsType = TVTNewsType.InitialNews;
                    }
                    else
                    {
                        news.NewsType = TVTNewsType.FollowingNews;
                    }
                }
            }

            foreach (var news in allNews)
            {
                //if ( news.NewsType == TVTNewsType.SingleNews )
                //    news.NewsThreadId = null;
                //else
                //{
                TVTNews thread_owner = allNews.FirstOrDefault(x => x.OldId == news.NewsThreadId);
                news.NewsThreadId = thread_owner.Id.ToString();
                //}
            }
        }
Ejemplo n.º 17
0
        public static void Convert(List <MovieOldV2> moviesOldV2, ITVTDatabase database, TVTDataRoot dataRoot)
        {
            foreach (var movSrc in moviesOldV2)
            {
                if (movSrc.parentID == 0)                   //Film
                {
                    var programme = new TVTProgramme();
                    programme.DataRoot      = dataRoot;
                    programme.ProductType   = TVTProductType.Programme;
                    programme.ProgrammeType = TVTProgrammeType.Movie;
                    programme.Approved      = movSrc.approved;

                    ConvertEpisode(movSrc, programme, database);

                    programme.CriticsRate = ConvertOldToNewValue(movSrc.critics);
                    programme.ViewersRate = ConvertOldToNewValue(movSrc.speed);
                    programme.PriceMod    = ((float)movSrc.price) / 150;
                    if (programme.PriceMod == 0.0)
                    {
                        programme.PriceMod = 1;
                    }
                    else if (programme.PriceMod > 10)
                    {
                        programme.PriceMod = 10;
                    }

                    programme.BoxOfficeRate = ConvertOldToNewValue(movSrc.outcome);

                    programme.Year    = movSrc.year;
                    programme.Country = movSrc.country;
                    programme.Blocks  = movSrc.blocks;

                    ConvertGenreAndFlags(programme, movSrc);

                    if (programme.Flags.Contains(TVTProgrammeFlag.Live) && movSrc.time > 0)
                    {
                        programme.LiveHour = movSrc.time;
                    }

                    if (movSrc.xrated)
                    {
                        programme.Flags.Add(TVTProgrammeFlag.XRated);
                    }

                    database.AddProgramme(programme);
                }
                else                 //Serien-Episode
                {
                    var episode = new TVTProgramme();
                    episode.DataRoot      = dataRoot;
                    episode.ProductType   = TVTProductType.Episode;
                    episode.ProgrammeType = TVTProgrammeType.Movie;
                    episode.Approved      = movSrc.approved;
                    ConvertEpisode(movSrc, episode, database);

                    episode.Tag = movSrc.parentID.ToString();

                    episode.CriticsRate = ConvertOldToNewValue(movSrc.critics);
                    if (episode.CriticsRate == 0)
                    {
                        episode.CriticsRate = -1;
                    }
                    episode.ViewersRate = ConvertOldToNewValue(movSrc.speed);
                    if (episode.ViewersRate == 0)
                    {
                        episode.ViewersRate = -1;
                    }
                    episode.EpisodeIndex = movSrc.episode;

                    episode.DistributionChannel = TVTDistributionChannel.Inherit;
                    episode.MainGenre           = TVTProgrammeGenre.Inherit;
                    episode.SubGenre            = TVTProgrammeGenre.Inherit;
                    episode.Flags.Add(TVTProgrammeFlag.Inhert);

                    episode.LiveHour = -1;

                    episode.TargetGroups.Add(TVTTargetGroup.Inhert);
                    episode.ProPressureGroups.Add(TVTPressureGroup.Inhert);
                    episode.ContraPressureGroups.Add(TVTPressureGroup.Inhert);

                    database.AddProgramme(episode);
                }
            }

            //Nachträglich die Parents auf IsSeries setzen
            var allMovies = database.GetAllProgrammes(true);

            foreach (var current in database.GetAllEpisodes())
            {
                var series = allMovies.FirstOrDefault(x => x.OldId.CompareTo(current.Tag) == 0);
                if (series != null)
                {
                    series.ProductType   = TVTProductType.Series;
                    current.SeriesMaster = new CodeKnight.Core.WeakReference <TVTProgramme>(series);
                }
                else
                {
                    current.DataStatus = TVTDataStatus.Incorrect;
                }
            }
        }
Ejemplo n.º 18
0
        private static void ConvertEpisode(MovieOldV2 movieOldV2, ITVTProgrammeCore episode, ITVTDatabase database)
        {
            if (movieOldV2.custom)
            {
                episode.DataType = TVTDataType.Fictitious;
            }
            else
            {
                episode.DataType = TVTDataType.Undefined;
            }

            ConvertCommon(movieOldV2, episode, database);
            episode.CreatorId    = movieOldV2.creatorID;
            episode.EditorId     = movieOldV2.editorID;
            episode.LastModified = new DateTime(2004, 1, 1);

            var director = GetPersonByNameOrCreate(database, movieOldV2.director, episode.DataType, movieOldV2.useFakeNames, TVTPersonFunction.Director);

            if (director != null)
            {
                episode.Staff.Add(new TVTStaff(director, TVTPersonFunction.Director));
            }

            var actors = GetPersonsByNameOrCreate(database, movieOldV2.actors, episode.DataType, movieOldV2.useFakeNames, TVTPersonFunction.Actor);

            actors.ForEach(x => episode.Staff.Add(new TVTStaff(x, TVTPersonFunction.Actor)));
        }
Ejemplo n.º 19
0
 public DatabaseMerging(ITVTDatabase leadingDatabase)
 {
     LeadingDatabase = leadingDatabase;
 }
Ejemplo n.º 20
0
        public static void FakePersonNames(ITVTDatabase database)
        {
            //var syl = new Dictionary<string, int>();

            //foreach (var person in database.GetAllPeople())
            //{
            //    var name = person.LastName;
            //    for (var i = 0; i <= name.Length - 3; i++)
            //    {
            //        var currSylKey = name.Substring(i, 3);
            //        if (!currSylKey.Contains(' '))
            //        {
            //            currSylKey = currSylKey.ToLower();

            //            if (syl.ContainsKey(currSylKey))
            //                syl[currSylKey] = syl[currSylKey] + 1;
            //            else
            //                syl.Add(currSylKey, 1);
            //        }
            //    }
            //}

            //var myList = syl.ToList();

            //myList.Sort((firstPair, nextPair) =>
            //{
            //    return firstPair.Value.CompareTo(nextPair.Value)*-1;
            //}
            //);

            //var i2 = 0;
            //foreach (var entry in myList)
            //{
            //    Console.WriteLine(entry.Key + " = " + entry.Value);
            //    i2++;
            //    if (i2 >= 100)
            //        break;
            //}

            int count = 0;
            var faker = new NameFaker();

            faker.InitializeData();

            foreach (var person in database.GetAllPeople())
            {
                if (person.DataType != TVTDataType.Fictitious)
                {
                    if (string.IsNullOrEmpty(person.FakeLastName) || person.LastName == person.FakeLastName)
                    {
                        var tempFakeName = faker.Fake(person.LastName);
                        if (tempFakeName != person.LastName)
                        {
                            person.FakeLastName = tempFakeName;
                        }
                        else
                        {
                            person.FakeLastName = tempFakeName.Substring(0, 1) + ".";
                            Console.WriteLine(person.LastName);
                            count++;
                        }
                    }
                }
            }
            Console.WriteLine("Result: " + count);
        }