public JsonResult UpdateRate() { try { cn.com.webxml.webservice.ForexRmbRateWebService server = new cn.com.webxml.webservice.ForexRmbRateWebService(); DataSet ds = server.getForexRmbRate(); foreach (DataRow dr in ds.Tables[0].Rows) { CurrencyType c = new CurrencyType(); c.CurrencyCode = dr["Symbol"].ToString(); c.CurrencyName = dr["Name"].ToString(); NSession.Delete(" from CurrencyType where CurrencyCode='" + c.CurrencyCode + "'"); NSession.Flush(); c.CurrencySign = ""; string str = dr["fBuyPrice"].ToString(); if (string.IsNullOrEmpty(str)) { str = "0"; } c.CurrencyValue = Math.Round(Convert.ToDecimal(str) / 100, 5); c.CreateOn = DateTime.Now;; NSession.Save(c); } } catch (Exception ee) { return(Json(new { IsSuccess = false, ErrorMsg = "出错了" })); } return(Json(new { IsSuccess = true })); }
public JsonResult UpdateRate() { try { cn.com.webxml.webservice.ForexRmbRateWebService server = new cn.com.webxml.webservice.ForexRmbRateWebService(); DataSet ds = server.getForexRmbRate(); foreach (DataRow dr in ds.Tables[0].Rows) { CurrencyType c = new CurrencyType(); c.CurrencyCode = dr["Symbol"].ToString(); c.CurrencyName = dr["Name"].ToString(); NSession.Delete(" from CurrencyType where CurrencyCode='" + c.CurrencyCode + "'"); NSession.Flush(); c.CurrencySign = ""; string str = dr["fBuyPrice"].ToString(); if (string.IsNullOrEmpty(str)) { str = "0"; } c.CurrencyValue = Math.Round(Convert.ToDecimal(str) / 100, 5); c.CreateOn = DateTime.Now; ; NSession.Save(c); } } catch (Exception ee) { return Json(new { IsSuccess = false, ErrorMsg = "出错了" }); } return Json(new { IsSuccess = true }); }