Example #1
0
        private SCRole LoadRoleByFullCodeName(SCRoleEnumMatrixUsersContext context, string roleFullCodeName)
        {
            string[] nameParts = roleFullCodeName.Split(':');

            string appCodeName  = nameParts[0].Trim(' ');
            string roleCodeName = nameParts[1].Trim(' ');

            SCApplication app = null;

            if (context.CachedApplication.TryGetValue(appCodeName, out app) == false)
            {
                app = SchemaObjectAdapter.Instance.LoadByCodeName(this.CurrentApplication.SchemaType, appCodeName, SchemaObjectStatus.Normal, DateTime.MinValue) as SCApplication;

                context.CachedApplication.Add(appCodeName, app);
            }

            SCRole role = null;

            if (app != null)
            {
                role = SchemaObjectAdapter.Instance.LoadByCodeName(this.SchemaType, roleCodeName, SchemaObjectStatus.Normal, DateTime.MinValue) as SCRole;
            }

            return(role);
        }
Example #2
0
        private void InternalEnumMatrixRows(SCRoleEnumMatrixUsersContext context, IEnumerator <SOARolePropertyRow> enumerator)
        {
            if (enumerator.MoveNext())
            {
                SOARolePropertyRow row = enumerator.Current;

                switch (row.OperatorType)
                {
                case SOARoleOperatorType.User:
                    if (context.UsersCodeNames.ContainsKey(row.Operator) == false)
                    {
                        context.UsersCodeNames.Add(row.Operator, row.Operator);
                    }
                    break;

                case SOARoleOperatorType.Role:
                    if (row.Operator.IndexOf(":") >= 0)
                    {
                        EnumInternalRoleMatrixUsers(context, row.Operator);
                    }
                    break;
                }

                InternalEnumMatrixRows(context, enumerator);
            }
        }
Example #3
0
        private static void InternalEnumMatrixUsers(SCRole role, SCRoleEnumMatrixUsersContext context)
        {
            SOARolePropertyRowCollection rows = SOARolePropertiesAdapter.Instance.LoadByRoleID(role.ID, null);

            IEnumerator <SOARolePropertyRow> enumerator = rows.GetEnumerator();

            role.InternalEnumMatrixRows(context, enumerator);
        }
Example #4
0
        private void EnumInternalRoleMatrixUsers(SCRoleEnumMatrixUsersContext context, string roleFullCodeName)
        {
            //防止嵌套后的死循环
            if (context.CalculatedRolesCodeNames.ContainsKey(roleFullCodeName) == false)
            {
                SCRole role = LoadRoleByFullCodeName(context, roleFullCodeName);

                context.CalculatedRolesCodeNames.Add(roleFullCodeName, roleFullCodeName);

                if (role != null)
                {
                    InternalEnumMatrixUsers(role, context);
                }
            }
        }
Example #5
0
        /// <summary>
        /// 枚举矩阵中的人员
        /// </summary>
        /// <returns></returns>
        private void EnumMatrixUsers(SchemaObjectCollection result)
        {
            if (this.CurrentApplication != null)
            {
                SOARolePropertyRowCollection rows = SOARolePropertiesAdapter.Instance.LoadByRoleID(this.ID, null);

                SCRoleEnumMatrixUsersContext context = new SCRoleEnumMatrixUsersContext();

                context.CachedApplication.Add(this.CurrentApplication.CodeName, this.CurrentApplication);

                string fullCodeName = this.GetFullCodeName();

                context.CalculatedRolesCodeNames.Add(fullCodeName, fullCodeName);

                InternalEnumMatrixUsers(this, context);

                FillMatrixUsers(context, result);
            }
        }
Example #6
0
        private static void FillMatrixUsers(SCRoleEnumMatrixUsersContext context, SchemaObjectCollection result)
        {
            SchemaObjectCollection users = SchemaObjectAdapter.Instance.LoadByCodeName(builder => { }, DateTime.MinValue, context.UsersCodeNames.Keys.ToArray());

            result.Merge(users);
        }