コード例 #1
0
 ///<summary>Inserts one PhoneMetric into the database.  Returns the new priKey.</summary>
 public static long Insert(PhoneMetric phoneMetric)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         phoneMetric.PhoneMetricNum = DbHelper.GetNextOracleKey("phonemetric", "PhoneMetricNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(phoneMetric, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     phoneMetric.PhoneMetricNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(phoneMetric, false));
     }
 }
コード例 #2
0
ファイル: PhoneMetricCrud.cs プロジェクト: mnisl/OD
		///<summary>Inserts one PhoneMetric into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(PhoneMetric phoneMetric,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				phoneMetric.PhoneMetricNum=ReplicationServers.GetKey("phonemetric","PhoneMetricNum");
			}
			string command="INSERT INTO phonemetric (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="PhoneMetricNum,";
			}
			command+="DateTimeEntry,VoiceMails,Triages,MinutesBehind) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(phoneMetric.PhoneMetricNum)+",";
			}
			command+=
				     POut.DateT (phoneMetric.DateTimeEntry)+","
				+    POut.Int   (phoneMetric.VoiceMails)+","
				+    POut.Int   (phoneMetric.Triages)+","
				+    POut.Int   (phoneMetric.MinutesBehind)+")";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				phoneMetric.PhoneMetricNum=Db.NonQ(command,true);
			}
			return phoneMetric.PhoneMetricNum;
		}
コード例 #3
0
        ///<summary>Inserts one PhoneMetric into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(PhoneMetric phoneMetric, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO phonemetric (";

            if (!useExistingPK && isRandomKeys)
            {
                phoneMetric.PhoneMetricNum = ReplicationServers.GetKeyNoCache("phonemetric", "PhoneMetricNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "PhoneMetricNum,";
            }
            command += "DateTimeEntry,VoiceMails,Triages,MinutesBehind) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(phoneMetric.PhoneMetricNum) + ",";
            }
            command +=
                POut.DateT(phoneMetric.DateTimeEntry) + ","
                + POut.Int(phoneMetric.VoiceMails) + ","
                + POut.Int(phoneMetric.Triages) + ","
                + POut.Int(phoneMetric.MinutesBehind) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                phoneMetric.PhoneMetricNum = Db.NonQ(command, true, "PhoneMetricNum", "phoneMetric");
            }
            return(phoneMetric.PhoneMetricNum);
        }
コード例 #4
0
ファイル: PhoneMetricCrud.cs プロジェクト: steev90/opendental
        ///<summary>Inserts one PhoneMetric into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(PhoneMetric phoneMetric, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                phoneMetric.PhoneMetricNum = ReplicationServers.GetKey("phonemetric", "PhoneMetricNum");
            }
            string command = "INSERT INTO phonemetric (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "PhoneMetricNum,";
            }
            command += "DateTimeEntry,VoiceMails,Triages,MinutesBehind) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(phoneMetric.PhoneMetricNum) + ",";
            }
            command +=
                POut.DateT(phoneMetric.DateTimeEntry) + ","
                + POut.Int(phoneMetric.VoiceMails) + ","
                + POut.Int(phoneMetric.Triages) + ","
                + POut.Int(phoneMetric.MinutesBehind) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                phoneMetric.PhoneMetricNum = Db.NonQ(command, true);
            }
            return(phoneMetric.PhoneMetricNum);
        }
コード例 #5
0
        ///<summary>Updates one PhoneMetric in the database.</summary>
        public static void Update(PhoneMetric phoneMetric)
        {
            string command = "UPDATE phonemetric SET "
                             + "DateTimeEntry =  " + POut.DateT(phoneMetric.DateTimeEntry) + ", "
                             + "VoiceMails    =  " + POut.Int(phoneMetric.VoiceMails) + ", "
                             + "Triages       =  " + POut.Int(phoneMetric.Triages) + ", "
                             + "MinutesBehind =  " + POut.Int(phoneMetric.MinutesBehind) + " "
                             + "WHERE PhoneMetricNum = " + POut.Long(phoneMetric.PhoneMetricNum);

            Db.NonQ(command);
        }
コード例 #6
0
ファイル: PhoneMetricCrud.cs プロジェクト: mnisl/OD
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<PhoneMetric> TableToList(DataTable table){
			List<PhoneMetric> retVal=new List<PhoneMetric>();
			PhoneMetric phoneMetric;
			for(int i=0;i<table.Rows.Count;i++) {
				phoneMetric=new PhoneMetric();
				phoneMetric.PhoneMetricNum= PIn.Long  (table.Rows[i]["PhoneMetricNum"].ToString());
				phoneMetric.DateTimeEntry = PIn.DateT (table.Rows[i]["DateTimeEntry"].ToString());
				phoneMetric.VoiceMails    = PIn.Int   (table.Rows[i]["VoiceMails"].ToString());
				phoneMetric.Triages       = PIn.Int   (table.Rows[i]["Triages"].ToString());
				phoneMetric.MinutesBehind = PIn.Int   (table.Rows[i]["MinutesBehind"].ToString());
				retVal.Add(phoneMetric);
			}
			return retVal;
		}
コード例 #7
0
 ///<summary>Inserts one PhoneMetric into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(PhoneMetric phoneMetric)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(phoneMetric, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             phoneMetric.PhoneMetricNum = DbHelper.GetNextOracleKey("phonemetric", "PhoneMetricNum");                  //Cacheless method
         }
         return(InsertNoCache(phoneMetric, true));
     }
 }
コード例 #8
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <PhoneMetric> TableToList(DataTable table)
        {
            List <PhoneMetric> retVal = new List <PhoneMetric>();
            PhoneMetric        phoneMetric;

            foreach (DataRow row in table.Rows)
            {
                phoneMetric = new PhoneMetric();
                phoneMetric.PhoneMetricNum = PIn.Long(row["PhoneMetricNum"].ToString());
                phoneMetric.DateTimeEntry  = PIn.DateT(row["DateTimeEntry"].ToString());
                phoneMetric.VoiceMails     = PIn.Int(row["VoiceMails"].ToString());
                phoneMetric.Triages        = PIn.Int(row["Triages"].ToString());
                phoneMetric.MinutesBehind  = PIn.Int(row["MinutesBehind"].ToString());
                retVal.Add(phoneMetric);
            }
            return(retVal);
        }
コード例 #9
0
ファイル: PhoneMetricCrud.cs プロジェクト: steev90/opendental
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <PhoneMetric> TableToList(DataTable table)
        {
            List <PhoneMetric> retVal = new List <PhoneMetric>();
            PhoneMetric        phoneMetric;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                phoneMetric = new PhoneMetric();
                phoneMetric.PhoneMetricNum = PIn.Long(table.Rows[i]["PhoneMetricNum"].ToString());
                phoneMetric.DateTimeEntry  = PIn.DateT(table.Rows[i]["DateTimeEntry"].ToString());
                phoneMetric.VoiceMails     = PIn.Int(table.Rows[i]["VoiceMails"].ToString());
                phoneMetric.Triages        = PIn.Int(table.Rows[i]["Triages"].ToString());
                phoneMetric.MinutesBehind  = PIn.Int(table.Rows[i]["MinutesBehind"].ToString());
                retVal.Add(phoneMetric);
            }
            return(retVal);
        }
コード例 #10
0
        ///<summary>Updates one PhoneMetric 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(PhoneMetric phoneMetric, PhoneMetric oldPhoneMetric)
        {
            string command = "";

            if (phoneMetric.DateTimeEntry != oldPhoneMetric.DateTimeEntry)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateTimeEntry = " + POut.DateT(phoneMetric.DateTimeEntry) + "";
            }
            if (phoneMetric.VoiceMails != oldPhoneMetric.VoiceMails)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "VoiceMails = " + POut.Int(phoneMetric.VoiceMails) + "";
            }
            if (phoneMetric.Triages != oldPhoneMetric.Triages)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Triages = " + POut.Int(phoneMetric.Triages) + "";
            }
            if (phoneMetric.MinutesBehind != oldPhoneMetric.MinutesBehind)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "MinutesBehind = " + POut.Int(phoneMetric.MinutesBehind) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE phonemetric SET " + command
                      + " WHERE PhoneMetricNum = " + POut.Long(phoneMetric.PhoneMetricNum);
            Db.NonQ(command);
            return(true);
        }
コード例 #11
0
 ///<summary>Returns true if Update(PhoneMetric,PhoneMetric) 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(PhoneMetric phoneMetric, PhoneMetric oldPhoneMetric)
 {
     if (phoneMetric.DateTimeEntry != oldPhoneMetric.DateTimeEntry)
     {
         return(true);
     }
     if (phoneMetric.VoiceMails != oldPhoneMetric.VoiceMails)
     {
         return(true);
     }
     if (phoneMetric.Triages != oldPhoneMetric.Triages)
     {
         return(true);
     }
     if (phoneMetric.MinutesBehind != oldPhoneMetric.MinutesBehind)
     {
         return(true);
     }
     return(false);
 }
コード例 #12
0
ファイル: PhoneMetricCrud.cs プロジェクト: mnisl/OD
		///<summary>Inserts one PhoneMetric into the database.  Returns the new priKey.</summary>
		public static long Insert(PhoneMetric phoneMetric){
			if(DataConnection.DBtype==DatabaseType.Oracle) {
				phoneMetric.PhoneMetricNum=DbHelper.GetNextOracleKey("phonemetric","PhoneMetricNum");
				int loopcount=0;
				while(loopcount<100){
					try {
						return Insert(phoneMetric,true);
					}
					catch(Oracle.DataAccess.Client.OracleException ex){
						if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
							phoneMetric.PhoneMetricNum++;
							loopcount++;
						}
						else{
							throw ex;
						}
					}
				}
				throw new ApplicationException("Insert failed.  Could not generate primary key.");
			}
			else {
				return Insert(phoneMetric,false);
			}
		}
コード例 #13
0
ファイル: PhoneMetricCrud.cs プロジェクト: mnisl/OD
		///<summary>Updates one PhoneMetric 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(PhoneMetric phoneMetric,PhoneMetric oldPhoneMetric){
			string command="";
			if(phoneMetric.DateTimeEntry != oldPhoneMetric.DateTimeEntry) {
				if(command!=""){ command+=",";}
				command+="DateTimeEntry = "+POut.DateT(phoneMetric.DateTimeEntry)+"";
			}
			if(phoneMetric.VoiceMails != oldPhoneMetric.VoiceMails) {
				if(command!=""){ command+=",";}
				command+="VoiceMails = "+POut.Int(phoneMetric.VoiceMails)+"";
			}
			if(phoneMetric.Triages != oldPhoneMetric.Triages) {
				if(command!=""){ command+=",";}
				command+="Triages = "+POut.Int(phoneMetric.Triages)+"";
			}
			if(phoneMetric.MinutesBehind != oldPhoneMetric.MinutesBehind) {
				if(command!=""){ command+=",";}
				command+="MinutesBehind = "+POut.Int(phoneMetric.MinutesBehind)+"";
			}
			if(command==""){
				return false;
			}
			command="UPDATE phonemetric SET "+command
				+" WHERE PhoneMetricNum = "+POut.Long(phoneMetric.PhoneMetricNum);
			Db.NonQ(command);
			return true;
		}
コード例 #14
0
ファイル: PhoneMetricCrud.cs プロジェクト: mnisl/OD
		///<summary>Updates one PhoneMetric in the database.</summary>
		public static void Update(PhoneMetric phoneMetric){
			string command="UPDATE phonemetric SET "
				+"DateTimeEntry =  "+POut.DateT (phoneMetric.DateTimeEntry)+", "
				+"VoiceMails    =  "+POut.Int   (phoneMetric.VoiceMails)+", "
				+"Triages       =  "+POut.Int   (phoneMetric.Triages)+", "
				+"MinutesBehind =  "+POut.Int   (phoneMetric.MinutesBehind)+" "
				+"WHERE PhoneMetricNum = "+POut.Long(phoneMetric.PhoneMetricNum);
			Db.NonQ(command);
		}
コード例 #15
0
 ///<summary>Inserts one PhoneMetric into the database.  Returns the new priKey.</summary>
 public static long Insert(PhoneMetric phoneMetric)
 {
     return(Insert(phoneMetric, false));
 }