Пример #1
0
        //--- Begin Custom Code ---

        #region Encoding

        public GreyFoxRoleCollection DecodeString(string roles, string separator)
        {
            GreyFoxRoleCollection encodedRoles = new GreyFoxRoleCollection();

            roles = roles.Trim();
            if (roles.Trim() == string.Empty)
            {
                return(encodedRoles);
            }

            string[] names = roles.Split(new string[] { separator },
                                         StringSplitOptions.RemoveEmptyEntries);

            if (names.Length < 20)
            {
                return(fastDecode(names));
            }

            GreyFoxRoleCollection allRoles =
                GetCollection(string.Empty, string.Empty);

            for (int x = 0; x < allRoles.Count; x++)
            {
                for (int y = 0; y <= names.GetUpperBound(0); y++)
                {
                    if (allRoles[x].Name == names[y])
                    {
                        encodedRoles.Add(allRoles[x]);
                    }
                }
            }

            return(encodedRoles);
        }
Пример #2
0
        /// <summary>
        /// Makes a shallow copy of the current GreyFoxRoleCollection.
        /// as the parent object.
        /// </summary>
        /// <returns>GreyFoxRoleCollection</returns>
        public GreyFoxRoleCollection Clone()
        {
            GreyFoxRoleCollection clonedGreyFoxRole = new GreyFoxRoleCollection(count);

            lock (this)
            {
                foreach (GreyFoxRole item in this)
                {
                    clonedGreyFoxRole.Add(item);
                }
            }
            return(clonedGreyFoxRole);
        }
Пример #3
0
        /// <summary>
        /// Makes a deep copy of the current GreyFoxRole.
        /// </summary>
        /// <param name="isolation">Placeholders are used to isolate the
        /// items in the GreyFoxRoleCollection from their children.</param>
        public GreyFoxRoleCollection Copy(bool isolated)
        {
            GreyFoxRoleCollection isolatedCollection = new GreyFoxRoleCollection(count);

            lock (this)
            {
                if (isolated)
                {
                    for (int i = 0; i < count; i++)
                    {
                        isolatedCollection.Add(GreyFoxRoleArray[i].NewPlaceHolder());
                    }
                }
                else
                {
                    for (int i = 0; i < count; i++)
                    {
                        isolatedCollection.Add(GreyFoxRoleArray[i].Copy());
                    }
                }
            }
            return(isolatedCollection);
        }
Пример #4
0
        public GreyFoxRoleCollection GetCollection(int topCount, string whereClause, string sortClause)
        {
            StringBuilder         query;
            Database              database;
            DbCommand             dbCommand;
            IDataReader           r;
            GreyFoxRoleCollection greyFoxRoleCollection;


            query = new StringBuilder("SELECT ");

            if (topCount > 0)
            {
                query.Append("TOP ");
                query.Append(topCount);
                query.Append(" ");
            }

            foreach (string columnName in InnerJoinFields)
            {
                query.Append("GreyFoxRole.");
                query.Append(columnName);
                query.Append(",");
            }

            //
            // Remove trailing comma
            //
            query.Length--;
            query.Append(" FROM sysGlobal_Roles AS GreyFoxRole");
            //
            // Render where clause
            //
            if (whereClause != string.Empty)
            {
                query.Append(" WHERE ");
                query.Append(whereClause);
            }

            //
            // Render sort clause
            //
            if (sortClause != string.Empty)
            {
                query.Append(" ORDER BY ");
                query.Append(sortClause);
            }

            //
            // Render final semicolon
            //
            query.Append(";");
            database  = DatabaseFactory.CreateDatabase();
            dbCommand = database.GetSqlStringCommand(query.ToString());
                        #if DEBUG
            try
            {
                r = database.ExecuteReader(dbCommand);
            }
            catch (Exception e)
            {
                string msg = e.Message;
                throw(new Exception(msg + " --- Query: " + query.ToString()));
            }
                        #else
            r = database.ExecuteReader(dbCommand);
                        #endif

            greyFoxRoleCollection = new GreyFoxRoleCollection();

            while (r.Read())
            {
                GreyFoxRole greyFoxRole = ParseFromReader(r, 0, 1);

                greyFoxRoleCollection.Add(greyFoxRole);
            }

            // Microsoft DAAB still needs to close readers.
            r.Close();

            return(greyFoxRoleCollection);
        }