コード例 #1
0
        ///<summary>Inserts one TriageMetric into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(TriageMetric triageMetric, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO triagemetric (";

            if (!useExistingPK && isRandomKeys)
            {
                triageMetric.TriageMetricNum = ReplicationServers.GetKeyNoCache("triagemetric", "TriageMetricNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "TriageMetricNum,";
            }
            command += "CountBlueTasks,CountWhiteTasks,CountRedTasks,DateTimeOldestTriageTaskOrTaskNote,DateTimeOldestUrgentTaskOrTaskNote) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(triageMetric.TriageMetricNum) + ",";
            }
            command +=
                POut.Int(triageMetric.CountBlueTasks) + ","
                + POut.Int(triageMetric.CountWhiteTasks) + ","
                + POut.Int(triageMetric.CountRedTasks) + ","
                + POut.DateT(triageMetric.DateTimeOldestTriageTaskOrTaskNote) + ","
                + POut.DateT(triageMetric.DateTimeOldestUrgentTaskOrTaskNote) + ")";
            //DateTStamp can only be set by MySQL
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                triageMetric.TriageMetricNum = Db.NonQ(command, true, "TriageMetricNum", "triageMetric");
            }
            return(triageMetric.TriageMetricNum);
        }
コード例 #2
0
 ///<summary>Returns true if Update(TriageMetric,TriageMetric) 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(TriageMetric triageMetric, TriageMetric oldTriageMetric)
 {
     if (triageMetric.CountBlueTasks != oldTriageMetric.CountBlueTasks)
     {
         return(true);
     }
     if (triageMetric.CountWhiteTasks != oldTriageMetric.CountWhiteTasks)
     {
         return(true);
     }
     if (triageMetric.CountRedTasks != oldTriageMetric.CountRedTasks)
     {
         return(true);
     }
     if (triageMetric.DateTimeOldestTriageTaskOrTaskNote != oldTriageMetric.DateTimeOldestTriageTaskOrTaskNote)
     {
         return(true);
     }
     if (triageMetric.DateTimeOldestUrgentTaskOrTaskNote != oldTriageMetric.DateTimeOldestUrgentTaskOrTaskNote)
     {
         return(true);
     }
     //DateTStamp can only be set by MySQL
     return(false);
 }
コード例 #3
0
ファイル: TriageMetricCrud.cs プロジェクト: royedwards/DRDNet
 ///<summary>Inserts one TriageMetric into the database.  Returns the new priKey.</summary>
 public static long Insert(TriageMetric triageMetric)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         triageMetric.TriageMetricNum = DbHelper.GetNextOracleKey("triagemetric", "TriageMetricNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(triageMetric, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     triageMetric.TriageMetricNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(triageMetric, false));
     }
 }
コード例 #4
0
        ///<summary>Updates one TriageMetric 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(TriageMetric triageMetric, TriageMetric oldTriageMetric)
        {
            string command = "";

            if (triageMetric.CountBlueTasks != oldTriageMetric.CountBlueTasks)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CountBlueTasks = " + POut.Int(triageMetric.CountBlueTasks) + "";
            }
            if (triageMetric.CountWhiteTasks != oldTriageMetric.CountWhiteTasks)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CountWhiteTasks = " + POut.Int(triageMetric.CountWhiteTasks) + "";
            }
            if (triageMetric.CountRedTasks != oldTriageMetric.CountRedTasks)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CountRedTasks = " + POut.Int(triageMetric.CountRedTasks) + "";
            }
            if (triageMetric.DateTimeOldestTriageTaskOrTaskNote != oldTriageMetric.DateTimeOldestTriageTaskOrTaskNote)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateTimeOldestTriageTaskOrTaskNote = " + POut.DateT(triageMetric.DateTimeOldestTriageTaskOrTaskNote) + "";
            }
            if (triageMetric.DateTimeOldestUrgentTaskOrTaskNote != oldTriageMetric.DateTimeOldestUrgentTaskOrTaskNote)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateTimeOldestUrgentTaskOrTaskNote = " + POut.DateT(triageMetric.DateTimeOldestUrgentTaskOrTaskNote) + "";
            }
            //DateTStamp can only be set by MySQL
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE triagemetric SET " + command
                      + " WHERE TriageMetricNum = " + POut.Long(triageMetric.TriageMetricNum);
            Db.NonQ(command);
            return(true);
        }
コード例 #5
0
        ///<summary>Updates one TriageMetric in the database.</summary>
        public static void Update(TriageMetric triageMetric)
        {
            string command = "UPDATE triagemetric SET "
                             + "CountBlueTasks                    =  " + POut.Int(triageMetric.CountBlueTasks) + ", "
                             + "CountWhiteTasks                   =  " + POut.Int(triageMetric.CountWhiteTasks) + ", "
                             + "CountRedTasks                     =  " + POut.Int(triageMetric.CountRedTasks) + ", "
                             + "DateTimeOldestTriageTaskOrTaskNote=  " + POut.DateT(triageMetric.DateTimeOldestTriageTaskOrTaskNote) + ", "
                             + "DateTimeOldestUrgentTaskOrTaskNote=  " + POut.DateT(triageMetric.DateTimeOldestUrgentTaskOrTaskNote) + " "
                             //DateTStamp can only be set by MySQL
                             + "WHERE TriageMetricNum = " + POut.Long(triageMetric.TriageMetricNum);

            Db.NonQ(command);
        }
コード例 #6
0
ファイル: TriageMetricCrud.cs プロジェクト: royedwards/DRDNet
 ///<summary>Inserts one TriageMetric into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(TriageMetric triageMetric)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(triageMetric, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             triageMetric.TriageMetricNum = DbHelper.GetNextOracleKey("triagemetric", "TriageMetricNum");                  //Cacheless method
         }
         return(InsertNoCache(triageMetric, true));
     }
 }
コード例 #7
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <TriageMetric> TableToList(DataTable table)
        {
            List <TriageMetric> retVal = new List <TriageMetric>();
            TriageMetric        triageMetric;

            foreach (DataRow row in table.Rows)
            {
                triageMetric = new TriageMetric();
                triageMetric.TriageMetricNum = PIn.Long(row["TriageMetricNum"].ToString());
                triageMetric.CountBlueTasks  = PIn.Int(row["CountBlueTasks"].ToString());
                triageMetric.CountWhiteTasks = PIn.Int(row["CountWhiteTasks"].ToString());
                triageMetric.CountRedTasks   = PIn.Int(row["CountRedTasks"].ToString());
                triageMetric.DateTimeOldestTriageTaskOrTaskNote = PIn.DateT(row["DateTimeOldestTriageTaskOrTaskNote"].ToString());
                triageMetric.DateTimeOldestUrgentTaskOrTaskNote = PIn.DateT(row["DateTimeOldestUrgentTaskOrTaskNote"].ToString());
                triageMetric.DateTStamp = PIn.DateT(row["DateTStamp"].ToString());
                retVal.Add(triageMetric);
            }
            return(retVal);
        }
コード例 #8
0
 ///<summary>Inserts one TriageMetric into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(TriageMetric triageMetric)
 {
     return(InsertNoCache(triageMetric, false));
 }