private async void AppBarButtonPersonRefresh_Click(object sender, RoutedEventArgs e)
        {
            textBlockPerson.Text = "People in " + globals.gPersonGroupSelected.name + " Group";
            if (null != globals.gPersonGroupSelected && (globals.gPersonGroupSelected.name.Equals("...") == false))
            {
                this.IsEnabled = false;
                personProgressRing.IsActive = true;

                appbarEditPersonButton.IsEnabled   = false;
                appbarPersonNextButton.IsEnabled   = false;
                appbarDeletePersonButton.IsEnabled = false;

                List <Persons> persons = await PersonsCmds.ListPersonInGroup(globals.gPersonGroupSelected.personGroupId);

                personListView.ItemsSource       = persons;
                personListView.DisplayMemberPath = "name";

                personProgressRing.IsActive = false;
                this.IsEnabled = true;
            }
            else
            {
                MessageDialog dialog = new MessageDialog("No person group selected", "Refresh Error");
                await dialog.ShowAsync();
            }
        }
        private async void AppBarButtonAddPerson_Click(object sender, RoutedEventArgs e)
        {
            if (null == personListView.SelectedItem || ((Persons)personListView.SelectedItem).name.Equals("..."))
            {
                if (txtPerson.Text.Trim() != "" && txtPerson.Text != "...")
                {
                    this.IsEnabled = false;
                    personProgressRing.IsActive = true;

                    string response = await PersonsCmds.CreatePerson(globals.gPersonGroupSelected.personGroupId,// txtPerson.Text.ToLower().Replace(' ', '_'),
                                                                     txtPerson.Text,
                                                                     txtPersonContext.Text);

                    personProgressRing.IsActive = false;
                    this.IsEnabled = true;
                }
                else
                {
                    MessageDialog dialog = new MessageDialog("Add a name for person", "Add Error");
                    await dialog.ShowAsync();
                }
            }

            AppBarButtonPersonRefresh_Click(null, null);
        }
Esempio n. 3
0
        //public static async Task<List<string>> CheckVisitorFace(string responseString, string personGroupId)
        public static async Task <List <string> > CheckVisitorFace(string responseString, List <PersonGroups> items)
        {
            List <Visitors> visitors = JsonConvert.DeserializeObject <List <Visitors> >(responseString);
            List <string>   faceIds  = new List <string>();
            List <string>   names    = new List <string>();

            foreach (Visitors visitor in visitors)
            {
                faceIds.Add(visitor.faceId);
            }

            foreach (var item in items.Skip(1))
            {
                string personGroupId   = item.personGroupId;
                string personGroupName = item.name;

                FaceQueryPayload jsonPayLoad = new FaceQueryPayload();
                jsonPayLoad.personGroupId = personGroupId;
                jsonPayLoad.faceIds       = faceIds;
                jsonPayLoad.maxNumOfCandidatesReturned = 1;
                jsonPayLoad.confidenceThreshold        = 0.5;


                string              uri        = "https://api.projectoxford.ai/face/v1.0/identify";
                string              jsonString = JsonConvert.SerializeObject(jsonPayLoad);
                HttpContent         content    = new StringContent(jsonString, Encoding.UTF8, "application/json");
                HttpResponseMessage response   = await HttpHandler.client.PostAsync(uri, content);

                if (response.IsSuccessStatusCode)
                {
                    string responseBody = await response.Content.ReadAsStringAsync();

                    List <CandidateObject> candidates = JsonConvert.DeserializeObject <List <CandidateObject> >(responseBody);

                    foreach (CandidateObject candidate in candidates)
                    {
                        //get person from personId
                        if (candidate.candidates.Count != 0)
                        {
                            string name = await PersonsCmds.GetPerson(personGroupId, personGroupName, candidate.candidates[0].personId);

                            if (null != name)
                            {
                                names.Add(name);
                                faceIds.Remove(candidate.faceId);
                            }
                        }
                    }
                }
            }
            return(names);
        }
        private async void AppBarButtonDeletePerson_Click(object sender, RoutedEventArgs e)
        {
            //TODO: Delete all Faces - Blobs - Thumbs
            if (null != personListView.SelectedItem)
            {
                this.IsEnabled = false;
                personProgressRing.IsActive = true;

                string response = await PersonsCmds.DeletePerson(globals.gPersonGroupSelected.personGroupId,
                                                                 globals.gPersonSelected.personId);

                personProgressRing.IsActive = false;
                this.IsEnabled = true;
            }
            else
            {
                MessageDialog dialog = new MessageDialog("Select a person group to delete!", "Delete Error");
                await dialog.ShowAsync();
            }

            AppBarButtonPersonRefresh_Click(null, null);
        }
        private async void AppBarButtonEditPerson_Click(object sender, RoutedEventArgs e)
        {
            if (null != personListView.SelectedItem && !((Persons)personListView.SelectedItem).name.Equals("..."))
            {
                this.IsEnabled = false;
                personProgressRing.IsActive = true;

                string response = await PersonsCmds.UpdatePerson(globals.gPersonGroupSelected.personGroupId,
                                                                 globals.gPersonSelected.personId,
                                                                 txtPerson.Text,
                                                                 txtPersonContext.Text);

                personProgressRing.IsActive = false;
                this.IsEnabled = true;
            }
            else
            {
                MessageDialog dialog = new MessageDialog("Select an existing person and change name", "Update Error");
                await dialog.ShowAsync();
            }

            AppBarButtonPersonRefresh_Click(null, null);
        }