public ApiResp Execute(System.Collections.Hashtable params_ht) { ApiResp resp = new ApiResp(); resp.code = "-1"; string client_id = params_ht["client_id"].ToString(); long timestamp = long.Parse(params_ht["timestamp"].ToString()); string sign = params_ht["sign"].ToString(); string batch_order_no = params_ht["batch_order_no"].ToString(); List <GetBatchOrderState_Item> data = new List <GetBatchOrderState_Item>(); if (!string.IsNullOrEmpty(batch_order_no)) { foreach (string order_no in batch_order_no.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)) { GetBatchOrderState_Item item = GetOrderState(order_no); if (item != null) { data.Add(item); } } resp.data = data; resp.code = "0"; } else { resp.msg = "订单号未填写"; resp.code = "-1"; } return(resp); }
public ApiResp Execute(System.Collections.Hashtable params_ht) { ApiResp resp = new ApiResp(); try { string jsonData = params_ht["json"].ToString(); dynamic jsonObj = DynamicJson.Parse(jsonData); string imei = ""; if (jsonObj.IsDefined("imei")) { imei = jsonObj.imei; } string type = ""; if (jsonObj.IsDefined("type")) { type = jsonObj.type; } Logger.Debug("上下线通知:" + imei + ",参数:" + jsonData); resp.Code = "0"; return(resp); } catch { resp.Code = "1"; return(resp); } }
public ApiResp Execute(System.Collections.Hashtable params_ht) { ApiResp resp = new ApiResp(); resp.code = "-1"; string client_id = params_ht["client_id"].ToString(); long timestamp = long.Parse(params_ht["timestamp"].ToString()); string sign = params_ht["sign"].ToString(); List <GetCompanyInfo_Item> data = new List <GetCompanyInfo_Item>(); GetCompanyInfo_Item item = new GetCompanyInfo_Item(); SysSettingManager settingManager = new SysSettingManager(); DictManager dictManager = new DictManager(); item.insurance_amount = 0.00; item.insurance_url = ""; item.return_in_fee = ""; string outServiceAreaFee = settingManager.GetValueByKey("OutServiceAreaFee"); if (outServiceAreaFee.StartsWith("+")) { item.return_out_fee = string.Format("超出运营区域将加收{0}元调度费", outServiceAreaFee.Substring(1, outServiceAreaFee.Length - 1)); } else { item.return_out_fee = string.Format("超出运营区域将加收{0}倍作为调度费", outServiceAreaFee.Substring(1, outServiceAreaFee.Length - 1)); } item.call_tel = settingManager.GetValueByKey("ServiceTel"); DataTable city_dt = dictManager.GetDictList("03"); string open_city = ""; if (city_dt != null && city_dt.Rows.Count > 0) { foreach (DataRow dr in city_dt.Rows) { if (open_city.Length > 0 && !open_city.EndsWith("|")) { open_city += "|"; } open_city += dr["Name"].ToString(); } } item.open_city = open_city; item.timestamp = (long)(DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds; data.Add(item); resp.code = "0"; resp.msg = "成功"; resp.data = data; return(resp); }
public void ProcessRequest(HttpContext context) { context.Response.CacheControl = "no-cache"; context.Response.AddHeader("Pragma", "no-cache"); context.Response.ContentType = "text/plain"; string clientData = ""; try { if (context.Request.HttpMethod.ToLower() != "post") { throw new Exception("调用方式错误"); } var reader = new System.IO.StreamReader(context.Request.InputStream); clientData = reader.ReadToEnd(); reader.Close(); if (!string.IsNullOrEmpty(clientData)) { clientData = clientData.Trim(); string cmd = ""; dynamic jsonObj = DynamicJson.Parse(clientData); if (jsonObj.IsDefined("cmd")) { cmd = jsonObj.cmd; } Assembly assembly = Assembly.GetExecutingAssembly(); string typeName = cmd.Substring(0, 1).ToUpper() + cmd.Substring(1, cmd.Length - 1) + "Action"; object obj = assembly.CreateInstance("YR.Web.api.xacloud.service." + typeName); IApiAction action = (IApiAction)obj; //调用相对应的接口方法 Hashtable args_ht = new Hashtable(); args_ht["json"] = clientData; ApiResp result = action.Execute(args_ht); Logger.Info("小安盒子接口网关上报数据," + result.Code + ",访问ip:" + context.Request.UserHostAddress + ",参数:" + clientData + ",返回值:" + JsonConvert.SerializeObject(result)); context.Response.Write(JsonConvert.SerializeObject(result)); } else { Logger.Error("小安盒子接口网关上报数据失败,请求参数为空"); throw new Exception("请求参数为空"); } } catch (Exception e) { ApiResp result = new ApiResp(); result.Code = "-1"; result.Message = e.Message; Logger.Error("小安盒子接口网关上报数据失败,访问ip:" + context.Request.UserHostAddress + ",参数:" + clientData + ",异常:" + e); context.Response.Write(JsonConvert.SerializeObject(result)); } }
private void GetCupInfo(HttpContext context) { SystemInfo sys = new SystemInfo(); const int GB_DIV = 1024 * 1024 * 1024; double cpu = Math.Round(sys.CpuLoad, 2); decimal memory = Math.Round((decimal)(sys.PhysicalMemory - sys.MemoryAvailable) / sys.PhysicalMemory, 2) * 100; string useInfo = string.Format("系统CPU使用率:{0}%,系统内存使用大小:{1}GB,{2}%", Math.Round(sys.CpuLoad, 2), Math.Round((sys.PhysicalMemory - sys.MemoryAvailable) / (double)GB_DIV, 2), memory); ApiResp resp = new ApiResp(); resp.Code = "0"; resp.Message = useInfo; context.Response.Write(JsonConvert.SerializeObject(resp)); }
public ApiResp Execute(System.Collections.Hashtable params_ht) { ApiResp resp = new ApiResp(); resp.code = "-1"; string client_id = params_ht["client_id"].ToString(); long timestamp = long.Parse(params_ht["timestamp"].ToString()); string sign = params_ht["sign"].ToString(); string order_no = params_ht["order_no"].ToString(); string mobile = params_ht["mobile"].ToString(); string money = params_ht["money"].ToString(); long paytime = long.Parse(params_ht["paytime"].ToString()); bool result = false; BaoJiaManager mgr = new BaoJiaManager(); Hashtable order_ht = mgr.GetOrderInfo(order_no); if (order_ht != null && order_ht.Keys.Count > 0) { string pay_state = SiteHelper.GetHashTableValueByKey(order_ht, "PayState"); if (pay_state == "0") { Hashtable ht = new Hashtable(); ht["OrderNum"] = SiteHelper.GetHashTableValueByKey(order_ht, "OrderNum"); ht["TotalFee"] = money; result = mgr.OrderPayCallback(ht); } } else { resp.code = "-1"; resp.msg = "未找到相关订单"; } if (result) { resp.code = "0"; resp.msg = "成功"; } else { resp.code = "-1"; resp.msg = "失败"; } return(resp); }
public ApiResp Execute(System.Collections.Hashtable params_ht) { ApiResp resp = new ApiResp(); resp.code = "-1"; string client_id = params_ht["client_id"].ToString(); long timestamp = long.Parse(params_ht["timestamp"].ToString()); string sign = params_ht["sign"].ToString(); List <GetStations_Item> data = new List <GetStations_Item>(); SysSettingManager settingManager = new SysSettingManager(); ServiceAreaManager areaManager = new ServiceAreaManager(); string returnVehicleMode = settingManager.GetValueByKey("ReturnVehicleMode"); DataTable dt = areaManager.GetAllParkings(1, 99999); if (returnVehicleMode == "1" && dt != null) { foreach (DataRow dr in dt.Rows) { GetStations_Item item = new GetStations_Item(); item.stationId = dr["ID"].ToString(); item.stationName = dr["ThisName"].ToString(); item.stationLat = double.Parse(dr["Latitude"].ToString()); item.stationLon = double.Parse(dr["Longitude"].ToString()); item.stationAddress = dr["Address"].ToString(); item.startTime = 0; item.endTime = 2400; item.radius = 0.00; item.parkType = 2; item.coordinatepoints = dr["Coordinates"].ToString().Replace(";", "|"); data.Add(item); } resp.code = "0"; resp.msg = "成功"; resp.data = data; } else { resp.code = "-1"; resp.msg = "未找到停车网点"; } return(resp); }
public void ProcessRequest(HttpContext context) { context.Response.CacheControl = "no-cache"; context.Response.AddHeader("Pragma", "no-cache"); context.Response.ContentType = "text/plain"; string clientData = ""; try { if (context.Request.HttpMethod.ToLower() != "post") { throw new Exception("调用方式错误"); } var reader = new System.IO.StreamReader(context.Request.InputStream); clientData = reader.ReadToEnd(); reader.Close(); if (!string.IsNullOrEmpty(clientData)) { Assembly assembly = Assembly.GetExecutingAssembly(); string typeName = "StatusAction"; object obj = assembly.CreateInstance("YR.Web.api.ydcloud.service." + typeName); IApiAction action = (IApiAction)obj; //if (action == null) // return; //调用相对应的接口方法 Hashtable args_ht = new Hashtable(); args_ht["json"] = clientData; ApiResp result = action.Execute(args_ht); Logger.Info("一动盒子接口网关上报数据(成功),访问ip:" + context.Request.UserHostAddress + ",参数:" + clientData + ",返回值:" + result); } else { throw new Exception("请求参数为空"); } } catch (Exception e) { Logger.Error("一动盒子接口网关上报数据(失败),访问ip:" + context.Request.UserHostAddress + ",参数:" + clientData + ",异常:" + e.Message); } }
public ApiResp <string> Register(string userName, string roleName) { _unitOfWork.BeginTransaction(); //创建用户 User user = _userRepository.GetByName(userName); if (user != null) { return(ApiResp.Failure("用户名重复")); } //添加用户 user = new User() { Id = Guid.NewGuid(), Name = userName }; _userRepository.Add(user); //添加角色 Role role = _roleRepositoty.GetByName(roleName); long roleId = 0L; if (role == null) { roleId = _roleRepositoty.Add(roleName); } //添加用户角色关联 var userRole = new UserRole() { UserId = user.Id, RoleId = roleId }; _userRoleRepository.Add(userRole); _unitOfWork.Commit(); return(ApiResp.Success("注册成功")); }
public ApiResp Execute(System.Collections.Hashtable params_ht) { ApiResp resp = new ApiResp(); try { string jsonData = params_ht["json"].ToString(); dynamic jsonObj = DynamicJson.Parse(jsonData); string carId = ""; if (jsonObj.IsDefined("carId")) { carId = jsonObj.carId; } return(resp); } catch { resp.Code = "1"; return(resp); } }
public ApiResp Execute(System.Collections.Hashtable params_ht) { ApiResp resp = new ApiResp(); try { string carId = SiteHelper.GetHashTableValueByKey(params_ht, "carId"); //车辆ID string latitude = SiteHelper.GetHashTableValueByKey(params_ht, "latitude"); //纬度 string longitude = SiteHelper.GetHashTableValueByKey(params_ht, "longitude"); //经度 string elevation = SiteHelper.GetHashTableValueByKey(params_ht, "elevation"); //海拔 string speed = SiteHelper.GetHashTableValueByKey(params_ht, "speed"); //车速 string direction = SiteHelper.GetHashTableValueByKey(params_ht, "direction"); //方向 string time = SiteHelper.GetHashTableValueByKey(params_ht, "time"); //时间 string surplusPercent = SiteHelper.GetHashTableValueByKey(params_ht, "surplusPercent"); //剩余电量百分比 string surplusDistance = SiteHelper.GetHashTableValueByKey(params_ht, "surplusDistance"); //剩余续航里程 string distance = SiteHelper.GetHashTableValueByKey(params_ht, "distance"); //总行驶里程 VehicleManager vm = new VehicleManager(); Hashtable vehicle_ht = vm.GetVehicleInfoByGPSNum(carId); if (vehicle_ht != null && vehicle_ht.Keys.Count > 0) { string vid = vehicle_ht["ID"].ToString(); Hashtable ht = new Hashtable(); if (!string.IsNullOrEmpty(longitude)) { ht["Longitude"] = string.Format("{0}", decimal.Parse(longitude) / 1000000); } if (!string.IsNullOrEmpty(latitude)) { ht["Latitude"] = string.Format("{0}", decimal.Parse(latitude) / 1000000); } if (!string.IsNullOrEmpty(speed)) { ht["CurrentSpeed"] = speed; } if (!string.IsNullOrEmpty(time)) { ht["GPSTime"] = DateTime.Now; } if (!string.IsNullOrEmpty(surplusPercent)) { ht["Electricity"] = surplusPercent; } if (!string.IsNullOrEmpty(surplusDistance)) { ht["ExpectRange"] = surplusDistance; } if (!string.IsNullOrEmpty(distance)) { ht["Mileage"] = distance; } bool result = vm.AddOrEditVehicleInfo(ht, vid); resp.Code = result ? "0" : "1"; } return(resp); } catch { resp.Code = "1"; return(resp); } }
public ApiResp Execute(System.Collections.Hashtable params_ht) { ApiResp resp = new ApiResp(); resp.code = "-1"; string client_id = params_ht["client_id"].ToString(); long timestamp = long.Parse(params_ht["timestamp"].ToString()); string sign = params_ht["sign"].ToString(); string plate_no = params_ht["plate_no"].ToString(); string order_no = params_ht["order_no"].ToString(); int op_type = int.Parse(params_ht["op_type"].ToString()); bool result = false; OrdersManager om = new OrdersManager(); BaoJiaManager mgr = new BaoJiaManager(); Hashtable order_ht = mgr.GetOrderInfo(order_no); if (order_ht != null && order_ht.Keys.Count > 0) { string order_state = SiteHelper.GetHashTableValueByKey(order_ht, "OrderState"); string vid = SiteHelper.GetHashTableValueByKey(order_ht, "VehicleID"); VehicleManager vm = new VehicleManager(); if (order_state == "1") { switch (op_type) { case 1: result = vm.OpenVehicle(vid); //如果是首次开车订单StartTime设为当前时间 if (result && string.IsNullOrEmpty(order_ht["STARTTIME"].ToString())) { mgr.SetCurrentOrderStartTime(order_ht["ID"].ToString()); om.UpdateOrderGPS(order_ht["ID"].ToString(), true); } break; case 2: result = vm.CloseVehicle(vid); break; case 3: result = vm.FindVehicle(vid); break; default: break; } } } else { resp.code = "-1"; resp.msg = "未找到相关订单"; } if (result) { resp.code = "0"; resp.msg = "成功"; } else { resp.code = "-1"; resp.msg = "失败"; } return(resp); }
public ApiResp Execute(Hashtable params_ht) { int start = DateTime.Now.Millisecond; ApiResp resp = new ApiResp(); ICache cache = null; try { cache = CacheFactory.GetCache(); string jsonData = params_ht["json"].ToString(); dynamic jsonObj = DynamicJson.Parse(jsonData); string carId = ""; if (jsonObj.IsDefined("carId")) { carId = jsonObj.carId; } double distance = 0.00; if (jsonObj.IsDefined("distance")) { distance = jsonObj.distance; } if (jsonObj.IsDefined("data")) { foreach (var item in jsonObj.data) { string acc = ""; if (item.IsDefined("acc")) { acc = item.acc; } double longitude = 0.00; if (item.IsDefined("longitude")) { longitude = item.longitude; } double latitude = 0.00; if (item.IsDefined("latitude")) { latitude = item.latitude; } double speed = 0.00; if (item.IsDefined("speed")) { speed = item.speed; } string defend = ""; if (item.IsDefined("defend")) { defend = item.defend; } VehicleManager vm = new VehicleManager(); Hashtable vehicle_ht = vm.GetVehicleInfoByGPSNum(carId); if (vehicle_ht != null && vehicle_ht.Keys.Count > 0) { string vid = vehicle_ht["ID"].ToString(); //车辆使用状态 1空闲,2预约中,3客户使用中,4运维操作中 string useState = SiteHelper.GetHashTableValueByKey(vehicle_ht, "UseState"); string strLastUpdateTime = SiteHelper.GetHashTableValueByKey(vehicle_ht, "LastUpdateTime"); int diffSecond = 5; if (!string.IsNullOrEmpty(strLastUpdateTime)) { DateTime lastUpdateTime = DateTime.Parse(strLastUpdateTime); diffSecond = SiteHelper.ExecDateDiffSecond(lastUpdateTime, DateTime.Now); } if (diffSecond > 3) { Hashtable ht = new Hashtable(); //车辆开关状态 LockState ,开:unlock,关:lock //acc =1 && defend =0 启动 unlock if (acc.Equals("1") && defend.Equals("0")) { ht["LockState"] = "unlock"; } //defend =1 设防 lock if (defend.Equals("1")) { ht["LockState"] = "lock"; } if (longitude > 0) { ht["Longitude"] = longitude; } if (latitude > 0) { ht["Latitude"] = latitude; } ht["CurrentSpeed"] = speed; ht["Mileage"] = distance / 1000.00; ht["GPSTime"] = DateTime.Now; ht["LastUpdateTime"] = DateTime.Now; bool result = false; if (ht.Keys.Count > 0) { result = vm.AddOrEditVehicleInfo(ht, vid); } Hashtable htAlarm = new Hashtable(); //超速 if (speed > 30) { string overSpeedKey = "over_speed_" + carId; string overSpeedValue = cache.Get <string>(overSpeedKey); if (string.IsNullOrEmpty(overSpeedValue)) { Logger.Warn("超速报警," + vid + "," + carId + ",speed=" + speed + ",defend =" + defend + ",acc=" + acc); VehicleAlarmManager alarmManager = new VehicleAlarmManager(); htAlarm["ID"] = Guid.NewGuid().ToString(); htAlarm["VehicleID"] = vid; htAlarm["IMEI"] = carId; htAlarm["AlarmType"] = 6; htAlarm["Speed"] = speed; htAlarm["AlarmTime"] = DateTime.Now; htAlarm["AlarmStatus"] = 0; htAlarm["CreateTime"] = DateTime.Now; if (alarmManager.AddOrEdit(htAlarm, null)) { DateTime timeSpan = DateTime.Now.AddMinutes(1); cache.Set(overSpeedKey, 1, timeSpan - DateTime.Now); Logger.Warn("超速报警记录添加成功," + vid + "," + carId + ",speed=" + speed + ",defend =" + defend + ",acc=" + acc); } else { Logger.Warn("超速报警记录添加失败," + vid + "," + carId + ",speed=" + speed + ",defend =" + defend + ",acc=" + acc); } } } else { if (speed >= 5 && "1".Equals(useState)) { string moveKey = "move_" + carId; string moveValue = cache.Get <string>(moveKey); if (string.IsNullOrEmpty(moveValue)) { Logger.Warn("无单移动报警," + vid + "," + carId + ",speed=" + speed + ",defend =" + defend + ",acc=" + acc + ",useState=" + useState); VehicleAlarmManager alarmManager = new VehicleAlarmManager(); htAlarm["ID"] = Guid.NewGuid().ToString(); htAlarm["VehicleID"] = vid; htAlarm["IMEI"] = carId; htAlarm["AlarmType"] = 1; htAlarm["Speed"] = speed; htAlarm["AlarmTime"] = DateTime.Now; htAlarm["AlarmStatus"] = 0; htAlarm["CreateTime"] = DateTime.Now; if (alarmManager.AddOrEdit(htAlarm, null)) { DateTime timeSpan = DateTime.Now.AddMinutes(10); cache.Set(moveKey, 1, timeSpan - DateTime.Now); Logger.Warn("无单移动报警记录添加成功," + vid + "," + carId + ",speed=" + speed + ",defend =" + defend + ",acc=" + acc); } else { Logger.Warn("无单移动报警记录添加失败," + vid + "," + carId + ",speed=" + speed + ",defend =" + defend + ",acc=" + acc); } } } } string outAreaKey = "out_area_" + carId; string outAreaValue = cache.Get <string>(outAreaKey); if (string.IsNullOrEmpty(outAreaValue) && latitude > 0 && longitude > 0) { string serviceAreaKey = "Service_Area_" + vehicle_ht["CITYID"].ToString(); string coordinates = cache.Get <string>(serviceAreaKey); if (string.IsNullOrEmpty(coordinates)) { ServiceAreaManager areaManager = new ServiceAreaManager(); Hashtable area_ht = areaManager.GetServiceAreaByVehicleID(vid); if (area_ht != null && area_ht.Keys.Count > 0) { coordinates = SiteHelper.GetHashTableValueByKey(area_ht, "Coordinates"); if (!string.IsNullOrEmpty(coordinates)) { DateTime timeSpan = DateTime.Now.AddDays(10); cache.Set(serviceAreaKey, coordinates, timeSpan - DateTime.Now); } } } List <LatLng> area_pts = new List <LatLng>(); if (!string.IsNullOrEmpty(coordinates)) { foreach (string str in coordinates.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries)) { string[] pt_arr = str.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); LatLng pt = new LatLng(double.Parse(pt_arr[1]), double.Parse(pt_arr[0])); area_pts.Add(pt); } LatLng vehicle_pt = new LatLng(latitude, longitude); //车辆GPS坐标转高德坐标 vehicle_pt = SiteHelper.GPSToGCJ02(longitude.ToString(), latitude.ToString()); vehicle_pt = new LatLng(Math.Round(vehicle_pt.latitude, 6), Math.Round(vehicle_pt.longitude, 6)); bool isInPoly = SiteHelper.IsPtInPoly(vehicle_pt, area_pts); if (!isInPoly) { Logger.Warn("越界报警," + vid + "," + carId + ",speed=" + speed + ",defend =" + defend + ",acc=" + acc); VehicleAlarmManager alarmManager = new VehicleAlarmManager(); htAlarm["ID"] = Guid.NewGuid().ToString(); htAlarm["VehicleID"] = vid; htAlarm["IMEI"] = carId; htAlarm["AlarmType"] = 4; htAlarm["Speed"] = speed; htAlarm["AlarmTime"] = DateTime.Now; htAlarm["AlarmStatus"] = 0; htAlarm["CreateTime"] = DateTime.Now; bool alarmResult = alarmManager.AddOrEdit(htAlarm, null); if (alarmResult) { //越界20分钟内有效 DateTime dt = DateTime.Now.AddMinutes(20); cache.Set(outAreaKey, carId, dt - DateTime.Now); Logger.Warn("越界报警记录添加成功," + vid + "," + carId + ",speed=" + speed + ",defend =" + defend + ",acc=" + acc); } else { Logger.Warn("越界报警记录添加失败," + vid + "," + carId + ",speed=" + speed + ",defend =" + defend + ",acc=" + acc); } } } } int end = DateTime.Now.Millisecond; Logger.Warn("小安盒子接口网关上报状态信息数据,耗时" + (end - start) + "ms," + vid + "," + carId + ",defend = " + defend + ",acc=" + acc + ",LockState=" + ht["LockState"]); resp.Code = result ? "0" : "1"; resp.Message = result ? "success" : "fail"; } else { resp.Code = "3"; } } } } if (cache != null) { cache.Dispose(); } return(resp); } catch (Exception e) { Logger.Error("盒子上报状态信息报错:" + e); string message = e.Message; if (cache != null) { cache.Dispose(); } resp.Code = "1"; resp.Message = "fail"; return(resp); } }
public ApiResp Execute(System.Collections.Hashtable params_ht) { ApiResp resp = new ApiResp(); resp.code = "-1"; string client_id = params_ht["client_id"].ToString(); long timestamp = long.Parse(params_ht["timestamp"].ToString()); string sign = params_ht["sign"].ToString(); string plate_no = null; if (params_ht["plate_no"] != null) { plate_no = params_ht["plate_no"].ToString(); if (plate_no != null && (plate_no.StartsWith("http://") || plate_no.StartsWith("https://"))) { //http://api.qingniaokeji.cn/download/app.aspx?no=xxxxxxxxxxxxx Uri uri = new Uri(plate_no); System.Collections.Specialized.NameValueCollection coll = System.Web.HttpUtility.ParseQueryString(uri.Query); plate_no = coll.Get("no"); } } List <GetNowCars_Item> data = new List <GetNowCars_Item>(); VehicleManager vm = new VehicleManager(); ServiceAreaManager areaManager = new ServiceAreaManager(); if (string.IsNullOrEmpty(plate_no)) { DataTable dt = areaManager.GetVehiclesByCity(null, 1, 9999); if (dt != null) { foreach (DataRow dr in dt.Rows) { GetNowCars_Item item = new GetNowCars_Item(); item.id = dr["ID"].ToString(); item.plate_no = dr["LicenseNumber"].ToString(); item.lng = double.Parse(dr["Longitude"].ToString()); item.lat = double.Parse(dr["Latitude"].ToString()); if (dr["LastUpdateTime"].ToString().Trim().Length > 0) { item.datetime = (long)(DateTime.Parse(dr["LastUpdateTime"].ToString()) - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime()).TotalSeconds; } item.mileage = dr["ExpectRange"].ToString(); item.power = (int)double.Parse(dr["Electricity"].ToString()); if (item.power > 100) { item.power = 100; } if (item.power < 0) { item.power = 0; } item.minute_price = double.Parse(dr["MinutePrice"].ToString()); item.mile_price = double.Parse(dr["KmPrice"].ToString()); item.start_price = double.Parse(dr["MinPrice"].ToString()); item.other_price = "每日封顶价格:" + dr["MaxPrice"].ToString() + "元"; string use_state = dr["UseState"].ToString(); string vehicle_state = dr["VehicleState"].ToString(); double electricity = 0.00; double.TryParse(dr["Electricity"].ToString(), out electricity); DateTime last_update_time = DateTime.Now; if (dr["LastUpdateTime"].ToString().Trim().Length > 0) { DateTime.TryParse(dr["LastUpdateTime"].ToString(), out last_update_time); } item.is_rent = 0; if (vehicle_state == VehicleState.Use.GetHashCode().ToString() && use_state == VehicleUseState.Free.GetHashCode().ToString() && electricity > 20 && (DateTime.Now - last_update_time).TotalMinutes < 5) { item.is_rent = 1; } data.Add(item); } resp.code = "0"; resp.msg = "成功"; resp.data = data; } else { resp.code = "-1"; resp.msg = "未找到车辆"; } } else { Hashtable ht = vm.GetVehicleInfoByIDORNumber(plate_no); if (ht != null && ht.Keys.Count > 0) { GetNowCars_Item item = new GetNowCars_Item(); item.id = SiteHelper.GetHashTableValueByKey(ht, "ID"); item.plate_no = SiteHelper.GetHashTableValueByKey(ht, "LicenseNumber"); item.lng = double.Parse(SiteHelper.GetHashTableValueByKey(ht, "Longitude")); item.lat = double.Parse(SiteHelper.GetHashTableValueByKey(ht, "Latitude")); if (SiteHelper.GetHashTableValueByKey(ht, "LastUpdateTime").Length > 0) { item.datetime = (long)(DateTime.Parse(SiteHelper.GetHashTableValueByKey(ht, "LastUpdateTime")) - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime()).TotalSeconds; } item.mileage = SiteHelper.GetHashTableValueByKey(ht, "ExpectRange"); item.power = (int)double.Parse(SiteHelper.GetHashTableValueByKey(ht, "Electricity")); if (item.power > 100) { item.power = 100; } if (item.power < 0) { item.power = 0; } item.minute_price = double.Parse(SiteHelper.GetHashTableValueByKey(ht, "MinutePrice")); item.mile_price = double.Parse(SiteHelper.GetHashTableValueByKey(ht, "KmPrice")); item.start_price = double.Parse(SiteHelper.GetHashTableValueByKey(ht, "MinPrice")); item.other_price = "每日封顶价格:" + SiteHelper.GetHashTableValueByKey(ht, "MaxPrice") + "元"; string use_state = SiteHelper.GetHashTableValueByKey(ht, "UseState"); string vehicle_state = SiteHelper.GetHashTableValueByKey(ht, "VehicleState"); double electricity = 0.00; double.TryParse(SiteHelper.GetHashTableValueByKey(ht, "Electricity"), out electricity); DateTime last_update_time = DateTime.Now; if (SiteHelper.GetHashTableValueByKey(ht, "LastUpdateTime").Length > 0) { DateTime.TryParse(SiteHelper.GetHashTableValueByKey(ht, "LastUpdateTime"), out last_update_time); } item.is_rent = 0; if (vehicle_state == VehicleState.Use.GetHashCode().ToString() && use_state == VehicleUseState.Free.GetHashCode().ToString() && electricity > 20 && (DateTime.Now - last_update_time).Minutes < 5) { item.is_rent = 1; } data.Add(item); resp.code = "0"; resp.msg = "成功"; resp.data = data; } else { resp.code = "-1"; resp.msg = "未找到车辆"; } } return(resp); }
public ApiResp Execute(System.Collections.Hashtable params_ht) { ApiResp resp = new ApiResp(); try { string jsonData = params_ht["json"].ToString(); dynamic jsonObj = DynamicJson.Parse(jsonData); string carId = ""; if (jsonObj.IsDefined("carId")) { carId = jsonObj.carId;//车辆ID } string latitude = ""; if (jsonObj.IsDefined("body.latitude")) { latitude = jsonObj.body.latitude;//纬度 } string longitude = ""; if (jsonObj.IsDefined("body.longitude")) { longitude = jsonObj.body.longitude;//经度 } string elevation = ""; if (jsonObj.IsDefined("body.elevation")) { elevation = jsonObj.body.elevation;//海拔 } string speed = ""; if (jsonObj.IsDefined("body.speed")) { speed = jsonObj.body.speed;//车速 } string direction = ""; if (jsonObj.IsDefined("body.direction")) { direction = jsonObj.body.direction;//方向 } string time = ""; if (jsonObj.IsDefined("body.time")) { time = jsonObj.body.time;//时间 } string surplusPercent = ""; if (jsonObj.IsDefined("body.surplusPercent")) { surplusPercent = jsonObj.body.surplusPercent;//剩余电量百分比 } string surplusDistance = ""; if (jsonObj.IsDefined("body.surplusDistance")) { surplusDistance = jsonObj.body.surplusDistance;//剩余续航里程 } string distance = ""; if (jsonObj.IsDefined("body.distance")) { distance = jsonObj.body.distance;//总行驶里程 } VehicleManager vm = new VehicleManager(); Hashtable vehicle_ht = vm.GetVehicleInfoByGPSNum(carId); if (vehicle_ht != null && vehicle_ht.Keys.Count > 0) { string vid = vehicle_ht["ID"].ToString(); Hashtable ht = new Hashtable(); if (!string.IsNullOrEmpty(longitude)) { ht["Longitude"] = longitude; } if (!string.IsNullOrEmpty(latitude)) { ht["Latitude"] = latitude; } if (!string.IsNullOrEmpty(speed)) { ht["CurrentSpeed"] = speed; } if (!string.IsNullOrEmpty(time)) { ht["GPSTime"] = DateTime.Now; } if (!string.IsNullOrEmpty(surplusPercent)) { ht["Electricity"] = surplusPercent; } if (!string.IsNullOrEmpty(surplusDistance)) { ht["ExpectRange"] = surplusDistance; } if (!string.IsNullOrEmpty(distance)) { ht["Mileage"] = distance; } bool result = false; if (ht.Keys.Count > 0) { result = vm.AddOrEditVehicleInfo(ht, vid); } resp.Code = result ? "0" : "1"; } return(resp); } catch { resp.Code = "1"; return(resp); } }
public ApiResp Execute(System.Collections.Hashtable params_ht) { ApiResp resp = new ApiResp(); try { string jsonData = params_ht["json"].ToString(); dynamic jsonObj = DynamicJson.Parse(jsonData); string carId = ""; if (jsonObj.IsDefined("carId")) { carId = jsonObj.carId; } string csq = ""; if (jsonObj.IsDefined("csq")) { csq = jsonObj.csq; } string voltage = ""; if (jsonObj.IsDefined("voltage")) { voltage = jsonObj.voltage; } string dumpEle = ""; if (jsonObj.IsDefined("dumpEle")) { dumpEle = jsonObj.dumpEle; } VehicleManager vm = new VehicleManager(); Hashtable vehicle_ht = vm.GetVehicleInfoByGPSNum(carId); if (vehicle_ht != null && vehicle_ht.Keys.Count > 0) { string strLastUpdateTime = SiteHelper.GetHashTableValueByKey(vehicle_ht, "LastUpdateTime"); int diffSecond = 5; if (!string.IsNullOrEmpty(strLastUpdateTime)) { DateTime lastUpdateTime = DateTime.Parse(strLastUpdateTime); diffSecond = SiteHelper.ExecDateDiffSecond(lastUpdateTime, DateTime.Now); } if (diffSecond > 3) { string vid = vehicle_ht["ID"].ToString(); Hashtable ht = new Hashtable(); if (!string.IsNullOrEmpty(dumpEle)) { double power = -1; double.TryParse(dumpEle, out power); if (power >= 0 && power <= 1) { ht["Electricity"] = (int)(power * 100); } } ht["LastUpdateTime"] = DateTime.Now; bool result = false; if (ht.Keys.Count > 0) { result = vm.AddOrEditVehicleInfo(ht, vid); } resp.Code = result ? "0" : "1"; } else { resp.Code = "3"; } } return(resp); } catch { resp.Code = "1"; return(resp); } }
public ApiResp Execute(System.Collections.Hashtable params_ht) { ApiResp resp = new ApiResp(); resp.code = "-1"; string client_id = params_ht["client_id"].ToString(); long timestamp = long.Parse(params_ht["timestamp"].ToString()); string sign = params_ht["sign"].ToString(); string plate_no = params_ht["plate_no"].ToString(); string order_no = params_ht["order_no"].ToString(); GetFeeData data = new GetFeeData(); BaoJiaManager mgr = new BaoJiaManager(); Hashtable ht = mgr.GetOrderInfo(order_no); if (ht == null) { resp.msg = "未找到相关订单"; resp.code = "-1"; } else { decimal kmprice = 0.80m, minuteprice = 0.40m, mileage = 0, TotalMoney = 0.00m, SettlementMoney = 0.00m, outServiceAreaFee = 0.00m; int minutes = 0; string returnLocType = "", lng = "0", lat = "0"; ServiceAreaManager areaManager = new ServiceAreaManager(); SysSettingManager settingManager = new SysSettingManager(); VehiclePriceManager priceManager = new VehiclePriceManager(); Hashtable billing_ht = priceManager.GetOrderSettlement(SiteHelper.GetHashTableValueByKey(ht, "id")); decimal.TryParse(SiteHelper.GetHashTableValueByKey(billing_ht, "MinutePrice"), out minuteprice); decimal.TryParse(SiteHelper.GetHashTableValueByKey(billing_ht, "KmPrice"), out kmprice); int.TryParse(SiteHelper.GetHashTableValueByKey(billing_ht, "Minutes"), out minutes); decimal.TryParse(SiteHelper.GetHashTableValueByKey(billing_ht, "TotalMoney"), out TotalMoney); decimal.TryParse(SiteHelper.GetHashTableValueByKey(ht, "SettlementMoney"), out SettlementMoney); returnLocType = SiteHelper.GetHashTableValueByKey(ht, "ReturnLocType"); decimal.TryParse(SiteHelper.GetHashTableValueByKey(ht, "OutServiceAreaFee"), out outServiceAreaFee); string orderState = SiteHelper.GetHashTableValueByKey(ht, "OrderState"); VehicleManager vm = new VehicleManager(); Hashtable vehicle_ht = vm.GetVehicleInfoByIDORNumber(SiteHelper.GetHashTableValueByKey(ht, "VehicleID")); lat = vehicle_ht["LATITUDE"].ToString(); lng = vehicle_ht["LONGITUDE"].ToString(); if (orderState == "1") { SettlementMoney = TotalMoney; #region 判断还车点是否在运营区域内,运营区域外加收费用 Hashtable area_ht = areaManager.GetServiceAreaByVehicleID(SiteHelper.GetHashTableValueByKey(ht, "VehicleID")); if (area_ht != null && area_ht.Keys.Count > 0) { returnLocType = "03"; List <LatLng> area_pts = new List <LatLng>(); string coordinates = SiteHelper.GetHashTableValueByKey(area_ht, "Coordinates"); foreach (string str in coordinates.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries)) { string[] pt_arr = str.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); LatLng pt = new LatLng(double.Parse(pt_arr[1]), double.Parse(pt_arr[0])); area_pts.Add(pt); } LatLng vehicle_pt = new LatLng(double.Parse(lat), double.Parse(lng)); //vehicle_pt = SiteHelper.TransformFromWGSToGCJ(vehicle_pt); vehicle_pt = SiteHelper.GPSToGCJ02(lng, lat); vehicle_pt = new LatLng(Math.Round(vehicle_pt.latitude, 6), Math.Round(vehicle_pt.longitude, 6)); bool isInPoly = SiteHelper.IsPtInPoly(vehicle_pt, area_pts); if (!isInPoly) { returnLocType = "04"; string serviceFee = settingManager.GetValueByKey("OutServiceAreaFee"); if (serviceFee.StartsWith("+")) { serviceFee = serviceFee.Substring(1, serviceFee.Length - 1); decimal.TryParse(serviceFee, out outServiceAreaFee); TotalMoney = TotalMoney + outServiceAreaFee; } else { serviceFee = serviceFee.Substring(1, serviceFee.Length - 1); decimal.TryParse(serviceFee, out outServiceAreaFee); TotalMoney = TotalMoney * outServiceAreaFee; } outServiceAreaFee = TotalMoney - SettlementMoney; } } #endregion #region 判断还车点是否在停车点内,否则加收费用 string returnVehicleMode = settingManager.GetValueByKey("ReturnVehicleMode"); if (outServiceAreaFee == 0 && returnVehicleMode == "1") { returnLocType = "01"; LatLng vehicle_pt = new LatLng(double.Parse(lat), double.Parse(lng)); //vehicle_pt = SiteHelper.TransformFromWGSToGCJ(vehicle_pt); vehicle_pt = SiteHelper.GPSToGCJ02(lng, lat); vehicle_pt = new LatLng(Math.Round(vehicle_pt.latitude, 6), Math.Round(vehicle_pt.longitude, 6)); Hashtable parking_ht = areaManager.GetNearestParking(vehicle_pt.longitude.ToString(), vehicle_pt.latitude.ToString(), SiteHelper.GetHashTableValueByKey(ht, "VehicleID")); List <LatLng> parking_pts = new List <LatLng>(); if (parking_ht != null && parking_ht.Keys.Count > 0) { string coordinates = SiteHelper.GetHashTableValueByKey(parking_ht, "Coordinates"); foreach (string str in coordinates.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries)) { string[] pt_arr = str.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); LatLng pt = new LatLng(double.Parse(pt_arr[1]), double.Parse(pt_arr[0])); parking_pts.Add(pt); } } bool isInPoly = SiteHelper.IsPtInPoly(vehicle_pt, parking_pts); if (!isInPoly) { returnLocType = "02"; string serviceFee = settingManager.GetValueByKey("OutParkingAreaFee"); if (serviceFee.StartsWith("+")) { serviceFee = serviceFee.Substring(1, serviceFee.Length - 1); decimal.TryParse(serviceFee, out outServiceAreaFee); TotalMoney = TotalMoney + outServiceAreaFee; } else { serviceFee = serviceFee.Substring(1, serviceFee.Length - 1); decimal.TryParse(serviceFee, out outServiceAreaFee); TotalMoney = TotalMoney * outServiceAreaFee; } outServiceAreaFee = TotalMoney - SettlementMoney; } } #endregion } SettlementMoney = Math.Round(SettlementMoney, 2); data.order_no = order_no; data.all_mile = double.Parse(SiteHelper.GetHashTableValueByKey(ht, "Mileage")); data.location_address_type = "3"; if (returnLocType == "01") { data.location_address_type = "3"; } if (returnLocType == "02" || returnLocType == "03") { data.location_address_type = "1"; } if (returnLocType == "04") { data.location_address_type = "2"; } data.location_address_msg = ""; data.order_status = 10000; if (orderState == "1") { data.order_status = 10000; } else if (orderState == "0") { data.order_status = 10301; } else if (orderState == "2" || orderState == "5" || orderState == "3") { data.order_status = 80200; } data.total_fee = (double)(SettlementMoney + outServiceAreaFee); data.timestamp = (long)(DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime()).TotalSeconds; data.lng = double.Parse(lng); data.lat = double.Parse(lat); data.details = new List <GetFeeData_Fee>(); GetFeeData_Fee item1 = new GetFeeData_Fee(); item1.name = "用车费用"; item1.amount = (double)SettlementMoney; data.details.Add(item1); if (returnLocType == "04") { GetFeeData_Fee item2 = new GetFeeData_Fee(); item2.name = "行驶区域外还车调度费"; item2.amount = (double)(outServiceAreaFee); data.details.Add(item2); } if (returnLocType == "02") { GetFeeData_Fee item3 = new GetFeeData_Fee(); item3.name = "停车点外还车调度费"; item3.amount = (double)(outServiceAreaFee); data.details.Add(item3); } data.isLock = "1"; int cnt = -1; DataTable parking_dt = areaManager.GetNearParking(9999, lng.ToString(), lat.ToString(), 1, 9999, ref cnt); if (parking_dt != null && parking_dt.Rows.Count > 0) { List <GetFeeData_StationItem> station_list = new List <GetFeeData_StationItem>(); foreach (DataRow dr in parking_dt.Rows) { GetFeeData_StationItem station = new GetFeeData_StationItem(); station.parkType = "2"; station.coordinatePoints = dr["Coordinates"].ToString().Replace(";", "|"); station.coordinate_center = dr["Longitude"].ToString() + "," + dr["Latitude"].ToString(); station_list.Add(station); } data.stationList = station_list; } resp.data = data; resp.code = "0"; } return(resp); }
public void ProcessRequest(HttpContext context) { context.Response.CacheControl = "no-cache"; context.Response.AddHeader("Pragma", "no-cache"); context.Response.ContentType = "text/plain"; Hashtable clientData = new Hashtable(); string cmd = null; try { if (context.Request.HttpMethod.ToLower() != "post") { throw new Exception("调用方式错误"); } clientData = GetRequestData(context); if (clientData != null && clientData.Keys.Count > 0) { if (!ZCloudSignUtil.verify(ZCloudCore.hashtableToDictionary(clientData), ZCloudConfig.md5_key)) { throw new Exception("验签失败"); } if (clientData["cmd"] != null) { cmd = clientData["cmd"].ToString(); } if (string.IsNullOrEmpty(cmd)) { throw new Exception("收到网关发来的通知,但是没有找到命令字"); } Assembly assembly = Assembly.GetExecutingAssembly(); string typeName = cmd.Substring(0, 1).ToUpper() + cmd.Substring(1, cmd.Length - 1) + "Action"; object obj = assembly.CreateInstance("YR.Web.api.zcloud.service." + typeName); IApiAction action = (IApiAction)obj; //if (action == null) // return; //调用相对应的接口方法 ApiResp result = action.Execute(clientData); if (!Not_Response_Cmd.Contains(cmd)) { Hashtable result_ht = new Hashtable(); result_ht.Add("rtCode", "0"); string sign = ZCloudSignUtil.getSign(ZCloudCore.hashtableToDictionary(result_ht), ZCloudConfig.md5_key); result_ht.Add("sign", sign); context.Response.Write(JsonConvert.SerializeObject(result_ht)); } Logger.Info("自由box接口网关上报数据(成功),访问ip:" + context.Request.UserHostAddress + ",参数:" + JsonConvert.SerializeObject(clientData) + ",返回值:" + result); } else { throw new Exception("请求参数为空"); } } catch (Exception e) { if (!Not_Response_Cmd.Contains(cmd)) { Hashtable result_ht = new Hashtable(); result_ht.Add("rtCode", "1"); string sign = ZCloudSignUtil.getSign(ZCloudCore.hashtableToDictionary(result_ht), ZCloudConfig.md5_key); result_ht.Add("sign", sign); context.Response.Write(JsonConvert.SerializeObject(result_ht)); } Logger.Error("自由box接口网关上报数据(失败),访问ip:" + context.Request.UserHostAddress + ",参数:" + JsonConvert.SerializeObject(clientData) + ",异常:" + e.Message); } }
public void ProcessRequest(HttpContext context) { try { context.Response.CacheControl = "no-cache"; context.Response.AddHeader("Pragma", "no-cache"); context.Response.ContentType = "text/plain"; string method = context.Request["method"]; if (string.IsNullOrEmpty(method)) { throw new Exception("系统参数错误"); } //if (!CheckAuth(context)) // throw new Exception("无权访问此操作"); switch (method) { case "GetVehicles": GetVehicles(context); break; case "GetCupInfo": GetCupInfo(context); break; case "GetNearVehicles": GetNearVehicles(context); break; case "GetVehicleByID": GetVehicleByID(context); break; case "GetVehicleTrace": GetVehicleTrace(context); break; case "GetOrdersByVehicle": GetOrdersByVehicle(context); break; case "GetServiceArea": GetServiceArea(context); break; case "GetServiceAreaByCityID": GetServiceAreaByCityID(context); break; case "GetServiceAreaByID": GetServiceAreaByID(context); break; case "GetParkingList": GetParkingList(context); break; case "GetForbidList": GetForbidList(context); break; default: ApiResp resp = new ApiResp(); resp.Code = "-1"; resp.Message = "调用异常,无效的方法调用"; context.Response.Write(JsonConvert.SerializeObject(resp));; break; } } catch (Exception e) { ApiResp resp = new ApiResp(); resp.Code = "-1"; resp.Message = "系统异常," + e.Message; context.Response.Write(JsonConvert.SerializeObject(resp)); } }
public ApiResp Execute(System.Collections.Hashtable params_ht) { ApiResp resp = new ApiResp(); resp.code = "-1"; string client_id = params_ht["client_id"].ToString(); long timestamp = long.Parse(params_ht["timestamp"].ToString()); string sign = params_ht["sign"].ToString(); string order_no = params_ht["order_no"].ToString(); BaoJiaManager mgr = new BaoJiaManager(); Hashtable order_ht = mgr.GetOrderInfo(order_no); if (order_ht != null && order_ht.Keys.Count > 0) { ServiceAreaManager areaManager = new ServiceAreaManager(); string vehicleid = SiteHelper.GetHashTableValueByKey(order_ht, "VehicleID"); string orderid = SiteHelper.GetHashTableValueByKey(order_ht, "ID"); GetOrderTracks_Data data = new GetOrderTracks_Data(); string returnLocType = SiteHelper.GetHashTableValueByKey(order_ht, "ReturnLocType"); if (returnLocType == "01") { data.return_location_address_type = "3"; data.return_location_address_msg = "网点还车"; string toParking = SiteHelper.GetHashTableValueByKey(order_ht, "ToParking"); if (!string.IsNullOrEmpty(toParking)) { Hashtable parking_ht = areaManager.GetInfoByID(toParking); if (parking_ht != null && parking_ht.Keys.Count > 0) { data.return_station_points = SiteHelper.GetHashTableValueByKey(parking_ht, "Coordinates").Replace(";", "|"); data.return_station_center = SiteHelper.GetHashTableValueByKey(parking_ht, "Longitude") + "," + SiteHelper.GetHashTableValueByKey(parking_ht, "Latitude"); } } } else if (returnLocType == "02" || returnLocType == "03") { data.return_location_address_type = "1"; data.return_location_address_msg = "行驶区域内网点外还车"; } else if (returnLocType == "04") { data.return_location_address_type = "2"; data.return_location_address_msg = "行驶区域外还车"; Hashtable area_ht = areaManager.GetServiceAreaByVehicleID(vehicleid); if (area_ht != null && area_ht.Keys.Count > 0) { data.return_xianzhi_points = SiteHelper.GetHashTableValueByKey(area_ht, "Coordinates").Replace(";", "|"); } } VehicleManager vm = new VehicleManager(); DataTable dt = vm.GetVehicleTrace(vehicleid, orderid, null, null); if (dt != null) { GetOrderTracks_Data Data = new GetOrderTracks_Data(); data.return_location_address_msg = ""; data.line_points = ""; List <LatLng> pts = new List <LatLng>(); foreach (DataRow dr in dt.Rows) { double lng = double.Parse(dr["AMAP_longitude"].ToString()); double lat = double.Parse(dr["AMAP_latitude"].ToString()); pts.Add(new LatLng(lat, lng)); if (data.line_points.Length > 0 && !data.line_points.EndsWith("|")) { data.line_points += "|"; } data.line_points += lng + "," + lat; } if (pts.Count > 0) { data.start_lng = pts[0].longitude; data.star_lat = pts[0].latitude; data.end_lng = pts[pts.Count - 1].longitude; data.end_lat = pts[pts.Count - 1].latitude; } else { LatLng latlng = new LatLng(double.Parse(SiteHelper.GetHashTableValueByKey(order_ht, "EndLatitude")), double.Parse(SiteHelper.GetHashTableValueByKey(order_ht, "EndLongitude"))); latlng = SiteHelper.TransformFromWGSToGCJ(latlng); data.start_lng = latlng.longitude; data.star_lat = latlng.latitude; data.end_lng = data.start_lng; data.end_lat = data.star_lat; } resp.code = "0"; resp.msg = "成功"; resp.data = data; } else { resp.code = "-1"; resp.msg = "未找到停车网点"; } } else { resp.code = "-1"; resp.msg = "未找到相关订单"; } return(resp); }
public ApiResp Execute(System.Collections.Hashtable params_ht) { ApiResp resp = new ApiResp(); resp.Code = "0"; resp.Message = "success"; string jsonData = params_ht["json"].ToString(); ICache cache = null; try { dynamic jsonObj = DynamicJson.Parse(jsonData); string carId = ""; if (jsonObj.IsDefined("carId")) { carId = jsonObj.carId; } double alarm = 0; if (jsonObj.IsDefined("alarm")) { alarm = jsonObj.alarm; } Logger.Warn("告警信息:" + carId + ",参数:" + jsonData); VehicleManager vm = new VehicleManager(); VehicleAlarmManager alarmManager = new VehicleAlarmManager(); Hashtable vehicle_ht = vm.GetVehicleIByGPSNum(carId); if (alarm == 6 && vehicle_ht != null && vehicle_ht.Keys.Count > 0) { string cacheKey = "alarm_" + carId + "_" + alarm; cache = CacheFactory.GetCache(); if (!string.IsNullOrEmpty(cache.Get <string>(cacheKey))) { cache.Dispose(); Logger.Warn("断电告警10分钟内," + carId); resp.Code = "1"; resp.Message = ""; return(resp); } int alarmType = 0; //if (alarm == 3) //{ // 振动 // alarmType = 7; //} if (alarm == 6) { //断电 alarmType = 2; } string vid = vehicle_ht["ID"].ToString(); //车辆使用状态 1空闲,2预约中,3客户使用中,4运维操作中 string useState = SiteHelper.GetHashTableValueByKey(vehicle_ht, "UseState"); Hashtable ht = new Hashtable(); ht["ID"] = Guid.NewGuid().ToString(); ht["VehicleID"] = vid; ht["IMEI"] = carId; ht["AlarmType"] = alarmType; ht["AlarmTime"] = DateTime.Now; ht["AlarmStatus"] = 0; ht["CreateTime"] = DateTime.Now; bool result = false; if (ht.Keys.Count > 0 && !"4".Equals(useState)) { Logger.Warn("告警信息,参数:" + jsonData + ",车辆状态:" + useState + "(1空闲,2预约中,3客户使用中,4运维操作中)"); result = alarmManager.AddOrEdit(ht, null); if (result) { DateTime dt = DateTime.Now.AddMinutes(10); cache.Set(cacheKey, carId, dt - DateTime.Now); cache.Dispose(); } } resp.Code = result ? "0" : "1"; resp.Message = result ? "success" : "fail"; } if (cache != null) { cache.Dispose(); } return(resp); } catch (Exception e) { if (cache != null) { cache.Dispose(); } Logger.Error("告警信息,参数:" + jsonData + ",异常:" + e); resp.Code = "1"; resp.Message = e.Message; return(resp); } }
public ApiResp Execute(System.Collections.Hashtable params_ht) { ApiResp resp = new ApiResp(); resp.code = "-1"; string client_id = params_ht["client_id"].ToString(); long timestamp = long.Parse(params_ht["timestamp"].ToString()); string sign = params_ht["sign"].ToString(); string plate_no = params_ht["plate_no"].ToString(); string order_no = params_ht["order_no"].ToString(); int order_status = int.Parse(params_ht["order_status"].ToString()); int status = int.Parse(params_ht["status"].ToString()); string mobile = params_ht["mobile"].ToString(); string user_name = params_ht["user_name"].ToString(); string card_no = params_ht["card_no"].ToString(); string card_pic_url = ""; if (params_ht["card_pic_url"] != null) { card_pic_url = params_ht["card_pic_url"].ToString(); } string fault_type = ""; if (params_ht["fault_type"] != null) { fault_type = params_ht["fault_type"].ToString(); } if (plate_no != null && (plate_no.StartsWith("http://") || plate_no.StartsWith("https://"))) { //http://api.qingniaokeji.cn/download/app.aspx?no=xxxxxxxxxxxxx Uri uri = new Uri(plate_no); System.Collections.Specialized.NameValueCollection coll = System.Web.HttpUtility.ParseQueryString(uri.Query); plate_no = coll.Get("no"); } bool result = false; string errmsg = ""; switch (order_status) { case 10000: result = CreateOrder(order_no, plate_no, user_name, mobile, card_no, out errmsg); break; case 10301: result = CancelOrder(order_no, fault_type, out errmsg); break; case 80200: result = ReturnVehicle(order_no, out errmsg); break; default: break; } if (result) { resp.code = "0"; resp.msg = "成功"; } else { resp.code = "-1"; resp.msg = errmsg; } return(resp); }
public ApiResp Execute(System.Collections.Hashtable params_ht) { ApiResp resp = new ApiResp(); resp.code = "-1"; string client_id = params_ht["client_id"].ToString(); long timestamp = long.Parse(params_ht["timestamp"].ToString()); string sign = params_ht["sign"].ToString(); List <GetCars_Item> data = new List <GetCars_Item>(); SysSettingManager settingManager = new SysSettingManager(); DictManager dictManager = new DictManager(); ServiceAreaManager areaManager = new ServiceAreaManager(); string depositMoney = settingManager.GetValueByKey("GoldDepositAmount"); DataTable city_dt = dictManager.GetDictList("03"); if (city_dt != null && city_dt.Rows.Count > 0) { foreach (DataRow city_dr in city_dt.Rows) { GetCars_Item item = new GetCars_Item(); Hashtable area_ht = areaManager.GetServiceAreaByCityCode(city_dr["remark"].ToString()); if (area_ht != null && area_ht.Keys.Count > 0) { item.coordinatePoints = SiteHelper.GetHashTableValueByKey(area_ht, "Coordinates").Replace(";", "|"); item.coordinate_center = SiteHelper.GetHashTableValueByKey(area_ht, "Longitude") + "," + SiteHelper.GetHashTableValueByKey(area_ht, "Latitude"); } item.city_name = city_dr["name"].ToString(); DataTable car_dt = areaManager.GetVehiclesByCity(item.city_name, 1, 9999); if (car_dt != null && car_dt.Rows.Count > 0) { List <GetCars_Car> car_list = new List <GetCars_Car>(); foreach (DataRow dr in car_dt.Rows) { GetCars_Car car = new GetCars_Car(); car.id = dr["ID"].ToString(); car.plate_no = dr["LicenseNumber"].ToString(); car.carname = dr["Brand"].ToString(); car.start_price = double.Parse(dr["MinPrice"].ToString()); car.minute_price = double.Parse(dr["MinutePrice"].ToString()); car.mile_price = double.Parse(dr["KmPrice"].ToString()); car.deposit_money = double.Parse(depositMoney); car_list.Add(car); } item.cars = car_list; } if (item.cars != null && item.cars.Count > 0) { data.Add(item); } } } if (data.Count > 0) { resp.code = "0"; resp.msg = "成功"; resp.data = data; } else { resp.code = "-1"; resp.msg = "未找到车辆信息"; } return(resp); }