/// <summary> /// 获取密码 /// </summary> public void GetPassWord() { string token = HttpWebPost.Request("http://116.247.83.157/StandardApiAction_login.action?account=gz&password=000000", false, ""); JObject tokenjson = (JObject)JsonConvert.DeserializeObject(token); jsession = tokenjson["jsession"].ToString(); }
public void GetGPS() { while (true) { QW_CarsBLL bll = new QW_CarsBLL(); List <QW_CarsModel> listCar = bll.GetCars().Where(a => !string.IsNullOrEmpty(a.remarks)).ToList(); foreach (QW_CarsModel item in listCar) { string url = string.Format(@"http://116.247.83.157/StandardApiAction_getDeviceStatus.action?jsession={0}&devIdno={1}&toMap=2", jsession, item.cartel); string Tracking = HttpWebPost.Request(url, false, ""); // 反序列化json JavaScriptSerializer jss = new JavaScriptSerializer(); JObject Trackingjson = (JObject)JsonConvert.DeserializeObject(Tracking); string result = Trackingjson["result"] == null ? "" : Trackingjson["result"].ToString(); if (result == "0") { string status = Trackingjson["status"] == null ? "" : Trackingjson["status"].ToString(); if (!string.IsNullOrEmpty(status)) { JArray jo = new JArray(); jo = (JArray)JsonConvert.DeserializeObject(status); foreach (JObject array in jo) { QW_CarHistoryPositionsModel model = new QW_CarHistoryPositionsModel(); model.carid = item.carid; model.cartel = item.cartel; model.isanalyze = 0; model.lc = array["lc"] == null ? 0 : Convert.ToDouble(array["lc"].ToString()); model.pk = array["pk"] == null ? 0 : Convert.ToInt32(array["pk"].ToString()); model.positiontime = array["gt"] == null ? DateTime.Now : Convert.ToDateTime(array["gt"].ToString()); model.speed = array["sp"] == null ? 0 : Convert.ToDecimal(array["sp"].ToString()); model.x84 = array["mlng"] == null ? 0 : Convert.ToDecimal(array["mlng"].ToString()); model.y84 = array["mlat"] == null ? 0 : Convert.ToDecimal(array["mlat"].ToString()); model.yl = array["yl"] == null ? 0 : Convert.ToDouble(array["yl"].ToString()); DateTime dt = model.positiontime; bool his = bll.GetBoolCarPostiton(item.carid, dt); if (!his) { bll.CarHistoryPositions(model); } bll.UpdateLastPosition(item.carid, dt, model); Console.WriteLine("车辆:" + item.carnumber + "---PositionTime:" + dt.ToString("yyyy-MM-dd hh:mm:ss")); } } } else { GetPassWord(); break; } } System.Threading.Thread.Sleep(20000); } }
public void GetAllListEvent() { try { while (true) { QW_CarsDAL cardal = new QW_CarsDAL(); string url = "http://116.247.83.157/StandardApiAction_queryUserVehicle.action?jsession=" + jsession; string Tracking = HttpWebPost.Request(url, false, ""); // 反序列化json JavaScriptSerializer jss = new JavaScriptSerializer(); JObject Trackingjson = (JObject)JsonConvert.DeserializeObject(Tracking); if (Trackingjson["result"].ToString() == "7") { GetPassWord(); } else if (Trackingjson["result"].ToString() == "3") { GetPassWord(); } else if (Trackingjson["result"].ToString() == "4") { GetPassWord(); } else { List <CarSynchronizeModel> TrackingList = jss.Deserialize <List <CarSynchronizeModel> >(Trackingjson["vehicles"].ToString()); foreach (CarSynchronizeModel item in TrackingList) { QW_CarsModel qcar = new QW_CarsModel(); if (!string.IsNullOrEmpty(item.nm)) { string[] nms = item.nm.Split('-'); switch (nms[0]) { case "高": qcar.unitid = 12; break; } switch (nms[1]) { case "扫": qcar.cartypeid = "4"; break; case "洒": qcar.cartypeid = "5"; break; case "压": qcar.cartypeid = "3"; break; } qcar.carnumber = nms[2]; } qcar.code = item.id.ToString(); qcar.cartel = item.dl[0].id; qcar.isonline = 1; qcar.createuserid = 1; qcar.createtime = DateTime.Now; qcar.status = 0; qcar.carstatus = 0; qcar.remarks = item.nm; cardal.AddCar(qcar); } } } } catch (Exception) { throw; } }