Esempio n. 1
0
        public async Task <JsonResult> DownloadOtcData()
        {
            bool   status = true;
            string msg    = "";

            try
            {
                DownloadModel downloadModel = new DownloadModel();
                SysModel      sysModel      = new SysModel();

                DateTime date = sysModel.getsysConfigotcUpdate();

                int count = 0;
                while (date <= DateTime.Now)
                {
                    DateTime taiwandatetime = date.AddYears(-1911);
                    string   datetime       = taiwandatetime.ToString("yyyy/MM/dd");
                    string   s = await downloadModel.DownloadOtc(datetime);

                    msg += s + "<br/>";
                    DateTime nextdate = date.AddDays(1);
                    count = sysModel.updatesysConfigotcUpdate(nextdate);
                    date  = nextdate;
                    Thread.Sleep(5000);
                }
            }
            catch (Exception e)
            {
                status = false;
                msg   += e.Message;
            }

            return(Json(new Results <DBNull>
            {
                Success = status,
                Message = msg,
                Data = null,
                TotalCount = status ? 1 : 0
            }));
        }
        public async Task <string> downloadOtcData()
        {
            DownloadModel downloadModel = new DownloadModel();
            SysModel      sysModel      = new SysModel();

            DateTime date     = sysModel.getsysConfigotcUpdate();
            string   totalmsg = "";

            while (date <= DateTime.Now)
            {
                DateTime taiwandatetime = date.AddYears(-1911);
                string   datetime       = taiwandatetime.ToString("yyyy/MM/dd");
                string   msg            = await downloadModel.DownloadOtc(datetime);

                totalmsg += msg + "<br/>";
                DateTime nextdate = date.AddDays(1);
                int      count    = sysModel.updatesysConfigotcUpdate(nextdate);
                date = nextdate;
                Thread.Sleep(5000);
            }
            return(totalmsg);
        }