コード例 #1
0
		private static AU.AUSchemaRole DoAction(AU.AdminUnit unit, UploadProgressStatus status, StringBuilder output, AU.AUSchemaRole currentRole, Dictionary<string, object> item)
		{
			string roleID, schemaRoleID, userID;
			int type;

			try
			{
				roleID = (string)item["RoleID"];
				schemaRoleID = (string)item["SchemaRoleID"];
				userID = (string)item["UserID"];
				type = (int)item["Type"];

				if (currentRole == null || currentRole.ID != roleID)
					currentRole = DbUtil.GetEffectiveObject<AU.AUSchemaRole>(schemaRoleID);

				status.StatusText = string.Format("正在向角色{0}{1}用户{2}", roleID, type == 0 ? "添加" : "删除", userID);
				output.AppendLine(status.StatusText);


				if (type == 0)
				{
					AU.Operations.Facade.InstanceWithPermissions.AddUserToRole(new PC.SCUser() { ID = userID }, unit, currentRole);
				}
				else
				{
					AU.Operations.Facade.InstanceWithPermissions.RemoveUserFromRole(new PC.SCUser() { ID = userID, CodeName = "abc", Name = "abc" }, unit, currentRole);
				}
			}
			catch (Exception ex)
			{
				status.StatusText = ex.Message;
				output.AppendLine(ex.ToString());
			}
			return currentRole;
		}
コード例 #2
0
		private static void CopyRoleMembers(AU.AdminUnit fromUnit, bool copyRoleMembers, AU.AdminUnit newUnit, StepContext context)
		{
			if (copyRoleMembers)
			{
				var roles = AU.Adapters.AUSnapshotAdapter.Instance.LoadAURoles(new string[] { fromUnit.ID }, true, DateTime.MinValue);
				var schemaRoles = AU.Adapters.AUSnapshotAdapter.Instance.LoadAUSchemaRoles(fromUnit.AUSchemaID, true, DateTime.MinValue);
				double allCount = roles.Count;
				foreach (AU.AURole r in roles)
				{
					var schemaRole = schemaRoles[r.SchemaRoleID];
					if (schemaRole == null)
						throw new AUObjectException(string.Format("未能找到对应角色{0}的管理架构角色{1}", r.ID, r.SchemaRoleID));

					context.Logger.WriteLine(ProcessProgress.Current.StatusText = string.Format("正在设置管理单元角色 {0} 成员", schemaRole.Name));
					ProcessProgress.Current.Response();
					var targetRole = AU.Adapters.AUSnapshotAdapter.Instance.LoadAURole(r.SchemaRoleID, newUnit.ID, true, DateTime.MinValue);

					if (targetRole != null)
					{
						var usersIDs = AU.AUCommon.DoDbProcess(() => PC.Adapters.SCMemberRelationAdapter.Instance.LoadByContainerID(r.ID, "Users")).FilterByStatus(SchemaObjectStatusFilterTypes.Normal).ToIDArray();

						var users = (from p in usersIDs select new PC.SCUser() { ID = p, Name = "Demo", CodeName = "Demo" }).ToArray();

						AU.Operations.Facade.InstanceWithPermissions.ReplaceUsersInRole(users, newUnit, DbUtil.GetEffectiveObject<AU.AUSchemaRole>(targetRole.SchemaRoleID));
						context.Logger.Write("已经添加{0}个人员\r\n", users.Length);
					}
				}
			}
		}
コード例 #3
0
		private static AU.AdminUnit CreateUnit(AU.AdminUnit fromUnit, string newName, string newCodeName)
		{
			AU.AdminUnit newUnit = new AU.AdminUnit();
			foreach (var item in fromUnit.Properties)
			{
				if (newUnit.Properties.ContainsKey(item.Definition.Name) == false)
					newUnit.Properties.Add(new SchemaPropertyValue(item.Definition));

				newUnit.Properties.SetValue<string>(item.Definition.Name, item.StringValue);

				var ppt = newUnit.Properties[item.Definition.Name];
				if (ppt == null)
					throw new AUObjectException(string.Format("管理单元的属性:{0}不匹配", ppt.Definition.Name));
				else
					ppt.StringValue = item.StringValue;
			}

			newUnit.ID = UuidHelper.NewUuidString();
			newUnit.AUSchemaID = fromUnit.AUSchemaID;
			newUnit.Name = newName;
			newUnit.CodeName = newCodeName;



			return newUnit;
		}
コード例 #4
0
		private static void CopyMembers(bool copyMembers, AU.AUAdminScope item, AU.AUAdminScope targetScope, StepContext context)
		{
			if (copyMembers)
			{
				context.Logger.WriteLine(ProcessProgress.Current.StatusText = "正在复制管理范围固定成员");
				ProcessProgress.Current.Response();
				var memberIDs = AU.AUCommon.DoDbProcess(() => PC.Adapters.SCMemberRelationAdapter.Instance.LoadByContainerID(item.ID, item.ScopeSchemaType)).ToIDArray();
				var actualMembers = AU.Adapters.AUSnapshotAdapter.Instance.LoadScopeItems(memberIDs, item.ScopeSchemaType, true, DateTime.MinValue);
				context.ResetInnerSteps(actualMembers.Count);

				foreach (AU.AUAdminScopeItem scopeItem in actualMembers)
				{
					context.Logger.WriteLine("正在添加" + scopeItem.AUScopeItemName);
					AU.Operations.Facade.InstanceWithPermissions.AddObjectToScope(scopeItem, targetScope);
					context.InnerStep++;
					context.Response();
				}
			}
		}
コード例 #5
0
		private static void CopyConditions(bool copyScopeConditions, AU.AUAdminScope srcScope, AU.AUAdminScope targetScope, StepContext context)
		{
			if (copyScopeConditions)
			{
				context.Logger.WriteLine(ProcessProgress.Current.StatusText = "正在复制管理范围条件成员");
				ProcessProgress.Current.Response();

				var srcCondition = AU.Adapters.AUConditionAdapter.Instance.Load(srcScope.ID, AU.AUCommon.ConditionType).Where(m => m.Status == SchemaObjectStatus.Normal).FirstOrDefault();
				if (srcCondition != null)
				{
					AU.Operations.Facade.InstanceWithPermissions.UpdateScopeCondition(targetScope, new PC.Conditions.SCCondition()
					{
						Condition = srcCondition.Condition,
						Description = srcCondition.Description,
						OwnerID = targetScope.ID,
						Type = AU.AUCommon.ConditionType,
						SortID = 0
					});
				}
			}
		}
コード例 #6
0
		private static void DoCopyUnit(StepContext context, AU.AdminUnit fromUnit, AU.AdminUnit targetParent, string newName, string newCodeName, bool copyRoleMembers, bool copyScopeMembers, bool copyScopeConditions)
		{
			AU.AdminUnit newUnit = CreateUnit(fromUnit, newName, newCodeName);

			int totalSteps = 1;
			if (copyRoleMembers)
				totalSteps++;
			if (copyScopeConditions)
				totalSteps++;
			if (copyScopeMembers)
				totalSteps++;

			context.TotalSteps = totalSteps;
			context.PassedSteps = 0;
			context.Div = 100.0 / totalSteps;

			ProcessProgress.Current.MinStep = 1;
			ProcessProgress.Current.CurrentStep = 1;
			ProcessProgress.Current.MaxStep = 100;

			context.Logger.WriteLine(ProcessProgress.Current.StatusText = "正在添加管理单元");

			AU.Operations.Facade.InstanceWithPermissions.AddAdminUnit(newUnit, targetParent);
			context.ResetInnerSteps();
			context.PassedSteps++;
			context.Response();

			CopyRoleMembers(fromUnit, copyRoleMembers, newUnit, context);
			context.PassedSteps++;
			context.ResetInnerSteps();
			context.Response();

			if (copyScopeMembers || copyScopeConditions)
			{
				var srcScopes = fromUnit.GetNormalScopes();
				var scopes = newUnit.GetNormalScopes();

				if (copyScopeMembers)
				{
					foreach (AU.AUAdminScope srcScope in srcScopes)
					{
						var targetScope = scopes.GetScope(srcScope.ScopeSchemaType);
						if (targetScope != null)
						{
							CopyMembers(copyScopeMembers, srcScope, targetScope, context);
						}
					}
					context.PassedSteps++;
					context.ResetInnerSteps();
					context.Response();
				}

				if (copyScopeConditions)
				{
					foreach (AU.AUAdminScope srcScope in srcScopes)
					{
						var targetScope = scopes.GetScope(srcScope.ScopeSchemaType);
						if (targetScope != null)
						{
							CopyConditions(copyScopeConditions, srcScope, targetScope, context);
							context.PassedSteps++;
							context.ResetInnerSteps();
							context.Response();
						}
					}
					context.PassedSteps++;
					context.ResetInnerSteps();
				}
			}
		}
コード例 #7
0
		private DeluxeTreeNode AddSchemaToTree(AU.AUSchema item, MCS.Web.WebControls.DeluxeTreeNodeCollection treeNodes)
		{
			DeluxeTreeNode node = new MCS.Web.WebControls.DeluxeTreeNode(item.Name, item.ID)
			{
				NodeOpenImg = ControlResources.OULogoUrl,
				NodeCloseImg = ControlResources.OULogoUrl,
				CssClass = "au-catenode",
				ChildNodesLoadingType = ChildNodesLoadingTypeDefine.Normal,
				ExtendedData = "Schema",
				Expanded = true
			};

			treeNodes.Add(node);

			return node;
		}
コード例 #8
0
		private void AddUnitToTree(AU.AdminUnit item, MCS.Web.WebControls.DeluxeTreeNodeCollection treeNodes)
		{
			treeNodes.Add(new MCS.Web.WebControls.DeluxeTreeNode(item.Name, item.ID)
			{
				NodeOpenImg = ControlResources.OULogoUrl,
				NodeCloseImg = ControlResources.OULogoUrl,
				CssClass = "au-catenode",
				ChildNodesLoadingType = ChildNodesLoadingTypeDefine.LazyLoading,
				ExtendedData = "AU",
				SubNodesLoaded = false
			});
		}