Example #1
0
 ///<summary>Returns true if Update(ApptReminderSent,ApptReminderSent) 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(ApptReminderSent apptReminderSent, ApptReminderSent oldApptReminderSent)
 {
     if (apptReminderSent.ApptNum != oldApptReminderSent.ApptNum)
     {
         return(true);
     }
     if (apptReminderSent.ApptDateTime != oldApptReminderSent.ApptDateTime)
     {
         return(true);
     }
     if (apptReminderSent.DateTimeSent != oldApptReminderSent.DateTimeSent)
     {
         return(true);
     }
     if (apptReminderSent.TSPrior != oldApptReminderSent.TSPrior)
     {
         return(true);
     }
     if (apptReminderSent.ApptReminderRuleNum != oldApptReminderSent.ApptReminderRuleNum)
     {
         return(true);
     }
     if (apptReminderSent.IsSmsSent != oldApptReminderSent.IsSmsSent)
     {
         return(true);
     }
     if (apptReminderSent.IsEmailSent != oldApptReminderSent.IsEmailSent)
     {
         return(true);
     }
     return(false);
 }
Example #2
0
        ///<summary>Inserts one ApptReminderSent into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(ApptReminderSent apptReminderSent, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                apptReminderSent.ApptReminderSentNum = ReplicationServers.GetKey("apptremindersent", "ApptReminderSentNum");
            }
            string command = "INSERT INTO apptremindersent (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "ApptReminderSentNum,";
            }
            command += "ApptNum,ApptDateTime,DateTimeSent,TSPrior,ApptReminderRuleNum,IsSmsSent,IsEmailSent) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(apptReminderSent.ApptReminderSentNum) + ",";
            }
            command +=
                POut.Long(apptReminderSent.ApptNum) + ","
                + POut.DateT(apptReminderSent.ApptDateTime) + ","
                + POut.DateT(apptReminderSent.DateTimeSent) + ","
                + "'" + POut.Long(apptReminderSent.TSPrior.Ticks) + "',"
                + POut.Long(apptReminderSent.ApptReminderRuleNum) + ","
                + POut.Bool(apptReminderSent.IsSmsSent) + ","
                + POut.Bool(apptReminderSent.IsEmailSent) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                apptReminderSent.ApptReminderSentNum = Db.NonQ(command, true, "ApptReminderSentNum", "apptReminderSent");
            }
            return(apptReminderSent.ApptReminderSentNum);
        }
Example #3
0
 ///<summary>Inserts one ApptReminderSent into the database.  Returns the new priKey.</summary>
 public static long Insert(ApptReminderSent apptReminderSent)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         apptReminderSent.ApptReminderSentNum = DbHelper.GetNextOracleKey("apptremindersent", "ApptReminderSentNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(apptReminderSent, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     apptReminderSent.ApptReminderSentNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(apptReminderSent, false));
     }
 }
Example #4
0
        ///<summary>Updates one ApptReminderSent in the database.</summary>
        public static void Update(ApptReminderSent apptReminderSent)
        {
            string command = "UPDATE apptremindersent SET "
                             + "ApptNum            =  " + POut.Long(apptReminderSent.ApptNum) + ", "
                             + "ApptDateTime       =  " + POut.DateT(apptReminderSent.ApptDateTime) + ", "
                             + "DateTimeSent       =  " + POut.DateT(apptReminderSent.DateTimeSent) + ", "
                             + "TSPrior            =  " + POut.Long(apptReminderSent.TSPrior.Ticks) + ", "
                             + "ApptReminderRuleNum=  " + POut.Long(apptReminderSent.ApptReminderRuleNum) + ", "
                             + "IsSmsSent          =  " + POut.Bool(apptReminderSent.IsSmsSent) + ", "
                             + "IsEmailSent        =  " + POut.Bool(apptReminderSent.IsEmailSent) + " "
                             + "WHERE ApptReminderSentNum = " + POut.Long(apptReminderSent.ApptReminderSentNum);

            Db.NonQ(command);
        }
Example #5
0
 ///<summary>Inserts one ApptReminderSent into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(ApptReminderSent apptReminderSent)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(apptReminderSent, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             apptReminderSent.ApptReminderSentNum = DbHelper.GetNextOracleKey("apptremindersent", "ApptReminderSentNum");                  //Cacheless method
         }
         return(InsertNoCache(apptReminderSent, true));
     }
 }
Example #6
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <ApptReminderSent> TableToList(DataTable table)
        {
            List <ApptReminderSent> retVal = new List <ApptReminderSent>();
            ApptReminderSent        apptReminderSent;

            foreach (DataRow row in table.Rows)
            {
                apptReminderSent = new ApptReminderSent();
                apptReminderSent.ApptReminderSentNum = PIn.Long(row["ApptReminderSentNum"].ToString());
                apptReminderSent.ApptNum             = PIn.Long(row["ApptNum"].ToString());
                apptReminderSent.ApptDateTime        = PIn.DateT(row["ApptDateTime"].ToString());
                apptReminderSent.DateTimeSent        = PIn.DateT(row["DateTimeSent"].ToString());
                apptReminderSent.TSPrior             = TimeSpan.FromTicks(PIn.Long(row["TSPrior"].ToString()));
                apptReminderSent.ApptReminderRuleNum = PIn.Long(row["ApptReminderRuleNum"].ToString());
                apptReminderSent.IsSmsSent           = PIn.Bool(row["IsSmsSent"].ToString());
                apptReminderSent.IsEmailSent         = PIn.Bool(row["IsEmailSent"].ToString());
                retVal.Add(apptReminderSent);
            }
            return(retVal);
        }
Example #7
0
        ///<summary>Updates one ApptReminderSent 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(ApptReminderSent apptReminderSent, ApptReminderSent oldApptReminderSent)
        {
            string command = "";

            if (apptReminderSent.ApptNum != oldApptReminderSent.ApptNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ApptNum = " + POut.Long(apptReminderSent.ApptNum) + "";
            }
            if (apptReminderSent.ApptDateTime != oldApptReminderSent.ApptDateTime)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ApptDateTime = " + POut.DateT(apptReminderSent.ApptDateTime) + "";
            }
            if (apptReminderSent.DateTimeSent != oldApptReminderSent.DateTimeSent)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateTimeSent = " + POut.DateT(apptReminderSent.DateTimeSent) + "";
            }
            if (apptReminderSent.TSPrior != oldApptReminderSent.TSPrior)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "TSPrior = '" + POut.Long(apptReminderSent.TSPrior.Ticks) + "'";
            }
            if (apptReminderSent.ApptReminderRuleNum != oldApptReminderSent.ApptReminderRuleNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ApptReminderRuleNum = " + POut.Long(apptReminderSent.ApptReminderRuleNum) + "";
            }
            if (apptReminderSent.IsSmsSent != oldApptReminderSent.IsSmsSent)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsSmsSent = " + POut.Bool(apptReminderSent.IsSmsSent) + "";
            }
            if (apptReminderSent.IsEmailSent != oldApptReminderSent.IsEmailSent)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsEmailSent = " + POut.Bool(apptReminderSent.IsEmailSent) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE apptremindersent SET " + command
                      + " WHERE ApptReminderSentNum = " + POut.Long(apptReminderSent.ApptReminderSentNum);
            Db.NonQ(command);
            return(true);
        }
Example #8
0
 ///<summary>Inserts one ApptReminderSent into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(ApptReminderSent apptReminderSent)
 {
     return(InsertNoCache(apptReminderSent, false));
 }
Example #9
0
 ///<summary>Inserts many ApptReminderSents into the database.  Provides option to use the existing priKey.</summary>
 public static void InsertMany(List <ApptReminderSent> listApptReminderSents, bool useExistingPK)
 {
     if (!useExistingPK && PrefC.RandomKeys)
     {
         foreach (ApptReminderSent apptReminderSent in listApptReminderSents)
         {
             Insert(apptReminderSent);
         }
     }
     else
     {
         StringBuilder sbCommands = null;
         int           index      = 0;
         int           countRows  = 0;
         while (index < listApptReminderSents.Count)
         {
             ApptReminderSent apptReminderSent = listApptReminderSents[index];
             StringBuilder    sbRow            = new StringBuilder("(");
             bool             hasComma         = false;
             if (sbCommands == null)
             {
                 sbCommands = new StringBuilder();
                 sbCommands.Append("INSERT INTO apptremindersent (");
                 if (useExistingPK)
                 {
                     sbCommands.Append("ApptReminderSentNum,");
                 }
                 sbCommands.Append("ApptNum,ApptDateTime,DateTimeSent,TSPrior,ApptReminderRuleNum,IsSmsSent,IsEmailSent) VALUES ");
                 countRows = 0;
             }
             else
             {
                 hasComma = true;
             }
             if (useExistingPK)
             {
                 sbRow.Append(POut.Long(apptReminderSent.ApptReminderSentNum)); sbRow.Append(",");
             }
             sbRow.Append(POut.Long(apptReminderSent.ApptNum)); sbRow.Append(",");
             sbRow.Append(POut.DateT(apptReminderSent.ApptDateTime)); sbRow.Append(",");
             sbRow.Append(POut.DateT(apptReminderSent.DateTimeSent)); sbRow.Append(",");
             sbRow.Append("'" + POut.Long(apptReminderSent.TSPrior.Ticks) + "'"); sbRow.Append(",");
             sbRow.Append(POut.Long(apptReminderSent.ApptReminderRuleNum)); sbRow.Append(",");
             sbRow.Append(POut.Bool(apptReminderSent.IsSmsSent)); sbRow.Append(",");
             sbRow.Append(POut.Bool(apptReminderSent.IsEmailSent)); 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 == listApptReminderSents.Count - 1)
                 {
                     Db.NonQ(sbCommands.ToString());
                 }
                 index++;
             }
         }
     }
 }