Ejemplo n.º 1
0
 public SearchItem(SearchPerson person)
 {
     MediaType  = MediaType.Person;
     Id         = person.Id;
     ResultName = person.Name;
     ImageUri   = ModelUtils.GetImageUri(person?.ProfilePath);
 }
        public List <IOutData> GetPersonHierarchyById(IInData input)
        {
            SearchPerson person = ((SearchPerson)input);

            return(this._VansawaliContext.LoadStoredProc("USP_GetPerson_Hierarchy_ByPersonId")
                   .WithSqlParam("@PersonId", person.PersonId)
                   .ExecuteStoredProc <PersonHierarchy>().ToList <IOutData>());
        }
Ejemplo n.º 3
0
        public PersonNode(IPerson person) : base(BuildNodeName(person))
        {
            _profiles = new Dictionary <string, Jobs>();

            Person = new SearchPerson(person.FirstName, person.MiddleName, person.LastName, person.BirthYear);

            Tag = this;
        }
        public ActionResult <IEnumerable <IOutData> > Get(string name, int villageId)
        {
            SearchPerson person = new SearchPerson {
                PersonId = 0, Name = name, VillageId = villageId
            };

            return(this._PersonService.GetPersonListByName(person));
        }
Ejemplo n.º 5
0
 private void WatermarkTextBox_TextChanged(object sender, TextChangedEventArgs e)
 {
     ViewModel.Persons.Clear();
     foreach (var person in SearchPerson.GetAll(ViewModel.LastName, ViewModel.FirstName, ViewModel.Patronymic, ViewModel.PassportSerial, ViewModel.AccountNumber))
     {
         ViewModel.Persons.Add(person);
     }
 }
        public ActionResult <IEnumerable <IOutData> > Get(int personid, int name)
        {
            //Console.Write("PErsonId: "+personid);
            SearchPerson person = new SearchPerson {
                PersonId = personid
            };

            return(this._PersonService.GetPersonHierarchyById(person));
        }
        public List <IOutData> GetPersonListByName(IInData input)
        {
            SearchPerson person = ((SearchPerson)input);

            return(this._VansawaliContext.LoadStoredProc("USP_Get_Person_ByName")
                   .WithSqlParam("@PersonName", person.Name)
                   .WithSqlParam("@VillageId", person.VillageId)
                   .ExecuteStoredProc <SearchPerson>().ToList <IOutData>());
        }
Ejemplo n.º 8
0
        private PersonContainer GetContainer(SearchPerson item)
        {
            PersonContainer container = People.FindById(item.Id);

            if (container == null)
            {
                container = new PersonContainer(item);
            }

            return(container);
        }
Ejemplo n.º 9
0
        public async Task TestSearchPersonAsync()
        {
            await TestHelpers.SearchPagesAsync(i => TMDbClient.SearchPersonAsync("Willis", i));

            SearchContainer <SearchPerson> result = await TMDbClient.SearchPersonAsync("Willis");

            SearchPerson item = result.Results.Single(s => s.Id == 62);

            await Verify(item);

            TestImagesHelpers.TestImagePaths(new[] { item.ProfilePath });
        }
Ejemplo n.º 10
0
        private static SearchPerson AddPerson(SearchPerson person)
        {
            SearchPerson existingItem = People.FirstOrDefault(x => x.Id == person.Id);

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

            People.Add(person);
            return(person);
        }
        public void AudreyDana()
        {
            var actor = new SearchPerson(firstName: "Audrey", lastName: "Dana", birthYear: 1977);

            var startNode = _graph.Nodes.First(n => n.Name == PersonNode.BuildNodeName(actor));

            var results = (new DeepFirstAlgorithm(_graph)).GetAllDistances(startNode);

            var distances = results.Values.Where(d => d > 2 && d < double.PositiveInfinity).ToList();

            var maxDistance = distances.Max();

            var maxDistances = results.Where(kvp => kvp.Value == maxDistance).ToList();
        }
Ejemplo n.º 12
0
        public void SearchBaseConverter_Person()
        {
            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.Converters.Add(new SearchBaseConverter());

            SearchPerson original = new SearchPerson();

            original.Name = "Hello world";

            string       json   = JsonConvert.SerializeObject(original, settings);
            SearchPerson result = JsonConvert.DeserializeObject <SearchBase>(json, settings) as SearchPerson;

            Assert.NotNull(result);
            Assert.Equal(original.MediaType, result.MediaType);
            Assert.Equal(original.Name, result.Name);
        }
Ejemplo n.º 13
0
        public async Task SearchBaseConverter_Person()
        {
            SearchPerson original = new SearchPerson();

            original.Name = "Hello world";

            string       json   = Serializer.SerializeToString(original);
            SearchPerson result = Serializer.DeserializeFromString <SearchBase>(json) as SearchPerson;

            Assert.Equal(original.MediaType, result.MediaType);
            Assert.Equal(original.Name, result.Name);
            await Verify(new
            {
                json,
                result
            });
        }
Ejemplo n.º 14
0
        private void LookUpName()
        {
            ResultListView.Items.Clear();

            var searchFor = new SearchPerson(FirstNameTextBox.Text, MiddleNameTextBox.Text, LastNameTextBox.Text, (ushort)BirthYearUpDown.Value);

            var matches = PersonFinder.Find(searchFor, _searchIn);

            var rows = matches.Select(CreateRow).ToArray();

            ResultListView.Items.AddRange(rows);

            if (ResultListView.Items.Count > 0)
            {
                ResultListView.Items[0].Selected = true;
            }
        }
Ejemplo n.º 15
0
        public void TestSearchPerson()
        {
            TestHelpers.SearchPages(i => _config.Client.SearchPerson("Willis", i).Result);

            SearchContainer <SearchPerson> result = _config.Client.SearchPerson("Willis").Result;

            Assert.IsTrue(result.Results.Any());
            SearchPerson item = result.Results.SingleOrDefault(s => s.Id == 62);

            Assert.IsNotNull(item);
            Assert.AreEqual(62, item.Id);
            Assert.AreEqual("Bruce Willis", item.Name);
            Assert.AreEqual("/kI1OluWhLJk3pnR19VjOfABpnTY.jpg", item.ProfilePath);
            Assert.AreEqual(false, item.Adult);
            Assert.IsTrue(item.Popularity > 0);

            Assert.IsNotNull(item.KnownFor);
            Assert.IsTrue(item.KnownFor.Any(s => s.Id == 680));
        }
Ejemplo n.º 16
0
        public void TestSearchPerson()
        {
            TestHelpers.SearchPages(i => Config.Client.SearchPersonAsync("Willis", i).Result);

            SearchContainer <SearchPerson> result = Config.Client.SearchPersonAsync("Willis").Result;

            Assert.True(result.Results.Any());
            SearchPerson item = result.Results.SingleOrDefault(s => s.Id == 62);

            Assert.NotNull(item);
            Assert.Equal(62, item.Id);
            Assert.Equal("Bruce Willis", item.Name);
            Assert.True(TestImagesHelpers.TestImagePath(item.ProfilePath), "item.ProfilePath was not a valid image path, was: " + item.ProfilePath);
            Assert.Equal(false, item.Adult);
            Assert.True(item.Popularity > 0);

            Assert.NotNull(item.KnownFor);
            Assert.True(item.KnownFor.Any(s => s.Id == 680));
        }
Ejemplo n.º 17
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            JObject jObject = JObject.Load(reader);

            SearchBase result;

            if (jObject["media_type"] == null)
            {
                // We cannot determine the correct type, let's hope we were provided one
                result = (SearchBase)Activator.CreateInstance(objectType);
            }
            else
            {
                // Determine the type based on the media_type
                MediaType mediaType = jObject["media_type"].ToObject <MediaType>();

                switch (mediaType)
                {
                case MediaType.Movie:
                    result = new SearchMovie();
                    break;

                case MediaType.Tv:
                    result = new SearchTv();
                    break;

                case MediaType.Person:
                    result = new SearchPerson();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            // Populate the result
            serializer.Populate(jObject.CreateReader(), result);

            return(result);
        }
Ejemplo n.º 18
0
        private void SearchPeople(List <SearchPerson> itemList, string query)
        {
            foreach (SearchPerson item in itemList)
            {
                AddPerson(item);
            }

            SearchPerson match = People.FirstOrDefault(x => x.Name.Equals(query, StringComparison.OrdinalIgnoreCase));

            if (match == null)
            {
                match = People.FirstOrDefault(x => x.Name.StartsWith(query, StringComparison.OrdinalIgnoreCase));
            }
            if (match == null)
            {
                match = People.FirstOrDefault(x => x.Name.IndexOf(query, StringComparison.OrdinalIgnoreCase) > 0);
            }

            if (match != null)
            {
                SelectedItems.Add(match);
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// This method is used to populate the list
        /// </summary>
        /// <param name="races"></param>
        /// <returns></returns>
        public List <SearchPerson> GetSearchPersonList(string races)
        {
            List <SearchPerson> personList = new List <SearchPerson>();

            if (!string.IsNullOrEmpty(races))
            {
                using (PersonContext context = new PersonContext())
                {
                    var person = context.person.Where(p => p.Races == races && p.Age / 2 == 0).ToList();
                    foreach (var item in person)
                    {
                        SearchPerson searchPerson = new SearchPerson();
                        searchPerson.PersonName = item.PersonName;
                        searchPerson.Races      = item.Races;
                        searchPerson.Age        = item.Age;
                        searchPerson.Height     = item.Height;
                        personList.Add(searchPerson);
                    }
                    context.Database.Connection.Close();
                }
            }
            return(personList);
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Convert a <see cref="SearchPerson"/> to a <see cref="People"/>.
 /// </summary>
 /// <param name="person">An internal TheMovieDB person.</param>
 /// <param name="provider">The provider that represent TheMovieDB inside Kyoo.</param>
 /// <returns>A <see cref="People"/> representing the person.</returns>
 public static People ToPeople(this SearchPerson person, Provider provider)
 {
     return(new People
     {
         Slug = Utility.ToSlug(person.Name),
         Name = person.Name,
         Images = new Dictionary <int, string>
         {
             [Images.Poster] = person.ProfilePath != null
                                         ? $"https://image.tmdb.org/t/p/original{person.ProfilePath}"
                                         : null
         },
         ExternalIDs = new[]
         {
             new MetadataID
             {
                 Provider = provider,
                 DataID = person.Id.ToString(),
                 Link = $"https://www.themoviedb.org/person/{person.Id}"
             }
         }
     });
 }
Ejemplo n.º 21
0
        public void TomHollandToToshiroMifuneDegree4()
        {
            var sourcePerson = new SearchPerson(firstName: "Tom", lastName: "Holland", birthYear: 1996);
            var targetPerson = new SearchPerson(firstName: "Toshirô", lastName: "Mifune", birthYear: 1920);

            var sourceNode = _graph.GetDistanceNode(PersonNode.BuildNodeName(sourcePerson));
            var targetNode = _graph.GetDistanceNode(PersonNode.BuildNodeName(targetPerson));

            var calculator = new DeepFirstAlgorithm(_graph);

            var shortestGraph = calculator.GetShortestGraph(sourceNode.Name, targetNode.Name);

            var shortestGraphTargetNode = shortestGraph.GetDistanceNode(PersonNode.BuildNodeName(targetPerson));

            var movieDistance = ForwardUnitTestSample.GetRealMovieDistance(shortestGraphTargetNode);

            Assert.AreEqual(4, movieDistance);

            var stepsList = GraphHelper.GetPaths(shortestGraphTargetNode).ToList();

            Assert.AreEqual(18, stepsList.Count);

            CheckSteps(sourceNode, targetNode, stepsList, movieDistance * 2);
        }
Ejemplo n.º 22
0
        public void TomWellingToGeorgeLucasDegree2Deep()
        {
            var sourcePerson = new SearchPerson(firstName: "Tom", lastName: "Welling", birthYear: 1977);
            var targetPerson = new SearchPerson(firstName: "George", lastName: "Lucas", birthYear: 1944);

            var sourceNode = _graph.GetDistanceNode(PersonNode.BuildNodeName(sourcePerson));
            var targetNode = _graph.GetDistanceNode(PersonNode.BuildNodeName(targetPerson));

            var calculator = new DeepFirstAlgorithm(_graph);

            var shortestGraph = calculator.GetShortestGraph(sourceNode.Name, targetNode.Name);

            var shortestGraphTargetNode = shortestGraph.GetDistanceNode(PersonNode.BuildNodeName(targetPerson));

            var movieDistance = ForwardUnitTestSample.GetRealMovieDistance(shortestGraphTargetNode);

            Assert.AreEqual(2, movieDistance);

            var stepsList = GraphHelper.GetPaths(shortestGraphTargetNode).ToList();

            Assert.AreEqual(1, stepsList.Count);

            ForwardUnitTestSample.CheckSteps(sourceNode, targetNode, stepsList, movieDistance * 2);
        }
        public void Test3Deep()
        {
            var sourcePerson = new SearchPerson(firstName: "Hans", lastName: "Alfredson");
            var targetPerson = new SearchPerson(firstName: "John", lastName: "Wayne");

            var sourceNode = _graph.GetDistanceNode(PersonNode.BuildNodeName(sourcePerson));
            var targetNode = _graph.GetDistanceNode(PersonNode.BuildNodeName(targetPerson));

            var calculator = new DeepFirstAlgorithm(_graph);

            var shortestGraph = calculator.GetShortestGraph(sourceNode.Name, targetNode.Name);

            var shortestGraphTargetNode = shortestGraph.GetDistanceNode(PersonNode.BuildNodeName(targetPerson));

            var movieDistance = ForwardUnitTestSample.GetRealMovieDistance(shortestGraphTargetNode);

            Assert.AreEqual(2, movieDistance);

            var stepsList = GraphHelper.GetPaths(shortestGraphTargetNode).ToList();

            Assert.AreEqual(1, stepsList.Count);

            ForwardUnitTestSample.CheckSteps(sourceNode, targetNode, stepsList, movieDistance * 2);
        }
Ejemplo n.º 24
0
        static TokenComboBoxEdit()
        {
            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MovieMatrix.Assets.Data.AutoSuggestData.zip"))
            {
                using (ZipArchive archive = new ZipArchive(stream))
                {
                    foreach (ZipArchiveEntry entry in archive.Entries)
                    {
                        if (entry.Name == "Companies.txt")
                        {
                            List <SearchCompany> companies = new List <SearchCompany>();
                            using (StreamReader reader = new StreamReader(entry.Open()))
                            {
                                string line = String.Empty;
                                while ((line = reader.ReadLine()) != null)
                                {
                                    SearchCompany company = JsonConvert.DeserializeObject <SearchCompany>(line);
                                    companies.Add(company);
                                }
                            }

                            Companies = new ObservableCollection <SearchCompany>(companies);
                        }
                        else if (entry.Name == "Keywords.txt")
                        {
                            List <SearchKeyword> keywords = new List <SearchKeyword>();
                            using (StreamReader reader = new StreamReader(entry.Open()))
                            {
                                string line = String.Empty;
                                while ((line = reader.ReadLine()) != null)
                                {
                                    SearchKeyword keyword = JsonConvert.DeserializeObject <SearchKeyword>(line);
                                    keywords.Add(keyword);
                                }
                            }

                            Keywords = new ObservableCollection <SearchKeyword>(keywords);
                        }
                        else if (entry.Name == "Networks.txt")
                        {
                            List <Network> networks = new List <Network>();
                            using (StreamReader reader = new StreamReader(entry.Open()))
                            {
                                string line = String.Empty;
                                while ((line = reader.ReadLine()) != null)
                                {
                                    Network network = JsonConvert.DeserializeObject <Network>(line);
                                    networks.Add(network);
                                }
                            }

                            Networks = new ObservableCollection <Network>(networks);
                        }
                        else if (entry.Name == "People.txt")
                        {
                            List <SearchPerson> people = new List <SearchPerson>();
                            using (StreamReader reader = new StreamReader(entry.Open()))
                            {
                                string line = String.Empty;
                                while ((line = reader.ReadLine()) != null)
                                {
                                    SearchPerson person = JsonConvert.DeserializeObject <SearchPerson>(line);
                                    people.Add(person);
                                }
                            }

                            People = new ObservableCollection <SearchPerson>(people);
                        }
                    }
                }
            }
        }
Ejemplo n.º 25
0
        public NewPersonVM()
        {
            Persons = new ObservableCollection <ResponsiblePerson>(ResponsiblePersonHandler.Instance.GetResponsiblePerson().OrderBy(p => p.Name));

            SaveCommand = new RelayCommand((o) =>
            {
                ResponsiblePerson vorhanden = ResponsiblePersonHandler.Instance.GetResponsiblePerson().Find(r => r.Name == Name && r.OfficeNumber == OfficeNumber && r.Department == Department);
                if (vorhanden == null && Name != null && OfficeNumber != null && Department != null)
                {
                    ResponsiblePerson r = new ResponsiblePerson()
                    {
                        Name         = Name,
                        OfficeNumber = OfficeNumber,
                        Department   = Department
                    };
                    ResponsiblePersonHandler.Instance.AddResponsiblePerson(r);
                    Persons.Add(r);
                    ResponsiblePersonHandler.Instance.Save(r);
                    Cancel(o);
                }
                else if (vorhanden != null)
                {
                    MessageBox.Show("This person already exists");
                }
                else if (Name == null)
                {
                    MessageBox.Show("Enter a name");
                }
                else if (OfficeNumber == null)
                {
                    MessageBox.Show("Enter the office Number");
                }
                else if (Department == null)
                {
                    MessageBox.Show($"Enter the department");
                }
            });

            CancelCommand = new RelayCommand(Cancel);

            ExitCommand = new RelayCommand(Exit);

            SearchCommand = new RelayCommand((o) =>
            {
                Persons = new ObservableCollection <ResponsiblePerson>(ResponsiblePersonHandler.Instance.GetResponsiblePerson().FindAll(r => r.Name.ToLower().Contains(SearchPerson.ToLower())));
            });

            SortCommand = new RelayCommand((o) =>
            {
                if (Sort == "Sort")
                {
                    Persons = new ObservableCollection <ResponsiblePerson>(ResponsiblePersonHandler.Instance.GetResponsiblePerson().OrderBy(r => r.Name));
                    Sort    = "Sort";
                }
                else if (Sort == "Kunden sortieren")
                {
                    //Rechnungen = new ObservableCollection<Rechnung>(Buchhaltung.Instance.GetRechnungen().OrderBy(r => r.KundenNummer));
                    //Sortieren = "Rechnung sortieren";
                }
            });

            SelectCommand = new RelayCommand(SelectPerson);

            ChangeCommand = new RelayCommand((o) =>
            {
                bool[] geandert = new bool[3] {
                    false, false, false
                };
                ResponsiblePerson vorhanden = ResponsiblePersonHandler.Instance.GetResponsiblePerson().Find(r => r.PersonID == PersonID);
                if (Name != null && OfficeNumber != null && Department != null)
                {
                    ResponsiblePerson r = new ResponsiblePerson()
                    {
                        PersonID     = vorhanden.PersonID,
                        Name         = Name,
                        OfficeNumber = OfficeNumber,
                        Department   = Department
                    };
                    if (vorhanden != null)
                    {
                        if (vorhanden.Name == null || r.Name != vorhanden.Name)
                        {
                            geandert[0] = true;
                        }
                        if (vorhanden.OfficeNumber == null || r.OfficeNumber != vorhanden.OfficeNumber)
                        {
                            geandert[1] = true;
                        }
                        if (vorhanden.Department == null || r.Department != vorhanden.Department)
                        {
                            geandert[2] = true;
                        }
                    }
                    else
                    {
                        geandert[0] = true;
                        geandert[1] = true;
                        geandert[2] = true;
                    }

                    ResponsiblePersonHandler.Instance.RemoveResponsiblePerson(vorhanden);
                    ResponsiblePersonHandler.Instance.AddResponsiblePerson(r);
                    ResponsiblePersonHandler.Instance.Change(r, geandert);
                    Persons = new ObservableCollection <ResponsiblePerson>(ResponsiblePersonHandler.Instance.GetResponsiblePerson().OrderBy(re => re.Name));
                    Cancel(o);
                }
                else if (vorhanden == null)
                {
                    MessageBox.Show("This person does not exists");
                }
                else if (Name == null)
                {
                    MessageBox.Show("Enter a name");
                }
                else if (OfficeNumber == null)
                {
                    MessageBox.Show("Enter the office Number");
                }
                else if (Department == null)
                {
                    MessageBox.Show($"Enter the department");
                }
            });
        }