Exemplo n.º 1
0
        public override SCObjectSet Execute(HttpRequest req)
        {
            string[] ids = req.Form.GetValues("id");

            if (ids == null || ids.Length < 0)
            {
                throw new HttpException("当获取应用数据时,必须提供ID参数");
            }

            SCObjectSet objectSet = new SCObjectSet();

            objectSet.Scope = "AllApps";

            objectSet.Objects = ExportQueryHelper.LoadObjects(ids, "Applications");

            // 查找应用下的角色和功能
            objectSet.Membership = ExportQueryHelper.LoadMembershipOf(ids, "Applications");

            var memberObjects = ExportQueryHelper.LoadObjects((from obj in objectSet.Membership select obj.ID).ToArray(), null);

            objectSet.Acls = ExportQueryHelper.LoadAclsFor(ids);             // ACL

            foreach (var obj in memberObjects)
            {
                if (objectSet.Objects.ContainsKey(obj.ID) == false)
                {
                    objectSet.Objects.Add(obj);                     // 成员对象(角色和功能)
                }
            }

            var roleIds = (from m in memberObjects where m is PC.SCRole select m.ID).ToArray();

            if (roleIds.Length > 0)
            {
                var roleMembers = ExportQueryHelper.LoadMembershipOf(roleIds);

                objectSet.Membership.CopyFrom(roleMembers);                       // 角色→固定成员

                objectSet.Conditions = ExportQueryHelper.LoadConditions(roleIds); // 角色→条件

                objectSet.Relations = ExportQueryHelper.LoadFullRelations(roleIds);
            }

            return(objectSet);
        }
Exemplo n.º 2
0
        public static SCObjectSet ExportAdminUnits(string auSchemaID, string[] unitIDs, bool deep)
        {
            auSchemaID.NullCheck("auSchemaID");

            SCObjectSet objectSet = new SCObjectSet();

            objectSet.Scope = "AdminUnits";

            objectSet.Objects = AU.Adapters.AUSnapshotAdapter.Instance.LoadAUBySchemaID(auSchemaID, unitIDs, true, DateTime.MinValue);

            if (objectSet.Objects.Count > 0)
            {
                var ids = objectSet.Objects.ToIDArray();

                if (deep)
                {
                    var allSubUnits = Adapters.AUSnapshotAdapter.Instance.LoadCurrentSubUnitsDeeply(ids, DateTime.MinValue);
                    objectSet.Objects.Merge(allSubUnits);
                }

                AUCommon.DoDbAction(() =>
                {
                    objectSet.Relations = ExportQueryHelper.LoadFullRelations(ids);

                    objectSet.Membership = ExportQueryHelper.LoadFullMemberships(ids, false);                     //包含删除的

                    objectSet.Acls = ExportQueryHelper.LoadAclsFor(ids);

                    //查找角色
                    var roleIDs  = objectSet.Membership.Where(m => m.MemberSchemaType == AU.AUCommon.SchemaAdminUnitRole).Select(m => m.ID).ToArray();
                    var scopeIDs = objectSet.Membership.Where(m => m.MemberSchemaType == AU.AUCommon.SchemaAUAdminScope).Select(m => m.ID).ToArray();

                    LookupMemberObjects(objectSet, roleIDs, AUCommon.SchemaAdminUnitRole);

                    LookupMemberObjects(objectSet, scopeIDs, AUCommon.SchemaAUAdminScope);

                    objectSet.Conditions = ExportQueryHelper.LoadConditions(scopeIDs);
                });
            }

            return(objectSet);
        }
Exemplo n.º 3
0
        public override SCObjectSet Execute(HttpRequest req)
        {
            string parentId = req.Form["ParentId"];

            if (string.IsNullOrEmpty(parentId))
            {
                throw new HttpException("当获取深度组织机构对象时,必须提供ParentId参数");
            }

            PC.SCOrganization parentObj = parentId == PC.SCOrganization.RootOrganizationID ? PC.SCOrganization.GetRoot() : (PC.SCOrganization)PC.Adapters.SchemaObjectAdapter.Instance.Load(parentId);
            if (parentObj == null || parentObj.Status != SchemaObjectStatus.Normal)
            {
                throw new HttpException("指定的父级对象不存在或者已删除");
            }

            List <string> ids;

            string[] requestIds = req.Form.GetValues("id");
            if (requestIds == null || requestIds.Length == 0)
            {
                PC.SCSimpleRelationObjectCollection allChildren = PC.Adapters.SchemaRelationObjectAdapter.Instance.LoadAllChildrenRelationsRecursively(parentObj);
                ids = new List <string>(allChildren.Count);
                allChildren.ForEach(so => ids.Add(so.ID));
            }
            else
            {
                PC.SCSimpleRelationObjectCollection allChildren = new PC.SCSimpleRelationObjectCollection();
                ids = new List <string>();

                var directRelations = ExportQueryHelper.LoadRelations(parentId, requestIds);

                foreach (var item in directRelations)
                {
                    ids.Add(item.ID);
                }

                var selectedObjects = DbUtil.LoadObjects(ids.ToArray());
                foreach (var item in selectedObjects)
                {
                    var subRelations = PC.Adapters.SchemaRelationObjectAdapter.Instance.LoadAllChildrenRelationsRecursively(item);
                    subRelations.ForEach(m => ids.Add(m.ID));
                }
            }

            SCObjectSet set = new SCObjectSet();

            if (ids.Count > 0)
            {
                set.Objects = DbUtil.LoadObjects(ids.ToArray());
                set.Objects.Distinct((m, n) => m.ID == n.ID);

                var objIds = set.Objects.ToIDArray();

                set.Relations = ExportQueryHelper.LoadFullRelations(objIds);
                set.Relations.Distinct((a, b) => a.ID == b.ID && a.ParentID == b.ParentID);

                set.Membership = ExportQueryHelper.LoadFullMemberships(objIds);
                set.Membership.Distinct((a, b) => a.ID == b.ID && a.ContainerID == b.ContainerID);

                set.Acls = ExportQueryHelper.LoadAclsFor(objIds);

                set.Conditions = ExportQueryHelper.LoadConditions(objIds);
            }

            set.Scope = "OguFull";
            return(set);
        }
Exemplo n.º 4
0
        public override SCObjectSet Execute(HttpRequest req)
        {
            string[] ids = req.Form.GetValues("id");

            if (ids == null && ids.Length < 0)
            {
                throw new HttpException("当获组织机构对象时,必须提供ID参数");
            }

            SCObjectSet objectSet = new SCObjectSet();

            objectSet.Scope = "OguObjects";

            WhereSqlClauseBuilder where = new WhereSqlClauseBuilder();
            where.AppendItem("Status", (int)SchemaObjectStatus.Normal);

            ConnectiveSqlClauseCollection conditios = new ConnectiveSqlClauseCollection(where, VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder());

            {
                string parentId = req.Form["ParentId"];
                if (string.IsNullOrEmpty(parentId))
                {
                    throw new HttpException("当获取组织机构对象时,必须提供ParentId参数");
                }

                PC.SCOrganization parentObj = parentId == PC.SCOrganization.RootOrganizationID ? PC.SCOrganization.GetRoot() : (PC.SCOrganization)PC.Adapters.SchemaObjectAdapter.Instance.Load(parentId);
                if (parentObj == null || parentObj.Status != SchemaObjectStatus.Normal)
                {
                    throw new HttpException("指定的父级对象不存在或者已删除");
                }

                InSqlClauseBuilder idIn = new InSqlClauseBuilder("ID");
                idIn.AppendItem(ids);
                conditios.Add(idIn);

                objectSet.Objects = PC.Adapters.SchemaObjectAdapter.Instance.Load(conditios);

                objectSet.Relations = this.FilterChildren(PC.Adapters.SchemaRelationObjectAdapter.Instance.LoadByParentID(parentId), ids);

                // 保存对象的下级关系(如果有)
                objectSet.Membership = ExportQueryHelper.LoadFullMemberships(ids);

                // 如果含有群组,导出群组的条件
                string[] groupIds = (from PC.SchemaObjectBase o in objectSet.Objects where o is PC.SCGroup select o.ID).ToArray();

                if (groupIds.Length > 0)
                {
                    var conditions = ExportQueryHelper.LoadConditions(groupIds);
                    if (conditions.Count > 0)
                    {
                        objectSet.Conditions = conditions;
                    }
                }

                // 如果含有组织,导出组织的Acl
                string[] orgIds = (from PC.SchemaObjectBase o in objectSet.Objects where o is PC.SCOrganization select o.ID).ToArray();

                objectSet.Acls = ExportQueryHelper.LoadAclsFor(orgIds);
            }

            return(objectSet);
        }