Exemplo n.º 1
0
        /// <summary>
        /// Makes a deep copy of the current DojoMemberType.
        /// </summary>
        /// <returns> A new DojoMemberType object reflecting the cloned DojoMemberType object.</returns>
        /// <param name="isolation">Placeholders are used to isolate the DojoMemberType from its children.</param>
        public DojoMemberType Copy(bool isolation)
        {
            DojoMemberType dojoMemberType = new DojoMemberType();

            CopyTo(dojoMemberType, isolation);
            return(dojoMemberType);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Makes a deep copy of the current DojoMemberType.
        /// </summary>
        /// <returns> A new DojoMemberType object reflecting the cloned DojoMemberType object.</returns>
        public DojoMemberType Copy()
        {
            DojoMemberType dojoMemberType = new DojoMemberType();

            CopyTo(dojoMemberType);
            return(dojoMemberType);
        }
Exemplo n.º 3
0
        public static DojoMemberType ParseFromReader(IDataReader r, int idOffset, int dataOffset)
        {
            DojoMemberType dojoMemberType = new DojoMemberType();

            FillFromReader(dojoMemberType, r, idOffset, dataOffset);
            return(dojoMemberType);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Fills the {0} from a OleIDataReader.
        /// </summary>
        public static void FillFromReader(DojoOrganization dojoOrganization, IDataReader r, int idOffset, int dataOffset)
        {
            dojoOrganization.iD            = r.GetInt32(idOffset);
            dojoOrganization.isSynced      = true;
            dojoOrganization.isPlaceHolder = false;

            dojoOrganization.name        = r.GetString(0 + dataOffset);
            dojoOrganization.description = r.GetString(1 + dataOffset);
            if (!r.IsDBNull(2 + dataOffset) && r.GetInt32(2 + dataOffset) > 0)
            {
                dojoOrganization.location = GreyFoxContact.NewPlaceHolder("kitTessen_Locations", r.GetInt32(2 + dataOffset));
            }
            if (!r.IsDBNull(3 + dataOffset) && r.GetInt32(3 + dataOffset) > 0)
            {
                dojoOrganization.administrativeContact = GreyFoxContact.NewPlaceHolder("sysGlobal_Contacts", r.GetInt32(3 + dataOffset));
            }
            dojoOrganization.webServiceUrl = r.GetString(4 + dataOffset);
            dojoOrganization.refreshTime   = TimeSpan.FromTicks((long)r.GetDouble(5 + dataOffset));
            dojoOrganization.isPrimary     = r.GetBoolean(6 + dataOffset);
            if (!r.IsDBNull(7 + dataOffset) && r.GetInt32(7 + dataOffset) > 0)
            {
                dojoOrganization.defaultMemberType = DojoMemberType.NewPlaceHolder(r.GetInt32(7 + dataOffset));
            }
            dojoOrganization.promotionFlagEnabled = r.GetBoolean(8 + dataOffset);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Inserts a DojoMemberType into the database. All children should have been
        /// saved to the database before insertion. New children will not be
        /// related to this object in the database.
        /// </summary>
        /// <param name="_DojoMemberType">The DojoMemberType to insert into the database.</param>
        internal static int _insert(DojoMemberType dojoMemberType)
        {
            int       id;
            string    query;
            Database  database;
            DbCommand dbCommand;

            database = DatabaseFactory.CreateDatabase();

            query = "INSERT INTO kitTessen_MemberTypes " +
                    "(" +
                    "Name," +
                    "Description," +
                    "OrderNum) VALUES (" +
                    "@Name," +
                    "@Description," +
                    "@OrderNum);";

            if (database.ConnectionStringWithoutCredentials.StartsWith("provider=microsoft.jet.oledb.4.0"))
            {
                // Microsoft Access
                // Connection must remain open for IDENTITY to return correct value,
                // therefore use the dbCommand object's Connection directly to control
                // connection state.
                dbCommand = database.GetSqlStringCommand(query);
                fillParameters(database, dbCommand, dojoMemberType);
                dbCommand.Connection = database.CreateConnection();
                dbCommand.Connection.Open();
                dbCommand.ExecuteNonQuery();
                dbCommand.CommandText = "SELECT @@IDENTITY AS LastID";
                id = (int)dbCommand.ExecuteScalar();
                dbCommand.Connection.Close();
            }
            else
            {
                //// Microsoft SQL Server
                dbCommand = database.GetSqlStringCommand(query + " SELECT @LastID = SCOPE_IDENTITY();");
                fillParameters(database, dbCommand, dojoMemberType);
                database.AddOutParameter(dbCommand, "@LastID", DbType.Int32, 10);
                database.ExecuteNonQuery(dbCommand);
                id = (int)dbCommand.Parameters["@LastID"].Value;
            }
            // Store dojoMemberType in cache.
            if (cacheEnabled)
            {
                cacheStore(dojoMemberType);
            }
            // ************************* WARNING ****************************
            // Insert operations must invalidate the cached collections.
            // Invalidation MUST invalidate any foreign cached collections that
            // with children objects this manager provides or else the foreign
            // caches retain invalidated and potentially corrupt data!
            // NOTE:
            // NitroCast only allows collection caching on objects that do not
            // have any children objects to minimize potential corruption.
            invalidateCachedCollections();
            return(id);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Duplicates DojoMemberType object into a database; may or may not be the same database
        /// as the parent object.
        /// </summary>
        /// <returns> A new DojoMemberType object reflecting the replicated DojoMemberType object.</returns>
        public DojoMemberType Duplicate()
        {
            DojoMemberType clonedDojoMemberType = this.Clone();

            // Insert must be called after children are replicated!
            clonedDojoMemberType.iD       = DojoMemberTypeManager._insert(clonedDojoMemberType);
            clonedDojoMemberType.isSynced = true;
            return(clonedDojoMemberType);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Deep copies the current DojoMemberType to another instance of DojoMemberType.
 /// </summary>
 /// <param name="DojoMemberType">The DojoMemberType to copy to.</param>
 /// <param name="isolation">Placeholders are used to isolate the DojoMemberType from its children.</param>
 public void CopyTo(DojoMemberType dojoMemberType, bool isolation)
 {
     dojoMemberType.iD            = iD;
     dojoMemberType.isPlaceHolder = isPlaceHolder;
     dojoMemberType.isSynced      = isSynced;
     dojoMemberType.name          = name;
     dojoMemberType.description   = description;
     dojoMemberType.orderNum      = orderNum;
 }
Exemplo n.º 8
0
        public static DojoMemberType NewPlaceHolder(int iD)
        {
            DojoMemberType dojoMemberType = new DojoMemberType();

            dojoMemberType.iD            = iD;
            dojoMemberType.isPlaceHolder = true;
            dojoMemberType.isSynced      = true;
            return(dojoMemberType);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Fills the {0} from a OleIDataReader.
        /// </summary>
        public static void FillFromReader(DojoMemberType dojoMemberType, IDataReader r, int idOffset, int dataOffset)
        {
            dojoMemberType.iD            = r.GetInt32(idOffset);
            dojoMemberType.isSynced      = true;
            dojoMemberType.isPlaceHolder = false;

            dojoMemberType.name        = r.GetString(0 + dataOffset);
            dojoMemberType.description = r.GetString(1 + dataOffset);
            dojoMemberType.orderNum    = r.GetInt32(2 + dataOffset);
        }
Exemplo n.º 10
0
        private static void fillParameters(Database database, DbCommand dbCommand, DojoMemberType dojoMemberType)
        {
            #region Default

            addParameter(database, dbCommand, "@Name", DbType.String, dojoMemberType.name);
            addParameter(database, dbCommand, "@Description", DbType.String, dojoMemberType.description);
            addParameter(database, dbCommand, "@OrderNum", DbType.Int32, dojoMemberType.orderNum);

            #endregion
        }
Exemplo n.º 11
0
        public void Remove(DojoMemberType value)
        {
            OnCollectionChanged(EventArgs.Empty);
            int index = IndexOf(value);

            if (index == -1)
            {
                throw(new Exception("DojoMemberType not found in collection."));
            }
            RemoveAt(index);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Clones DojoMemberType object and clones child objects with cloning or replication.
        /// as the parent object.
        /// </summary>
        /// <returns> A new DojoMemberType object reflecting the replicated DojoMemberType object.</returns>
        public DojoMemberType Clone()
        {
            DojoMemberType clonedDojoMemberType = new DojoMemberType();

            clonedDojoMemberType.iD          = iD;
            clonedDojoMemberType.isSynced    = isSynced;
            clonedDojoMemberType.name        = name;
            clonedDojoMemberType.description = description;
            clonedDojoMemberType.orderNum    = orderNum;


            return(clonedDojoMemberType);
        }
Exemplo n.º 13
0
 public int IndexOf(DojoMemberType value)
 {
     lock (this)
     {
         for (int x = 0; x < count; x++)
         {
             if (DojoMemberTypeArray[x].Equals(value))
             {
                 return(x);
             }
         }
         return(-1);
     }
 }
Exemplo n.º 14
0
        internal static bool _fill(DojoMemberType dojoMemberType)
        {
            // Clone item from cache.
            if (cacheEnabled)
            {
                object cachedObject = cacheFind(dojoMemberType.iD);
                if (cachedObject != null)
                {
                    ((DojoMemberType)cachedObject).CopyTo(dojoMemberType, true);
                    return(dojoMemberType.isSynced);
                }
            }

            StringBuilder query;
            Database      database;
            DbCommand     dbCommand;

            query = new StringBuilder("SELECT ");
            query.Append(string.Join(",", InnerJoinFields));
            query.Append(" FROM kitTessen_MemberTypes WHERE DojoMemberTypeID=");
            query.Append(dojoMemberType.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 DojoMemberTypeID '{0}'.",
                                                  dojoMemberType.iD)));
            }

            FillFromReader(dojoMemberType, r, 0, 1);

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

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

            return(true);
        }
Exemplo n.º 15
0
 public int Add(DojoMemberType value)
 {
     OnCollectionChanged(EventArgs.Empty);
     lock (this)
     {
         count++;
         // Resize the array if the count is greater than the length
         // of the array.
         if (count > DojoMemberTypeArray.GetUpperBound(0) + 1)
         {
             DojoMemberType[] tempDojoMemberTypeArray = new DojoMemberType[count * 2];
             Array.Copy(DojoMemberTypeArray, tempDojoMemberTypeArray, count - 1);
             DojoMemberTypeArray = tempDojoMemberTypeArray;
         }
         DojoMemberTypeArray[count - 1] = value;
     }
     return(count - 1);
 }
Exemplo n.º 16
0
 public void Insert(int index, DojoMemberType value)
 {
     OnCollectionChanged(EventArgs.Empty);
     lock (this)
     {
         count++;
         // Resize the array if the count is greater than the length
         // of the array.
         if (count > DojoMemberTypeArray.GetUpperBound(0) + 1)
         {
             DojoMemberType[] tempDojoMemberTypeArray = new DojoMemberType[count * 2];
             Array.Copy(DojoMemberTypeArray, tempDojoMemberTypeArray, count - 1);
             DojoMemberTypeArray = tempDojoMemberTypeArray;
         }
         for (int x = index + 1; x == count - 2; x++)
         {
             DojoMemberTypeArray[x] = DojoMemberTypeArray[x - 1];
         }
         DojoMemberTypeArray[index] = value;
     }
 }
Exemplo n.º 17
0
        internal static int _update(DojoMemberType dojoMemberType)
        {
            Database  database;
            DbCommand dbCommand;

            database = DatabaseFactory.CreateDatabase();

            dbCommand = database.GetSqlStringCommand("UPDATE kitTessen_MemberTypes SET Name=@Name," +
                                                     "Description=@Description," +
                                                     "OrderNum=@OrderNum WHERE DojoMemberTypeID=@DojoMemberTypeID;");

            fillParameters(database, dbCommand, dojoMemberType);
            database.AddInParameter(dbCommand, "DojoMemberTypeID", DbType.Int32, dojoMemberType.iD);
            // Abandon remaining updates if no rows have been updated by returning false immediately.
            if (database.ExecuteNonQuery(dbCommand) == 0)
            {
                return(-1);
            }

            // Store dojoMemberType in cache.
            if (cacheEnabled)
            {
                cacheStore(dojoMemberType);
            }
            // ************************* WARNING ****************************
            // Update operations must invalidate the cached collections.
            // Invalidation MUST invalidate any foreign cached collections that
            // with children objects this manager provides or else the foreign
            // caches retain invalidated and potentially corrupt data!
            // NOTE:
            // NitroCast only allows collection caching on objects that do not
            // have any children objects to minimize potential corruption.
            // ************************* WARNING ****************************

            invalidateCachedCollections();

            return(dojoMemberType.iD);
        }
Exemplo n.º 18
0
 /// <summary>
 /// Compares the object's ID to another object's ID.
 /// </summary>
 public int CompareTo(DojoMemberType dojoMemberType)
 {
     return(this.iD - dojoMemberType.iD);
 }
Exemplo n.º 19
0
        /// <summary>
        /// Compares the object's ID to another object's ID.
        /// </summary>
        int IComparable.CompareTo(object obj)
        {
            DojoMemberType dojoMemberType = (DojoMemberType)obj;

            return(this.iD - dojoMemberType.iD);
        }
Exemplo n.º 20
0
        public DojoMemberTypeCollection GetCollection(int topCount, string whereClause, string sortClause)
        {
            StringBuilder            query;
            Database                 database;
            DbCommand                dbCommand;
            IDataReader              r;
            DojoMemberTypeCollection dojoMemberTypeCollection;
            int hashcode;

            // Cache Handling

            hashcode = 0;

            if (cacheEnabled)
            {
                hashcode = topCount.GetHashCode() +
                           whereClause.GetHashCode() +
                           sortClause.GetHashCode() +
                           tableName.GetHashCode();

                DojoMemberTypeCollection collection = cacheFindCollection(hashcode);
                if (collection != null)
                {
                    return(collection);
                }
            }


            query = new StringBuilder("SELECT ");

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

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

            //
            // Remove trailing comma
            //
            query.Length--;
            query.Append(" FROM kitTessen_MemberTypes AS DojoMemberType");
            //
            // 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

            dojoMemberTypeCollection = new DojoMemberTypeCollection();

            while (r.Read())
            {
                DojoMemberType dojoMemberType = ParseFromReader(r, 0, 1);

                dojoMemberTypeCollection.Add(dojoMemberType);
            }

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

            if (cacheEnabled)
            {
                cacheStoreCollection(hashcode, dojoMemberTypeCollection);
            }

            return(dojoMemberTypeCollection);
        }
Exemplo n.º 21
0
 /// <summary>
 /// Deep copies the current DojoMemberType to another instance of DojoMemberType.
 /// This method does not provide isolated copies; use overriden method for this feature.
 /// </summary>
 /// <param name="DojoMemberType">The DojoMemberType to copy to.</param>
 public void CopyTo(DojoMemberType dojoMemberType)
 {
     CopyTo(dojoMemberType, false);
 }
Exemplo n.º 22
0
        private static void cacheStore(DojoMemberType dojoMemberType)
        {
            CacheManager cache = CacheFactory.GetCacheManager();

            cache.Add("kitTessen_MemberTypes_" + dojoMemberType.iD.ToString(), dojoMemberType);
        }
Exemplo n.º 23
0
 public bool Contains(DojoMemberType value)
 {
     return(IndexOf(value) != -1);
 }