Exemple #1
0
 ///<summary>Inserts one EduResource into the database.  Returns the new priKey.</summary>
 internal static long Insert(EduResource eduResource)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         eduResource.EduResourceNum=DbHelper.GetNextOracleKey("eduresource","EduResourceNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(eduResource,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     eduResource.EduResourceNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(eduResource,false);
     }
 }
Exemple #2
0
 ///<summary>Inserts one EduResource into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(EduResource eduResource,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         eduResource.EduResourceNum=ReplicationServers.GetKey("eduresource","EduResourceNum");
     }
     string command="INSERT INTO eduresource (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="EduResourceNum,";
     }
     command+="DiseaseDefNum,MedicationNum,LabResultID,LabResultName,LabResultCompare,ResourceUrl,Icd9Num) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(eduResource.EduResourceNum)+",";
     }
     command+=
              POut.Long  (eduResource.DiseaseDefNum)+","
         +    POut.Long  (eduResource.MedicationNum)+","
         +"'"+POut.String(eduResource.LabResultID)+"',"
         +"'"+POut.String(eduResource.LabResultName)+"',"
         +"'"+POut.String(eduResource.LabResultCompare)+"',"
         +"'"+POut.String(eduResource.ResourceUrl)+"',"
         +    POut.Long  (eduResource.Icd9Num)+")";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         eduResource.EduResourceNum=Db.NonQ(command,true);
     }
     return eduResource.EduResourceNum;
 }
Exemple #3
0
 ///<summary>Returns true if Update(EduResource,EduResource) 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(EduResource eduResource, EduResource oldEduResource)
 {
     if (eduResource.DiseaseDefNum != oldEduResource.DiseaseDefNum)
     {
         return(true);
     }
     if (eduResource.MedicationNum != oldEduResource.MedicationNum)
     {
         return(true);
     }
     if (eduResource.LabResultID != oldEduResource.LabResultID)
     {
         return(true);
     }
     if (eduResource.LabResultName != oldEduResource.LabResultName)
     {
         return(true);
     }
     if (eduResource.LabResultCompare != oldEduResource.LabResultCompare)
     {
         return(true);
     }
     if (eduResource.ResourceUrl != oldEduResource.ResourceUrl)
     {
         return(true);
     }
     if (eduResource.SmokingSnoMed != oldEduResource.SmokingSnoMed)
     {
         return(true);
     }
     return(false);
 }
 ///<summary>Inserts one EduResource into the database.  Returns the new priKey.</summary>
 public static long Insert(EduResource eduResource)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         eduResource.EduResourceNum = DbHelper.GetNextOracleKey("eduresource", "EduResourceNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(eduResource, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     eduResource.EduResourceNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(eduResource, false));
     }
 }
        ///<summary>Updates one EduResource 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.</summary>
        public static void Update(EduResource eduResource, EduResource oldEduResource)
        {
            string command = "";

            if (eduResource.DiseaseDefNum != oldEduResource.DiseaseDefNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DiseaseDefNum = " + POut.Long(eduResource.DiseaseDefNum) + "";
            }
            if (eduResource.MedicationNum != oldEduResource.MedicationNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "MedicationNum = " + POut.Long(eduResource.MedicationNum) + "";
            }
            if (eduResource.LabResultID != oldEduResource.LabResultID)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "LabResultID = '" + POut.String(eduResource.LabResultID) + "'";
            }
            if (eduResource.LabResultName != oldEduResource.LabResultName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "LabResultName = '" + POut.String(eduResource.LabResultName) + "'";
            }
            if (eduResource.LabResultCompare != oldEduResource.LabResultCompare)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "LabResultCompare = '" + POut.String(eduResource.LabResultCompare) + "'";
            }
            if (eduResource.ResourceUrl != oldEduResource.ResourceUrl)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ResourceUrl = '" + POut.String(eduResource.ResourceUrl) + "'";
            }
            if (command == "")
            {
                return;
            }
            command = "UPDATE eduresource SET " + command
                      + " WHERE EduResourceNum = " + POut.Long(eduResource.EduResourceNum);
            Db.NonQ(command);
        }
        ///<summary>Inserts one EduResource into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(EduResource eduResource, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                eduResource.EduResourceNum = ReplicationServers.GetKey("eduresource", "EduResourceNum");
            }
            string command = "INSERT INTO eduresource (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "EduResourceNum,";
            }
            command += "DiseaseDefNum,MedicationNum,LabResultID,LabResultName,LabResultCompare,ResourceUrl) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(eduResource.EduResourceNum) + ",";
            }
            command +=
                POut.Long(eduResource.DiseaseDefNum) + ","
                + POut.Long(eduResource.MedicationNum) + ","
                + "'" + POut.String(eduResource.LabResultID) + "',"
                + "'" + POut.String(eduResource.LabResultName) + "',"
                + "'" + POut.String(eduResource.LabResultCompare) + "',"
                + "'" + POut.String(eduResource.ResourceUrl) + "')";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                eduResource.EduResourceNum = Db.NonQ(command, true);
            }
            return(eduResource.EduResourceNum);
        }
        ///<summary>Updates one EduResource in the database.</summary>
        public static void Update(EduResource eduResource)
        {
            string command = "UPDATE eduresource SET "
                             + "DiseaseDefNum   =  " + POut.Long(eduResource.DiseaseDefNum) + ", "
                             + "MedicationNum   =  " + POut.Long(eduResource.MedicationNum) + ", "
                             + "LabResultID     = '" + POut.String(eduResource.LabResultID) + "', "
                             + "LabResultName   = '" + POut.String(eduResource.LabResultName) + "', "
                             + "LabResultCompare= '" + POut.String(eduResource.LabResultCompare) + "', "
                             + "ResourceUrl     = '" + POut.String(eduResource.ResourceUrl) + "' "
                             + "WHERE EduResourceNum = " + POut.Long(eduResource.EduResourceNum);

            Db.NonQ(command);
        }
Exemple #8
0
 ///<summary>Inserts one EduResource into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(EduResource eduResource)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(eduResource, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             eduResource.EduResourceNum = DbHelper.GetNextOracleKey("eduresource", "EduResourceNum");                  //Cacheless method
         }
         return(InsertNoCache(eduResource, true));
     }
 }
Exemple #9
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<EduResource> TableToList(DataTable table){
			List<EduResource> retVal=new List<EduResource>();
			EduResource eduResource;
			for(int i=0;i<table.Rows.Count;i++) {
				eduResource=new EduResource();
				eduResource.EduResourceNum  = PIn.Long  (table.Rows[i]["EduResourceNum"].ToString());
				eduResource.DiseaseDefNum   = PIn.Long  (table.Rows[i]["DiseaseDefNum"].ToString());
				eduResource.MedicationNum   = PIn.Long  (table.Rows[i]["MedicationNum"].ToString());
				eduResource.LabResultID     = PIn.String(table.Rows[i]["LabResultID"].ToString());
				eduResource.LabResultName   = PIn.String(table.Rows[i]["LabResultName"].ToString());
				eduResource.LabResultCompare= PIn.String(table.Rows[i]["LabResultCompare"].ToString());
				eduResource.ResourceUrl     = PIn.String(table.Rows[i]["ResourceUrl"].ToString());
				retVal.Add(eduResource);
			}
			return retVal;
		}
Exemple #10
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <EduResource> TableToList(DataTable table)
        {
            List <EduResource> retVal = new List <EduResource>();
            EduResource        eduResource;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                eduResource = new EduResource();
                eduResource.EduResourceNum   = PIn.Long(table.Rows[i]["EduResourceNum"].ToString());
                eduResource.DiseaseDefNum    = PIn.Long(table.Rows[i]["DiseaseDefNum"].ToString());
                eduResource.MedicationNum    = PIn.Long(table.Rows[i]["MedicationNum"].ToString());
                eduResource.LabResultID      = PIn.String(table.Rows[i]["LabResultID"].ToString());
                eduResource.LabResultName    = PIn.String(table.Rows[i]["LabResultName"].ToString());
                eduResource.LabResultCompare = PIn.String(table.Rows[i]["LabResultCompare"].ToString());
                eduResource.ResourceUrl      = PIn.String(table.Rows[i]["ResourceUrl"].ToString());
                retVal.Add(eduResource);
            }
            return(retVal);
        }
Exemple #11
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <EduResource> TableToList(DataTable table)
        {
            List <EduResource> retVal = new List <EduResource>();
            EduResource        eduResource;

            foreach (DataRow row in table.Rows)
            {
                eduResource = new EduResource();
                eduResource.EduResourceNum   = PIn.Long(row["EduResourceNum"].ToString());
                eduResource.DiseaseDefNum    = PIn.Long(row["DiseaseDefNum"].ToString());
                eduResource.MedicationNum    = PIn.Long(row["MedicationNum"].ToString());
                eduResource.LabResultID      = PIn.String(row["LabResultID"].ToString());
                eduResource.LabResultName    = PIn.String(row["LabResultName"].ToString());
                eduResource.LabResultCompare = PIn.String(row["LabResultCompare"].ToString());
                eduResource.ResourceUrl      = PIn.String(row["ResourceUrl"].ToString());
                eduResource.SmokingSnoMed    = PIn.String(row["SmokingSnoMed"].ToString());
                retVal.Add(eduResource);
            }
            return(retVal);
        }
Exemple #12
0
        ///<summary>Inserts one EduResource into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(EduResource eduResource, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO eduresource (";

            if (!useExistingPK && isRandomKeys)
            {
                eduResource.EduResourceNum = ReplicationServers.GetKeyNoCache("eduresource", "EduResourceNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "EduResourceNum,";
            }
            command += "DiseaseDefNum,MedicationNum,LabResultID,LabResultName,LabResultCompare,ResourceUrl,SmokingSnoMed) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(eduResource.EduResourceNum) + ",";
            }
            command +=
                POut.Long(eduResource.DiseaseDefNum) + ","
                + POut.Long(eduResource.MedicationNum) + ","
                + "'" + POut.String(eduResource.LabResultID) + "',"
                + "'" + POut.String(eduResource.LabResultName) + "',"
                + "'" + POut.String(eduResource.LabResultCompare) + "',"
                + "'" + POut.String(eduResource.ResourceUrl) + "',"
                + "'" + POut.String(eduResource.SmokingSnoMed) + "')";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                eduResource.EduResourceNum = Db.NonQ(command, true, "EduResourceNum", "eduResource");
            }
            return(eduResource.EduResourceNum);
        }
Exemple #13
0
 ///<summary>Updates one EduResource 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.</summary>
 internal static void Update(EduResource eduResource,EduResource oldEduResource)
 {
     string command="";
     if(eduResource.DiseaseDefNum != oldEduResource.DiseaseDefNum) {
         if(command!=""){ command+=",";}
         command+="DiseaseDefNum = "+POut.Long(eduResource.DiseaseDefNum)+"";
     }
     if(eduResource.MedicationNum != oldEduResource.MedicationNum) {
         if(command!=""){ command+=",";}
         command+="MedicationNum = "+POut.Long(eduResource.MedicationNum)+"";
     }
     if(eduResource.LabResultID != oldEduResource.LabResultID) {
         if(command!=""){ command+=",";}
         command+="LabResultID = '"+POut.String(eduResource.LabResultID)+"'";
     }
     if(eduResource.LabResultName != oldEduResource.LabResultName) {
         if(command!=""){ command+=",";}
         command+="LabResultName = '"+POut.String(eduResource.LabResultName)+"'";
     }
     if(eduResource.LabResultCompare != oldEduResource.LabResultCompare) {
         if(command!=""){ command+=",";}
         command+="LabResultCompare = '"+POut.String(eduResource.LabResultCompare)+"'";
     }
     if(eduResource.ResourceUrl != oldEduResource.ResourceUrl) {
         if(command!=""){ command+=",";}
         command+="ResourceUrl = '"+POut.String(eduResource.ResourceUrl)+"'";
     }
     if(eduResource.Icd9Num != oldEduResource.Icd9Num) {
         if(command!=""){ command+=",";}
         command+="Icd9Num = "+POut.Long(eduResource.Icd9Num)+"";
     }
     if(command==""){
         return;
     }
     command="UPDATE eduresource SET "+command
         +" WHERE EduResourceNum = "+POut.Long(eduResource.EduResourceNum);
     Db.NonQ(command);
 }
Exemple #14
0
 ///<summary>Updates one EduResource in the database.</summary>
 internal static void Update(EduResource eduResource)
 {
     string command="UPDATE eduresource SET "
         +"DiseaseDefNum   =  "+POut.Long  (eduResource.DiseaseDefNum)+", "
         +"MedicationNum   =  "+POut.Long  (eduResource.MedicationNum)+", "
         +"LabResultID     = '"+POut.String(eduResource.LabResultID)+"', "
         +"LabResultName   = '"+POut.String(eduResource.LabResultName)+"', "
         +"LabResultCompare= '"+POut.String(eduResource.LabResultCompare)+"', "
         +"ResourceUrl     = '"+POut.String(eduResource.ResourceUrl)+"', "
         +"Icd9Num         =  "+POut.Long  (eduResource.Icd9Num)+" "
         +"WHERE EduResourceNum = "+POut.Long(eduResource.EduResourceNum);
     Db.NonQ(command);
 }
Exemple #15
0
 ///<summary>Inserts one EduResource into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(EduResource eduResource)
 {
     return(InsertNoCache(eduResource, false));
 }