Exemple #1
0
        public static SCObjectSet ExportAUSchemas(string[] auSchemaIDs)
        {
            auSchemaIDs.NullCheck("auSchemaIDs");

            if (auSchemaIDs.Length == 0)
            {
                throw new ArgumentException("至少应包含一个AUSchemaID", "auSchemaIDs");
            }

            SCObjectSet objectSet = new SCObjectSet();

            objectSet.Scope = "AUSchemas";

            AUCommon.DoDbAction(() =>
            {
                var schemas = ExportQueryHelper.LoadObjects(auSchemaIDs, AUCommon.SchemaAUSchema);
                if (schemas.Count > 0)
                {
                    var members          = ExportQueryHelper.LoadMembershipOf(schemas.ToIDArray());            //查找Schema中的角色关系
                    var roles            = ExportQueryHelper.LoadObjects(members.Select(m => m.ID).ToArray(), AUCommon.SchemaAUSchemaRole);
                    objectSet.Objects    = schemas + roles;
                    objectSet.Membership = members;
                }
            });

            return(objectSet);
        }
Exemple #2
0
        public AUSchema GetUnitSchema()
        {
            AUSchema schema = null;

            AUCommon.DoDbAction(() =>
            {
                schema = (AUSchema)SchemaObjectAdapter.Instance.Load(this.AUSchemaID, DateTime.MinValue);
            });

            return(schema);
        }
Exemple #3
0
        /// <summary>
        /// 获取最接近的父级(Schema或者另一个Unit)
        /// </summary>
        /// <returns></returns>
        public SCRelationObject GetCurrentVeryParentRelation()
        {
            SCRelationObject result = null;
            SCParentsRelationObjectCollection parents = null;

            AUCommon.DoDbAction(() =>
            {
                parents = PC.Adapters.SchemaRelationObjectAdapter.Instance.LoadByObjectID(this.ID);
            });

            result = FindActualParent(result, parents);

            return(result);
        }
Exemple #4
0
        public SchemaObjectCollection GetCurrentObjects()
        {
            SCMemberRelationCollectionBase members = null;

            AUCommon.DoDbAction(() =>
            {
                members = PC.Adapters.SCMemberRelationAdapter.Instance.LoadByContainerID(this.ID, this.ScopeSchemaType).FilterByStatus(SchemaObjectStatusFilterTypes.Normal);
            });
            if (members.Count > 0)
            {
                return(Adapters.AUSnapshotAdapter.Instance.LoadScopeItems(members.ToIDArray(), this.ScopeSchemaType, true, DateTime.MinValue));
            }
            else
            {
                return(new SchemaObjectCollection());
            }
        }
Exemple #5
0
 private void ImportRoleMembers(MCS.Library.SOA.DataObjects.Security.SCObjectSet objectSet, Operations.IFacade exec, ImportContextWrapper wrapper, int totalSteps, AdminUnit unit, int currentStep, AURole[] roles)
 {
     if (this.IncludeRoleMembers)
     {
         wrapper.SetStatusAndLog(currentStep, totalSteps, "正在替换管理单元角色成员" + unit.GetQualifiedName());
         foreach (AURole role in roles)
         {
             var userIDS    = (from c in objectSet.Membership where c.ContainerID == role.ID && c.MemberSchemaType == "Users" && c.Status == Schemas.SchemaProperties.SchemaObjectStatus.Normal select c.ID).ToArray();
             var users      = MCS.Library.OGUPermission.OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.Guid, userIDS);
             var scUsers    = (from u in users select new SCUser()
             {
             }).ToArray();
             var schemaRole = AUCommon.DoDbProcess <AUSchemaRole>(() => (AUSchemaRole)PC.Adapters.SchemaObjectAdapter.Instance.Load(role.SchemaRoleID));
             exec.ReplaceUsersInRole(scUsers, unit, schemaRole);
         }
     }
 }
Exemple #6
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);
        }
Exemple #7
0
        public static SCObjectSet ExportAUSchemas(string category)
        {
            SCObjectSet objectSet = new SCObjectSet();

            objectSet.Scope = "AUSchemas";

            var schemas = Adapters.AUSnapshotAdapter.Instance.LoadAUSchemaByCategory(category, true, DateTime.MinValue);

            AUCommon.DoDbAction(() =>
            {
                if (schemas.Count > 0)
                {
                    var members          = ExportQueryHelper.LoadMembershipOf(schemas.ToIDArray());            //查找Schema中的角色关系
                    var roles            = ExportQueryHelper.LoadObjects(members.Select(m => m.ID).ToArray(), AUCommon.SchemaAUSchemaRole);
                    objectSet.Objects    = schemas + roles;
                    objectSet.Membership = members;
                }
            });

            return(objectSet);
        }
Exemple #8
0
        public void DoImport(MCS.Library.SOA.DataObjects.Security.SCObjectSet objectSet, IImportContext context)
        {
            var exec = this.IgnorePermission ? Operations.Facade.DefaultInstance : Operations.Facade.InstanceWithPermissions;

            ImportContextWrapper wrapper = new ImportContextWrapper(context);

            if (string.IsNullOrEmpty(this.ParentID))
            {
                throw new InvalidOperationException("操作前必须对ParentID进行赋值");
            }


            var parent = AUCommon.DoDbProcess <SchemaObjectBase>(() => PC.Adapters.SchemaObjectAdapter.Instance.Load(this.ParentID));

            if (parent == null || parent.Status != Schemas.SchemaProperties.SchemaObjectStatus.Normal)
            {
                throw new AUObjectException("不存在指定的父级单元,请确认");
            }

            if (parent is AUSchema)
            {
                parent = null;
            }
            else if (!(parent is AdminUnit))
            {
                throw new AUObjectException("指定的ParentID不是一个AUSchema或者AdminUnit对象的ID");
            }

            var subs  = (from r in objectSet.Relations where r.ParentID == this.ParentID && r.ChildSchemaType == AUCommon.SchemaAdminUnit && r.Status == Schemas.SchemaProperties.SchemaObjectStatus.Normal join o in objectSet.Objects on r.ID equals o.ID where o.Status == Schemas.SchemaProperties.SchemaObjectStatus.Normal && o.SchemaType == AUCommon.SchemaAdminUnit select(AdminUnit) o).ToArray();
            int count = subs.Length;

            foreach (AdminUnit s in subs)
            {
                ImportOneUnit(objectSet, exec, wrapper, parent, count, s);
            }
        }
Exemple #9
0
 long ISCRelationContainer.GetCurrentMaxInnerSort()
 {
     return(AUCommon.DoDbProcess(() => SchemaRelationObjectAdapter.Instance.GetMaxInnerSort(this.ID, null, DateTime.MinValue)));
 }
Exemple #10
0
 /// <summary>
 /// 创建一个基本的日志
 /// </summary>
 /// <param name="data"></param>
 /// <param name="aUOperationType"></param>
 /// <returns></returns>
 internal static Logs.AUOperationLog ToOperationLog(this SchemaObjectBase data, Executors.AUOperationType opType)
 {
     return(ToOperationLog(data, opType, string.Format("{0}: {1}",
                                                       EnumItemDescriptionAttribute.GetDescription(opType), AUCommon.DisplayNameFor(data))));
 }