public async Task <string> downloadStockData() { DownloadModel downloadModel = new DownloadModel(); SysModel sysModel = new SysModel(); DateTime date = sysModel.getsysConfigstockUpdate(); string totalmsg = ""; while (date <= DateTime.Now) { string datetime = date.ToString("yyyy-MM-dd"); string msg = await downloadModel.DownloadStock(datetime); totalmsg += msg + "<br/>"; DateTime nextdate = date.AddDays(1); int count = sysModel.updatesysConfigstockUpdate(nextdate); date = nextdate; Thread.Sleep(5000); } return(totalmsg); }
public async Task <JsonResult> DownloadStockData() { bool status = true; string msg = ""; try { DownloadModel downloadModel = new DownloadModel(); SysModel sysModel = new SysModel(); DateTime date = sysModel.getsysConfigstockUpdate(); int count = 0; while (date <= DateTime.Now) { string datetime = date.ToString("yyyy-MM-dd"); string s = await downloadModel.DownloadStock(datetime); msg += s + "<br/>"; DateTime nextdate = date.AddDays(1); count = sysModel.updatesysConfigstockUpdate(nextdate); date = nextdate; Thread.Sleep(5000); } status = true; } catch (Exception e) { status = false; msg += e.Message; } return(Json(new Results <DBNull> { Success = status, Message = msg, Data = null, TotalCount = status ? 1 : 0 })); }