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 static TVTPerson GetMinimalPerson(string firstName, string lastName)
        {
            var person = new TVTPerson();

            person.GenerateGuid();
            person.FirstName = firstName;
            person.LastName  = lastName;
            return(person);
        }
Ejemplo n.º 3
0
        public static void ConvertFullname(TVTPerson person, string fullname)
        {
            string firstName = null;
            string lastName  = null;

            ConvertFullnameInternal(fullname, out firstName, out lastName);

            person.FirstName = firstName;
            person.LastName  = lastName;
        }
Ejemplo n.º 4
0
        public static TVTPerson GetIconicPerson(string firstName, string lastName)
        {
            var person = new TVTPerson();

            person.GenerateGuid();
            person.OldId        = "110";
            person.DataType     = TVTDataType.Undefined;
            person.DataStatus   = TVTDataStatus.Approved;
            person.DataRoot     = TVTDataRoot.MadTV;
            person.DataUsage    = TVTDataUsage.MadTVOriginal;
            person.Approved     = true;
            person.CreatorId    = "creatorX";
            person.EditorId     = "editorY";
            person.LastModified = DateTime.Now.AddDays(-1);
            person.IsNew        = true;
            person.IsChanged    = true;

            person.FirstName = firstName;
            person.LastName  = lastName;
            person.NickName  = "nick";

            person.FakeFirstName = firstName + "Fake";
            person.FakeLastName  = lastName + "Fake";
            person.FakeNickName  = "nickFake";

            person.TmdbId   = 111;
            person.ImdbId   = "dbdb";
            person.ImageUrl = "imgUrl";

            person.Functions.Add(TVTPersonFunction.Actor);

            person.Gender         = TVTPersonGender.Female;
            person.Birthday       = 1999;
            person.Deathday       = 2010;
            person.Country        = "FR";
            person.Prominence     = 2;
            person.Skill          = 99;
            person.Fame           = 10;
            person.Scandalizing   = 33;
            person.PriceMod       = 20;
            person.Power          = 30;
            person.Humor          = 20;
            person.Charisma       = 70;
            person.Appearance     = 80;
            person.TopGenre1      = TVTProgrammeGenre.Erotic;
            person.TopGenre2      = TVTProgrammeGenre.Fantasy;
            person.ProgrammeCount = 33;

            return(person);
        }
Ejemplo n.º 5
0
        public TVTPerson RegisterDirector(Crew crew)
        {
            var person = Database.GetPersonByTmdbId(crew.id);

            if (person == null)
            {
                person = new TVTPerson();
                PersonConverter.ConvertFullname(person, crew.name);
                person.TmdbId = crew.id;
                person.Functions.Add(TVTPersonFunction.Director);
                person.AdditionalInfo = crew.job + "/" + crew.department;

                RegisterPerson(person, crew.id);

                Database.AddPerson(person);
            }

            return(person);
        }
Ejemplo n.º 6
0
        public TVTPerson RegisterActor(Cast cast)
        {
            var person = Database.GetPersonByTmdbId(cast.id);

            if (person == null)
            {
                person = new TVTPerson();
                PersonConverter.ConvertFullname(person, cast.name);
                person.TmdbId = cast.id;
                person.Functions.Add(TVTPersonFunction.Actor);
                person.AdditionalInfo = cast.character;

                RegisterPerson(person, cast.id);

                Database.AddPerson(person);
            }

            return(person);
        }
Ejemplo n.º 7
0
        public void AssertPeople(TVTPerson pers1, TVTPerson pers2, TestMode testMode, bool isFake = false)
        {
            AssertEntity(pers1, pers2, testMode);

            if (isFake)
            {
                Assert.AreEqual(pers1.FakeFirstName, pers2.FakeFirstName);
                Assert.AreEqual(pers1.FakeLastName, pers2.FakeLastName);
                Assert.AreEqual(pers1.FakeNickName, pers2.FakeNickName);
            }
            else
            {
                Assert.AreEqual(pers1.FirstName, pers2.FirstName);
                Assert.AreEqual(pers1.LastName, pers2.LastName);
                Assert.AreEqual(pers1.NickName, pers2.NickName);
            }
            Assert.AreEqual(pers1.TmdbId, pers2.TmdbId);
            Assert.AreEqual(pers1.ImdbId, pers2.ImdbId);
            Assert.AreEqual(pers1.ImageUrl, pers2.ImageUrl);
            AssertExt.AreCollectionEqual(pers1.Functions, pers2.Functions);
            Assert.AreEqual(pers1.Gender, pers2.Gender);
            Assert.AreEqual(pers1.Birthday, pers2.Birthday);
            Assert.AreEqual(pers1.Deathday, pers2.Deathday);
            Assert.AreEqual(pers1.Country, pers2.Country);
            Assert.AreEqual(pers1.Prominence, pers2.Prominence);
            Assert.AreEqual(pers1.Skill, pers2.Skill);
            Assert.AreEqual(pers1.Fame, pers2.Fame);
            Assert.AreEqual(pers1.Scandalizing, pers2.Scandalizing);
            Assert.AreEqual(pers1.PriceMod, pers2.PriceMod);
            Assert.AreEqual(pers1.Power, pers2.Power);
            Assert.AreEqual(pers1.Humor, pers2.Humor);
            Assert.AreEqual(pers1.Charisma, pers2.Charisma);
            Assert.AreEqual(pers1.Appearance, pers2.Appearance);
            Assert.AreEqual(pers1.TopGenre1, pers2.TopGenre1);
            Assert.AreEqual(pers1.TopGenre2, pers2.TopGenre2);
            if (testMode != TestMode.XMLV3)
            {
                Assert.AreEqual(pers1.ProgrammeCount, pers2.ProgrammeCount);
            }
        }
Ejemplo n.º 8
0
        private void RegisterPerson(TVTPerson person, int id)
        {
            RequestChecker.TmDbReadyOrWait();
            var personInfo = ServiceApi.TmdbApi.GetPersonInfo(id);

            person.ImdbId   = personInfo.imdb_id;
            person.ImageUrl = @"https://d3gtl9l2a4fn1j.cloudfront.net/t/p/original" + personInfo.profile_path;
            int parseValue;

            if (int.TryParse(personInfo.birthday, out parseValue))
            {
                person.Birthday = parseValue;
            }

            if (int.TryParse(personInfo.deathday, out parseValue))
            {
                person.Deathday = parseValue;
            }
            //person.PlaceOfBirth = personInfo.place_of_birth;
            person.Country = GetCountryCode(GetCountry(personInfo.place_of_birth));
            //person.MovieRegistrations++;
        }
        //public void AddEpisode( TVTEpisode episode )
        //{
        //    EpisodeData.Add( episode );
        //}

        //public void AddEpisodes( IEnumerable<TVTEpisode> episodes )
        //{
        //    foreach ( var episode in episodes )
        //        AddEpisode( episode );
        //}

        public void AddPerson(TVTPerson person)
        {
            PersonData.Add(person);
        }
Ejemplo n.º 10
0
        public void MergeProgrammeData(TVTProgramme target, TVTProgramme leading, bool mergeStaffOnlyWhenEmpty = false)
        {
            //new List<string>() { "Staff", "Children", "SeriesMaster", "MasterId" }

            var type = typeof(TVTProgramme);

            foreach (var property in type.GetProperties())
            {
                if (property.Name == "Staff")
                {
                    if (!mergeStaffOnlyWhenEmpty || (target.Staff == null || target.Staff.Count == 0))
                    {
                        target.Staff.Clear();

                        foreach (var member in leading.Staff)
                        {
                            var person = FindPersonMatch(member.Person);

                            if (person == null)
                            {
                                if (member.Person.FakeLastName != "-" && member.Person.FakeLastName != "XXX")
                                {
                                    person = new TVTPerson();
                                    person.GenerateGuid();
                                    CopyPropertyValues <TVTPerson>(person, member.Person);
                                    person.IsNew     = true;
                                    person.IsChanged = true;
                                    LeadingDatabase.AddPerson(person);
                                }
                            }

                            if (person != null)
                            {
                                target.Staff.Add(new TVTStaff(person, member.Function, member.Index));
                            }
                        }
                    }
                }
                else if (property.Name == "Children")
                {
                    if (target.ProductType == TVTProductType.Series || target.ProductType == TVTProductType.Bundle)
                    {
                        if (target.Children != null)
                        {
                            target.Children.Clear();
                        }
                        else
                        {
                            target.Children = new List <TVTProgramme>();
                        }

                        foreach (var child in leading.Children)
                        {
                            var episode = FindProgrammeMatch(child);

                            if (episode == null)
                            {
                                episode = new TVTProgramme();
                                episode.GenerateGuid();
                                MergeProgrammeData(episode, child);
                                episode.IsNew = true;
                                LeadingDatabase.AddProgramme(episode);
                            }

                            if (episode != null)
                            {
                                episode.SeriesMaster = new WeakReference <TVTProgramme>(target);
                                episode.MasterId     = target.Id.ToString();
                                episode.IsChanged    = true;
                                target.Children.Add(episode);
                            }
                        }
                    }
                }
                else if (property.Name == "Children" || property.Name == "SeriesMaster" || property.Name == "MasterId")
                {
                    //TODO: Später mehr
                }
                else
                {
                    if (property.Name != "Id")
                    {
                        if (property.CanWrite && property.CanRead)
                        {
                            property.SetValue(target, property.GetValue(leading, null), null);
                        }
                    }
                }
            }
        }
Ejemplo n.º 11
0
        public TVTPerson FindPersonMatch(TVTPerson other)
        {
            var allPeople = LeadingDatabase.GetAllPeople();

            var person = allPeople.FirstOrDefault(x => x.Id == other.Id);

            if (person != null)
            {
                return(person);
            }

            if (other.TmdbId > 0)
            {
                person = allPeople.FirstOrDefault(x => x.TmdbId == other.TmdbId);
                if (person != null)
                {
                    return(person);
                }
            }

            var results1 = allPeople.Where(x => x.FullName == other.FullName || x.FakeFullName == other.FullName || x.FullName == other.FakeFullName || x.FakeFullName == other.FakeFullName);

            if (results1.Count() == 1)
            {
                return(results1.First());
            }
            else
            {
                var results2 = allPeople.Where(new Func <TVTPerson, bool>(x =>
                {
                    //if ( x.Genre == other.Genre && x.Topicality == other.Topicality && x.NewsType == other.NewsType && x.Price == other.Price )
                    //{
                    //    if ( x.NewsType == TVTNewsType.FollowingNews && !string.IsNullOrEmpty( x.NewsThreadId ) && !string.IsNullOrEmpty( other.NewsThreadId ) )
                    //    {
                    //        if ( x.NewsThreadInitial != null && other.NewsThreadInitial != null )
                    //        {
                    //            if ( x.NewsThreadInitial.TitleDE == other.NewsThreadInitial.TitleDE )
                    //                return true;
                    //        }
                    //        else
                    //            return true;
                    //    }
                    //    else
                    //        return true;
                    //}

                    return(false);
                }));

                if (results2.Count() == 0)
                {
                    System.Diagnostics.Trace.WriteLine("Not found: " + other.FullName);
                }
                else if (results2.Count() == 1)
                {
                    return(results2.First());
                }
                else
                {
                    System.Diagnostics.Trace.WriteLine("Found more then one: " + other.FullName);
                }
            }

            return(null);
        }