private void ReadCars(string content, bool printMessage) { if (printMessage) SetMessageLn("读取汽车信息:"); string strMyCars = JsonHelper.GetMid(content, "v_userdata = ", "\n"); if (strMyCars != null) { this._seatList.Clear(); this._carList.Clear(); JsonTextParser parser = new JsonTextParser(); JsonObjectCollection objects = parser.Parse(strMyCars) as JsonObjectCollection; //我的信息 JsonObjectCollection myself = objects["user"] as JsonObjectCollection; int uid = JsonHelper.GetIntegerValue(myself["uid"]); string realname = JsonHelper.GetStringValue(myself["real_name"]); this._parkcash = JsonHelper.GetIntegerValue(myself["cash"]); //我的车位 JsonArrayCollection seatlist = objects["parking"] as JsonArrayCollection; foreach (JsonObjectCollection item in seatlist) { SeatInfo seat = new SeatInfo(); seat.ParkId = JsonHelper.GetIntegerValue(item["parkid"]); seat.CarId = JsonHelper.GetIntegerValue(item["carid"]); seat.CarName = JsonHelper.GetStringValue(item["car_name"]); seat.CarOwnerId = JsonHelper.GetIntegerValue(item["car_uid"]); seat.CarOwnerName = JsonHelper.GetStringValue(item["car_real_name"]); seat.CarProfit = JsonHelper.GetIntegerValue(item["car_profit"]); seat.CarPrice = JsonHelper.GetIntegerValue(item["car_price"]); this._seatList.Add(seat); } //我的汽车 _carprice = 0; JsonArrayCollection carlist = objects["car"] as JsonArrayCollection; foreach (JsonObjectCollection item in carlist) { CarInfo car = new CarInfo(); car.CarId = JsonHelper.GetIntegerValue(item["carid"]); car.CarName = JsonHelper.GetStringValue(item["car_name"]); car.CarPrice = JsonHelper.GetIntegerValue(item["price"]); car.Profit = JsonHelper.GetIntegerValue(item["park_profit"]); car.ParkingMinutes = JsonHelper.GetIntegerValue(item["park_profit"]) / JsonHelper.GetIntegerValue(item["park_moneyminute"]); car.ParkUserId = JsonHelper.GetIntegerValue(item["park_uid"]); car.ParkUserName = JsonHelper.GetStringValue(item["park_real_name"]); car.CarColor = GetCarColor(JsonHelper.GetStringValue(item["car_logo_big"])); string profitPerMin = JsonHelper.GetStringValue(item["park_moneyminute"]); car.IsPosted = null == profitPerMin; _carprice += JsonHelper.GetIntegerValue(item["price"]); this._carList.Add(car); } if (printMessage) SetMessageLn(string.Format("{0}({1}) 现金:{2} 车价:{3} 总价:{4}", new object[] { realname, uid, _parkcash, _carprice, _parkcash + _carprice })); } }
private string BuildSeatInfo(SeatInfo seat, ref bool isFree) { string message; if (IsFreeSeat(seat.ParkId)) { message = " 我的车位#{0}: 免费车位 "; isFree = true; } else { message = " 我的车位#{0}: 收费车位 "; isFree = false; } if (seat.CarId <= 0) { message += "空闲"; } else { message += string.Format("{0} 的 {1} (收入{2}元) ", new object[] { seat.CarOwnerName, seat.CarName, seat.CarProfit }); } return message; }