示例#1
0
            private void DoImportMembers(SCObjectSet objectSet, IImportContext context, IDictionary <string, PC.SchemaObjectBase> knownObjects, PC.SCGroup group)
            {
                if (this.ImportMembers && objectSet.HasMembership)
                {
                    var members = ImportService.Instance.FilterMembership(objectSet.Membership, m => m.ContainerID == group.ID && m.Status == SchemaObjectStatus.Normal).ToArray();
                    if (members.Length > 0)
                    {
                        context.SetStatus(Owner.currentSteps, Owner.allSteps, string.Format("正在查找群组 {0} 的固定成员", group.ToDescription()));

                        for (int j = 0; j < members.Length; j++)
                        {
                            try
                            {
                                var gm = members[j];

                                ImportService.Instance.WithEffectObject <PC.SCUser>(gm.ID, knownObjects, user =>
                                {
                                    context.SetSubStatusAndLog(j, members.Length, string.Format("正在向群组 {0} 添加成员 {1} ", group.Name, user.Name));
                                    PC.Executors.SCObjectOperations.Instance.AddUserToGroup(user, group);
                                }, null);
                            }
                            catch (Exception ex2)
                            {
                                context.SetSubStatusAndLog(j, members.Length, string.Format("向群组 {0} 添加成员时出错:", group.ToDescription(), ex2.ToString()));
                            }
                        }
                    }
                }
            }
示例#2
0
            public override void ExecutePostOperation(SCObjectSet objectSet, IImportContext context, IDictionary <string, PC.SchemaObjectBase> knownObjects, PC.SCOrganization org, Dictionary <string, IList <PC.SCOrganization> > orgToOrgRelations, Dictionary <string, IList <PC.SCUser> > orgToUserRelations, Dictionary <string, IList <PC.SCGroup> > orgToGroupRelations)
            {
                if (this.ImportSecretaries)
                {
                    var allUsers           = this.importedUsers.Values.ToArray();
                    var reducedMemberships = ImportService.Instance.FilterMembership(objectSet.Membership, m => Util.IsUser(m.MemberSchemaType) && Util.IsUser(m.ContainerSchemaType)).ToList();

                    if (reducedMemberships.Count > 0)
                    {
                        int count = reducedMemberships.Count;
                        int step  = 0;
                        context.SetStatus(Owner.currentSteps, Owner.allSteps, "正在查找人员秘书");

                        foreach (var r in reducedMemberships)
                        {
                            step++;
                            try
                            {
                                if (this.importedUsers.ContainsKey(r.ContainerID))
                                {
                                    var boss = this.importedUsers[r.ContainerID];

                                    // 导入的用户是上司的
                                    ImportService.Instance.WithEffectObject <PC.SCUser>(r.ID, knownObjects, secretary =>
                                    {
                                        context.SetSubStatusAndLog(step, count, string.Format("正在替 {0} 添加秘书 {1}", boss.Name, secretary.Name));
                                        PC.Executors.SCObjectOperations.Instance.AddSecretaryToUser(secretary, boss);
                                    }, null);
                                }
                                else if (this.importedUsers.ContainsKey(r.ID))
                                {
                                    var secretary = this.importedUsers[r.ID];

                                    // 作为秘书的
                                    ImportService.Instance.WithEffectObject <PC.SCUser>(r.ContainerID, knownObjects, boss =>
                                    {
                                        context.SetSubStatusAndLog(step, count, string.Format("正在替 {0} 添加秘书 {1}", boss.Name, secretary.Name));
                                        PC.Executors.SCObjectOperations.Instance.AddSecretaryToUser(secretary, boss);
                                    }, null);
                                }
                            }
                            catch (Exception ex)
                            {
                                context.SetSubStatusAndLog(step, count, string.Format("未能完成添加秘书操作:{0}", ex.ToString()));
                            }
                        }
                    }
                }
            }
示例#3
0
            public override void ExecuteEachOrganization(SCObjectSet objectSet, IImportContext context, IDictionary <string, PC.SchemaObjectBase> knownObjects, PC.SCOrganization org, Dictionary <string, IList <PC.SCOrganization> > orgToOrgRelations, Dictionary <string, IList <PC.SCUser> > orgToUserRelations, Dictionary <string, IList <PC.SCGroup> > orgToGroupRelations)
            {
                if (orgToGroupRelations.ContainsKey(org.ID))
                {
                    var groups = orgToGroupRelations[org.ID];

                    if (groups.Count > 0)
                    {
                        context.SetStatus(Owner.currentSteps, Owner.allSteps, string.Format("正在查找 {0} 中的群组", org.ToDescription()));
                    }

                    for (int i = 0; i < groups.Count; i++)
                    {
                        var group = groups[i];
                        try
                        {
                            context.SetSubStatusAndLog(i + 1, groups.Count, string.Format("正在向组织 {0} 添加群组 {1}", org.Name, group.Name));

                            PC.Executors.SCObjectOperations.Instance.AddGroup(group, org);

                            knownObjects.Add(group.ID, group);

                            this.DoImportMembers(objectSet, context, knownObjects, group);

                            this.DoImportConditions(objectSet, context, group);
                        }
                        catch (Exception ex)
                        {
                            context.AppendLog(string.Format("向组织 {0} 导入群组 {1} 时出错:", org.ToDescription(), group.Name, ex.ToString()));
                        }
                    }
                }
            }
示例#4
0
            public override void ExecuteEachOrganization(SCObjectSet objectSet, IImportContext context, IDictionary <string, PC.SchemaObjectBase> knownObjects, PC.SCOrganization org, Dictionary <string, IList <PC.SCOrganization> > orgToOrgRelations, Dictionary <string, IList <PC.SCUser> > orgToUserRelations, Dictionary <string, IList <PC.SCGroup> > orgToGroupRelations)
            {
                if (orgToUserRelations.ContainsKey(org.ID))
                {
                    var users = orgToUserRelations[org.ID];

                    if (users.Count > 0)
                    {
                        context.SetStatus(Owner.currentSteps, Owner.allSteps, string.Format("正在查找 {0} 中的用户", org.ToDescription()));
                    }

                    for (int i = 0; i < users.Count; i++)
                    {
                        var user = users[i];
                        try
                        {
                            if (this.importedUsers.ContainsKey(user.ID) == false)
                            {
                                context.SetSubStatusAndLog(i + 1, users.Count, string.Format("正在向组织 {0} 导入用户 {1}", org.Name, user.Name));

                                PC.Executors.SCObjectOperations.Instance.AddUser(user, org);
                                this.importedUsers.Add(user.ID, user);

                                if (knownObjects.ContainsKey(user.ID) == false)
                                {
                                    knownObjects.Add(user.ID, user);
                                }
                            }
                            else
                            {
                                context.SetSubStatusAndLog(i + 1, users.Count, string.Format("正在向组织 {0} 添加用户 {1}", org.Name, user.Name));
                                PC.Executors.SCObjectOperations.Instance.AddUserToOrganization(user, org);

                                if (knownObjects.ContainsKey(user.ID) == false)
                                {
                                    knownObjects.Add(user.ID, user);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            context.AppendLog(string.Format("向组织 {0} 导入用户 {1} 时出错:", org.Name, user.Name, ex.ToString()));
                        }
                    }
                }
            }
示例#5
0
 public void SetStatusAndLog(int currentStep, int maxStep, string message)
 {
     if (level > 0)
     {
         context.SetSubStatusAndLog(currentStep, maxStep, message);
     }
     else
     {
         context.SetStatusAndLog(currentStep, maxStep, message);
     }
 }
示例#6
0
 private void ImportSchemaRoles(MCS.Library.SOA.DataObjects.Security.SCObjectSet objectSet, IImportContext context, Operations.IFacade exec, AUSchema item)
 {
     if (this.IncludeSchemaRoles)
     {
         var roles     = (from p in objectSet.Membership where p.ContainerID == item.ID && p.MemberSchemaType == AUCommon.SchemaAUSchemaRole join q in objectSet.Objects on p.ID equals q.ID select q);
         int total     = roles.Count();
         int roleCount = 0;
         foreach (AUSchemaRole role in roles)
         {
             roleCount++;
             try
             {
                 context.SetSubStatusAndLog(roleCount, total, "正在添加角色:" + role.GetQualifiedName());
                 exec.AddAdminSchemaRole(role, item);
             }
             catch (Exception ex)
             {
                 context.ErrorCount++;
                 context.AppendLog("对角色的操作失败,原因是:" + ex.Message);
             }
         }
     }
 }
		private void ImportSchemaRoles(MCS.Library.SOA.DataObjects.Security.SCObjectSet objectSet, IImportContext context, Operations.IFacade exec, AUSchema item)
		{
			if (this.IncludeSchemaRoles)
			{
				var roles = (from p in objectSet.Membership where p.ContainerID == item.ID && p.MemberSchemaType == AUCommon.SchemaAUSchemaRole join q in objectSet.Objects on p.ID equals q.ID select q);
				int total = roles.Count();
				int roleCount = 0;
				foreach (AUSchemaRole role in roles)
				{
					roleCount++;
					try
					{
						context.SetSubStatusAndLog(roleCount, total, "正在添加角色:" + role.GetQualifiedName());
						exec.AddAdminSchemaRole(role, item);
					}
					catch (Exception ex)
					{
						context.ErrorCount++;
						context.AppendLog("对角色的操作失败,原因是:" + ex.Message);
					}
				}
			}
		}
			private void DoImportMembers(SCObjectSet objectSet, IImportContext context, IDictionary<string, PC.SchemaObjectBase> knownObjects, PC.SCGroup group)
			{
				if (this.ImportMembers && objectSet.HasMembership)
				{
					var members = ImportService.Instance.FilterMembership(objectSet.Membership, m => m.ContainerID == group.ID && m.Status == SchemaObjectStatus.Normal).ToArray();
					if (members.Length > 0)
					{
						context.SetStatus(Owner.currentSteps, Owner.allSteps, string.Format("正在查找群组 {0} 的固定成员", group.ToDescription()));

						for (int j = 0; j < members.Length; j++)
						{
							try
							{
								var gm = members[j];

								ImportService.Instance.WithEffectObject<PC.SCUser>(gm.ID, knownObjects, user =>
								{
									context.SetSubStatusAndLog(j, members.Length, string.Format("正在向群组 {0} 添加成员 {1} ", group.Name, user.Name));
									PC.Executors.SCObjectOperations.Instance.AddUserToGroup(user, group);
								}, null);
							}
							catch (Exception ex2)
							{
								context.SetSubStatusAndLog(j, members.Length, string.Format("向群组 {0} 添加成员时出错:", group.ToDescription(), ex2.ToString()));
							}
						}
					}
				}
			}
			public override void ExecuteEachOrganization(SCObjectSet objectSet, IImportContext context, IDictionary<string, PC.SchemaObjectBase> knownObjects, PC.SCOrganization org, Dictionary<string, IList<PC.SCOrganization>> orgToOrgRelations, Dictionary<string, IList<PC.SCUser>> orgToUserRelations, Dictionary<string, IList<PC.SCGroup>> orgToGroupRelations)
			{
				if (orgToGroupRelations.ContainsKey(org.ID))
				{
					var groups = orgToGroupRelations[org.ID];

					if (groups.Count > 0)
					{
						context.SetStatus(Owner.currentSteps, Owner.allSteps, string.Format("正在查找 {0} 中的群组", org.ToDescription()));
					}

					for (int i = 0; i < groups.Count; i++)
					{
						var group = groups[i];
						try
						{
							context.SetSubStatusAndLog(i + 1, groups.Count, string.Format("正在向组织 {0} 添加群组 {1}", org.Name, group.Name));

							PC.Executors.SCObjectOperations.Instance.AddGroup(group, org);

							knownObjects.Add(group.ID, group);

							this.DoImportMembers(objectSet, context, knownObjects, group);

							this.DoImportConditions(objectSet, context, group);
						}
						catch (Exception ex)
						{
							context.AppendLog(string.Format("向组织 {0} 导入群组 {1} 时出错:", org.ToDescription(), group.Name, ex.ToString()));
						}
					}
				}
			}
			public override void ExecuteEachOrganization(SCObjectSet objectSet, IImportContext context, IDictionary<string, PC.SchemaObjectBase> knownObjects, PC.SCOrganization org, Dictionary<string, IList<PC.SCOrganization>> orgToOrgRelations, Dictionary<string, IList<PC.SCUser>> orgToUserRelations, Dictionary<string, IList<PC.SCGroup>> orgToGroupRelations)
			{
				if (orgToUserRelations.ContainsKey(org.ID))
				{
					var users = orgToUserRelations[org.ID];

					if (users.Count > 0)
					{
						context.SetStatus(Owner.currentSteps, Owner.allSteps, string.Format("正在查找 {0} 中的用户", org.ToDescription()));
					}

					for (int i = 0; i < users.Count; i++)
					{
						var user = users[i];
						try
						{
							if (this.importedUsers.ContainsKey(user.ID) == false)
							{
								context.SetSubStatusAndLog(i + 1, users.Count, string.Format("正在向组织 {0} 导入用户 {1}", org.Name, user.Name));

								PC.Executors.SCObjectOperations.Instance.AddUser(user, org);
								this.importedUsers.Add(user.ID, user);

								if (knownObjects.ContainsKey(user.ID) == false)
									knownObjects.Add(user.ID, user);
							}
							else
							{
								context.SetSubStatusAndLog(i + 1, users.Count, string.Format("正在向组织 {0} 添加用户 {1}", org.Name, user.Name));
								PC.Executors.SCObjectOperations.Instance.AddUserToOrganization(user, org);

								if (knownObjects.ContainsKey(user.ID) == false)
									knownObjects.Add(user.ID, user);
							}
						}
						catch (Exception ex)
						{
							context.AppendLog(string.Format("向组织 {0} 导入用户 {1} 时出错:", org.Name, user.Name, ex.ToString()));
						}
					}
				}
			}
			public override void ExecutePostOperation(SCObjectSet objectSet, IImportContext context, IDictionary<string, PC.SchemaObjectBase> knownObjects, PC.SCOrganization org, Dictionary<string, IList<PC.SCOrganization>> orgToOrgRelations, Dictionary<string, IList<PC.SCUser>> orgToUserRelations, Dictionary<string, IList<PC.SCGroup>> orgToGroupRelations)
			{
				if (this.ImportSecretaries)
				{
					var allUsers = this.importedUsers.Values.ToArray();
					var reducedMemberships = ImportService.Instance.FilterMembership(objectSet.Membership, m => Util.IsUser(m.MemberSchemaType) && Util.IsUser(m.ContainerSchemaType)).ToList();

					if (reducedMemberships.Count > 0)
					{
						int count = reducedMemberships.Count;
						int step = 0;
						context.SetStatus(Owner.currentSteps, Owner.allSteps, "正在查找人员秘书");

						foreach (var r in reducedMemberships)
						{
							step++;
							try
							{
								if (this.importedUsers.ContainsKey(r.ContainerID))
								{
									var boss = this.importedUsers[r.ContainerID];

									// 导入的用户是上司的
									ImportService.Instance.WithEffectObject<PC.SCUser>(r.ID, knownObjects, secretary =>
									{
										context.SetSubStatusAndLog(step, count, string.Format("正在替 {0} 添加秘书 {1}", boss.Name, secretary.Name));
										PC.Executors.SCObjectOperations.Instance.AddSecretaryToUser(secretary, boss);
									}, null);
								}
								else if (this.importedUsers.ContainsKey(r.ID))
								{
									var secretary = this.importedUsers[r.ID];

									// 作为秘书的
									ImportService.Instance.WithEffectObject<PC.SCUser>(r.ContainerID, knownObjects, boss =>
									{
										context.SetSubStatusAndLog(step, count, string.Format("正在替 {0} 添加秘书 {1}", boss.Name, secretary.Name));
										PC.Executors.SCObjectOperations.Instance.AddSecretaryToUser(secretary, boss);
									}, null);
								}
							}
							catch (Exception ex)
							{
								context.SetSubStatusAndLog(step, count, string.Format("未能完成添加秘书操作:{0}", ex.ToString()));
							}
						}
					}
				}
			}