public Task GetObjectImportTask(MmsSchema schema, BlockingCollection <object> collection, CancellationToken cancellationToken) { HashSet <string> fieldList = new HashSet <string> { "resourceName", "resourceEmail", "resourceId" }; foreach (string fieldName in ManagementAgent.Schema[SchemaConstants.Calendar].GetFieldNames(schema.Types[SchemaConstants.Calendar], "calendar")) { fieldList.Add(fieldName); } string fields = String.Format("items({0}), nextPageToken", String.Join(",", fieldList)); Task t = new Task(() => { Logger.WriteLine("Requesting calendar fields: " + fields); Parallel.ForEach(this.config.ResourcesService.GetCalendars(this.config.CustomerID, fields), calendar => { collection.Add(this.GetCSEntryForCalendar(calendar, schema, this.config)); Debug.WriteLine($"Created CSEntryChange for calendar: {calendar.ResourceEmail}"); }); }, cancellationToken); t.Start(); return(t); }
public Task GetObjectImportTask(MmsSchema schema, BlockingCollection <object> collection, CancellationToken cancellationToken) { HashSet <string> fieldList = new HashSet <string> { "name" }; foreach (string fieldName in ManagementAgent.Schema[SchemaConstants.Feature].GetFieldNames(schema.Types[SchemaConstants.Feature], "feature")) { fieldList.Add(fieldName); } string fields = string.Format("features({0}), nextPageToken", string.Join(",", fieldList)); Task t = new Task(() => { Logger.WriteLine("Requesting feature fields: " + fields); foreach (Feature feature in this.config.ResourcesService.GetFeatures(this.config.CustomerID, fields)) { collection.Add(this.GetCSEntryForFeature(feature, schema)); Debug.WriteLine($"Created CSEntryChange for feature: {feature.Name}"); continue; } }, cancellationToken); t.Start(); return(t); }
public Task GetObjectImportTask(MmsSchema schema, BlockingCollection <object> collection, CancellationToken cancellationToken) { bool studentsRequired = ManagementAgent.Schema[SchemaConstants.Course].AttributeAdapters.Where(u => u.Api == "coursestudents").Any(v => { return(v.MmsAttributeNames.Any(attributeName => schema.Types[SchemaConstants.Course].Attributes.Contains(attributeName))); }); bool teachersRequired = ManagementAgent.Schema[SchemaConstants.Course].AttributeAdapters.Where(u => u.Api == "courseteachers").Any(v => { return(v.MmsAttributeNames.Any(attributeName => schema.Types[SchemaConstants.Course].Attributes.Contains(attributeName))); }); Task t = new Task(() => { Logger.WriteLine("Starting course import task"); Logger.WriteLine("Requesting students: " + studentsRequired); Logger.WriteLine("Requesting teachers: " + teachersRequired); Logger.WriteLine("Skip members for ARCHIVED Courses: " + this.config.SkipMemberImportOnArchivedCourses); // Fetch all users and cache for performance translation of id to PrimaryEmail this.InitializeUserMappingCache(); foreach (GoogleCourse course in this.config.ClassroomService.GetCourses(this.config.CustomerID, studentsRequired, teachersRequired, this.config.SkipMemberImportOnArchivedCourses, MAConfigurationSection.Configuration.ClassroomApi.ImportThreadsCourseMember)) { // Translate OwnerId to Email. Use cache. course.Course.OwnerId = this.GetUserPrimaryEmailForId(course.Course.OwnerId); // Translate students and teachers course.Students = new CourseStudents(this.TranslateMembers(course.Students.GetAllStudents())); course.Teachers = new CourseTeachers(this.TranslateMembers(course.Teachers.GetAllTeachers())); collection.Add(this.GetCSEntryForCourse(course, schema)); Debug.WriteLine($"Created CSEntryChange for course: {course.Course.Id}"); continue; } Logger.WriteLine("Courses import task complete"); }, cancellationToken); t.Start(); return(t); }
private CSEntryChange GetCSEntryForCourse(GoogleCourse course, Microsoft.MetadirectoryServices.Schema schema) { CSEntryChange csentry; if (course.Errors.Count > 0) { csentry = CSEntryChange.Create(); csentry.ObjectType = "course"; csentry.ObjectModificationType = ObjectModificationType.Add; csentry.DN = course.Course.Id; csentry.ErrorCodeImport = MAImportError.ImportErrorCustomContinueRun; csentry.ErrorDetail = course.Errors.FirstOrDefault()?.StackTrace; csentry.ErrorName = course.Errors.FirstOrDefault()?.Message; } else { csentry = ImportProcessor.GetCSEntryChange(course, schema.Types[SchemaConstants.Course], this.config); } return(csentry); }
private CSEntryChange GetCSEntryForFeature(Feature feature, MmsSchema schema) { return(ImportProcessor.GetCSEntryChange(feature, schema.Types[SchemaConstants.Feature], this.config)); }
private CSEntryChange GetCSEntryForBuilding(Building building, MmsSchema schema, IManagementAgentParameters config) { return(ImportProcessor.GetCSEntryChange(building, schema.Types[SchemaConstants.Building], config)); }
public Task GetObjectImportTask(MmsSchema schema, BlockingCollection <object> collection, CancellationToken cancellationToken) { HashSet <string> groupFieldList = new HashSet <string> { SchemaConstants.Email, SchemaConstants.ID }; foreach (string fieldName in ManagementAgent.Schema[SchemaConstants.Group].GetFieldNames(schema.Types[SchemaConstants.Group], "group")) { groupFieldList.Add(fieldName); } foreach (string fieldName in ManagementAgent.Schema[SchemaConstants.Group].GetFieldNames(schema.Types[SchemaConstants.Group], "groupaliases")) { groupFieldList.Add(fieldName); } string groupFields = string.Format("groups({0}), nextPageToken", string.Join(",", groupFieldList)); HashSet <string> groupSettingList = new HashSet <string>(); foreach (string fieldName in ManagementAgent.Schema[SchemaConstants.Group].GetFieldNames(schema.Types[SchemaConstants.Group], "groupsettings")) { groupSettingList.Add(fieldName); } bool settingsRequired = groupSettingList.Count > 0; string groupSettingsFields = string.Join(",", groupSettingList); bool membersRequired = ManagementAgent.Schema[SchemaConstants.Group].AttributeAdapters.Where(u => u.Api == "groupmembership").Any(v => { return(v.MmsAttributeNames.Any(attributeName => schema.Types[SchemaConstants.Group].Attributes.Contains(attributeName))); }); Task t = new Task(() => { Logger.WriteLine("Requesting group fields: " + groupFields); Logger.WriteLine("Requesting group settings fields: " + groupSettingsFields); Logger.WriteLine("Requesting settings: " + settingsRequired); Logger.WriteLine("Requesting members: " + membersRequired); Regex filter = null; if (this.config.GroupRegexFilter != null) { filter = new Regex(this.config.GroupRegexFilter); } foreach (GoogleGroup group in this.config.GroupsService.GetGroups(this.config.CustomerID, membersRequired, settingsRequired, groupFields, MAConfigurationSection.Configuration.GroupSettingsApi.ImportThreadsGroupSettings, MAConfigurationSection.Configuration.DirectoryApi.ImportThreadsGroupMember, this.config.ExcludeUserCreated, filter)) { collection.Add(this.GetCSEntryForGroup(group, schema)); Debug.WriteLine($"Created CSEntryChange for group: {group.Group.Email}"); continue; } }, cancellationToken); t.Start(); return(t); }
private CSEntryChange GetCSEntryForCalendar(CalendarResource calendar, MmsSchema schema, IManagementAgentParameters config) { return(ImportProcessor.GetCSEntryChange(calendar, schema.Types[SchemaConstants.Calendar], config)); }