예제 #1
0
        private async void TakePicture_Click(object sender, RoutedEventArgs e)
        {
            if (currentPerson == null)
            {
                Debug.WriteLine("Creating person in group.");

                var userData = new UserData(App.Settings.Values["userID"].ToString(), App.Settings.Values["Token"].ToString());
                var id       = await FaceApiService.CreatePersonInGroupAsync(personGroupId, viewModel.UserName, userData);

                Debug.WriteLine("Person created with ID: " + id);

                currentPerson = new OxfordPerson()
                {
                    personId = id,
                    name     = viewModel.UserName,
                    userData = JsonConvert.SerializeObject(userData).EncodeBase64()
                };
            }

            var stream = await capturePhotoStreamAsync();

            if (stream != null)
            {
                var image = new BitmapImage();
                await image.SetSourceAsync(stream);

                photo.Source = image;

                var faceId = await FaceApiService.AddPersonFaceAsync(personGroupId, currentPerson.personId, stream);

                Debug.WriteLine($"Face added to person {currentPerson.personId} with ID: {faceId}");

                stream.Dispose();
            }
            else
            {
                viewModel.OxfordStatus = "Unable to capture the photo.";
            }
        }
예제 #2
0
        private async Task <bool> checkUserRegistrationAsync()
        {
            var userId = App.Settings.Values["userID"].ToString();
            var people = await FaceApiService.GetPeopleInGroupAsync(personGroupId);

            if (people.Count == 0)
            {
                return(false); // no users yet
            }

            var res = (from p in people
                       where JsonConvert.DeserializeObject <UserData>(p.userData.DecodeBase64()).UserId == userId
                       select p).FirstOrDefault();

            if (res == null)
            {
                return(false); // user not registered
            }
            else
            {
                currentPerson = res;
                return(true);
            }
        }
예제 #3
0
 public static Task <bool> UpdatePersonAsync(string groupId, OxfordPerson person)
 {
     return(UpdatePersonAsync(groupId, person.personId, person.name, person.userData));
 }