public static DateTime GetBetaReleaseDate() { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <DateTime>(MethodBase.GetCurrentMethod())); } DateTime releaseDate = DateTime.Now; DataAction.RunBugsHQ(() => { string command = "SELECT * FROM versionrelease " + "WHERE IsForeign=0 " + "AND BuildNum=1 "; //Exclude black listed versions. for (int i = 0; i < _versionsBlackList.Count; i++) { command += "AND (MajorNum,MinorNum) != (" + POut.Int(_versionsBlackList[i].Major) + "," + POut.Int(_versionsBlackList[i].Minor) + ") "; } command += "ORDER BY MajorNum DESC,MinorNum DESC,BuildNum DESC " + "LIMIT 3"; //Might not be 3. List <VersionRelease> listVersionReleases = RefreshAndFill(command); if (!listVersionReleases.IsNullOrEmpty()) { releaseDate = listVersionReleases[0].DateRelease; } }, false); return(releaseDate); }
public static List <int> GetVersionsAfter(int majorVersion, int minorVersion) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <int> >(MethodBase.GetCurrentMethod(), majorVersion, minorVersion)); } string command = $@" SELECT * FROM versionrelease WHERE DateRelease < '1880-01-01' AND IsForeign = 0 " ; //Exclude black listed versions. for (int i = 0; i < _versionsBlackList.Count; i++) { command += "AND (MajorNum,MinorNum) != (" + POut.Int(_versionsBlackList[i].Major) + "," + POut.Int(_versionsBlackList[i].Minor) + ") "; } command += $@"AND MajorNum>={majorVersion} ORDER BY MajorNum DESC,MinorNum DESC,BuildNum DESC" ; List <VersionRelease> listVersions = new List <VersionRelease>(); DataAction.RunBugsHQ(() => listVersions = RefreshAndFill(command), false); List <int> retVal = new List <int>(); foreach (VersionRelease version in listVersions) { if (version.MajorNum <= majorVersion && version.MinorNum <= minorVersion) { continue; } retVal.Add(PIn.Int(version.MajorNum.ToString() + version.MinorNum.ToString())); } return(retVal); }
///<summary></summary> public static List <BugSubmission> GetAllInRange(DateTime dateFrom, DateTime dateTo, List <string> listVersionFilters = null, bool useConnectionStore = false) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <BugSubmission> >(MethodBase.GetCurrentMethod(), dateFrom, dateTo, listVersionFilters, useConnectionStore)); } bool hasSelections = (!listVersionFilters.IsNullOrEmpty()); List <BugSubmission> listBugSubs = new List <BugSubmission>(); DataAction.RunBugsHQ(() => { string command = $@"SELECT * FROM bugsubmission WHERE {DbHelper.BetweenDates("SubmissionDateTime",dateFrom,dateTo)} {(hasSelections ? $@" AND ({string.Join(" OR ",listVersionFilters.Select(x => (x=="Mobile" ? "DbInfoJson like '%\"DeviceId\":%' and DbInfoJson NOT LIKE '%\"DeviceId\":null%'" : "DbVersion LIKE '"+POut.String(x)+"%'" ))) })" : "" )} " ; listBugSubs = Crud.BugSubmissionCrud.SelectMany(command); }, useConnectionStore); return(listBugSubs); }
///<summary>Returns a list of all versions ordered by MajorNum, MinorNum, BuildNum, and IsForeign.</summary> public static List <VersionRelease> Refresh(bool useConnectionStore = false) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <VersionRelease> >(MethodBase.GetCurrentMethod(), useConnectionStore)); } List <VersionRelease> listVersionReleases = new List <VersionRelease>(); DataAction.RunBugsHQ(() => { string command = "SELECT * FROM versionrelease "; //Exclude black listed versions. for (int i = 0; i < _versionsBlackList.Count; i++) { if (i == 0) { command += "WHERE "; } else { command += "AND "; } command += "(MajorNum,MinorNum) != (" + POut.Int(_versionsBlackList[i].Major) + "," + POut.Int(_versionsBlackList[i].Minor) + ") "; } //The order is very important to other entites calling this method. command += "ORDER BY MajorNum DESC,MinorNum DESC,BuildNum DESC,IsForeign"; listVersionReleases = RefreshAndFill(command); }, useConnectionStore); return(listVersionReleases); }
///<summary></summary> public static void Update(Bug bug) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), bug); return; } DataAction.RunBugsHQ(() => Crud.BugCrud.Update(bug), false); }
///<summary></summary> public static long Insert(Bug bug) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { bug.BugId = Meth.GetLong(MethodBase.GetCurrentMethod(), bug); return(bug.BugId); } DataAction.RunBugsHQ(() => Crud.BugCrud.Insert(bug), false); return(bug.BugId); }
///<summary></summary> public static void Delete(long bugId) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), bugId); return; } JobLinks.DeleteForType(JobLinkType.Bug, bugId); DataAction.RunBugsHQ(() => Crud.BugCrud.Delete(bugId), false); }
///<summary>Gets one Bug from the db.</summary> public static Bug GetOne(long bugId) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <Bug>(MethodBase.GetCurrentMethod(), bugId)); } Bug bug = null; DataAction.RunBugsHQ(() => bug = Crud.BugCrud.SelectOne(bugId), false); return(bug); }
///<summary></summary> public static void Update(BugSubmission subNew, BugSubmission subOld, bool useConnectionStore = false) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), subNew, subOld, useConnectionStore); return; } DataAction.RunBugsHQ(() => { Crud.BugSubmissionCrud.Update(subNew, subOld); }, useConnectionStore); }
///<summary></summary> public static void InsertMany(List <BugSubmissionHash> listBugSubmissionHash, bool useConnectionStore = true) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), listBugSubmissionHash, useConnectionStore); return; } DataAction.RunBugsHQ(() => { Crud.BugSubmissionHashCrud.InsertMany(listBugSubmissionHash); }, useConnectionStore); }
///<summary></summary> public static void Delete(long bugSubmissionId) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), bugSubmissionId); return; } DataAction.RunBugsHQ(() => { Crud.BugSubmissionCrud.Delete(bugSubmissionId); }, false); }
///<summary></summary> public static void Delete(long bugSubmissionHashNum, bool useConnectionStore) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), bugSubmissionHashNum, useConnectionStore); return; } DataAction.RunBugsHQ(() => { Crud.BugSubmissionHashCrud.Delete(bugSubmissionHashNum); }, useConnectionStore); }
/// <summary> /// Returns the BugSubmissionResult result for a given bug submission hash check. /// </summary> /// <param name="sub"></param> /// <param name="matchedBugId"></param> /// <param name="matchedFixedVersions"></param> /// <param name="matchedBugSubmissionHashNum"></param> /// <param name="submissionVersionOverride"></param> /// <returns></returns> public static BugSubmissionResult ProcessSubmission(BugSubmission sub, out long matchedBugId, out string matchedFixedVersions , out long matchedBugSubmissionHashNum, Version submissionVersionOverride = null, bool useConnectionStore = true) { matchedBugId = -1; matchedFixedVersions = null; matchedBugSubmissionHashNum = -1; if (sub.ListMatchedBugInfos == null) //Not already defined (like in unit test) so query for it. { DataAction.RunBugsHQ(() => { DataTable table = Db.GetTable($@" SELECT bugSubmissionHashNum, COALESCE(bug.BugId,0) _bugId,COALESCE(bug.VersionsFixed,'') _versionsFixed FROM bugsubmissionhash LEFT JOIN bug on bug.BugId=bugsubmissionhash.BugId WHERE FullHash='{sub.HashedStackTrace}' AND PartialHash='{sub.HashedSimpleStackTrace}'" ); sub.ListMatchedBugInfos = table.Select().Select(x => new BugSubmission.MatchedBugInfo(x.GetLong("bugSubmissionHashNum"), x.GetLong("_bugId"), x.GetString("_versionsFixed") )).ToList(); }, useConnectionStore); } if (sub.ListPendingFixBugInfos.Count > 1) //There are too many pending bugs and a developer will have to decide which to associate with. { return(BugSubmissionResult.Failed); } else if (sub.ListPendingFixBugInfos.Count == 1) { matchedBugId = sub.ListPendingFixBugInfos.First().BugId; matchedBugSubmissionHashNum = sub.ListPendingFixBugInfos.First().BugSubmissionHashNum; return(BugSubmissionResult.SuccessMatched); } //At this point, there are no pending fixes. Decide if a new bug submission hash should be inserted or find a pertinent fix. BugSubmission.MatchedBugInfo bugInfo = sub.GetPertinentFixedVersion(submissionVersionOverride); if (bugInfo == null) //No previously fixed bugs apply to this submission version. { if (sub.ListMatchedBugInfos.Any(x => x.BugSubmissionHashNum > 0 && x.BugId == 0 && string.IsNullOrEmpty(x.VersionsFixed))) { //We have seen this submission/hash before but it has not been associated to an internal bug yet. matchedBugSubmissionHashNum = sub.ListMatchedBugInfos.First(x => x.BugSubmissionHashNum > 0 && x.BugId == 0 && string.IsNullOrEmpty(x.VersionsFixed)).BugSubmissionHashNum; return(BugSubmissionResult.SuccessHashFound); } //Insert new hash for submission that indicates that a previous fix did not work as intended or we have not seen this submission yet. return(BugSubmissionResult.SuccessHashNeeded); } if (!sub.ListMatchedBugInfos.Any(x => x.BugSubmissionHashNum > 0 && x.BugId == 0 && string.IsNullOrEmpty(x.VersionsFixed))) { //Even though we found a pertinent fix for the inbound submission there appears to be another hash that was created due to the bug resurfacing again. matchedFixedVersions = bugInfo.VersionsFixed; } matchedBugId = bugInfo.BugId; matchedBugSubmissionHashNum = bugInfo.BugSubmissionHashNum; return(BugSubmissionResult.SuccessMatchedFixed); }
///<summary>Gets one BugSubmissionHash from the db.</summary> public static BugSubmissionHash GetOne(long bugSubmissionHashNum, bool useConnectionStore = true) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <BugSubmissionHash>(MethodBase.GetCurrentMethod(), bugSubmissionHashNum, useConnectionStore)); } BugSubmissionHash bugHash = null; DataAction.RunBugsHQ(() => { bugHash = Crud.BugSubmissionHashCrud.SelectOne(bugSubmissionHashNum); }, useConnectionStore); return(bugHash); }
///<summary>Returns a list of bugs for given bugIds.</summary> public static List <Bug> GetMany(List <long> listBugIds) { if (listBugIds == null || listBugIds.Count == 0) { return(new List <Bug>()); } List <Bug> listBugs = new List <Bug>(); DataAction.RunBugsHQ(() => { listBugs = Crud.BugCrud.TableToList(DataCore.GetTable("SELECT * FROM bug WHERE BugID IN (" + string.Join(",", listBugIds) + ")")); }, false); return(listBugs); }
///<summary>Gets one BugSubmission from the db.</summary> public static BugSubmission GetOne(long bugSubmissionId) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <BugSubmission>(MethodBase.GetCurrentMethod(), bugSubmissionId)); } BugSubmission bugSub = null; DataAction.RunBugsHQ(() => { bugSub = Crud.BugSubmissionCrud.SelectOne(bugSubmissionId); }, false); return(bugSub); }
///<summary>Returns a list of bug submissions and their corresponding bugs. ///If a bugsubmission is not associated to a bug then the BugObj field on the bugsubmission object will be null. ///Performs grouping logic in order to minimize the amount of bugsubmissions in the return results.</summary> public static List <BugSubmission> GetBugSubsForRegKeys(List <string> listRegKeys, DateTime dateFrom, DateTime dateTo) { if (listRegKeys == null || listRegKeys.Count == 0) { return(new List <BugSubmission>()); //No point in going through middle tier. } if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <BugSubmission> >(MethodBase.GetCurrentMethod(), listRegKeys, dateFrom, dateTo)); } List <BugSubmission> listRetVals = new List <BugSubmission>(); DataAction.RunBugsHQ(() => { string command = "SELECT * FROM bugsubmission " + "LEFT JOIN bug ON bug.BugId=bugsubmission.BugId " + "WHERE bugsubmission.RegKey IN(" + string.Join(",", listRegKeys.Select(x => "'" + POut.String(x) + "'")) + ") " + "AND " + DbHelper.BetweenDates("SubmissionDateTime", dateFrom, dateTo) + " " + "ORDER BY bug.CreationDate DESC, bugsubmission.SubmissionDateTime DESC"; //The query selects all columns for the bugsubmission and bug tables in one query. Hopefully we never have conflicting columns that differ. DataTable table = Db.GetTable(command); //Make a clone of the table structure for the bug objects and only fill it with entries where the BugId row is valid. DataTable tableBugs = table.Clone(); foreach (DataRow row in table.Select().Where(x => PIn.Long(x["BugId"].ToString(), false) != 0)) { tableBugs.ImportRow(row); } //Extract all of the bug objects from the subset table. List <Bug> listBugs = Crud.BugCrud.TableToList(tableBugs); //Extract all of the bugsubmission objects from the results. List <BugSubmission> listBugSubs = Crud.BugSubmissionCrud.TableToList(table); //Associate any bug object with its corresponding bugsubmission object. listBugSubs.ForEach(x => x.BugObj = listBugs.FirstOrDefault(y => y.BugId == x.BugId)); //Group the bug submissions by RegKey, ExceptionStackTrace, and BugId. //Each grouping will be ordered by ProgramVersion individually. //Take the first bugsubmission from each group and add it to listGroupedBugSubs for the return value. foreach (BugSubmission bugSub in listBugSubs) { if (bugSub.TagCustom != null) //Used to skip already considered bug submissions via grouping logic. { continue; } List <BugSubmission> listGroupedSubs = listBugSubs.FindAll(x => x.RegKey == bugSub.RegKey && x.ExceptionStackTrace == bugSub.ExceptionStackTrace && x.BugId == bugSub.BugId); listGroupedSubs.ForEach(x => x.TagCustom = true); //Flag all bugsubmissions in this group as handled. //Only add the most pertinent item from the group to our return value. listRetVals.Add(listGroupedSubs.OrderByDescending(x => new Version(x.TryGetPrefValue(PrefName.ProgramVersion, "0.0.0.0"))).First()); } }, false); return(listRetVals); }
///<summary></summary> public static List <string> GetFilterPhrases() { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <string> >(MethodBase.GetCurrentMethod())); } List <string> listPhrases = null; //Query the database for all phrases that we don't accept and see if the exception text passed in contains any of the phrases from the database. DataAction.RunBugsHQ(() => { listPhrases = Db.GetListString("SELECT Phrase FROM bugsubmissionfilter WHERE Phrase!=''"); }); return(listPhrases); }
///<summary></summary> public static long Insert(BugSubmissionHash bugSubmissionHash, bool useConnectionStore = true) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { bugSubmissionHash.BugSubmissionHashNum = Meth.GetLong(MethodBase.GetCurrentMethod(), bugSubmissionHash, useConnectionStore); return(bugSubmissionHash.BugSubmissionHashNum); } long val = -1; DataAction.RunBugsHQ(() => { val = Crud.BugSubmissionHashCrud.Insert(bugSubmissionHash); }, useConnectionStore); return(val); }
///<Summary>Gets name from database for the submitter passed in. Not very efficient.</Summary> public static string GetSubmitterName(long bugUserId) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetString(MethodBase.GetCurrentMethod(), bugUserId)); } string submitterName = ""; DataAction.RunBugsHQ(() => { string command = "SELECT UserName FROM buguser WHERE BugUserId=" + POut.Long(bugUserId); submitterName = Db.GetScalar(command); }, false); return(submitterName); }
///<summary></summary> public static List <BugSubmission> GetAll(bool useConnectionStore = false) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <BugSubmission> >(MethodBase.GetCurrentMethod(), useConnectionStore)); } List <BugSubmission> listBugSubs = new List <BugSubmission>(); DataAction.RunBugsHQ(() => { string command = "SELECT * FROM bugsubmission"; listBugSubs = Crud.BugSubmissionCrud.SelectMany(command); }, useConnectionStore); return(listBugSubs); }
///<summary></summary> public static long Insert(BugSubmission bugSubmission) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetLong(MethodBase.GetCurrentMethod(), bugSubmission)); } long retVal = 0; //Always use the connection store config file because creating BugSubmissions should always happen via OpenDentalWebServiceHQ. DataAction.RunBugsHQ(() => { retVal = Crud.BugSubmissionCrud.Insert(bugSubmission); }); return(retVal); }
public static List <BugSubmission> GetAllAttached() { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <BugSubmission> >(MethodBase.GetCurrentMethod())); } List <BugSubmission> listBugSubs = new List <BugSubmission>(); DataAction.RunBugsHQ(() => { string command = "SELECT * FROM bugsubmission WHERE BugId!=0"; listBugSubs = Crud.BugSubmissionCrud.SelectMany(command); }, false); return(listBugSubs); }
///<summary></summary> public static List <BugSubmission> GetAllInRange(DateTime dateFrom, DateTime dateTo) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <BugSubmission> >(MethodBase.GetCurrentMethod(), dateFrom, dateTo)); } List <BugSubmission> listBugSubs = new List <BugSubmission>(); DataAction.RunBugsHQ(() => { string command = "SELECT * FROM bugsubmission WHERE " + DbHelper.BetweenDates("SubmissionDateTime", dateFrom, dateTo); listBugSubs = Crud.BugSubmissionCrud.TableToList(DataCore.GetTable(command)); }, false); return(listBugSubs); }
///<summary></summary> public static List <BugSubmission> GetAll() { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <BugSubmission> >(MethodBase.GetCurrentMethod())); } List <BugSubmission> listBugSubs = new List <BugSubmission>(); DataAction.RunBugsHQ(() => { string command = "SELECT * FROM bugsubmission"; listBugSubs = Crud.BugSubmissionCrud.TableToList(DataCore.GetTable(command)); }, false); return(listBugSubs); }
///<summary>Gets all bugs ordered by CreationDate DESC</summary> public static List <Bug> GetAll() { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <Bug> >(MethodBase.GetCurrentMethod())); } List <Bug> listBugs = new List <Bug>(); DataAction.RunBugsHQ(() => { string command = "SELECT * FROM bug ORDER BY CreationDate DESC"; listBugs = Crud.BugCrud.SelectMany(command); }, false); return(listBugs); }
///<summary>Returns a list of bug submissions and any associated bugs. ///If a bugSubmission is not associated to a bug then bug entry will be null.</summary> public static List <Tuple <BugSubmission, Bug> > GetBugSubsForRegKeys(List <string> listRegKeys, DateTime dateFrom, DateTime dateTo) { if (listRegKeys == null || listRegKeys.Count == 0) { return(new List <Tuple <BugSubmission, Bug> >()); //No point in going through middle tier. } if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <Tuple <BugSubmission, Bug> > >(MethodBase.GetCurrentMethod(), listRegKeys, dateFrom, dateTo)); } List <long> listBugIDs = new List <long>(); List <Tuple <BugSubmission, Bug> > listSubBugs = new List <Tuple <BugSubmission, Bug> >(); DataAction.RunBugsHQ(() => { string command = "SELECT * FROM bugsubmission " + "LEFT JOIN bug ON bug.BugId=bugsubmission.BugId " + "WHERE bugsubmission.RegKey IN(" + string.Join(",", listRegKeys.Select(x => "'" + POut.String(x) + "'")) + ") " + "AND " + DbHelper.BetweenDates("SubmissionDateTime", dateFrom, dateTo) + " " + "ORDER BY bug.CreationDate DESC, bugsubmission.SubmissionDateTime DESC"; DataTable table = DataCore.GetTable(command); DataTable tableBugs = table.Clone(); //Clones structure, not row data. foreach (DataRow row in table.Rows) { if (PIn.Long(row["BugId"].ToString(), false) == 0) { continue; //Do not import rows that do not have bugs, LEFT JOIN bug must be successful. } tableBugs.ImportRow(row); } List <Bug> listBugs = Crud.BugCrud.TableToList(tableBugs); List <BugSubmission> listBugSubs = Crud.BugSubmissionCrud.TableToList(table); foreach (BugSubmission sub in listBugSubs) { if (sub.TagOD != null) { continue; //Already handled. } //Grouping mimics FormBugSubmissions.cs List <BugSubmission> listGroupedSubs = listBugSubs.FindAll(x => x.RegKey == sub.RegKey && x.ExceptionStackTrace == sub.ExceptionStackTrace && x.BugId == sub.BugId); listGroupedSubs.ForEach(x => x.TagOD = true); //Used to skip already considered bug submissions via grouping logic. BugSubmission subMax = listGroupedSubs.OrderByDescending(x => new Version(x.Info.DictPrefValues[PrefName.ProgramVersion])).First(); Bug bug = listBugs.FirstOrDefault(x => x.BugId == subMax.BugId); //Can be null. listSubBugs.Add(new Tuple <BugSubmission, Bug>(subMax, bug)); } }, false); return(listSubBugs); }
///<Summary>Checks bugIDs in list for incompletes. Returns false if incomplete exists.</Summary> public static bool CheckForCompletion(List <long> listBugIDs) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetBool(MethodBase.GetCurrentMethod(), listBugIDs)); } int count = 0; DataAction.RunBugsHQ(() => { string command = "SELECT COUNT(*) FROM bug " + "WHERE VersionsFixed='' " + "AND BugId IN (" + String.Join(",", listBugIDs) + ")"; count = PIn.Int(Db.GetCount(command)); }, false); return(count == 0); }
///<summary>Updates all bugIds for given bugSubmissionNums.</summary> public static void UpdateBugIds(long bugId, List <long> listBugSubmissionNums) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), bugId, listBugSubmissionNums); return; } if (listBugSubmissionNums == null || listBugSubmissionNums.Count == 0) { return; } DataAction.RunBugsHQ(() => { Db.NonQ("UPDATE bugsubmission SET BugId=" + POut.Long(bugId) + " WHERE BugSubmissionNum IN (" + string.Join(",", listBugSubmissionNums) + ")"); }, false); }
///<summary>Attempts to get the ValueString from the bug's preference table for the given PrefName. The ValueString retrieved from the db will be converted to T. ///Returns true if the preference was found and successfully converted to the type of T. Otherwise retVal will be set to the default for T and false will be returned.</summary> public static bool TryGetPrefValue <T>(string prefName, out T retVal) { retVal = default(T); try { string val = ""; DataAction.RunBugsHQ(() => { val = Db.GetScalar("SELECT ValueString FROM preference WHERE PrefName='" + prefName + "'"); }, false); retVal = (T)Convert.ChangeType(val, typeof(T)); } catch (Exception ex) { ex.DoNothing(); return(false); } return(true); }