public override async Task Apply(State.Linked.LinkedGroup linkedGroup) { var wisa = linkedGroup.Wisa.Group; var parentName = AccountApi.Smartschool.GroupManager.GetLogicalParent(wisa.Name); var parent = (AccountApi.Smartschool.GroupManager.Root as AccountApi.Smartschool.Group).FindByCode(parentName); if (parent != null) { var group = new AccountApi.Smartschool.Group(parent); group.Name = wisa.Name; group.Description = wisa.Description; group.Code = wisa.Name; group.Untis = wisa.Name; group.InstituteNumber = wisa.SchoolCode; group.AdminNumber = int.Parse(wisa.AdminCode); group.Official = true; group.Type = AccountApi.GroupType.Class; bool result = await AccountApi.Smartschool.GroupManager.Save(group).ConfigureAwait(false); if (result) { parent.Children.Add(group); } } }
private void AddSmartschoolChildGroups(AccountApi.Smartschool.Group group) { if (group.Official) { if (List.ContainsKey(group.Name)) { List[group.Name].Smartschool.Group = group; } else { List.Add(group.Name, new LinkedGroup(group)); } } if (group.Children != null) { foreach (var child in group.Children) { if (child != null) { AddSmartschoolChildGroups(child as AccountApi.Smartschool.Group); } } } }
public LinkedGroup(AccountApi.Smartschool.Group group) { Smartschool.Group = group; }
private void DoRelink() { //if (!Data.Instance.ConfigReady) return; if (AccountApi.Smartschool.GroupManager.Root == null) { return; } List.Clear(); foreach (var group in AccountApi.Wisa.ClassGroupManager.All) { if (List.ContainsKey(group.FullName)) { List[group.FullName].Wisa.Group = group; } else { List.Add(group.FullName, new LinkedGroup(group)); } } foreach (var group in AccountApi.Directory.ClassGroupManager.All) { AddDirectoryChildGroups(group); } // only compare class groups AccountApi.Smartschool.Group students = (AccountApi.Smartschool.Group)AccountApi.Smartschool.GroupManager.Root.Find("Leerlingen"); if (students != null) { AddSmartschoolChildGroups(students); } // count totalWisaGroups = totalDirectoryGroups = totalSmartschoolGroups = 0; unlinkedWisaGroups = unlinkedDirectoryGroups = unlinkedSmartschoolGroups = 0; linkedWisaGroups = linkedDirectoryGroups = linkedSmartschoolGroups = 0; foreach (var group in List.Values) { bool incomplete = (group.Wisa.Group == null || group.Smartschool.Group == null || group.Directory.Group == null); if (group.Wisa.Group != null) { totalWisaGroups++; if (incomplete) { unlinkedWisaGroups++; } else { linkedWisaGroups++; } } if (group.Smartschool.Group != null) { totalSmartschoolGroups++; if (incomplete) { unlinkedSmartschoolGroups++; } else { linkedSmartschoolGroups++; } } if (group.Directory.Group != null) { totalDirectoryGroups++; if (incomplete) { unlinkedDirectoryGroups++; } else { linkedDirectoryGroups++; } } } // add actions foreach (var group in List.Values) { GroupActionParser.AddActions(group); } }