Пример #1
0
        private void button17_Click(object sender, EventArgs e)
        {

            var symbol = "SCR";
            var redis = new RedisClient(ConfigRedis.Host, ConfigRedis.Port);
            var sql = new SqlDb();
            var test = redis.Get<TienDoBDS>(string.Format(RedisKey.BDSKey, "SCR_07"));

            //var ls = redis.Get<List<TienDoBDS>>(key) ?? new List<TienDoBDS>();
            var ldt = sql.GetLandProject(symbol);
            var adt = sql.GetLandProject_Area(symbol);
            var pdt = sql.GetLandProject_Profit(symbol);
            foreach (DataRow ldr in ldt.Rows)
            {
                var key = string.Format(RedisKey.BDSKey, ldr["MaTienDo"].ToString());
                var o = new TienDoBDS() { MaCK = ldr["MaCK"].ToString(), MaTienDo = ldr["MaTienDo"].ToString(), TenDuAn = ldr["TenDuAn"].ToString(), HinhThucKinhDoanh = ldr["HinhThucKinhDoanh"].ToString(), DiaDiem = ldr["DiaDiem"].ToString(), ThanhPho = ldr["ThanhPho"].ToString(), TongVon = decimal.Parse(ldr["TongVon"].ToString()), Donvi = ldr["Donvi"].ToString(), TyLeGhopVon = ldr["TyLeGhopVon"].ToString(), TyLeDenBu = ldr["TyLeDenBu"].ToString(), GhiChu = ldr["GhiChu"].ToString(), MoTa = ldr["Mota"].ToString(), URL = ldr["URL"].ToString(), ID = int.Parse(ldr["ID"].ToString()), BDSImages = GetLandImages(ldr["MaTienDo"].ToString()) };
                DateTime d;
                if (DateTime.TryParse(ldr["ViewDate"].ToString(), out d))
                {
                    o.ViewDate = d;      
                }
              
                var adrs = adt.Select("MaTienDo='" + o.MaTienDo + "'");
                var als = new List<TienDoBDSDienTich>();
                foreach(var adr in adrs)
                {
                    als.Add(new TienDoBDSDienTich(){MaTienDo = o.MaTienDo, DienTich = decimal.Parse(adr["DienTich"].ToString()), LoaiDienTich = adr["LoaiDienTich"].ToString()});
                }
                o.DienTichs = als;

                var pdrs = pdt.Select("MaTienDo='" + o.MaTienDo + "'");
                var pls = new List<TienDoBDSLoiNhuan>();
                foreach (var pdr in pdrs)
                {
                    pls.Add(new TienDoBDSLoiNhuan() { MaTienDo = o.MaTienDo, LoiNhuanDoanhThu = decimal.Parse(pdr["LoiNhuanDoanhThu"].ToString()), LoaiLoiNhuan = pdr["LoaiLoiNhuan"].ToString() });
                }
                o.LoiNhuans = pls;

                if (redis.ContainsKey(key))
                    redis.Set(key, o);
                else
                    redis.Add(key, o);

                //ls.Add(o);
            }

            var a = 0;
        }