示例#1
0
        /// <summary>
        /// 导出指定AUSchemaID
        /// </summary>
        /// <param name="auSchemaID"></param>
        /// <param name="roleIDs">为null或长度为0时,取出所有角色</param>
        /// <returns></returns>
        public static SCObjectSet ExportAUSchemaRoles(string auSchemaID, string[] roleIDs)
        {
            auSchemaID.NullCheck("auSchemaID");

            var auSchema = AU.Adapters.AUSnapshotAdapter.Instance.LoadAUSchema(auSchemaID, true, DateTime.MinValue).FirstOrDefault();

            if (auSchema == null)
            {
                throw new AUObjectException("指定的管理架构ID无效");
            }

            SCObjectSet objectSet = new SCObjectSet();

            objectSet.Scope = "AUSchemaRoles";
            AU.AUCommon.DoDbAction(() =>
            {
                if (roleIDs != null && roleIDs.Length > 0)
                {
                    objectSet.Objects = new SchemaObjectCollection(AU.Adapters.AUSnapshotAdapter.Instance.LoadAUSchemaRoles(auSchema.ID, roleIDs, false, DateTime.MinValue));                     //包含删除的
                }
                else
                {
                    objectSet.Objects = new SchemaObjectCollection(AU.Adapters.AUSnapshotAdapter.Instance.LoadAUSchemaRoles(auSchema.ID, false, DateTime.MinValue));                     //包含删除的
                }
                objectSet.Membership = ExportQueryHelper.LoadFullMemberships(objectSet.Objects.ToIDArray());
            });

            return(objectSet);
        }
示例#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);
        }
示例#3
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 = "AllUsers";

            objectSet.Objects = ExportQueryHelper.LoadObjects(ids, null);

            objectSet.Relations = ExportQueryHelper.LoadFullRelations(ids);

            objectSet.Membership = ExportQueryHelper.LoadFullMemberships(ids);

            return(objectSet);
        }
示例#4
0
        public override SCObjectSet Execute(HttpRequest req)
        {
            string[] ids = req.Form.GetValues("id");

            if (ids == null && ids.Length == 0)
            {
                throw new HttpException("当获取角色对象时,必须提供ID参数");
            }

            string appId = req.Form["appId"];

            if (string.IsNullOrEmpty(appId))
            {
                throw new HttpException("当获取角色对象时,必须提供appId参数");
            }

            SCObjectSet objectSet = new SCObjectSet();

            objectSet.Scope = "AppRoles";

            PC.SCApplication appObj = (PC.SCApplication)PC.Adapters.SchemaObjectAdapter.Instance.Load(appId);
            if (appObj == null || appObj.Status != SchemaObjectStatus.Normal)
            {
                throw new HttpException("指定的应用不存在或者已删除");
            }

            objectSet.Objects = ExportQueryHelper.LoadObjects(ids, null);

            objectSet.Membership = ExportQueryHelper.LoadFullMemberships(ids);        // 应用与角色的关系 & 应用的成员关系

            objectSet.Conditions = ExportQueryHelper.LoadConditions(ids);             // 保存对象的条件

            objectSet.Relations = ExportQueryHelper.LoadFullRelations(ids);           // 与权限的绑定关系

            return(objectSet);
        }
示例#5
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);
        }
示例#6
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);
        }