Beispiel #1
0
        /// <summary>
        /// Clones GreyFoxRole object and clones child objects with cloning or replication.
        /// as the parent object.
        /// </summary>
        /// <returns> A new GreyFoxRole object reflecting the replicated GreyFoxRole object.</returns>
        public GreyFoxRole Clone()
        {
            lock (this)
            {
                GreyFoxRole clonedGreyFoxRole = new GreyFoxRole();
                clonedGreyFoxRole.iD          = iD;
                clonedGreyFoxRole.isSynced    = isSynced;
                clonedGreyFoxRole.name        = name;
                clonedGreyFoxRole.description = description;
                clonedGreyFoxRole.isDisabled  = isDisabled;


                return(clonedGreyFoxRole);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Fills the {0} from a OleIDataReader.
        /// </summary>
        public static void FillFromReader(GreyFoxRole greyFoxRole, IDataReader r, int idOffset, int dataOffset)
        {
            greyFoxRole.iD            = r.GetInt32(idOffset);
            greyFoxRole.isSynced      = true;
            greyFoxRole.isPlaceHolder = false;

            greyFoxRole.name = r.GetString(0 + dataOffset);
            if (!r.IsDBNull(1 + dataOffset))
            {
                greyFoxRole.description = r.GetString(1 + dataOffset);
            }
            else
            {
                greyFoxRole.description = null;
            }
            greyFoxRole.isDisabled = r.GetBoolean(2 + dataOffset);
        }
Beispiel #3
0
        internal static bool _fill(GreyFoxRole greyFoxRole)
        {
            // Clone item from cache.
            if (cacheEnabled)
            {
                object cachedObject = cacheFind(greyFoxRole.iD);
                if (cachedObject != null)
                {
                    ((GreyFoxRole)cachedObject).CopyTo(greyFoxRole, true);
                    return(greyFoxRole.isSynced);
                }
            }

            StringBuilder query;
            Database      database;
            DbCommand     dbCommand;

            query = new StringBuilder("SELECT ");
            query.Append(string.Join(",", InnerJoinFields));
            query.Append(" FROM sysGlobal_Roles WHERE GreyFoxRoleID=");
            query.Append(greyFoxRole.iD);
            query.Append(";");

            database  = DatabaseFactory.CreateDatabase();
            dbCommand = database.GetSqlStringCommand(query.ToString());
            IDataReader r = database.ExecuteReader(dbCommand);

            if (!r.Read())
            {
                throw(new Exception(string.Format("Cannot find GreyFoxRoleID '{0}'.",
                                                  greyFoxRole.iD)));
            }

            FillFromReader(greyFoxRole, r, 0, 1);

            // Microsoft DAAB still needs to have the reader closed.
            r.Close();

            // Store greyFoxRole in cache.
            if (cacheEnabled)
            {
                cacheStore(greyFoxRole);
            }

            return(true);
        }
Beispiel #4
0
 public int Add(GreyFoxRole value)
 {
     OnCollectionChanged(EventArgs.Empty);
     lock (this)
     {
         count++;
         // Resize the array if the count is greater than the length
         // of the array.
         if (count > GreyFoxRoleArray.GetUpperBound(0) + 1)
         {
             GreyFoxRole[] tempGreyFoxRoleArray = new GreyFoxRole[count * 2];
             Array.Copy(GreyFoxRoleArray, tempGreyFoxRoleArray, count - 1);
             GreyFoxRoleArray = tempGreyFoxRoleArray;
         }
         GreyFoxRoleArray[count - 1] = value;
     }
     return(count - 1);
 }
Beispiel #5
0
        public static void FillRoles(GreyFoxUser greyFoxUser)
        {
            StringBuilder s;
            Database      database;
            DbCommand     dbCommand;
            IDataReader   r;

            s = new StringBuilder("SELECT GreyFoxRoleID FROM sysGlobal_UsersChildren_Roles ");
            s.Append("WHERE GreyFoxUserID=");
            s.Append(greyFoxUser.iD);
            s.Append(";");

            database  = DatabaseFactory.CreateDatabase();
            dbCommand = database.GetSqlStringCommand(s.ToString());
            r         = database.ExecuteReader(dbCommand);

            GreyFoxRoleCollection roles;

            if (greyFoxUser.roles != null)
            {
                roles = greyFoxUser.roles;
                roles.Clear();
            }
            else
            {
                roles             = new GreyFoxRoleCollection();
                greyFoxUser.roles = roles;
            }

            while (r.Read())
            {
                roles.Add(GreyFoxRole.NewPlaceHolder(r.GetInt32(0)));
            }

            greyFoxUser.Roles = roles;
            // Store GreyFoxUser in cache.
            if (cacheEnabled)
            {
                cacheStore(greyFoxUser);
            }
        }
Beispiel #6
0
 public void Insert(int index, GreyFoxRole value)
 {
     OnCollectionChanged(EventArgs.Empty);
     lock (this)
     {
         count++;
         // Resize the array if the count is greater than the length
         // of the array.
         if (count > GreyFoxRoleArray.GetUpperBound(0) + 1)
         {
             GreyFoxRole[] tempGreyFoxRoleArray = new GreyFoxRole[count * 2];
             Array.Copy(GreyFoxRoleArray, tempGreyFoxRoleArray, count - 1);
             GreyFoxRoleArray = tempGreyFoxRoleArray;
         }
         for (int x = index + 1; x == count - 2; x++)
         {
             GreyFoxRoleArray[x] = GreyFoxRoleArray[x - 1];
         }
         GreyFoxRoleArray[index] = value;
     }
 }
Beispiel #7
0
 /// <summary>
 /// Compares the object's ID to another object's ID.
 /// </summary>
 public int CompareTo(GreyFoxRole greyFoxRole)
 {
     return(this.iD - greyFoxRole.iD);
 }
Beispiel #8
0
        /// <summary>
        /// Compares the object's ID to another object's ID.
        /// </summary>
        int IComparable.CompareTo(object obj)
        {
            GreyFoxRole greyFoxRole = (GreyFoxRole)obj;

            return(this.iD - greyFoxRole.iD);
        }
Beispiel #9
0
 /// <summary>
 /// Deep copies the current GreyFoxRole to another instance of GreyFoxRole.
 /// This method does not provide isolated copies; use overriden method for this feature.
 /// </summary>
 /// <param name="GreyFoxRole">The GreyFoxRole to copy to.</param>
 public void CopyTo(GreyFoxRole greyFoxRole)
 {
     CopyTo(greyFoxRole, false);
 }
Beispiel #10
0
        private static void cacheStore(GreyFoxRole greyFoxRole)
        {
            CacheManager cache = CacheFactory.GetCacheManager();

            cache.Add("sysGlobal_Roles_" + greyFoxRole.iD.ToString(), greyFoxRole);
        }
Beispiel #11
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);
        }
Beispiel #12
0
 public bool Contains(GreyFoxRole value)
 {
     return(IndexOf(value) != -1);
 }