Exemple #1
0
		///<summary>Inserts one ErxLog into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(ErxLog erxLog,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				erxLog.ErxLogNum=ReplicationServers.GetKey("erxlog","ErxLogNum");
			}
			string command="INSERT INTO erxlog (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="ErxLogNum,";
			}
			command+="PatNum,MsgText,ProvNum) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(erxLog.ErxLogNum)+",";
			}
			command+=
				     POut.Long  (erxLog.PatNum)+","
				+    DbHelper.ParamChar+"paramMsgText,"
				//DateTStamp can only be set by MySQL
				+    POut.Long  (erxLog.ProvNum)+")";
			if(erxLog.MsgText==null) {
				erxLog.MsgText="";
			}
			OdSqlParameter paramMsgText=new OdSqlParameter("paramMsgText",OdDbType.Text,erxLog.MsgText);
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command,paramMsgText);
			}
			else {
				erxLog.ErxLogNum=Db.NonQ(command,true,paramMsgText);
			}
			return erxLog.ErxLogNum;
		}
Exemple #2
0
 ///<summary>Inserts one ErxLog into the database.  Returns the new priKey.</summary>
 public static long Insert(ErxLog erxLog)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         erxLog.ErxLogNum = DbHelper.GetNextOracleKey("erxlog", "ErxLogNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(erxLog, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     erxLog.ErxLogNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(erxLog, false));
     }
 }
Exemple #3
0
        ///<summary>Updates one ErxLog 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(ErxLog erxLog, ErxLog oldErxLog)
        {
            string command = "";

            if (erxLog.PatNum != oldErxLog.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(erxLog.PatNum) + "";
            }
            if (erxLog.MsgText != oldErxLog.MsgText)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "MsgText = " + DbHelper.ParamChar + "paramMsgText";
            }
            //DateTStamp can only be set by MySQL
            if (erxLog.ProvNum != oldErxLog.ProvNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ProvNum = " + POut.Long(erxLog.ProvNum) + "";
            }
            if (erxLog.UserNum != oldErxLog.UserNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "UserNum = " + POut.Long(erxLog.UserNum) + "";
            }
            if (command == "")
            {
                return(false);
            }
            if (erxLog.MsgText == null)
            {
                erxLog.MsgText = "";
            }
            OdSqlParameter paramMsgText = new OdSqlParameter("paramMsgText", OdDbType.Text, POut.StringParam(erxLog.MsgText));

            command = "UPDATE erxlog SET " + command
                      + " WHERE ErxLogNum = " + POut.Long(erxLog.ErxLogNum);
            Db.NonQ(command, paramMsgText);
            return(true);
        }
Exemple #4
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<ErxLog> TableToList(DataTable table){
			List<ErxLog> retVal=new List<ErxLog>();
			ErxLog erxLog;
			for(int i=0;i<table.Rows.Count;i++) {
				erxLog=new ErxLog();
				erxLog.ErxLogNum = PIn.Long  (table.Rows[i]["ErxLogNum"].ToString());
				erxLog.PatNum    = PIn.Long  (table.Rows[i]["PatNum"].ToString());
				erxLog.MsgText   = PIn.String(table.Rows[i]["MsgText"].ToString());
				erxLog.DateTStamp= PIn.DateT (table.Rows[i]["DateTStamp"].ToString());
				erxLog.ProvNum   = PIn.Long  (table.Rows[i]["ProvNum"].ToString());
				retVal.Add(erxLog);
			}
			return retVal;
		}
Exemple #5
0
 ///<summary>Inserts one ErxLog into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(ErxLog erxLog)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(erxLog, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             erxLog.ErxLogNum = DbHelper.GetNextOracleKey("erxlog", "ErxLogNum");                  //Cacheless method
         }
         return(InsertNoCache(erxLog, true));
     }
 }
Exemple #6
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <ErxLog> TableToList(DataTable table)
        {
            List <ErxLog> retVal = new List <ErxLog>();
            ErxLog        erxLog;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                erxLog            = new ErxLog();
                erxLog.ErxLogNum  = PIn.Long(table.Rows[i]["ErxLogNum"].ToString());
                erxLog.PatNum     = PIn.Long(table.Rows[i]["PatNum"].ToString());
                erxLog.MsgText    = PIn.String(table.Rows[i]["MsgText"].ToString());
                erxLog.DateTStamp = PIn.DateT(table.Rows[i]["DateTStamp"].ToString());
                erxLog.ProvNum    = PIn.Long(table.Rows[i]["ProvNum"].ToString());
                retVal.Add(erxLog);
            }
            return(retVal);
        }
Exemple #7
0
        ///<summary>Updates one ErxLog in the database.</summary>
        public static void Update(ErxLog erxLog)
        {
            string command = "UPDATE erxlog SET "
                             + "PatNum    =  " + POut.Long(erxLog.PatNum) + ", "
                             + "MsgText   =  " + DbHelper.ParamChar + "paramMsgText, "
                             //DateTStamp can only be set by MySQL
                             + "ProvNum   =  " + POut.Long(erxLog.ProvNum) + " "
                             + "WHERE ErxLogNum = " + POut.Long(erxLog.ErxLogNum);

            if (erxLog.MsgText == null)
            {
                erxLog.MsgText = "";
            }
            OdSqlParameter paramMsgText = new OdSqlParameter("paramMsgText", OdDbType.Text, erxLog.MsgText);

            Db.NonQ(command, paramMsgText);
        }
Exemple #8
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <ErxLog> TableToList(DataTable table)
        {
            List <ErxLog> retVal = new List <ErxLog>();
            ErxLog        erxLog;

            foreach (DataRow row in table.Rows)
            {
                erxLog            = new ErxLog();
                erxLog.ErxLogNum  = PIn.Long(row["ErxLogNum"].ToString());
                erxLog.PatNum     = PIn.Long(row["PatNum"].ToString());
                erxLog.MsgText    = PIn.String(row["MsgText"].ToString());
                erxLog.DateTStamp = PIn.DateT(row["DateTStamp"].ToString());
                erxLog.ProvNum    = PIn.Long(row["ProvNum"].ToString());
                erxLog.UserNum    = PIn.Long(row["UserNum"].ToString());
                retVal.Add(erxLog);
            }
            return(retVal);
        }
Exemple #9
0
 ///<summary>Returns true if Update(ErxLog,ErxLog) 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(ErxLog erxLog, ErxLog oldErxLog)
 {
     if (erxLog.PatNum != oldErxLog.PatNum)
     {
         return(true);
     }
     if (erxLog.MsgText != oldErxLog.MsgText)
     {
         return(true);
     }
     //DateTStamp can only be set by MySQL
     if (erxLog.ProvNum != oldErxLog.ProvNum)
     {
         return(true);
     }
     if (erxLog.UserNum != oldErxLog.UserNum)
     {
         return(true);
     }
     return(false);
 }
Exemple #10
0
        ///<summary>Inserts one ErxLog into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(ErxLog erxLog, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO erxlog (";

            if (!useExistingPK && isRandomKeys)
            {
                erxLog.ErxLogNum = ReplicationServers.GetKeyNoCache("erxlog", "ErxLogNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "ErxLogNum,";
            }
            command += "PatNum,MsgText,ProvNum,UserNum) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(erxLog.ErxLogNum) + ",";
            }
            command +=
                POut.Long(erxLog.PatNum) + ","
                + DbHelper.ParamChar + "paramMsgText,"
                //DateTStamp can only be set by MySQL
                + POut.Long(erxLog.ProvNum) + ","
                + POut.Long(erxLog.UserNum) + ")";
            if (erxLog.MsgText == null)
            {
                erxLog.MsgText = "";
            }
            OdSqlParameter paramMsgText = new OdSqlParameter("paramMsgText", OdDbType.Text, POut.StringParam(erxLog.MsgText));

            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command, paramMsgText);
            }
            else
            {
                erxLog.ErxLogNum = Db.NonQ(command, true, "ErxLogNum", "erxLog", paramMsgText);
            }
            return(erxLog.ErxLogNum);
        }
Exemple #11
0
        ///<summary>Inserts one ErxLog into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(ErxLog erxLog, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                erxLog.ErxLogNum = ReplicationServers.GetKey("erxlog", "ErxLogNum");
            }
            string command = "INSERT INTO erxlog (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "ErxLogNum,";
            }
            command += "PatNum,MsgText,ProvNum) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(erxLog.ErxLogNum) + ",";
            }
            command +=
                POut.Long(erxLog.PatNum) + ","
                + DbHelper.ParamChar + "paramMsgText,"
                //DateTStamp can only be set by MySQL
                + POut.Long(erxLog.ProvNum) + ")";
            if (erxLog.MsgText == null)
            {
                erxLog.MsgText = "";
            }
            OdSqlParameter paramMsgText = new OdSqlParameter("paramMsgText", OdDbType.Text, erxLog.MsgText);

            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command, paramMsgText);
            }
            else
            {
                erxLog.ErxLogNum = Db.NonQ(command, true, paramMsgText);
            }
            return(erxLog.ErxLogNum);
        }
Exemple #12
0
		///<summary>Inserts one ErxLog into the database.  Returns the new priKey.</summary>
		public static long Insert(ErxLog erxLog){
			if(DataConnection.DBtype==DatabaseType.Oracle) {
				erxLog.ErxLogNum=DbHelper.GetNextOracleKey("erxlog","ErxLogNum");
				int loopcount=0;
				while(loopcount<100){
					try {
						return Insert(erxLog,true);
					}
					catch(Oracle.DataAccess.Client.OracleException ex){
						if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
							erxLog.ErxLogNum++;
							loopcount++;
						}
						else{
							throw ex;
						}
					}
				}
				throw new ApplicationException("Insert failed.  Could not generate primary key.");
			}
			else {
				return Insert(erxLog,false);
			}
		}
Exemple #13
0
 ///<summary>Inserts one ErxLog into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(ErxLog erxLog)
 {
     return(InsertNoCache(erxLog, false));
 }
Exemple #14
0
 ///<summary>Inserts one ErxLog into the database.  Returns the new priKey.</summary>
 public static long Insert(ErxLog erxLog)
 {
     return(Insert(erxLog, false));
 }
Exemple #15
0
		///<summary>Updates one ErxLog 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(ErxLog erxLog,ErxLog oldErxLog){
			string command="";
			if(erxLog.PatNum != oldErxLog.PatNum) {
				if(command!=""){ command+=",";}
				command+="PatNum = "+POut.Long(erxLog.PatNum)+"";
			}
			if(erxLog.MsgText != oldErxLog.MsgText) {
				if(command!=""){ command+=",";}
				command+="MsgText = "+DbHelper.ParamChar+"paramMsgText";
			}
			//DateTStamp can only be set by MySQL
			if(erxLog.ProvNum != oldErxLog.ProvNum) {
				if(command!=""){ command+=",";}
				command+="ProvNum = "+POut.Long(erxLog.ProvNum)+"";
			}
			if(command==""){
				return false;
			}
			if(erxLog.MsgText==null) {
				erxLog.MsgText="";
			}
			OdSqlParameter paramMsgText=new OdSqlParameter("paramMsgText",OdDbType.Text,erxLog.MsgText);
			command="UPDATE erxlog SET "+command
				+" WHERE ErxLogNum = "+POut.Long(erxLog.ErxLogNum);
			Db.NonQ(command,paramMsgText);
			return true;
		}
Exemple #16
0
		///<summary>Updates one ErxLog in the database.</summary>
		public static void Update(ErxLog erxLog){
			string command="UPDATE erxlog SET "
				+"PatNum    =  "+POut.Long  (erxLog.PatNum)+", "
				+"MsgText   =  "+DbHelper.ParamChar+"paramMsgText, "
				//DateTStamp can only be set by MySQL
				+"ProvNum   =  "+POut.Long  (erxLog.ProvNum)+" "
				+"WHERE ErxLogNum = "+POut.Long(erxLog.ErxLogNum);
			if(erxLog.MsgText==null) {
				erxLog.MsgText="";
			}
			OdSqlParameter paramMsgText=new OdSqlParameter("paramMsgText",OdDbType.Text,erxLog.MsgText);
			Db.NonQ(command,paramMsgText);
		}