try
{
WebClient client = new WebClient();
client.Encoding = Encoding.UTF8;
string datas;
string GetZCS = HttpRuntime.Cache.Get("GetZCS_htmlStr") == null ? "" : HttpRuntime.Cache.Get("GetZCS_htmlStr").ToString ();
if (GetZCS != "")
{
datas = GetZCS;
}
else
{
datas = client.DownloadString(Config.Kzr_Url);
HttpRuntime.Cache.Insert("GetZCS_htmlStr", datas, null, DateTime.Now.AddHours(1), TimeSpan.Zero);
}
if (!String.IsNullOrEmpty(datas))
{
var Data = JsonHelper.Deserialize<Dictionary<string, object>>(datas);
var List = new List<Dictionary<string, object>>();
if (Data == null || Data["Datas"] == null)
List = JsonHelper.Deserialize<List<Dictionary<string, object>>>(datas);
else
List = JsonHelper.Deserialize<List<Dictionary<string, object>>>(JsonHelper.Serialize(Data["Datas"]));
foreach (Dictionary<string, object> item in List)
{
if (List.IndexOf(item) == 0)
{
kzr_FullName = (string)item["FundName"];
kzr_Rate = ((decimal)item["Rate"]).ToString();
kzr_Period = (item["Period"]).ToString();
kzr_MinRgAppend = Math.Ceiling(((decimal)item["minRgAppend"])).ToString();
}
}
if (List == null)
{
List = new List<Dictionary<string, object>>();
}
//Rmjj_DicResult.Add("Rmjj", List);
}
}
catch (Exception ex)
{
}
通过http cache来避免频繁调用接口
最新推荐文章于 2022-08-24 16:06:32 发布