private async void GetPersonGroups() { try { PersonGroup[] personGroups = await _faceServiceClient.ListPersonGroupsAsync(); if (personGroups == null || personGroups.Length == 0) { StatusText = "No person groups found."; return; } PersonGroups.Clear(); foreach (PersonGroup personGroup in personGroups) { PersonGroups.Add(personGroup); } } catch (FaceAPIException ex) { StatusText = $"Failed to fetch person groups: {ex.ErrorMessage}"; } catch (Exception ex) { StatusText = $"Failed to fetch person groups: {ex.Message}"; } }
private async void GetPersonGroups() { try { PersonGroup[] personGroups = await _faceServiceClient.ListPersonGroupsAsync(); if (personGroups == null || personGroups.Length == 0) { return; } PersonGroups.Clear(); foreach (PersonGroup group in personGroups) { PersonGroups.Add(group); } } catch (FaceAPIException ex) { SystemResponse = $"Failed to get person groups: {ex.ErrorMessage}"; } catch (Exception ex) { SystemResponse = $"Failed to get person groups: {ex.Message}"; } }
public async Task InitializeAsync() { try { IsLoading = true; if (FaceService == null) { FaceService = await FaceServiceHelper.CreateNewFaceServiceAsync(); } var personGroupResult = await FaceService.ListPersonGroupsAsync(); personGroupResult.OrderBy(pg => pg.Name); personGroupResult.ForEach(pg => PersonGroups.Add(pg)); IsLoading = false; } catch (FaceAPIException ex)//Handle API-Exception { await MessageDialogHelper.MessageDialogAsync(ex.ErrorMessage); } catch (Exception ex) { await MessageDialogHelper.MessageDialogAsync(ex.Message); } }
/// <summary> /// Loads groups and cleanup the ObservableCollection /// </summary> /// <returns></returns> private async Task LoadGroupsAsync() { PersonGroups.Clear(); var fscPersonGroups = await FaceService.ListPersonGroupsAsync(); fscPersonGroups.OrderBy(pg => pg.Name).ForEach(pg => PersonGroups.Add(pg)); }
private async Task LoadPersonGroupsAsync() { if (PersonGroups.Count > 0) { PersonGroups.Clear(); } var groups = await _client.GetPersonGroupsAsync(); foreach (var group in groups) { var groupItem = new PersonGroupItem() { Group = group }; try { var trainingResult = await _client.GetPersonGroupTrainingStatusAsync(group.PersonGroupId); groupItem.LastTrained = trainingResult.EndTime; } catch (ClientException ex) { // hopefully, this means the groupId had no entries for training Debug.WriteLine(ex.Message); } finally { PersonGroups.Add(groupItem); await LoadPersons(groupItem); } } }
private async void SaveGroupButton_OnClick(object sender, RoutedEventArgs e) { if (SelectedPersonGroupItem != null) { if (_isSaveNew) { await CreatePersonGroupAsync(SelectedPersonGroupItem.Group); PersonGroups.Add((SelectedPersonGroupItem)); _isSaveNew = false; } else { await UpdatePersonGroupAsync(SelectedPersonGroupItem.Group); await LoadPersonGroupsAsync(); } } }
public InMemoryUser(User dbUser, IEnumerable <UserProfile> initializedProfiles, int?timezoneOffset) { DBUser = dbUser; _login = dbUser.UserName; SiteId = dbUser.SiteId; _firstName = dbUser.FirstName; _lastName = dbUser.LastName; _email = dbUser.Email; _orgId = dbUser.OrgId; _department = dbUser.Department; _phone = dbUser.Phone; _language = dbUser.Language; _dbId = dbUser.Id; _timezoneOffset = timezoneOffset; _maximoPersonId = dbUser.MaximoPersonId; _personGroups = (dbUser.PersonGroups ?? new HashedSet <PersonGroupAssociation>()); if (initializedProfiles == null) { initializedProfiles = new List <UserProfile>(); } var userProfiles = initializedProfiles as UserProfile[] ?? initializedProfiles.ToArray(); _profiles = userProfiles; var roles = new List <Role>(); var dataConstraints = new List <DataConstraint>(); foreach (var profile in userProfiles) { roles.AddRange(profile.Roles); dataConstraints.AddRange(profile.DataConstraints); } if (dbUser.CustomRoles != null) { foreach (var role in dbUser.CustomRoles) { if (role.Exclusion) { roles.Remove(role.Role); } else { roles.Add(role.Role); } } } if (dbUser.PersonGroups != null) { foreach (var personGroup in dbUser.PersonGroups) { PersonGroups.Add(personGroup); } } if (dbUser.CustomConstraints != null) { foreach (var constraint in dbUser.CustomConstraints) { if (constraint.Exclusion) { dataConstraints.Remove(constraint.Constraint); } else { dataConstraints.Add(constraint.Constraint); } } } _roles = roles; _dataConstraints = dataConstraints; Identity = new GenericIdentity(_login); }