Exemple #1
0
        private bool UpgradeTheCar(CarInfo oldcar, NewCarInfo newcar)
        {
            try
            {
                if (oldcar.CarName == newcar.CarName)
                    return false;

                SetMessageLn(string.Format("=>被换购的汽车:{0}({1})", oldcar.CarName, oldcar.CarPrice));
                string param = string.Format("verify={0}&carid={1}&color={2}&oldcarid={3}&interval={4}", new object[] { this._verifyCode, newcar.CarId, DataConvert.GetInt32(newcar.CarColor), oldcar.CarId, oldcar.CarPrice - newcar.CarPrice });
                string query = "";
                HH.DelayedTime = Constants.DELAY_2SECONDS;
                HH.Post("http://www.kaixin001.com/parking/updatecar.php", ref query, param);
                string content = HH.Get(string.Format("http://www.kaixin001.com/parking/updatecar.php{0}", query));
                if (GetBuildTeamFeedback(content))
                {
                    _parkcash -= newcar.CarPrice - oldcar.CarPrice;
                    _carprice += newcar.CarPrice - oldcar.CarPrice;
                    oldcar.CarId = newcar.CarId;
                    oldcar.CarName = newcar.CarName;
                    oldcar.CarPrice = newcar.CarPrice;
                    return true;
                }
                if (query.Contains("action=3"))
                    this._outofmoney = true;
                return false;
            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (ThreadInterruptedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                LogHelper.Write("GamePark.UpgradeTheCar", ex, LogSeverity.Error);
                SetMessage("升级汽车失败!错误:" + ex.Message);
                return false;
            }
        }
Exemple #2
0
        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 }));
            }
        }
Exemple #3
0
 private bool BuyTheCar(NewCarInfo newcar)
 {
     try
     {
         string query = "";
         HH.DelayedTime = Constants.DELAY_1SECONDS;                
         //HH.Post("http://www.kaixin001.com/!parking/purchase.php", ref query, string.Format("verify={0}&carid={1}&color={2}", this._verifyCode, newcar.CarId, DataConvert.GetInt32(newcar.CarColor)));
         //string content = HH.Get(string.Format("http://www.kaixin001.com/parking/purchase.php{0}", query));
         string content = HH.Post("http://www.kaixin001.com/!parking/purchase.php", ref query, string.Format("verify={0}&carid={1}&color={2}", this._verifyCode, newcar.CarId, DataConvert.GetInt32(newcar.CarColor)));
         //<script language="JavaScript">
         //window.location="/!parking/!purchase.php?action=2&carid=28&color=16776960";
         //</script>
         string navigationurl = JsonHelper.GetMid(content, "window.location=\"/", "\";");
         content = HH.Get(string.Format("http://www.kaixin001.com/{0}", navigationurl));
         if (PrintBuyFeedback(content))
         {
             _parkcash -= newcar.CarPrice;
             _carprice += newcar.CarPrice;
             CarInfo oldcar = new CarInfo();
             oldcar.CarId = newcar.CarId;
             oldcar.CarName = newcar.CarName;
             oldcar.CarPrice = newcar.CarPrice;
             oldcar.CarColor = newcar.CarColor;
             _carList.Add(oldcar);
             return true;
         }
         return false;
     }
     catch (ThreadAbortException)
     {
         throw;
     }
     catch (ThreadInterruptedException)
     {
         throw;
     }
     catch (Exception ex)
     {
         LogHelper.Write("GamePark.BuyTheCar", ex, LogSeverity.Error);
         SetMessage("购买新车失败!错误:" + ex.Message);
         return false;
     }
 }