private async Task Create() { CreateIndicator = true; account = await AccountApi.Directory.AccountManager.Create( FirstName, LastName, "", getRole()).ConfigureAwait(false); if (account != null) { UID = account.UID; CopyCode = getCopyCode(); account.CopyCode = CopyCode; NetworkPassword = Password.Create(); account.SetPassword(NetworkPassword); MainWindow.Instance.Log.AddMessage(Origin.Directory, "Added account for " + account.FullName); await createSmartschoolAccount(account).ConfigureAwait(false); //await createGoogleAccount(account).ConfigureAwait(false); PrintEnabled = true; } CreateIndicator = false; State.App.Instance.AD.UpdateObservers(); }
public void SetAccount(AccountApi.Directory.Account account) { this.account = account; SaveEnabled = false; if (account != null) { DeleteEnabled = true; switch (account.Role) { case AccountApi.AccountRole.Director: roleIndex = 3; break; case AccountApi.AccountRole.IT: roleIndex = 2; break; case AccountApi.AccountRole.Support: roleIndex = 1; break; case AccountApi.AccountRole.Teacher: roleIndex = 0; break; default: roleIndex = -1; break; } firstName = account.FirstName; lastName = account.LastName; copyCode = account.CopyCode; if (account.Gender == "male") { gender = 8.0f; } else if (account.Gender == "female") { gender = 2.0f; } else { gender = 5.0f; } } else { DeleteEnabled = false; roleIndex = -1; firstName = string.Empty; lastName = string.Empty; copyCode = 0; gender = 5.0f; } PropertyChanged(this, new PropertyChangedEventArgs(nameof(Title))); PropertyChanged(this, new PropertyChangedEventArgs(nameof(UID))); PropertyChanged(this, new PropertyChangedEventArgs(nameof(CopyCodeEnabled))); PropertyChanged(this, new PropertyChangedEventArgs(nameof(RoleIndex))); PropertyChanged(this, new PropertyChangedEventArgs(nameof(FirstName))); PropertyChanged(this, new PropertyChangedEventArgs(nameof(LastName))); PropertyChanged(this, new PropertyChangedEventArgs(nameof(CopyCode))); PropertyChanged(this, new PropertyChangedEventArgs(nameof(Gender))); }
public StaffAccountEditor(AccountApi.Directory.Account account) { SetAccount(account); DeleteCommand = new RelayAsyncCommand(DeleteAccount); SaveCommand = new RelayAsyncCommand(SaveAccount); CopyCodeCommand = new RelayAsyncCommand(CreateCopyCode); NewNetworkPasswordCommand = new RelayAsyncCommand(NewNetworkPassword); NewSmartschoolPasswordCommand = new RelayAsyncCommand(NewSmartschoolPassword); NewPasswordsCommand = new RelayAsyncCommand(NewPasswords); DeleteEnabled = account != null; }
private async Task createSmartschoolAccount(AccountApi.Directory.Account account) { var smartschoolAccount = new AccountApi.Smartschool.Account(); SmartschoolPassword = AccountApi.Password.Create(); smartschoolAccount.UID = UID; smartschoolAccount.Role = getRole(); smartschoolAccount.GivenName = FirstName; smartschoolAccount.SurName = LastName; smartschoolAccount.AccountID = UID; smartschoolAccount.Gender = getGender(); smartschoolAccount.Mail = UID + "@" + AccountApi.Directory.Connector.AzureDomain; var result = await AccountApi.Smartschool.AccountManager .Save(smartschoolAccount, SmartschoolPassword) .ConfigureAwait(false); if (!result) { MainWindow.Instance.Log.AddError(Origin.Smartschool, "Failed to add " + account.FullName); return; } else { MainWindow.Instance.Log.AddMessage(Origin.Smartschool, "Added account for " + account.FullName); IGroup group = null; switch (smartschoolAccount.Role) { case AccountRole.Teacher: group = AccountApi.Smartschool.GroupManager.Root.Find("Leerkrachten"); break; case AccountRole.Director: group = AccountApi.Smartschool.GroupManager.Root.Find("Directie"); break; case AccountRole.IT: group = AccountApi.Smartschool.GroupManager.Root.Find("Leerkrachten"); break; case AccountRole.Maintenance: group = AccountApi.Smartschool.GroupManager.Root.Find("Onderhoudspersoneel"); break; case AccountRole.Support: group = AccountApi.Smartschool.GroupManager.Root.Find("Secretariaat"); break; default: group = AccountApi.Smartschool.GroupManager.Root.Find("Personeel"); break; } var groupResult = await AccountApi.Smartschool.GroupManager.AddUserToGroup(smartschoolAccount, group).ConfigureAwait(false); if (!groupResult) { MainWindow.Instance.Log.AddError(Origin.Smartschool, "Failed to add " + account.FullName + " to group " + group.Name); } } }
private void DoRelink() { List.Clear(); foreach (var account in AccountApi.Directory.AccountManager.Staff) { bool import = true; foreach (var rule in App.Instance.AD.ImportRules) { if (rule.Rule == Rule.AD_DontImportUser && rule.ShouldApply(account)) { import = false; break; } } if (import) { if (List.ContainsKey(account.UID)) { List[account.UID].Directory.Account = account; } else { List.Add(account.UID, new LinkedStaffMember(account)); } } } //if (AccountApi.Google.AccountManager.All != null) //foreach (var account in AccountApi.Google.AccountManager.All.Values) //{ // if (account.IsStaff) // { // if (List.ContainsKey(account.UID)) // { // List[account.UID].Google.Account = account; // } // else // { // List.Add(account.UID, new LinkedStaffMember(account)); // } // } //} var staff = AccountApi.Smartschool.GroupManager.Root == null ? null : AccountApi.Smartschool.GroupManager.Root.Find("Personeel"); if (staff != null) { addSmartschoolAccounts(staff); } AccountApi.Wisa.StaffManager.ApplyImportRules(App.Instance.Wisa.ImportRules.ToList()); foreach (var account in AccountApi.Wisa.StaffManager.All) { bool linked = false; AccountApi.Directory.Account directoryMatch = AccountApi.Directory.AccountManager.GetStaffmemberByWisaID(account.CODE); if (directoryMatch == null) { directoryMatch = AccountApi.Directory.AccountManager.GetStaffmemberByName(account.FirstName, account.LastName); } if (directoryMatch != null) { if (List.ContainsKey(directoryMatch.UID) && !List[directoryMatch.UID].Wisa.Exists) { List[directoryMatch.UID].Wisa.Account = account; linked = true; } else { List.Add("WISA-" + account.CODE, new LinkedStaffMember(account)); linked = true; } } if (!linked) { var smartschoolMatch = (staff as AccountApi.Smartschool.Group).FindAccountByWisaID(account.CODE); if (smartschoolMatch != null) { if (List.ContainsKey(smartschoolMatch.UID)) { List[smartschoolMatch.UID].Wisa.Account = account; linked = true; } } } if (!linked) { List.Add("WISA-" + account.CODE, new LinkedStaffMember(account)); } } countAccounts(); addActions(); }
public StudentPasswordItem(AccountApi.Directory.Account account) { Account = account; }
private void DoRelink() { //if (!Data.Instance.ConfigReady) return; if (AccountApi.Smartschool.GroupManager.Root == null) { return; } List.Clear(); foreach (var account in AccountApi.Directory.AccountManager.Students) { if (List.ContainsKey(account.UID)) { List[account.UID].Directory.Account = account; } else { List.Add(account.UID, new LinkedAccount(account)); } } //foreach(var account in AccountApi.Google.AccountManager.All.Values) //{ // if(!account.IsStaff) // { // if(List.ContainsKey(account.UID)) // { // List[account.UID].Google.Account = account; // } else // { // List.Add(account.UID, new LinkedAccount(account)); // } // } //} var lln = AccountApi.Smartschool.GroupManager.Root.Find("Leerlingen"); if (lln != null) { AddSmartschoolAccounts(lln); } foreach (var account in AccountApi.Wisa.Students.All) { bool linked = false; AccountApi.Directory.Account directoryMatch = AccountApi.Directory.AccountManager.GetStudentByWisaID(account.WisaID); if (directoryMatch != null) { if (List.ContainsKey(directoryMatch.UID)) { List[directoryMatch.UID].Wisa.Account = account; linked = true; } else { List.Add(directoryMatch.UID, new LinkedAccount(account)); linked = true; } } if (!linked) { var smartschoolMatch = (lln as AccountApi.Smartschool.Group).FindAccountByWisaID(account.WisaID); if (smartschoolMatch != null) { if (List.ContainsKey(smartschoolMatch.UID)) { List[smartschoolMatch.UID].Wisa.Account = account; linked = true; } } } if (!linked) { List.Add(account.WisaID, new LinkedAccount(account)); } } // count totalWisaAccounts = totalDirectoryAccounts = totalSmartschoolAccounts = totalGoogleAccounts = 0; unlinkedWisaAccounts = unlinkedDirectoryAccounts = unlinkedSmartschoolAccounts = unlinkedGoogleAccounts = 0; linkedWisaAccounts = linkedDirectoryAccounts = linkedSmartschoolAccounts = linkedGoogleAccounts = 0; foreach (var group in List.Values) { if (group == null) { continue; } bool incomplete = (!group.Wisa.Exists || !group.Smartschool.Exists || !group.Directory.Exists); if (group.Wisa.Exists) { totalWisaAccounts++; if (incomplete) { unlinkedWisaAccounts++; } else { linkedWisaAccounts++; } } if (group.Smartschool.Exists) { totalSmartschoolAccounts++; if (incomplete) { unlinkedSmartschoolAccounts++; } else { linkedSmartschoolAccounts++; } } if (group.Directory.Exists) { totalDirectoryAccounts++; if (incomplete) { unlinkedDirectoryAccounts++; } else { linkedDirectoryAccounts++; } } //if (group.Google.Exists) //{ // totalGoogleAccounts++; // if (incomplete) unlinkedGoogleAccounts++; // else linkedGoogleAccounts++; //} } // add actions foreach (var account in List.Values) { AccountActionParser.AddActions(account); } }
public LinkedAccount(AccountApi.Directory.Account account) { Directory.Account = account; }
public LinkedStaffMember(AccountApi.Directory.Account account) { Directory.Account = account; }
public static async Task Add(State.Linked.LinkedAccount linkedAccount, AccountApi.Wisa.Student wisa, AccountApi.Directory.Account directory) { var ssAccount = new AccountApi.Smartschool.Account(); ssAccount.UID = directory.UID; ssAccount.RegisterID = wisa.StateID; try { ssAccount.StemID = Convert.ToInt32(wisa.StemID); } catch (Exception) { ssAccount.StemID = 0; } ssAccount.Role = AccountRole.Student; ssAccount.GivenName = wisa.FirstName; ssAccount.SurName = wisa.Name; ssAccount.Gender = wisa.Gender; ssAccount.Birthday = wisa.DateOfBirth; ssAccount.BirthPlace = wisa.PlaceOfBirth; ssAccount.Street = wisa.Street; ssAccount.HouseNumber = wisa.HouseNumber; ssAccount.HouseNumberAdd = wisa.HouseNumberAdd; ssAccount.PostalCode = wisa.PostalCode; ssAccount.City = wisa.City; ssAccount.Mail = directory.PrincipalName; var result = await AccountApi.Smartschool.AccountManager.Save(ssAccount, "FakeP4ssword").ConfigureAwait(false); if (!result) { MainWindow.Instance.Log.AddError(Origin.Smartschool, "Failed to add " + wisa.FullName); return; } else { linkedAccount.Smartschool.Account = ssAccount; MainWindow.Instance.Log.AddMessage(Origin.Smartschool, "Added account for " + wisa.FullName); } IGroup classgroup; if (wisa.ClassGroup.Contains("ANS") || wisa.ClassGroup.Contains("BNS")) { classgroup = AccountApi.Smartschool.GroupManager.Root.Find("Leerlingen"); } else { classgroup = AccountApi.Smartschool.GroupManager.Root.Find(wisa.ClassGroup); } await MoveToSmartschoolClassGroup.Move(linkedAccount, classgroup).ConfigureAwait(false); }