Exemplo n.º 1
0
        private TodayPrice Download(string id)
        {
            TodayPrice todayPrice;

            try
            {
                Tick tick = DownloadIt(id);
                if (tick == null)
                {
                    return(null);
                }
                if (tick.Ticker != id)
                {
                    //Just a threadsafe?? control clause
                    //throw new Exception("The returned ticker doesn't match the specified in the request, maybe a crossthread issue");
                    return(new TodayPrice());
                }

                todayPrice = new TodayPrice()
                {
                    Ticker = id,
                    Last   = tick.Price,
                    Open   = tick.Open
                };
            }
            catch (Exception exception)
            {
                Console.WriteLine(string.Format("download error;err:{0}", exception.Message));
                return(new TodayPrice());
            }
            return(todayPrice);
        }
Exemplo n.º 2
0
        private List <T> GetToDayPrice(List <HouseInfoView> houseInfoView = null)
        {
            CustomDAL customDAL = new CustomDAL();
            DateTime  dtm       = Convert.ToDateTime(GetNetDateTime());//获取网络时间
            string    date      = dtm.ToString("yyyy-MM-dd");

            houseInfoView.ForEach(x =>
            {
                TodayPrice todayPrice = customDAL.GetTodayPrice <TodayPrice>(x.ID, date).FirstOrDefault();
                if (todayPrice != null)
                {
                    x.Price = todayPrice.todayprice;
                }
            });

            return(houseInfoView as List <T>);
        }