private HashSet<string> GetSchemaTypes(PC.SchemaObjectCollection objects)
		{
			HashSet<string> result = new HashSet<string>();
			objects.ForEach<PC.SchemaObjectBase>(item => result.Add(item.SchemaType));

			return result;
		}
		private static void PrepareTreeNodeRecursively(PC.SCSimpleObject parentOrg, DeluxeTreeNode parentTreeNode, Dictionary<string, PC.SCSimpleObject> parentsList, bool godMode, DateTime timePoint, string[] requiredPermissions, string excludeId, string exceptID)
		{
			if (excludeId != parentOrg.ID)
			{
				PC.SCObjectAndRelationCollection relations = PC.Adapters.SCSnapshotAdapter.Instance.QueryObjectAndRelationByParentIDs(PC.SchemaInfo.FilterByCategory("Organizations").ToSchemaNames(), new string[] { parentOrg.ID }, false, true, false, timePoint);

				PC.Permissions.SCContainerAndPermissionCollection permissions = null;

				if (requiredPermissions != null)
				{
					permissions = PC.Adapters.SCAclAdapter.Instance.LoadCurrentContainerAndPermissions(Util.CurrentUser.ID, relations.ToIDArray());
				}

				BindObjectsToTreeNodes(relations, parentTreeNode.Nodes, godMode, requiredPermissions, permissions, excludeId, exceptID);

				foreach (DeluxeTreeNode childNode in parentTreeNode.Nodes)
				{
					PC.SCSimpleObject obj = null;

					if (parentsList.TryGetValue(childNode.Value, out obj))
					{
						childNode.ChildNodesLoadingType = ChildNodesLoadingTypeDefine.Normal;
						childNode.Expanded = true;

						PrepareTreeNodeRecursively(obj, childNode, parentsList, godMode, timePoint, requiredPermissions, excludeId, exceptID);
					}
				}
			}
		}
		private static void BindObjectsToTreeNodes(PC.SCObjectAndRelationCollection relations, DeluxeTreeNodeCollection nodes, bool godMode, string[] requiredPermissions, PC.Permissions.SCContainerAndPermissionCollection permissions, string excludeID, string exceptID)
		{
			relations.Sort((m, n) => m.InnerSort.CompareTo(n.InnerSort));
			foreach (PC.SCObjectAndRelation r in relations)
			{
				if (r.ID != excludeID && Util.IsOrganization(r.SchemaType))
				{
					bool showCheckBoxes;
					bool selectable;

					if (r.ID == exceptID)
					{
						selectable = false;
					}
					else if (godMode)
					{
						selectable = true;
					}
					else
					{
						selectable = true;
						if (requiredPermissions != null && permissions != null)
						{
							foreach (string p in requiredPermissions)
							{
								selectable &= Util.ContainsPermission(permissions, r.ID, p);
							}
						}
					}

					if (HttpContext.Current.Request.QueryString["mode"] == "single")
					{
						showCheckBoxes = false;
					}
					else
					{
						showCheckBoxes = selectable;
					}

					DeluxeTreeNode newTreeNode = CreateTreeNode(r.ID, r.Name, r.DisplayName, r.FullPath, selectable, showCheckBoxes);

					nodes.Add(newTreeNode);
				}
			}
		}
Exemple #4
0
 internal static bool ContainsPermission(PC.Permissions.SCContainerAndPermissionCollection permissions, string containerID, string permission)
 {
     if (permissions == null || string.IsNullOrEmpty(containerID))
         return false;
     else
         return permissions.ContainsKey(containerID, permission);
 }