private bool MonitorTriggerTable(ITriggerTables theObj)
        {
            SqlDataReader dataReader  = null;
            bool          bFound      = false;
            int           nKey        = -1;
            List <string> serialsList = new List <string>();

            try
            {
                Console.WriteLine(DateTime.Now.ToString() + " - Polling " + theObj.GetTableName() + "...");

                // ja - read from the generic trigger table (only unprocessed keys) ordered by the table key
                dataReader = SqlCmd.GetTrigerReader(theObj);

                // ja - only read first result
                while (dataReader.Read())
                {
                    bFound = true;

                    string sKey          = dataReader[theObj.GetKeyName()].ToString().Trim();
                    string sSerialNumber = dataReader[theObj.GetBasePlate()].ToString().Trim();

                    Console.WriteLine("Found Key in " + theObj.GetTableName() + ": Key = " + sKey + "...");
                    Console.WriteLine("Found Serial in " + theObj.GetTableName() + ": Serial = " + sSerialNumber + "...");

                    // ja - store serial numbers so they can be written after this reader is closed as I only maintain one DB connection at a time
                    if (!String.IsNullOrEmpty(sSerialNumber) && !sSerialNumber.Contains("End"))
                    {
                        serialsList.Add(sSerialNumber);
                    }

                    // ja - get the last key used
                    nKey = Convert.ToInt32(sKey);
                }

                // ja - store the last key...
                if (nKey > -1)
                {
                    theObj.LastKeyUsed = nKey;
                }

                dataReader.Close();

                foreach (string serial in serialsList)
                {
                    SqlCmd.FillJobsQueue(theObj, serial);
                }
            }
            catch (Exception ex)
            {
                dataReader.Close();
                Config.Log(ex.Message);
            }

            return(bFound);
        }
        private string GetTriggerTableSql(ITriggerTables TheClass)
        {
            string sSql = "Select ";

            sSql += TheClass.GetKeyName() + ", " + TheClass.GetBasePlate();
            sSql += " from " + TheClass.GetTableName();
            sSql += " where " + TheClass.GetKeyName() + " > " + TheClass.LastKeyUsed.ToString();
            sSql += " order by " + TheClass.GetKeyName();

            return(sSql);
        }