///<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>Returns serialized DbInfo object as JSON string of database info from both the preference table and non preferernce table info.</summary> private string GetDbInfoJSON(long patNum, string moduleName) { _info = new BugSubmission.SubmissionInfo(); try { //This list is not in a separate method because we want to ensure that future development related to bug submissions don't try to make assumptions //on which preferences are in an object at any given time. //Ex. Let's say in version 17.4, the list doesn't contain the payplan version preference, but 17.5 does. //If we called the method that retrieves the used preferences from WebServiceMainHQ which in this example is on version 17.5, // it would think all bugsubmission rows contain the payplan version preference when that is not the case. List <PrefName> listPrefs = new List <PrefName>() { PrefName.AtoZfolderUsed, PrefName.ClaimSnapshotEnabled, PrefName.ClaimSnapshotRunTime, PrefName.ClaimSnapshotTriggerType, PrefName.CorruptedDatabase, PrefName.DataBaseVersion, PrefName.EasyNoClinics, PrefName.LanguageAndRegion, PrefName.MySqlVersion, PrefName.PayPlansVersion, PrefName.ProcessSigsIntervalInSecs, PrefName.ProgramVersionLastUpdated, PrefName.ProgramVersion, PrefName.RandomPrimaryKeys, PrefName.RegistrationKey, PrefName.RegistrationKeyIsDisabled, PrefName.ReplicationFailureAtServer_id, PrefName.ReportingServerCompName, PrefName.ReportingServerDbName, PrefName.ReportingServerMySqlUser, PrefName.ReportingServerMySqlPassHash, PrefName.ReportingServerURI, PrefName.WebServiceServerName }; foreach (PrefName pref in listPrefs) { _info.DictPrefValues[pref] = Prefs.GetOne(pref).ValueString; } _info.CountClinics = Clinics.GetCount(); _info.EnabledPlugins = Programs.GetWhere(x => x.Enabled && !string.IsNullOrWhiteSpace(x.PluginDllName)).Select(x => x.ProgName).ToList(); _info.ClinicNumCur = Clinics.ClinicNum; _info.UserNumCur = Security.CurUser.UserNum; _info.PatientNumCur = patNum; _info.IsOfficeOnReplication = (ReplicationServers.GetCount() > 0 ? true : false); _info.IsOfficeUsingMiddleTier = (RemotingClient.RemotingRole == RemotingRole.ClientWeb ? true : false); _info.WindowsVersion = MiscData.GetOSVersionInfo(); _info.CompName = Environment.MachineName; List <UpdateHistory> listHist = UpdateHistories.GetPreviouUpdateHistories(2); //Ordered by newer versions first. _info.PreviousUpdateVersion = listHist.Count == 2 ? listHist[1].ProgramVersion : ""; //Show the previous version they updated from _info.PreviousUpdateTime = listHist.Count > 0 ? listHist[0].DateTimeUpdated : DateTime.MinValue; //Show when they updated to the current version. _info.ModuleNameCur = moduleName; _info.DatabaseName = DataConnection.GetDatabaseName(); } catch (Exception ex) { ex.DoNothing(); } return(JsonConvert.SerializeObject(_info)); }
///<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 (Prefs.DictIsNull()) { return(""); } Pref pref = null; ODException.SwallowAnyException(() => { pref = Prefs.GetOne(prefName); }); return(pref == null ? "" : pref.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 (Prefs.DictIsNull()) { return(silentDefault); } Pref pref = null; ODException.SwallowAnyException(() => { pref = Prefs.GetOne(prefName); }); return(pref == null ? silentDefault : PIn.Bool(pref.ValueString)); }
///<summary>Gets culture info from DB if possible, if not returns current culture.</summary> public static CultureInfo GetLanguageAndRegion() { CultureInfo cultureInfo = CultureInfo.CurrentCulture; ODException.SwallowAnyException(() => { Pref pref = Prefs.GetOne("LanguageAndRegion"); if (!string.IsNullOrEmpty(pref.ValueString)) { cultureInfo = CultureInfo.GetCultureInfo(pref.ValueString); } }); return(cultureInfo); }
///<summary>Gets YN value for use in pref setup windows with a 3 state checkbox.</summary> public static System.Windows.Forms.CheckState GetYNCheckState(PrefName prefName) { YN yn = (YN)PIn.Int(Prefs.GetOne(prefName).ValueString); if (yn == YN.Yes) { return(System.Windows.Forms.CheckState.Checked); } if (yn == YN.No) { return(System.Windows.Forms.CheckState.Unchecked); } return(System.Windows.Forms.CheckState.Indeterminate); }
///<summary>Used sometimes for prefs that are not part of the enum, especially for outside developers.</summary> public static string GetRaw(string prefName) { return(Prefs.GetOne(prefName).ValueString); }
///<summary>Gets a color from an int32 pref.</summary> public static Color GetColor(PrefName prefName) { return(Color.FromArgb(PIn.Int(Prefs.GetOne(prefName).ValueString))); }
///<summary>Gets a pref of type datetime.</summary> public static DateTime GetDateT(PrefName prefName) { return(PIn.DateT(Prefs.GetOne(prefName).ValueString)); }
///<summary>Gets a pref of type bool.</summary> public static bool GetBool(PrefName prefName) { return(PIn.Bool(Prefs.GetOne(prefName).ValueString)); }
///<summary>Gets a pref of type double.</summary> public static double GetDouble(PrefName prefName, bool doUseEnUSFormat) { return(PIn.Double(Prefs.GetOne(prefName).ValueString, doUseEnUSFormat)); }
///<summary>Gets a pref of type double.</summary> public static double GetDouble(PrefName prefName) { return(PIn.Double(Prefs.GetOne(prefName).ValueString)); }
///<summary>Gets a pref of type byte. Used when the pref is a very small integer (0-255).</summary> public static byte GetByte(PrefName prefName) { return(PIn.Byte(Prefs.GetOne(prefName).ValueString)); }
///<summary>Gets a pref of type int32. Used when the pref is an enumeration, itemorder, etc. Also used for historical queries in ConvertDatabase.</summary> public static int GetInt(PrefName prefName) { return(PIn.Int(Prefs.GetOne(prefName).ValueString)); }
///<summary>Gets a pref of type long.</summary> public static long GetLong(PrefName prefName) { return(PIn.Long(Prefs.GetOne(prefName).ValueString)); }
///<summary>Gets a Pref object when the PrefName is provided</summary> public static Pref GetPref(String PrefName) { return(Prefs.GetOne(PrefName)); }
public static Dictionary <ConnectionNames, CentralConnection> GetHqConnections() { return(GetHqConnectionsFromString(Prefs.GetOne(PrefName.ConnectionSettingsHQ).ValueString)); }