Esempio n. 1
0
 ///<summary>Returns true if Update(DbmLog,DbmLog) 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(DbmLog dbmLog, DbmLog oldDbmLog)
 {
     if (dbmLog.UserNum != oldDbmLog.UserNum)
     {
         return(true);
     }
     if (dbmLog.FKey != oldDbmLog.FKey)
     {
         return(true);
     }
     if (dbmLog.FKeyType != oldDbmLog.FKeyType)
     {
         return(true);
     }
     if (dbmLog.ActionType != oldDbmLog.ActionType)
     {
         return(true);
     }
     //DateTimeEntry not allowed to change
     if (dbmLog.MethodName != oldDbmLog.MethodName)
     {
         return(true);
     }
     if (dbmLog.LogText != oldDbmLog.LogText)
     {
         return(true);
     }
     return(false);
 }
Esempio n. 2
0
        ///<summary>Inserts one DbmLog into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(DbmLog dbmLog, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO dbmlog (";

            if (!useExistingPK && isRandomKeys)
            {
                dbmLog.DbmLogNum = ReplicationServers.GetKeyNoCache("dbmlog", "DbmLogNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "DbmLogNum,";
            }
            command += "UserNum,FKey,FKeyType,ActionType,DateTimeEntry,MethodName,LogText) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(dbmLog.DbmLogNum) + ",";
            }
            command +=
                POut.Long(dbmLog.UserNum) + ","
                + POut.Long(dbmLog.FKey) + ","
                + POut.Int((int)dbmLog.FKeyType) + ","
                + POut.Int((int)dbmLog.ActionType) + ","
                + DbHelper.Now() + ","
                + "'" + POut.String(dbmLog.MethodName) + "',"
                + DbHelper.ParamChar + "paramLogText)";
            if (dbmLog.LogText == null)
            {
                dbmLog.LogText = "";
            }
            OdSqlParameter paramLogText = new OdSqlParameter("paramLogText", OdDbType.Text, POut.StringParam(dbmLog.LogText));

            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command, paramLogText);
            }
            else
            {
                dbmLog.DbmLogNum = Db.NonQ(command, true, "DbmLogNum", "dbmLog", paramLogText);
            }
            return(dbmLog.DbmLogNum);
        }
Esempio n. 3
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <DbmLog> TableToList(DataTable table)
        {
            List <DbmLog> retVal = new List <DbmLog>();
            DbmLog        dbmLog;

            foreach (DataRow row in table.Rows)
            {
                dbmLog               = new DbmLog();
                dbmLog.DbmLogNum     = PIn.Long(row["DbmLogNum"].ToString());
                dbmLog.UserNum       = PIn.Long(row["UserNum"].ToString());
                dbmLog.FKey          = PIn.Long(row["FKey"].ToString());
                dbmLog.FKeyType      = (OpenDentBusiness.DbmLogFKeyType)PIn.Int(row["FKeyType"].ToString());
                dbmLog.ActionType    = (OpenDentBusiness.DbmLogActionType)PIn.Int(row["ActionType"].ToString());
                dbmLog.DateTimeEntry = PIn.DateT(row["DateTimeEntry"].ToString());
                dbmLog.MethodName    = PIn.String(row["MethodName"].ToString());
                dbmLog.LogText       = PIn.String(row["LogText"].ToString());
                retVal.Add(dbmLog);
            }
            return(retVal);
        }
Esempio n. 4
0
        ///<summary>Updates one DbmLog in the database.</summary>
        public static void Update(DbmLog dbmLog)
        {
            string command = "UPDATE dbmlog SET "
                             + "UserNum      =  " + POut.Long(dbmLog.UserNum) + ", "
                             + "FKey         =  " + POut.Long(dbmLog.FKey) + ", "
                             + "FKeyType     =  " + POut.Int((int)dbmLog.FKeyType) + ", "
                             + "ActionType   =  " + POut.Int((int)dbmLog.ActionType) + ", "
                             //DateTimeEntry not allowed to change
                             + "MethodName   = '" + POut.String(dbmLog.MethodName) + "', "
                             + "LogText      =  " + DbHelper.ParamChar + "paramLogText "
                             + "WHERE DbmLogNum = " + POut.Long(dbmLog.DbmLogNum);

            if (dbmLog.LogText == null)
            {
                dbmLog.LogText = "";
            }
            OdSqlParameter paramLogText = new OdSqlParameter("paramLogText", OdDbType.Text, POut.StringParam(dbmLog.LogText));

            Db.NonQ(command, paramLogText);
        }
Esempio n. 5
0
        ///<summary>Updates one DbmLog 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(DbmLog dbmLog, DbmLog oldDbmLog)
        {
            string command = "";

            if (dbmLog.UserNum != oldDbmLog.UserNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "UserNum = " + POut.Long(dbmLog.UserNum) + "";
            }
            if (dbmLog.FKey != oldDbmLog.FKey)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FKey = " + POut.Long(dbmLog.FKey) + "";
            }
            if (dbmLog.FKeyType != oldDbmLog.FKeyType)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FKeyType = " + POut.Int((int)dbmLog.FKeyType) + "";
            }
            if (dbmLog.ActionType != oldDbmLog.ActionType)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ActionType = " + POut.Int((int)dbmLog.ActionType) + "";
            }
            //DateTimeEntry not allowed to change
            if (dbmLog.MethodName != oldDbmLog.MethodName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "MethodName = '" + POut.String(dbmLog.MethodName) + "'";
            }
            if (dbmLog.LogText != oldDbmLog.LogText)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "LogText = " + DbHelper.ParamChar + "paramLogText";
            }
            if (command == "")
            {
                return(false);
            }
            if (dbmLog.LogText == null)
            {
                dbmLog.LogText = "";
            }
            OdSqlParameter paramLogText = new OdSqlParameter("paramLogText", OdDbType.Text, POut.StringParam(dbmLog.LogText));

            command = "UPDATE dbmlog SET " + command
                      + " WHERE DbmLogNum = " + POut.Long(dbmLog.DbmLogNum);
            Db.NonQ(command, paramLogText);
            return(true);
        }
Esempio n. 6
0
 ///<summary>Inserts one DbmLog into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(DbmLog dbmLog)
 {
     return(InsertNoCache(dbmLog, false));
 }
Esempio n. 7
0
 ///<summary>Inserts many DbmLogs into the database.  Provides option to use the existing priKey.</summary>
 public static void InsertMany(List <DbmLog> listDbmLogs, bool useExistingPK)
 {
     if (!useExistingPK && PrefC.RandomKeys)
     {
         foreach (DbmLog dbmLog in listDbmLogs)
         {
             Insert(dbmLog);
         }
     }
     else
     {
         StringBuilder sbCommands = null;
         int           index      = 0;
         int           countRows  = 0;
         while (index < listDbmLogs.Count)
         {
             DbmLog        dbmLog   = listDbmLogs[index];
             StringBuilder sbRow    = new StringBuilder("(");
             bool          hasComma = false;
             if (sbCommands == null)
             {
                 sbCommands = new StringBuilder();
                 sbCommands.Append("INSERT INTO dbmlog (");
                 if (useExistingPK)
                 {
                     sbCommands.Append("DbmLogNum,");
                 }
                 sbCommands.Append("UserNum,FKey,FKeyType,ActionType,DateTimeEntry,MethodName,LogText) VALUES ");
                 countRows = 0;
             }
             else
             {
                 hasComma = true;
             }
             if (useExistingPK)
             {
                 sbRow.Append(POut.Long(dbmLog.DbmLogNum)); sbRow.Append(",");
             }
             sbRow.Append(POut.Long(dbmLog.UserNum)); sbRow.Append(",");
             sbRow.Append(POut.Long(dbmLog.FKey)); sbRow.Append(",");
             sbRow.Append(POut.Int((int)dbmLog.FKeyType)); sbRow.Append(",");
             sbRow.Append(POut.Int((int)dbmLog.ActionType)); sbRow.Append(",");
             sbRow.Append(DbHelper.Now()); sbRow.Append(",");
             sbRow.Append("'" + POut.String(dbmLog.MethodName) + "'"); sbRow.Append(",");
             sbRow.Append("'" + POut.String(dbmLog.LogText) + "'"); 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 == listDbmLogs.Count - 1)
                 {
                     Db.NonQ(sbCommands.ToString());
                 }
                 index++;
             }
         }
     }
 }
Esempio n. 8
0
 ///<summary>Inserts one DbmLog into the database.  Returns the new priKey.</summary>
 public static long Insert(DbmLog dbmLog)
 {
     return(Insert(dbmLog, false));
 }