public bool IsRiskWeather(OWMCurWeather curWeather) { SwitcherDisableLog(); #if RiskRangeEnabled return(this.IsRiskWeather(curWeather.Weather.Value) || this.IsRiskTemperature(curWeather.Temperature.Value)); #else return(true); #endif }
CheckerResult CheckChineseSpecialFogWeather(OWMCurWeather obj) { if (!obj.Weather.Value.Contains("雾")) { return(CheckerResult.Init); } const int FogThreadholdVal = 140; return(CheckSpecialStationAQI(FogThreadholdVal)); }
public override bool Equals(object obj) { OWMCurWeather newObj = obj as OWMCurWeather; if (newObj != null) { return(newObj.City.Name == this.City.Name && newObj.Weather.ToString() == this.Weather.ToString() && newObj.Temperature.RoughlyEqual(this.Temperature)); } return(base.Equals(obj)); }
CheckerResult CheckCurrentWeatherInfo() { FeitionPoster poster = new FeitionPoster(this.ReceiverMan.FeitionAccount); OWMCurWeather record = null; try { OWMWebRequest <OWMCurWeather> req = new OWMWebRequest <OWMCurWeather>( OWMPublic.OWMRequest(OWMRequestKind.CurrentWeather), this.ReceiverMan.Location.OWM.CityID, this.ReceiverMan.Location.OWM.CityName); req.Coordinary = this.ReceiverMan.Location.OWM.Coordinary; req.Language = "zh_cn"; record = req.GetResponse(); } catch (Exception ex) { CheckerLogWrite(string.Format("CheckCurrentWeatherInfo: {0}", ex.ToString())); } if (record == null) { CheckerLogWrite("OWMWebRequest<OWMCurWeather>:GetResponse returns null."); return(CheckerResult.NetworkIssue); } if (HRWNRiskDefinition.Instance.IsRiskWeather(record)) { // Maybe the fog weather is fake if there is. CheckerResult cResult = CheckChineseSpecialFogWeather(record); switch (cResult) { case CheckerResult.Sent: case CheckerResult.Existing: case CheckerResult.IsNotRisk: { CheckerLogWrite("Current Weather: This is a chinese fake fog, report AQI successfully instead."); // and we just regard it as a good check process is done. return(CheckerResult.Sent); } case CheckerResult.NetworkIssue: case CheckerResult.DataIssue: { CheckerLogWrite("Current Weather: Not sure whether this is a chinese fake fog as it failed to get AQI data."); // and we just regard it as a good check process is done. return(CheckerResult.Sent); } } string str = record.GetReadableText(this.ReceiverMan.Location.OWM.CityNickName); poster.AppendMessage(str); bool fExist = curWeatherHistoryList.Exists(record); if (fExist) { //ConsoleMe.WriteLine("Existing current weather: {0}.", record.ToString()); CheckerLogWrite("Existing current weather."); return(CheckerResult.Existing); } bool status = poster.Send(); if (!fExist && status) { curWeatherHistoryList.Add(record); } poster.ResetMessage(); return(CheckerResult.Sent); } else { CheckerLogWrite("OWMCurWeather: isn't a risk."); return(CheckerResult.IsNotRisk); } }