Esempio n. 1
0
        public static List <Dictionary <string, string> > GetForecastInfo(string area)
        {
            List <Dictionary <string, string> > result = new List <Dictionary <string, string> >();

            try
            {
                WeatherForecast f = GetForecast(area);
                if (f.CNCityName != string.Empty)
                {
                    Dictionary <string, string> dict = new Dictionary <string, string>();
                    dict["Title"]       = f.CNCityName + "天气预报 " + DateTime.Now.ToString("yyyy年M月d日");
                    dict["Description"] = "";
                    dict["PicUrl"]      = "";
                    dict["Url"]         = "";
                    result.Add(dict);

                    dict          = new Dictionary <string, string>();
                    dict["Title"] = string.Format("{0}市今天天气情况如下:{1}日出,白天{2},{3}摄氏度,{4}{5};{6}日落,晚上{7},{8}摄氏度,{9}{10}。--发布时间[{11}]", f.CNCityName, f.SunriseTimeOne, WeatherForecast.GetWeatherCNByCode(f.DayWeatherCodeOne), f.DayTemperatureOne,
                                                  WeatherForecast.GetWindDirectionCNByCode(f.DayWindDirectionOne), WeatherForecast.GetWindForceCNByCode(f.DayWindForceOne), f.SunsetTimeOne, WeatherForecast.GetWeatherCNByCode(f.NightWeatherCodeOne), f.NightTemperatureOne, WeatherForecast.GetWindDirectionCNByCode(f.NightWindDirectionOne), WeatherForecast.GetWindForceCNByCode(f.NightWindForceOne), f.PublishTime.ToString("yyyy年MM月dd日-HH:mm:ss")).Replace(" ", "");
                    dict["Description"] = "";

                    if (int.Parse(DateTime.Now.ToString("HH")) < 6 || int.Parse(DateTime.Now.ToString("HH")) > 18)
                    {
                        dict["PicUrl"] = string.Format("http://demonlue.wicp.net/111/Images/Weather/Night/{0}.png", f.NightWeatherCodeOne);
                        //Log.WriteLog("晚上");
                    }
                    else //(int.Parse(DateTime.Now.ToString("HH")) > 6 && int.Parse(DateTime.Now.ToString("HH")) < 18)
                    {
                        dict["PicUrl"] = string.Format("http://demonlue.wicp.net/111/Images/Weather/Day/{0}.png", f.DayWeatherCodeOne);
                        //Log.WriteLog("白天");
                    }
                    Log.WriteLog(dict["PicUrl"]);
                    dict["Url"] = "";
                    result.Add(dict);
                }

                return(result);
            }
            catch (Exception ex)
            {
                Log.WriteDebug(ex.Message);
                return(result);
            }
        }