private async Task UpdateRemoteDB() { var localPeople = Context.Person.ToList(); var peopleInFaceApi = await FaceClient.ListPersonsInLargePersonGroupAsync(Constants.MainPersonGroupId); foreach (var person in localPeople) { if (!peopleInFaceApi.Where(p => p.Name.Equals(person.Name + "_" + person.LastName)).Any()) { await FaceClient.CreatePersonInLargePersonGroupAsync(Constants.MainPersonGroupId, $"{person.Name}_{person.LastName}"); } } }
public async Task RegisterEmployee(string title, Person employee, MediaFile photo) { if (IsBusy) { return; } IsBusy = true; try { // Step 1 - Create Face List try { await _faceServiceClient.GetLargePersonGroupAsync(groupId); } catch { await _faceServiceClient.CreateLargePersonGroupAsync(groupId, title); } // Step 2 - Add people to face list var p = await _faceServiceClient.CreatePersonInLargePersonGroupAsync(groupId, employee.Name); await _faceServiceClient.AddPersonFaceInLargePersonGroupAsync(groupId, p.PersonId, photo.GetStream()); // Step 3 - Train face group await _faceServiceClient.TrainLargePersonGroupAsync(groupId); await _faceServiceClient.GetLargePersonGroupTrainingStatusAsync(groupId); } catch (Exception ex) { Debug.WriteLine(ex.Message); UserDialogs.Instance.ShowError(ex.Message); } finally { IsBusy = false; } }