Esempio n. 1
0
        public async Task <MyfundPageView> GetPageList(MyfundParm parm)
        {
            return(await WithConnection(async c =>
            {
                StringBuilder sql = new StringBuilder();
                sql.Append($@"  SELECT 
                id,
                code,
                name,
                balance,
                costavg,
                networth,
                totalworth,
                worthdate,expectgrowth,
                daygrowth,updatetime FROM myfund
                 ");
                StringBuilder whereSql = new StringBuilder();


                sql.Append(whereSql);

                var data = await c.QueryAsync <Myfund>(sql.ToString());
                var total = data.ToList().Count;
                sql.Append(" order by " + parm.sort + " " + parm.order)
                .Append(" limit " + (parm.page - 1) * parm.rows + "," + parm.rows);
                var ets = await c.QueryAsync <Myfund>(sql.ToString());

                MyfundPageView ret = new MyfundPageView();
                ret.rows = ets.ToList();
                ret.total = total;
                return ret;
            }));
        }
Esempio n. 2
0
 public Task Execute(IJobExecutionContext context)
 {
     return(Task.Run(() =>
     {
         Console.WriteLine(DateTime.Now);
         string codes = string.Empty;
         MyfundParm parm = new MyfundParm()
         {
             page = 1, rows = 1000, sort = "id", order = "asc"
         };
         var data = _repo.GetPageList(parm).Result;
         //foreach (var d in data.rows)
         //{
         //    codes += d.Code + ",";
         //}
         //string url = "https://api.doctorxiong.club/v1/fund?code=" + codes;
         //FundRetComm response = HttpClientHelper.GetResponse<FundRetComm>(url);
         foreach (var d in data.rows)
         {
             try
             {
                 //string url = "https://api.doctorxiong.club/v1/fund?code=" + d.Code;
                 //FundRetComm response = HttpClientHelper.GetResponse<FundRetComm>(url);
                 string url = $@"https://fundmobapi.eastmoney.com/FundMApi/FundValuationDetail.ashx?FCODE=" + d.Code + "&deviceid=Wap&plat=Wap&product=EFund&version=2.0.0&Uid=9572315881384690&_=" + MathHelper.GetTimeStamp();
                 Root2 response = HttpClientHelper.GetResponse <Root2>(url);
                 if (response.ErrCode == 0)
                 {
                     var cur = response.Datas[0];
                     if (cur != null)
                     {
                         if (!string.IsNullOrEmpty(cur.gszzl))
                         {
                             _repo.UpdateExpectGrowth(new Myfund()
                             {
                                 Id = d.Id, ExpectGrowth = decimal.Parse(cur.gszzl)
                             });
                         }
                     }
                 }
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.ToString());
             }
         }
     }));
 }
Esempio n. 3
0
        public async Task <ActionResult <ApiResult> > GetPageList([FromQuery] MyfundParm parm)
        {
            ApiResult ret = new ApiResult {
                code = Code.Failure
            };

            try
            {
                ret = await _service.GetPageList(parm);
            }
            catch (System.Exception ex)
            {
                ret.msg = string.Format(
                    "获取分页数据Myfund失败, 异常信息:{0}",
                    ex.Message);
            }
            return(ret);
        }