///<summary>Event handler for TextBox leave.</summary> private void WebSchedVerify_TextLeave(object sender, EventArgs e) { TextBox textBox = (TextBox)sender; PrefName prefName = (PrefName)textBox.Tag; WebSchedVerify_UpdateClinicPref(prefName, textBox.Text); }
///<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; }
///<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>Creates a row for the passed in template type. Unchecks checkUseDefaults if a clinic-level template is in use.</summary> private ODGridRow BuildRowForTemplate(PrefName prefName, string templateName, string availableVars) { string templateText; bool doShowDefault = false; if (_selectedClinicNum == 0) { templateText = PrefC.GetString(prefName); checkUseDefaults.Checked = false; } else { ClinicPref clinicPref = ClinicPrefs.GetPref(prefName, _selectedClinicNum); if (clinicPref == null || clinicPref.ValueString == null) { templateText = PrefC.GetString(prefName); doShowDefault = true; } else { templateText = clinicPref.ValueString; checkUseDefaults.Checked = false; } } ODGridRow row = new ODGridRow(); row.Cells.Add(Lan.g(this, templateName) + (doShowDefault ? " " + Lan.g(this, "(Default)") : "")); row.Cells.Add(availableVars); row.Cells.Add(templateText); row.Tag = prefName; return(row); }
///<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>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>Essentially a "sync" method although it doesn't save to the db. Takes the list of new clinic preference values ///and compares it to the database. Returns a list of clinics that have had their preference values changed.</summary> public List <long> GetClinicsWithChanges(PrefName prefName) { List <ClinicPref> listClinicPrefsThisPrefName = _listClinicPrefs.FindAll(x => x.PrefName == prefName); List <long> listRet = new List <long>(); List <ClinicPref> listDb = ClinicPrefs.GetPrefAllClinics(prefName, includeDefault: true); listRet.AddRange(listClinicPrefsThisPrefName.Where(x => //Get the items from the new list that aren't in the old list !listDb.Select(y => y.ClinicNum).Contains(x.ClinicNum) //AND that aren't using the default preference value && x.ValueString != PrefC.GetString(prefName)) //Add the clinic nums .Select(x => x.ClinicNum)); //Add any items that have been deleted or updated. foreach (ClinicPref oldCp in listDb) { ClinicPref newCp = listClinicPrefsThisPrefName.FirstOrDefault(x => x.ClinicNum == oldCp.ClinicNum); if (newCp == null) //Item was in db and now is not. { listRet.Add(oldCp.ClinicNum); continue; } if (newCp.ValueString != oldCp.ValueString) //Item has changed. { listRet.Add(oldCp.ClinicNum); } } return(listRet.Distinct().ToList()); }
///<summary>Checks the currently selected radio button for the given PrefName and groupBox, based on the radio button tags.</summary> private void WebSchedVerify_SetRadioButtonVal(PrefName prefName, GroupBox groupBox) { WebSchedVerifyType type = (WebSchedVerifyType)PIn.Int(WebSchedVerify_GetTemplateVal(prefName)); RadioButton buttonMatch = groupBox.Controls.OfType <RadioButton>().FirstOrDefault(x => (WebSchedVerifyType)x.Tag == type); buttonMatch.Checked = true; }
///<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 the bool value for a YN pref. If Unknown, then returns the default. If you want the 3 state version, then use PrefC.GetEnum<YN> or PrefC.GetCheckState.</summary> public static bool GetYN(PrefName prefName) { YN yn = (YN)PIn.Int(Prefs.GetOne(prefName).ValueString); if (yn == YN.Yes) { return(true); } if (yn == YN.No) { return(false); } //unknown, so use the default PrefValueType prefValueType = prefName.GetValueType(); if (prefValueType == PrefValueType.YN_DEFAULT_FALSE) { return(false); } if (prefValueType == PrefValueType.YN_DEFAULT_TRUE) { return(true); } throw new ArgumentException("Invalid type"); }
///<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 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>Returns the clinic pref value for the currently selected clinic and provided PrefName, or the default pref if there is none.</summary> private string WebSchedVerify_GetTemplateVal(PrefName prefName) { ClinicPref clinicPref = _listWebSchedVerifyClinicPrefs.FirstOrDefault(x => x.ClinicNum == comboClinicVerify.SelectedClinicNum && x.PrefName == prefName); ClinicPref defaultPref = _listWebSchedVerifyClinicPrefs.FirstOrDefault(x => x.ClinicNum == CLINIC_NUM_DEFAULT && x.PrefName == prefName); //ClinicPref won't be available if it has not been created previously. return(clinicPref != null ? clinicPref.ValueString : defaultPref.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; }
private void AddClinicPrefToList(PrefName prefName, long clinicNum) { ClinicPref clinicPref = ClinicPrefs.GetPref(prefName, clinicNum); if (clinicPref != null) { _listClinicPrefsWebSchedNewPats.Add(clinicPref); } }
///<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 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)); }
public string TryGetPrefValue(PrefName prefName, string defaultReturn = "") { string prefValue; if (Info.DictPrefValues.TryGetValue(PrefName.ProgramVersion, out prefValue)) { return(prefValue); } return(defaultReturn); }
///<summary>Gets the ValueString as a boolean for this clinic's pref or gets the actual preference if it does not exist.</summary> public static bool GetBool(PrefName prefName, long clinicNum) { ClinicPref pref = GetPref(prefName, clinicNum); if (pref == null) { return(PrefC.GetBool(prefName)); } return(PIn.Bool(pref.ValueString)); }
private void UpdateEClipboardDefaultsIfNeeded(PrefName prefName, string newVal) { if (_clinicNumEClipboardTab == 0) //we are making changes to the default { foreach (ClinicPref cp in _clinicPrefHelperEClipboard.GetWhere(PrefName.EClipboardUseDefaults, "1")) { _clinicPrefHelperEClipboard.ValChangedByUser(prefName, cp.ClinicNum, newVal); } } }
///<summary>For UI display when we store a zero/meaningless value as -1. Returns "0" when useZero is true, otherwise "".</summary> public static string GetLongHideNegOne(PrefName prefName, bool useZero = false) { long prefVal = PrefC.GetLong(prefName); if (prefVal == -1) { return(useZero?"0":""); } return(POut.Long(prefVal)); }
///<summary>For saving from the UI when we want "0" or "" to be saved as a -1 in the database.</summary> public static bool UpdateLongAsNegOne(PrefName prefName, string newVal) { long val = -1; if (!string.IsNullOrWhiteSpace(newVal)) { val = PIn.Long(newVal) > 0?PIn.Long(newVal):-1; } return(UpdateLong(prefName, val)); }
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>Tries to get the original clinic pref that was loaded in when the form first opened, and reload it into the in-memory clinic pref /// list. If there is no old pref, this loads the default pref value for that clinic into the in-memory list.</summary> private void WebSchedVerify_TryRestoreClinicPrefOld(PrefName prefName) { ClinicPref pref = _listWebSchedVerifyClinicPrefs_Old.FindAll(x => x.ClinicNum == comboClinicVerify.SelectedClinicNum && x.PrefName == prefName).FirstOrDefault(); if (pref == null) { pref = _listWebSchedVerifyClinicPrefs.FindAll(x => x.ClinicNum == CLINIC_NUM_DEFAULT && x.PrefName == prefName).First(); } WebSchedVerify_UpdateClinicPref(prefName, pref.ValueString); }
private ClinicPref GetClinicPrefToSave(long clinicNum, PrefName prefName, string value) { ClinicPref clinicPref = _listClinicPrefsWebSchedNewPats.FirstOrDefault(x => x.ClinicNum == clinicNum && x.PrefName == prefName)?.Clone(); if (clinicPref == null) { return(new ClinicPref(clinicNum, prefName, value)); } clinicPref.ValueString = value; return(clinicPref); }
///<summary>Helper method for setting UI for boolean preferences. Some of the preferences calling this may not exist in the database.</summary> private void FillOptionalPrefBool(CheckBox checkPref, PrefName pref) { string valueString = GetHiddenPrefString(pref); if (valueString == null) { checkPref.Visible = false; return; } checkPref.Checked = PIn.Bool(valueString); }
///<summary>Returns the ValueString of a pref or null if that pref is not found in the database.</summary> private string GetHiddenPrefString(PrefName pref) { try { Pref hiddenPref = Prefs.GetOne(pref); return(hiddenPref.ValueString); } catch (Exception ex) { ex.DoNothing(); return(null); } }
///<summary>Gets the ValueString for this clinic's pref or gets the actual preference if it does not exist.</summary> public static string GetPrefValue(PrefName pref, long clinicNum) { //No need to check RemotingRole; no call to db. ClinicPref clinicPref = GetPrefAllClinics(pref).FirstOrDefault(x => x.ClinicNum == clinicNum); if (clinicPref == null) { return(PrefC.GetString(pref)); } return(clinicPref.ValueString); }
///<summary>Returns 0 if there is no clinicpref entry for the specified pref.</summary> public static long GetLong(PrefName prefName, long clinicNum) { //No need to check RemotingRole; no call to db. ClinicPref pref = GetPref(prefName, clinicNum); if (pref == null) { return(0); } return(PIn.Long(pref.ValueString)); }
///<summary></summary> public string GetStringVal(PrefName prefName, long clinicNum) { if (clinicNum < 0) //Shouldn't happen { return(""); } if (_listClinicPrefs.Any(x => x.ClinicNum == clinicNum && x.PrefName == prefName)) //we've already loaded this item, just load it's checked value { return(_listClinicPrefs.FirstOrDefault(x => x.ClinicNum == clinicNum && x.PrefName == prefName).ValueString); } return(_listClinicPrefs.FirstOrDefault(x => x.ClinicNum == 0 && x.PrefName == prefName).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>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. 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>Returns true if a change was required, or false if no change needed.</summary> public static bool UpdateBool(PrefName prefName,bool newValue) { //No need to check RemotingRole; no call to db. return UpdateBool(prefName,newValue,false); }
///<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; }
public FormRecallMessageEdit(PrefName prefName) { InitializeComponent(); Lan.F(this); _prefName=prefName; }
///<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 UpdateLong(prefName,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; }
///<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 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>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); }