Ejemplo n.º 1
0
        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);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        protected void tree_GetChildrenData(MCS.Web.WebControls.DeluxeTreeNode parentNode, MCS.Web.WebControls.DeluxeTreeNodeCollection result, string callBackContext)
        {
            var excludeSubTree = this.Request.QueryString["superOf"];

            var exceptOrg = this.Request.QueryString["exceptOrg"];

            var exceptID = excludeSubTree ?? exceptOrg;

            bool godBehavior = callBackContext == "godMode";

            if (excludeSubTree != parentNode.Value)
            {
                PC.SCObjectAndRelationCollection relations = PC.Adapters.SCSnapshotAdapter.Instance.QueryObjectAndRelationByParentIDs(PC.SchemaInfo.FilterByCategory("Organizations").ToSchemaNames(), new string[] { parentNode.Value }, false, true, false, DateTime.MinValue);

                var pmLimitString = this.Request.QueryString.Get("permission");

                var requiredPermissions = pmLimitString != null?pmLimitString.Split(',') : null;

                PC.Permissions.SCContainerAndPermissionCollection permissions = null;

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

                BindObjectsToTreeNodes(relations, result, godBehavior, requiredPermissions, permissions, excludeSubTree, exceptID);
            }
        }
Ejemplo n.º 3
0
        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);
                }
            }
        }
Ejemplo n.º 4
0
        public SchemaObjectCollection GetCurrentUsers()
        {
            SchemaObjectCollection result = null;

            SCRelationObject relation = this.CurrentParentRelations.FirstOrDefault();

            if (relation != null)
            {
                SCObjectAndRelationCollection objsAndRelations = SCSnapshotAdapter.Instance.QueryObjectAndRelationByParentFullPath(
                    SchemaInfo.FilterByCategory("Users").ToSchemaNames(), new string[] { relation.FullPath }, true, true, false, DateTime.MinValue);

                result = objsAndRelations.ToSchemaObjects();
            }
            else
            {
                result = new SchemaObjectCollection();
            }

            return(result);
        }