基本信息
源码名称:C#通过webservice获取天气预报 例子源码下载
源码大小:0.21M
文件格式:.zip
开发语言:C#
更新时间:2015-05-06
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 1 元×
微信扫码支付:1 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
webservice网址是 <add key="cn.com.webxml.WeatherWebService" value="http://www.webxml.com.cn/WebServices/WeatherWebService.asmx"/>
webservice网址是 <add key="cn.com.webxml.WeatherWebService" value="http://www.webxml.com.cn/WebServices/WeatherWebService.asmx"/>
Imports Microsoft.VisualBasic
Imports cn.com.webxml
Public Class WeatherClass
Public Shared Function getDataSet() As DataSet
Dim ds As DataSet = CType(HttpContext.Current.Cache("dataSetCache"), DataSet)
If ds Is Nothing Then '判断缓存
Dim weather As WeatherWebService = New WeatherWebService()
ds = weather.getSupportDataSet()
HttpContext.Current.Cache.Insert("dataSetCache", ds, Nothing, DateTime.Now.AddHours(12), _
TimeSpan.Zero, CacheItemPriority.High, Nothing) '添加Cache缓存数据提高速度
End If
Return ds
End Function
Public Shared Function getCityWeather(ByVal cityCode As String) As String()
Dim cacheName As String = "weather" & cityCode.Trim()
Dim weatherArray() As String = CType(HttpContext.Current.Cache(cacheName), String())
If weatherArray Is Nothing Then
Dim weather As WeatherWebService = New WeatherWebService()
weatherArray = weather.getWeatherbyCityName(cityCode)
HttpContext.Current.Cache.Insert(cacheName, weatherArray, Nothing, DateTime.Now.AddMinutes(90), _
TimeSpan.Zero, CacheItemPriority.High, Nothing) '添加Cache缓存数据提高速度
End If
Return weatherArray
End Function
End Class