///<summary>Updates a pref of type long. Returns true if a change was required, or false if no change needed.</summary> public static bool UpdateLong(PrefName prefName, long newValue) { //Very unusual. Involves cache, so Meth is used further down instead of here at the top. if (!PrefC.Dict.ContainsKey(prefName.ToString())) { throw new ApplicationException(prefName + " is an invalid pref name."); } if (PrefC.GetLong(prefName) == newValue) { return(false); //no change needed } string command = "UPDATE preference SET " + "ValueString = '" + POut.Long(newValue) + "' " + "WHERE PrefName = '" + POut.String(prefName.ToString()) + "'"; bool retVal = true; if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { retVal = Meth.GetBool(MethodBase.GetCurrentMethod(), prefName, newValue); } else { Db.NonQ(command); } Pref pref = new Pref(); pref.PrefName = prefName.ToString(); pref.ValueString = newValue.ToString(); PrefC.Dict[prefName.ToString()] = pref; //in some cases, we just want to change the pref in local memory instead of doing a refresh afterwards. return(retVal); }
///<summary>Returns true if a change was required, or false if no change needed.</summary> public static bool UpdateDateT(PrefName prefName, DateTime newValue) { //Very unusual. Involves cache, so Meth is used further down instead of here at the top. DateTime curValue = PrefC.GetDateT(prefName); if (curValue == newValue) { return(false); //no change needed } string command = "UPDATE preference SET " + "ValueString = '" + POut.DateT(newValue, false) + "' " + "WHERE PrefName = '" + POut.String(prefName.ToString()) + "'"; bool retVal = true; if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { retVal = Meth.GetBool(MethodBase.GetCurrentMethod(), prefName, newValue); } else { Db.NonQ(command); } Pref pref = new Pref(); pref.PrefName = prefName.ToString(); pref.ValueString = POut.DateT(newValue, false); Prefs.UpdateValueForKey(pref); return(retVal); }
///<summary>Returns true if a change was required, or false if no change needed.</summary> public static bool UpdateBool(PrefName prefName, bool newValue, bool isForced) { //Very unusual. Involves cache, so Meth is used further down instead of here at the top. if (!PrefC.Dict.ContainsKey(prefName.ToString())) { throw new ApplicationException(prefName + " is an invalid pref name."); } if (!isForced && PrefC.GetBool(prefName) == newValue) { return(false); //no change needed } string command = "UPDATE preference SET " + "ValueString = '" + POut.Bool(newValue) + "' " + "WHERE PrefName = '" + POut.String(prefName.ToString()) + "'"; bool retVal = true; if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { retVal = Meth.GetBool(MethodBase.GetCurrentMethod(), prefName, newValue, isForced); } else { Db.NonQ(command); } Pref pref = new Pref(); pref.PrefName = prefName.ToString(); pref.ValueString = POut.Bool(newValue); PrefC.Dict[prefName.ToString()] = pref; return(retVal); }
///<summary>Gets a pref of type double.</summary> public static double GetDouble(PrefName prefName) { Dictionary<string,Pref> dictPrefs=GetDict(); if(!dictPrefs.ContainsKey(prefName.ToString())) { throw new Exception(prefName+" is an invalid pref name."); } return PIn.Double(dictPrefs[prefName.ToString()].ValueString); }
///<Summary>Gets a pref of type bool, but will not throw an exception if null or not found. Indicate whether the silent default is true or false.</Summary> public static bool GetBoolSilent(PrefName prefName,bool silentDefault) { if(Dict==null) { return silentDefault; } if(!Dict.ContainsKey(prefName.ToString())) { return silentDefault; } return PIn.Bool(Dict[prefName.ToString()].ValueString); }
///<summary>Gets a pref of type bool.</summary> public static bool GetBool(PrefName prefName) { if(Dict==null) { Prefs.RefreshCache(); } if(!Dict.ContainsKey(prefName.ToString())) { throw new Exception(prefName+" is an invalid pref name."); } return PIn.Bool(Dict[prefName.ToString()].ValueString); }
///<summary>Gets a pref of type string. Will not throw an exception if null or not found.</summary> public static string GetStringSilent(PrefName prefName) { if (Dict == null) { return(""); } if (!Dict.ContainsKey(prefName.ToString())) { return(""); } return(Dict[prefName.ToString()].ValueString); }
///<summary>Gets a color from an int32 pref.</summary> public static Color GetColor(PrefName prefName) { if (Dict == null) { Prefs.RefreshCache(); } if (!Dict.ContainsKey(prefName.ToString())) { throw new Exception(prefName + " is an invalid pref name."); } return(Color.FromArgb(PIn.Int(Dict[prefName.ToString()].ValueString))); }
///<Summary>Gets a pref of type bool, but will not throw an exception if null or not found. Indicate whether the silent default is true or false.</Summary> public static bool GetBoolSilent(PrefName prefName, bool silentDefault) { if (Dict == null) { return(silentDefault); } if (!Dict.ContainsKey(prefName.ToString())) { return(silentDefault); } return(PIn.Bool(Dict[prefName.ToString()].ValueString)); }
///<summary>Gets a pref of type string.</summary> public static string GetString(PrefName prefName) { if (Dict == null) { Prefs.RefreshCache(); } if (!Dict.ContainsKey(prefName.ToString())) { throw new Exception(prefName + " is an invalid pref name."); } return(Dict[prefName.ToString()].ValueString); }
///<summary>Updates a pref of type long for the specified clinic. Returns true if a change was required, or false if no change needed.</summary> public static bool UpdateLong(PrefName prefName, long clinicNum, long newValue) { //Very unusual. Involves cache, so Meth is used further down instead of here at the top. ClinicPref clinicPref = GetFirstOrDefault(x => x.ClinicNum == clinicNum && x.PrefName == prefName); if (clinicPref == null) { throw new ApplicationException("The PrefName " + prefName + " does not exist for ClinicNum: " + clinicNum); } if (PIn.Long(clinicPref.ValueString) == newValue) { return(false); //no change needed } string command = "UPDATE clinicpref SET ValueString='" + POut.Long(newValue) + "' " + "WHERE PrefName='" + POut.String(prefName.ToString()) + "' " + "AND ClinicNum='" + POut.Long(clinicNum) + "'"; bool retVal = true; if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { retVal = Meth.GetBool(MethodBase.GetCurrentMethod(), prefName, newValue); } else { Db.NonQ(command); } //Update local cache even though we should be invalidating the cache outside of this method. ClinicPref cachedClinicPref = clinicPref; cachedClinicPref.PrefName = prefName; cachedClinicPref.ValueString = newValue.ToString(); cachedClinicPref.ClinicNum = clinicNum; return(retVal); }
///<summary>Updates a pref of type long. Returns true if a change was required, or false if no change needed.</summary> public static bool UpdateLong(PrefName prefName,long newValue) { //Very unusual. Involves cache, so Meth is used further down instead of here at the top. Dictionary<string,Pref> dictPrefs=PrefC.GetDict(); if(!dictPrefs.ContainsKey(prefName.ToString())) { throw new ApplicationException(prefName+" is an invalid pref name."); } if(PrefC.GetLong(prefName)==newValue) { return false;//no change needed } string command= "UPDATE preference SET " +"ValueString = '"+POut.Long(newValue)+"' " +"WHERE PrefName = '"+POut.String(prefName.ToString())+"'"; bool retVal=true; if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) { retVal=Meth.GetBool(MethodBase.GetCurrentMethod(),prefName,newValue); } else{ Db.NonQ(command); } Pref pref=new Pref(); pref.PrefName=prefName.ToString(); pref.ValueString=newValue.ToString(); Dictionary<string,Pref> dictPrefsUpdated=PrefC.GetDict(); dictPrefsUpdated[prefName.ToString()]=pref;//in some cases, we just want to change the pref in local memory instead of doing a refresh afterwards. PrefC.Dict=dictPrefsUpdated; return retVal; }
private static void AddToDict(PrefName prefName, string newValue) { string oldValue = Prefs.GetPref(prefName.ToString()).ValueString; if (oldValue == newValue || _dictPrefsOrig.ContainsKey(prefName)) { return; } _dictPrefsOrig[prefName] = oldValue; }
///<summary>Uploads Preferences to the Patient Portal /Mobile Web.</summary> public static void UploadPreference(PrefName prefname) { try { if (TestWebServiceExists()) { Prefm prefm = Prefms.GetPrefm(prefname.ToString()); mb.SetPreference(PrefC.GetString(PrefName.RegistrationKey), prefm); } } catch (Exception ex) { MessageBox.Show(ex.Message); //may not show if called from a thread but that does not matter - the failing of this method should not stop the the code from proceeding. } }
///<summary>Uploads Preferences to the Patient Portal /Mobile Web.</summary> public static void UploadPreference(PrefName prefname) { if (PrefC.GetString(PrefName.RegistrationKey) == "") { return; //Prevents a bug when using the trial version with no registration key. Practice edit, OK, was giving error. } try { if (TestWebServiceExists()) { Prefm prefm = Prefms.GetPrefm(prefname.ToString()); mb.SetPreference(PrefC.GetString(PrefName.RegistrationKey), prefm); } } catch (Exception ex) { MessageBox.Show(ex.Message); //may not show if called from a thread but that does not matter - the failing of this method should not stop the the code from proceeding. } }
///<summary>Returns a deep copy of the corresponding preference by name from the cache. ///Throws an exception indicating that the prefName passed in is invalid if it cannot be found in the cache (old behavior).</summary> public static Pref GetOne(PrefName prefName) { return(GetOne(prefName.ToString())); }
///<summary>Gets a pref of type bool without using the cache.</summary> public static bool GetBoolNoCache(PrefName prefName) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetBool(MethodBase.GetCurrentMethod(), prefName)); } string command = "SELECT ValueString FROM preference WHERE PrefName = '" + POut.String(prefName.ToString()) + "'"; return(PIn.Bool(Db.GetScalar(command))); }
///<summary>Updates a pref string without using the cache classes. Useful for multithreaded connections.</summary> public static void UpdateStringNoCache(PrefName prefName, string newValue) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), prefName, newValue); return; } string command = "UPDATE preference SET ValueString='" + POut.String(newValue) + "' WHERE PrefName='" + POut.String(prefName.ToString()) + "'"; Db.NonQ(command); }
///<summary>Uploads Preferences to the Patient Portal /Mobile Web.</summary> public static void UploadPreference(PrefName prefname) { if(PrefC.GetString(PrefName.RegistrationKey)=="") { return;//Prevents a bug when using the trial version with no registration key. Practice edit, OK, was giving error. } try { if(TestWebServiceExists()) { Prefm prefm = Prefms.GetPrefm(prefname.ToString()); mb.SetPreference(PrefC.GetString(PrefName.RegistrationKey),prefm); } } catch(Exception ex) { MessageBox.Show(ex.Message);//may not show if called from a thread but that does not matter - the failing of this method should not stop the the code from proceeding. } }
///<summary>Gets a color from an int32 pref.</summary> public static Color GetColor(PrefName prefName) { if(Dict==null) { Prefs.RefreshCache(); } if(!Dict.ContainsKey(prefName.ToString())) { throw new Exception(prefName+" is an invalid pref name."); } return Color.FromArgb(PIn.Int(Dict[prefName.ToString()].ValueString)); }
///<summary>Gets a pref of type string. Will not throw an exception if null or not found.</summary> public static string GetStringSilent(PrefName prefName) { if(Dict==null) { return ""; } if(!Dict.ContainsKey(prefName.ToString())) { return ""; } return Dict[prefName.ToString()].ValueString; }
///<Summary>Gets a pref of type bool, but will not throw an exception if null or not found. Indicate whether the silent default is true or false.</Summary> public static bool GetBoolSilent(PrefName prefName,bool silentDefault) { if(HListIsNull()) { return silentDefault; } Dictionary<string,Pref> dictPrefs=GetDict(); if(!dictPrefs.ContainsKey(prefName.ToString())) { return silentDefault; } return PIn.Bool(dictPrefs[prefName.ToString()].ValueString); }
///<summary>Gets a pref of type string. Will not throw an exception if null or not found.</summary> public static string GetStringSilent(PrefName prefName) { if(HListIsNull()) { return ""; } Dictionary<string,Pref> dictPrefs=GetDict(); if(!dictPrefs.ContainsKey(prefName.ToString())) { return ""; } return dictPrefs[prefName.ToString()].ValueString; }
///<summary>Gets a color from an int32 pref.</summary> public static Color GetColor(PrefName prefName) { Dictionary<string,Pref> dictPrefs=GetDict(); if(!dictPrefs.ContainsKey(prefName.ToString())) { throw new Exception(prefName+" is an invalid pref name."); } return Color.FromArgb(PIn.Int(dictPrefs[prefName.ToString()].ValueString)); }
///<summary>Updates a pref of type long. Returns true if a change was required, or false if no change needed.</summary> public static bool UpdateLong(PrefName prefName, long newValue) { return(UpdateLong(prefName.ToString(), newValue)); }
///<summary>Updates a pref of type int. Returns true if a change was required, or false if no change needed.</summary> public static bool UpdateInt(PrefName prefName, int newValue) { return(UpdateInt(prefName.ToString(), newValue)); }
private static void AddToDict(PrefName prefName, string newValue) { AddToDict(prefName.ToString(), newValue); }
///<summary>Uploads Preferences to the Patient Portal /Mobile Web.</summary> public static void UploadPreference(PrefName prefname) { try { if(TestWebServiceExists()) { Prefm prefm = Prefms.GetPrefm(prefname.ToString()); mb.SetPreference(PrefC.GetString(PrefName.RegistrationKey),prefm); } } catch(Exception ex) { MessageBox.Show(ex.Message);//may not show if called from a thread but that does not matter - the failing of this method should not stop the the code from proceeding. } }
///<summary>Updates a pref of type double. Returns true if a change was required, or false if no change needed.</summary> public static bool UpdateDouble(PrefName prefName,double newValue) { //Very unusual. Involves cache, so Meth is used further down instead of here at the top. if(!PrefC.Dict.ContainsKey(prefName.ToString())) { throw new ApplicationException(prefName+" is an invalid pref name."); } if(PrefC.GetDouble(prefName)==newValue) { return false;//no change needed } string command = "UPDATE preference SET " +"ValueString = '"+POut.Double(newValue)+"' " +"WHERE PrefName = '"+POut.String(prefName.ToString())+"'"; bool retVal=true; if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) { retVal=Meth.GetBool(MethodBase.GetCurrentMethod(),prefName,newValue); } else{ Db.NonQ(command); } return retVal; }