///<summary>Used for prefs that are non-standard. Especially by outside programmers. Returns true if a change was required, or false if no change needed.</summary> public static bool UpdateRaw(string prefName, string newValue) { //Very unusual. Involves cache, so Meth is used further down instead of here at the top. string curValue = PrefC.GetRaw(prefName); if (curValue == newValue) { return(false); //no change needed } string command = "UPDATE preference SET " + "ValueString = '" + POut.String(newValue) + "' " + "WHERE PrefName = '" + POut.String(prefName) + "'"; 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; pref.ValueString = newValue; Prefs.UpdateValueForKey(pref); return(retVal); }
///<summary>Used for prefs that are non-standard. Especially by outside programmers. Returns true if a change was required, or false if no change needed.</summary> public static bool UpdateRaw(string prefName, string newValue) { //Very unusual. Involves cache, so Meth is used further down instead of here at the top. if (!PrefC.Dict.ContainsKey(prefName)) { throw new ApplicationException(prefName + " is an invalid pref name."); } if (PrefC.GetRaw(prefName) == newValue) { return(false); //no change needed } string command = "UPDATE preference SET " + "ValueString = '" + POut.String(newValue) + "' " + "WHERE PrefName = '" + POut.String(prefName) + "'"; 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; pref.ValueString = newValue; PrefC.Dict[prefName] = pref; return(retVal); }
///<summary>Get metrics from serviceshq.</summary> public static EServiceMetrics CalculateMetrics(float accountBalanceEuro) { //No remoting role check, No call to database. DateTime dateTimeStart = DateTime.Today; DateTime dateTimeEnd = dateTimeStart.AddDays(1); List <string> websitesDown = PrefC.GetRaw("BroadcasterWebsitesToMonitor").Split(',') .Select(x => WebSiteIsAvailable(x)).ToList(); websitesDown.RemoveAll(x => string.IsNullOrEmpty(x.Trim())); EServiceMetrics ret = new EServiceMetrics() { Timestamp = DateTime.Now, AccountBalanceEuro = accountBalanceEuro, IsBroadcasterHeartbeatOk = GetIsBroadcasterHeartbeatOk(), WebsitesDown = string.Join("; ", websitesDown), IsValid = true, }; return(ret); }