public override void DoImport(SCObjectSet objectSet, IImportContext context) { if (objectSet.HasRelations && objectSet.HasObjects) { context.SetStatus(0, 1, "正在分析数据。"); // 查找组织关系 var pendingOperations = new List <Action <object> >(); var objects = objectSet.Objects; Dictionary <string, IList <PC.SCOrganization> > orgToOrgRelations = new Dictionary <string, IList <PC.SCOrganization> >(); Dictionary <string, IList <PC.SCUser> > orgToUserRelations = new Dictionary <string, IList <PC.SCUser> >(); Dictionary <string, IList <PC.SCGroup> > orgToGroupRelations = new Dictionary <string, IList <PC.SCGroup> >(); Dictionary <string, PC.SchemaObjectBase> knownObjects = new Dictionary <string, PC.SchemaObjectBase>(); // 缓存已知对象,避免多次往返 context.SetStatus(0, 1, "正在统计需要导入的对象"); Stat stat = new Stat(); // 统计信息 FindFullOURelations(objectSet, orgToOrgRelations, orgToUserRelations, orgToGroupRelations, new PC.SCOrganization[] { this.Parent }, stat); // 爬出所有组织关系 Dictionary <PC.SCOrganization, IList <PC.SCRelationObject> > userToOrgRelations = new Dictionary <PC.SCOrganization, IList <PC.SCRelationObject> >(); this.allSteps = this.CalculateSteps(stat); this.currentSteps = 0; bool orgValid = false; // 必须校验组织 context.SetStatus(0, this.allSteps, "正在导入数据。"); // 递归导入组织,并剔除错误的数据 orgValid = this.PrepareOrganizations(objectSet, context, knownObjects, orgToOrgRelations, this.Parent, this.IncludeOrganizations == false); if (this.IncludeAcl) { // 递归导入Acl var action = new AclAction(this); action.ExecutePreOperation(objectSet, context, knownObjects, this.Parent, orgToOrgRelations, orgToUserRelations, orgToGroupRelations); this.DoHierarchicalAction(objectSet, context, knownObjects, orgToOrgRelations, orgToUserRelations, orgToGroupRelations, this.Parent, action); action.ExecutePostOperation(objectSet, context, knownObjects, this.Parent, orgToOrgRelations, orgToUserRelations, orgToGroupRelations); } if (this.IncludeUser) { var action = new UserAction(this); action.ImportSecretaries = this.IncludeSecretaries; action.ExecutePreOperation(objectSet, context, knownObjects, this.Parent, orgToOrgRelations, orgToUserRelations, orgToGroupRelations); this.DoHierarchicalAction(objectSet, context, knownObjects, orgToOrgRelations, orgToUserRelations, orgToGroupRelations, this.Parent, action); action.ExecutePostOperation(objectSet, context, knownObjects, this.Parent, orgToOrgRelations, orgToUserRelations, orgToGroupRelations); } if (this.IncludeGroup) { var action = new GroupAction(this); action.ImportMembers = this.IncludeGroupMembers; action.ImportConditions = this.IncludeGroupConditions; action.ExecutePreOperation(objectSet, context, knownObjects, this.Parent, orgToOrgRelations, orgToUserRelations, orgToGroupRelations); this.DoHierarchicalAction(objectSet, context, knownObjects, orgToOrgRelations, orgToUserRelations, orgToGroupRelations, this.Parent, action); action.ExecutePostOperation(objectSet, context, knownObjects, this.Parent, orgToOrgRelations, orgToUserRelations, orgToGroupRelations); } } }
public override void DoImport(SCObjectSet objectSet, IImportContext context) { if (objectSet.HasRelations && objectSet.HasObjects) { context.SetStatus(0, 1, "正在分析数据。"); // 查找组织关系 var pendingOperations = new List<Action<object>>(); var objects = objectSet.Objects; Dictionary<string, IList<PC.SCOrganization>> orgToOrgRelations = new Dictionary<string, IList<PC.SCOrganization>>(); Dictionary<string, IList<PC.SCUser>> orgToUserRelations = new Dictionary<string, IList<PC.SCUser>>(); Dictionary<string, IList<PC.SCGroup>> orgToGroupRelations = new Dictionary<string, IList<PC.SCGroup>>(); Dictionary<string, PC.SchemaObjectBase> knownObjects = new Dictionary<string, PC.SchemaObjectBase>(); // 缓存已知对象,避免多次往返 context.SetStatus(0, 1, "正在统计需要导入的对象"); Stat stat = new Stat(); // 统计信息 FindFullOURelations(objectSet, orgToOrgRelations, orgToUserRelations, orgToGroupRelations, new PC.SCOrganization[] { this.Parent }, stat); // 爬出所有组织关系 Dictionary<PC.SCOrganization, IList<PC.SCRelationObject>> userToOrgRelations = new Dictionary<PC.SCOrganization, IList<PC.SCRelationObject>>(); this.allSteps = this.CalculateSteps(stat); this.currentSteps = 0; bool orgValid = false; // 必须校验组织 context.SetStatus(0, this.allSteps, "正在导入数据。"); // 递归导入组织,并剔除错误的数据 orgValid = this.PrepareOrganizations(objectSet, context, knownObjects, orgToOrgRelations, this.Parent, this.IncludeOrganizations == false); if (this.IncludeAcl) { // 递归导入Acl var action = new AclAction(this); action.ExecutePreOperation(objectSet, context, knownObjects, this.Parent, orgToOrgRelations, orgToUserRelations, orgToGroupRelations); this.DoHierarchicalAction(objectSet, context, knownObjects, orgToOrgRelations, orgToUserRelations, orgToGroupRelations, this.Parent, action); action.ExecutePostOperation(objectSet, context, knownObjects, this.Parent, orgToOrgRelations, orgToUserRelations, orgToGroupRelations); } if (this.IncludeUser) { var action = new UserAction(this); action.ImportSecretaries = this.IncludeSecretaries; action.ExecutePreOperation(objectSet, context, knownObjects, this.Parent, orgToOrgRelations, orgToUserRelations, orgToGroupRelations); this.DoHierarchicalAction(objectSet, context, knownObjects, orgToOrgRelations, orgToUserRelations, orgToGroupRelations, this.Parent, action); action.ExecutePostOperation(objectSet, context, knownObjects, this.Parent, orgToOrgRelations, orgToUserRelations, orgToGroupRelations); } if (this.IncludeGroup) { var action = new GroupAction(this); action.ImportMembers = this.IncludeGroupMembers; action.ImportConditions = this.IncludeGroupConditions; action.ExecutePreOperation(objectSet, context, knownObjects, this.Parent, orgToOrgRelations, orgToUserRelations, orgToGroupRelations); this.DoHierarchicalAction(objectSet, context, knownObjects, orgToOrgRelations, orgToUserRelations, orgToGroupRelations, this.Parent, action); action.ExecutePostOperation(objectSet, context, knownObjects, this.Parent, orgToOrgRelations, orgToUserRelations, orgToGroupRelations); } } }