///<summary>Inserts one BugSubmissionHash into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(BugSubmissionHash bugSubmissionHash, bool useExistingPK)
        {
            string command = "INSERT INTO bugsubmissionhash (";

            if (useExistingPK)
            {
                command += "BugSubmissionHashNum,";
            }
            command += "FullHash,PartialHash,BugId,DateTimeEntry) VALUES(";
            if (useExistingPK)
            {
                command += POut.Long(bugSubmissionHash.BugSubmissionHashNum) + ",";
            }
            command +=
                "'" + POut.String(bugSubmissionHash.FullHash) + "',"
                + "'" + POut.String(bugSubmissionHash.PartialHash) + "',"
                + POut.Long(bugSubmissionHash.BugId) + ","
                //DateTimeModify can only be set by MySQL
                + DbHelper.Now() + ")";
            if (useExistingPK)
            {
                Db.NonQ(command);
            }
            else
            {
                bugSubmissionHash.BugSubmissionHashNum = Db.NonQ(command, true, "BugSubmissionHashNum", "bugSubmissionHash");
            }
            return(bugSubmissionHash.BugSubmissionHashNum);
        }
Esempio n. 2
0
        ///<summary>Returns true if given hash passes filter validation.</summary>
        private bool PassesHashFilter(BugSubmissionHash hash)
        {
            bool isHashNumFilterPassed  = (textHashNum.Text.IsNullOrEmpty() || hash.BugSubmissionHashNum.ToString().Contains(textHashNum.Text));
            bool isFullHashFilterPassed = (textFullHash.Text.IsNullOrEmpty() || hash.FullHash.ToLower().Contains(textFullHash.Text.ToLower()));
            bool isPartHashFilterPassed = (textPartHash.Text.IsNullOrEmpty() || hash.FullHash.ToLower().Contains(textPartHash.Text.ToLower()));
            bool isBugIdFilterPassed    = (textBugIds.Text.IsNullOrEmpty() || hash.BugId.ToString().Contains(textBugIds.Text));

            return(isHashNumFilterPassed && isFullHashFilterPassed && isPartHashFilterPassed && isBugIdFilterPassed);
        }
        ///<summary>Inserts many BugSubmissionHashs into the database.  Provides option to use the existing priKey.</summary>
        public static void InsertMany(List <BugSubmissionHash> listBugSubmissionHashs, bool useExistingPK)
        {
            StringBuilder sbCommands = null;
            int           index      = 0;
            int           countRows  = 0;

            while (index < listBugSubmissionHashs.Count)
            {
                BugSubmissionHash bugSubmissionHash = listBugSubmissionHashs[index];
                StringBuilder     sbRow             = new StringBuilder("(");
                bool hasComma = false;
                if (sbCommands == null)
                {
                    sbCommands = new StringBuilder();
                    sbCommands.Append("INSERT INTO bugsubmissionhash (");
                    if (useExistingPK)
                    {
                        sbCommands.Append("BugSubmissionHashNum,");
                    }
                    sbCommands.Append("FullHash,PartialHash,BugId,DateTimeEntry) VALUES ");
                    countRows = 0;
                }
                else
                {
                    hasComma = true;
                }
                if (useExistingPK)
                {
                    sbRow.Append(POut.Long(bugSubmissionHash.BugSubmissionHashNum)); sbRow.Append(",");
                }
                sbRow.Append("'" + POut.String(bugSubmissionHash.FullHash) + "'"); sbRow.Append(",");
                sbRow.Append("'" + POut.String(bugSubmissionHash.PartialHash) + "'"); sbRow.Append(",");
                sbRow.Append(POut.Long(bugSubmissionHash.BugId)); sbRow.Append(",");
                //DateTimeModify can only be set by MySQL
                sbRow.Append(DbHelper.Now()); sbRow.Append(")");
                if (sbCommands.Length + sbRow.Length + 1 > TableBase.MaxAllowedPacketCount && countRows > 0)
                {
                    Db.NonQ(sbCommands.ToString());
                    sbCommands = null;
                }
                else
                {
                    if (hasComma)
                    {
                        sbCommands.Append(",");
                    }
                    sbCommands.Append(sbRow.ToString());
                    countRows++;
                    if (index == listBugSubmissionHashs.Count - 1)
                    {
                        Db.NonQ(sbCommands.ToString());
                    }
                    index++;
                }
            }
        }
        ///<summary>Updates one BugSubmissionHash in the database.</summary>
        public static void Update(BugSubmissionHash bugSubmissionHash)
        {
            string command = "UPDATE bugsubmissionhash SET "
                             + "FullHash            = '" + POut.String(bugSubmissionHash.FullHash) + "', "
                             + "PartialHash         = '" + POut.String(bugSubmissionHash.PartialHash) + "', "
                             + "BugId               =  " + POut.Long(bugSubmissionHash.BugId) + " "
                             //DateTimeModify can only be set by MySQL
                             //DateTimeEntry not allowed to change
                             + "WHERE BugSubmissionHashNum = " + POut.Long(bugSubmissionHash.BugSubmissionHashNum);

            Db.NonQ(command);
        }
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <BugSubmissionHash> TableToList(DataTable table)
        {
            List <BugSubmissionHash> retVal = new List <BugSubmissionHash>();
            BugSubmissionHash        bugSubmissionHash;

            foreach (DataRow row in table.Rows)
            {
                bugSubmissionHash = new BugSubmissionHash();
                bugSubmissionHash.BugSubmissionHashNum = PIn.Long(row["BugSubmissionHashNum"].ToString());
                bugSubmissionHash.FullHash             = PIn.String(row["FullHash"].ToString());
                bugSubmissionHash.PartialHash          = PIn.String(row["PartialHash"].ToString());
                bugSubmissionHash.BugId          = PIn.Long(row["BugId"].ToString());
                bugSubmissionHash.DateTimeModify = PIn.DateT(row["DateTimeModify"].ToString());
                bugSubmissionHash.DateTimeEntry  = PIn.DateT(row["DateTimeEntry"].ToString());
                retVal.Add(bugSubmissionHash);
            }
            return(retVal);
        }
 ///<summary>Returns true if Update(BugSubmissionHash,BugSubmissionHash) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(BugSubmissionHash bugSubmissionHash, BugSubmissionHash oldBugSubmissionHash)
 {
     if (bugSubmissionHash.FullHash != oldBugSubmissionHash.FullHash)
     {
         return(true);
     }
     if (bugSubmissionHash.PartialHash != oldBugSubmissionHash.PartialHash)
     {
         return(true);
     }
     if (bugSubmissionHash.BugId != oldBugSubmissionHash.BugId)
     {
         return(true);
     }
     //DateTimeModify can only be set by MySQL
     //DateTimeEntry not allowed to change
     return(false);
 }
        ///<summary>Updates one BugSubmissionHash in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
        public static bool Update(BugSubmissionHash bugSubmissionHash, BugSubmissionHash oldBugSubmissionHash)
        {
            string command = "";

            if (bugSubmissionHash.FullHash != oldBugSubmissionHash.FullHash)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FullHash = '" + POut.String(bugSubmissionHash.FullHash) + "'";
            }
            if (bugSubmissionHash.PartialHash != oldBugSubmissionHash.PartialHash)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PartialHash = '" + POut.String(bugSubmissionHash.PartialHash) + "'";
            }
            if (bugSubmissionHash.BugId != oldBugSubmissionHash.BugId)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "BugId = " + POut.Long(bugSubmissionHash.BugId) + "";
            }
            //DateTimeModify can only be set by MySQL
            //DateTimeEntry not allowed to change
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE bugsubmissionhash SET " + command
                      + " WHERE BugSubmissionHashNum = " + POut.Long(bugSubmissionHash.BugSubmissionHashNum);
            Db.NonQ(command);
            return(true);
        }
 ///<summary>Inserts one BugSubmissionHash into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(BugSubmissionHash bugSubmissionHash)
 {
     return(InsertNoCache(bugSubmissionHash, false));
 }