天气预报源码、包括从IP获取天气预报C#
标签:
•
文件类型: .rar
•
文件大小: 5.49MB
•
下载次数: 1
•
天气预报源码、包括从IP获取天气预报,具体教程http://www.cnblogs.com/ailiangwu/archive/2009/07/22/1528342.html
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 60416 2009-04-02 22:20 Flashado.WeatherinDebugFlashado.framework.dll
文件 165376 2009-04-02 22:20 Flashado.WeatherinDebugFlashado.framework.pdb
文件 132756 2009-04-02 22:20 Flashado.WeatherinDebugFlashado.framework.xml
文件 20480 2009-07-21 18:06 Flashado.WeatherinDebugFlashado.Weather.dll
文件 30208 2009-07-21 18:06 Flashado.WeatherinDebugFlashado.Weather.pdb
文件 7290 2009-07-21 18:06 Flashado.WeatherinDebugFlashado.Weather.xml
文件 20480 2006-12-16 00:23 Flashado.WeatherinDebugIPLocation.dll
文件 139264 2005-05-30 19:22 Flashado.WeatherinDebugSgmlReaderDll.dll
文件 4867 2009-07-21 16:41 Flashado.WeatherCity.cs
文件 863 2009-05-19 18:59 Flashado.WeatherCityxmlInfo.cs
文件 1243 2009-07-21 17:14 Flashado.WeatherExponential.cs
文件 3481 2009-07-20 10:12 Flashado.WeatherFlashado.Weather.csproj
文件 168 2009-07-21 16:05 Flashado.WeatherFlashado.Weather.csproj.user
文件 942 2009-07-21 18:06 Flashado.WeatherobjDebugFlashado.Weather.csproj.FileListAbsolute.txt
文件 20480 2009-07-21 18:06 Flashado.WeatherobjDebugFlashado.Weather.dll
文件 30208 2009-07-21 18:06 Flashado.WeatherobjDebugFlashado.Weather.pdb
文件 10240 2009-07-21 17:05 Flashado.WeatherobjDebugRefactorFlashado.Weather.dll
文件 1400 2009-05-05 18:17 Flashado.WeatherPropertiesAssemblyInfo.cs
文件 7882 2009-07-21 18:03 Flashado.WeatherWeather.cs
文件 900 2009-07-20 10:12 Flashado.WeatherWeatherSimple.cs
文件 2244 2009-07-20 10:12 Flashado.WeatherWeatherSimpleInfo.cs
文件 60416 2009-04-02 22:20 Flashado.Weather.WInForminDebugFlashado.framework.dll
文件 165376 2009-04-02 22:20 Flashado.Weather.WInForminDebugFlashado.framework.pdb
文件 132756 2009-04-02 22:20 Flashado.Weather.WInForminDebugFlashado.framework.xml
文件 20480 2009-07-21 18:06 Flashado.Weather.WInForminDebugFlashado.Weather.dll
文件 30208 2009-07-21 18:06 Flashado.Weather.WInForminDebugFlashado.Weather.pdb
文件 13824 2009-07-21 18:06 Flashado.Weather.WInForminDebugFlashado.Weather.WInForm.exe
文件 26112 2009-07-21 18:06 Flashado.Weather.WInForminDebugFlashado.Weather.WInForm.pdb
文件 14328 2009-07-22 08:50 Flashado.Weather.WInForminDebugFlashado.Weather.WInForm.vshost.exe
文件 490 2007-07-21 01:33 Flashado.Weather.WInForminDebugFlashado.Weather.WInForm.vshost.exe.manifest
............此处省略175个文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Regularexpressions;
using System.Net;
using System.xml;
using System.IO;
using Flashado.framework;
namespace Flashado.Weather
{
/// 城市类
public class City
{
private const string __Url = “http://www.weather.com.cn/data/listinfo/city{0}.xml“;
/// 名称
public string Name { get; set; }
/// ID
public string ID { get; set; }
/// 城市xml路径
public static string _CityxmlPath = “WeatherCity.xml“;
private static CityxmlInfo[] _Citys=null;
public static CityxmlInfo[] Default{
get{
if (_Citys == null)
{
_Citys = Load(Path.GetFullPath(_CityxmlPath));
}
return _Citys;
}
}
public override string ToString()
{
return this.Name;
}
/// 获取城市类的集合
/// 城市类
public static City[] GetList()
{
return GetList(string.Empty);
}
/// 获取城市类的集合
/// 城市Id
/// 城市类
public static City[] GetList(string id)
{
var url = string.Format(__Url id);
using (WebClient wc = new WebClient())
{
wc.Encoding = Encoding.UTF8;
string str = wc.DownloadString(url);
List citys = new List();
var cs = str.Split(‘‘);
foreach (var c in cs)
{
var carr = c.Split(‘|‘);
citys.Add(new City()
{
ID = carr[0]
Name = carr[1]
});
}
return citys.ToArray();
}
}
///
/// 获取城市代码
///
/// 城市名称
/// 城市代码
public static string GetCityCodeByName(string name){
var city=Default.FirstOrDefaultlInfo>(c=>c.Name==name);
if(city==null){
return string.Empty;
}
return city.Code;
}
private static string GetCityByIp(string regex string input)
{
var reg = new Regex(regex);
var match = reg.Matches(input);
if(match.Count==0){
return string.Empty;
}
return match[match.Count-1].Result(“$1“);
}
/// 更具IP获取城市代码
/// IP库地址
/// IP地址
/// 城市代码
public static string GetCityCodeByIp(string ipDataPathstring ip){
IPLocation.IPLocation.IPLocate(ipDataPathip);
var country = IPLocation.IPLocation.Country;
var regex = new Regex(“([^市省]+)市“);
var match=regex.Match(country);
var area=string.Empty;
var province = string.Empty;
var city = string.Empty;
var matCity = Regex.Matches(country “([^市省]+)市“);
var matArea = Regex.Matches(country “([^市省区]+)区“);
var matProvince = Regex.Matches(country “([^省]+)省“);
if(matArea.Count>0){
area = matArea[0].Result(“$1“);
}
if (matProvince.Count > 0
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 60416 2009-04-02 22:20 Flashado.WeatherinDebugFlashado.fr
文件 165376 2009-04-02 22:20 Flashado.WeatherinDebugFlashado.fr
文件 132756 2009-04-02 22:20 Flashado.WeatherinDebugFlashado.fr
文件 20480 2009-07-21 18:06 Flashado.WeatherinDebugFlashado.Weather.dll
文件 30208 2009-07-21 18:06 Flashado.WeatherinDebugFlashado.Weather.pdb
文件 7290 2009-07-21 18:06 Flashado.WeatherinDebugFlashado.Weather.xm
文件 20480 2006-12-16 00:23 Flashado.WeatherinDebugIPLocation.dll
文件 139264 2005-05-30 19:22 Flashado.WeatherinDebugSgmlReaderDll.dll
文件 4867 2009-07-21 16:41 Flashado.WeatherCity.cs
文件 863 2009-05-19 18:59 Flashado.WeatherCityxm
文件 1243 2009-07-21 17:14 Flashado.WeatherExponential.cs
文件 3481 2009-07-20 10:12 Flashado.WeatherFlashado.Weather.csproj
文件 168 2009-07-21 16:05 Flashado.WeatherFlashado.Weather.csproj.user
文件 942 2009-07-21 18:06 Flashado.WeatherobjDebugFlashado.Weather.csproj.FileListAbsolute.txt
文件 20480 2009-07-21 18:06 Flashado.WeatherobjDebugFlashado.Weather.dll
文件 30208 2009-07-21 18:06 Flashado.WeatherobjDebugFlashado.Weather.pdb
文件 10240 2009-07-21 17:05 Flashado.WeatherobjDebugRefactorFlashado.Weather.dll
文件 1400 2009-05-05 18:17 Flashado.WeatherPropertiesAssemblyInfo.cs
文件 7882 2009-07-21 18:03 Flashado.WeatherWeather.cs
文件 900 2009-07-20 10:12 Flashado.WeatherWeatherSimple.cs
文件 2244 2009-07-20 10:12 Flashado.WeatherWeatherSimpleInfo.cs
文件 60416 2009-04-02 22:20 Flashado.Weather.WInForminDebugFlashado.fr
文件 165376 2009-04-02 22:20 Flashado.Weather.WInForminDebugFlashado.fr
文件 132756 2009-04-02 22:20 Flashado.Weather.WInForminDebugFlashado.fr
文件 20480 2009-07-21 18:06 Flashado.Weather.WInForminDebugFlashado.Weather.dll
文件 30208 2009-07-21 18:06 Flashado.Weather.WInForminDebugFlashado.Weather.pdb
文件 13824 2009-07-21 18:06 Flashado.Weather.WInForminDebugFlashado.Weather.WInForm.exe
文件 26112 2009-07-21 18:06 Flashado.Weather.WInForminDebugFlashado.Weather.WInForm.pdb
文件 14328 2009-07-22 08:50 Flashado.Weather.WInForminDebugFlashado.Weather.WInForm.vshost.exe
文件 490 2007-07-21 01:33 Flashado.Weather.WInForminDebugFlashado.Weather.WInForm.vshost.exe.manifest
............此处省略175个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)