Пример #1
0
        /// <summary>
        /// Duplicates DojoTestListStatus object into a database; may or may not be the same database
        /// as the parent object.
        /// </summary>
        /// <returns> A new DojoTestListStatus object reflecting the replicated DojoTestListStatus object.</returns>
        public DojoTestListStatus Duplicate()
        {
            DojoTestListStatus clonedDojoTestListStatus = this.Clone();

            // Insert must be called after children are replicated!
            clonedDojoTestListStatus.iD       = DojoTestListStatusManager._insert(clonedDojoTestListStatus);
            clonedDojoTestListStatus.isSynced = true;
            return(clonedDojoTestListStatus);
        }
Пример #2
0
        /// <summary>
        /// Ensures that the object's fields and children are
        /// pre-loaded before any updates or reads.
        /// </summary>
        public void EnsurePreLoad()
        {
            if (!isPlaceHolder)
            {
                return;
            }

            DojoTestListStatusManager._fill(this);
            isPlaceHolder = false;
        }
Пример #3
0
        /// <summary>
        /// Saves the DojoTestListStatus object state to the database.
        /// </summary>
        public int Save()
        {
            if (isSynced)
            {
                return(iD);
            }

            if (iD == -1)
            {
                throw (new Exception("Invalid record; cannot be saved."));
            }
            if (iD == 0)
            {
                iD = DojoTestListStatusManager._insert(this);
            }
            else
            {
                DojoTestListStatusManager._update(this);
            }
            isSynced = iD != -1;
            return(iD);
        }
Пример #4
0
        public DojoTestListStatusCollection GetCollection(int topCount, string whereClause, string sortClause, params DojoTestListStatusFlags[] optionFlags)
        {
            StringBuilder query;
            Database      database;
            DbCommand     dbCommand;
            IDataReader   r;
            DojoTestListStatusCollection dojoTestListStatusCollection;

            int innerJoinOffset;

            query = new StringBuilder("SELECT ");

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

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

            innerJoinOffset = InnerJoinFields.GetUpperBound(0) + 1;
            int onFinalizedOffset            = -1;
            int onFinalizedOnFinalizedOffset = -1;
            int onFinalizedOnCompletedOffset = -1;
            int onCompletedOffset            = -1;
            int onCompletedOnFinalizedOffset = -1;
            int onCompletedOnCompletedOffset = -1;

            //
            // Append Option Flag Fields
            //
            if (optionFlags != null)
            {
                for (int x = 0; x < optionFlags.Length; x++)
                {
                    switch (optionFlags[x])
                    {
                    case DojoTestListStatusFlags.OnFinalized:
                        for (int i = 0; i <= DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0); i++)
                        {
                            query.Append("OnFinalized.");
                            query.Append(DojoTestListStatusManager.InnerJoinFields[i]);
                            query.Append(",");
                        }
                        onFinalizedOffset = innerJoinOffset;
                        innerJoinOffset   = onFinalizedOffset + DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0) + 1;
                        break;

                    case DojoTestListStatusFlags.OnFinalizedOnFinalized:
                        for (int i = 0; i <= DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0); i++)
                        {
                            query.Append("OnFinalized_OnFinalized.");
                            query.Append(DojoTestListStatusManager.InnerJoinFields[i]);
                            query.Append(",");
                        }
                        onFinalizedOnFinalizedOffset = innerJoinOffset;
                        innerJoinOffset = onFinalizedOnFinalizedOffset + DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0) + 1;
                        break;

                    case DojoTestListStatusFlags.OnFinalizedOnCompleted:
                        for (int i = 0; i <= DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0); i++)
                        {
                            query.Append("OnFinalized_OnCompleted.");
                            query.Append(DojoTestListStatusManager.InnerJoinFields[i]);
                            query.Append(",");
                        }
                        onFinalizedOnCompletedOffset = innerJoinOffset;
                        innerJoinOffset = onFinalizedOnCompletedOffset + DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0) + 1;
                        break;

                    case DojoTestListStatusFlags.OnCompleted:
                        for (int i = 0; i <= DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0); i++)
                        {
                            query.Append("OnCompleted.");
                            query.Append(DojoTestListStatusManager.InnerJoinFields[i]);
                            query.Append(",");
                        }
                        onCompletedOffset = innerJoinOffset;
                        innerJoinOffset   = onCompletedOffset + DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0) + 1;
                        break;

                    case DojoTestListStatusFlags.OnCompletedOnFinalized:
                        for (int i = 0; i <= DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0); i++)
                        {
                            query.Append("OnCompleted_OnFinalized.");
                            query.Append(DojoTestListStatusManager.InnerJoinFields[i]);
                            query.Append(",");
                        }
                        onCompletedOnFinalizedOffset = innerJoinOffset;
                        innerJoinOffset = onCompletedOnFinalizedOffset + DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0) + 1;
                        break;

                    case DojoTestListStatusFlags.OnCompletedOnCompleted:
                        for (int i = 0; i <= DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0); i++)
                        {
                            query.Append("OnCompleted_OnCompleted.");
                            query.Append(DojoTestListStatusManager.InnerJoinFields[i]);
                            query.Append(",");
                        }
                        onCompletedOnCompletedOffset = innerJoinOffset;
                        innerJoinOffset = onCompletedOnCompletedOffset + DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0) + 1;
                        break;
                    }
                }
            }

            //
            // Remove trailing comma
            //
            query.Length--;
            if (optionFlags != null)
            {
                query.Append(" FROM ");

                //
                // Start INNER JOIN expressions
                //
                for (int x = 0; x < optionFlags.Length; x++)
                {
                    query.Append("(");
                }

                query.Append("kitTessen_DojoTestListStatuses AS DojoTestListStatus");
            }
            else
            {
                query.Append(" FROM kitTessen_DojoTestListStatuses AS DojoTestListStatus");
            }
            //
            // Finish INNER JOIN expressions
            //
            if (optionFlags != null)
            {
                for (int x = 0; x < optionFlags.Length; x++)
                {
                    switch (optionFlags[x])
                    {
                    case DojoTestListStatusFlags.OnFinalized:
                        query.Append(" LEFT JOIN kitTessen_DojoTestListStatuses AS OnFinalized ON DojoTestListStatus.OnFinalizedID = OnFinalized.DojoTestListStatusID)");
                        break;

                    case DojoTestListStatusFlags.OnFinalizedOnFinalized:
                        query.Append(" LEFT JOIN kitTessen_DojoTestListStatuses AS OnFinalized_OnFinalized ON OnFinalized.OnFinalizedID = OnFinalized_OnFinalized.DojoTestListStatusID)");
                        break;

                    case DojoTestListStatusFlags.OnFinalizedOnCompleted:
                        query.Append(" LEFT JOIN kitTessen_DojoTestListStatuses AS OnFinalized_OnCompleted ON OnFinalized.OnCompletedID = OnFinalized_OnCompleted.DojoTestListStatusID)");
                        break;

                    case DojoTestListStatusFlags.OnCompleted:
                        query.Append(" LEFT JOIN kitTessen_DojoTestListStatuses AS OnCompleted ON DojoTestListStatus.OnCompletedID = OnCompleted.DojoTestListStatusID)");
                        break;

                    case DojoTestListStatusFlags.OnCompletedOnFinalized:
                        query.Append(" LEFT JOIN kitTessen_DojoTestListStatuses AS OnCompleted_OnFinalized ON OnCompleted.OnFinalizedID = OnCompleted_OnFinalized.DojoTestListStatusID)");
                        break;

                    case DojoTestListStatusFlags.OnCompletedOnCompleted:
                        query.Append(" LEFT JOIN kitTessen_DojoTestListStatuses AS OnCompleted_OnCompleted ON OnCompleted.OnCompletedID = OnCompleted_OnCompleted.DojoTestListStatusID)");
                        break;
                    }
                }
            }

            //
            // 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

            dojoTestListStatusCollection = new DojoTestListStatusCollection();

            while (r.Read())
            {
                DojoTestListStatus dojoTestListStatus = ParseFromReader(r, 0, 1);

                // Fill OnFinalized
                if (onFinalizedOffset != -1 && !r.IsDBNull(onFinalizedOffset))
                {
                    DojoTestListStatusManager.FillFromReader(dojoTestListStatus.onFinalized, r, onFinalizedOffset, onFinalizedOffset + 1);

                    // Fill
                    if (onFinalizedOnFinalizedOffset != -1 && !r.IsDBNull(onFinalizedOnFinalizedOffset))
                    {
                        DojoTestListStatusManager.FillFromReader(dojoTestListStatus.onFinalized.OnFinalized, r, onFinalizedOnFinalizedOffset, onFinalizedOnFinalizedOffset + 1);
                    }

                    // Fill
                    if (onFinalizedOnCompletedOffset != -1 && !r.IsDBNull(onFinalizedOnCompletedOffset))
                    {
                        DojoTestListStatusManager.FillFromReader(dojoTestListStatus.onFinalized.OnCompleted, r, onFinalizedOnCompletedOffset, onFinalizedOnCompletedOffset + 1);
                    }
                }

                // Fill OnCompleted
                if (onCompletedOffset != -1 && !r.IsDBNull(onCompletedOffset))
                {
                    DojoTestListStatusManager.FillFromReader(dojoTestListStatus.onCompleted, r, onCompletedOffset, onCompletedOffset + 1);

                    // Fill
                    if (onCompletedOnFinalizedOffset != -1 && !r.IsDBNull(onCompletedOnFinalizedOffset))
                    {
                        DojoTestListStatusManager.FillFromReader(dojoTestListStatus.onCompleted.OnFinalized, r, onCompletedOnFinalizedOffset, onCompletedOnFinalizedOffset + 1);
                    }

                    // Fill
                    if (onCompletedOnCompletedOffset != -1 && !r.IsDBNull(onCompletedOnCompletedOffset))
                    {
                        DojoTestListStatusManager.FillFromReader(dojoTestListStatus.onCompleted.OnCompleted, r, onCompletedOnCompletedOffset, onCompletedOnCompletedOffset + 1);
                    }
                }

                dojoTestListStatusCollection.Add(dojoTestListStatus);
            }

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

            return(dojoTestListStatusCollection);
        }
Пример #5
0
 /// <summary>
 /// Overwrites and existing DojoTestListStatus object in the database.
 /// </summary>
 public void Overwrite(int id)
 {
     iD = id;
     DojoTestListStatusManager._update(this);
     isSynced = true;
 }
Пример #6
0
 public void Delete()
 {
     DojoTestListStatusManager._delete(this.iD);
     this.iD  = 0;
     isSynced = false;
 }
Пример #7
0
 public DojoTestListStatus(int id)
 {
     this.iD  = id;
     isSynced = DojoTestListStatusManager._fill(this);
 }