public string Execute(Hashtable params_ht) { Hashtable res = params_ht; if (res["UID"] == null || res["VID"] == null || res["UID"].ToString().Trim().Length <= 0 || res["VID"].ToString().Trim().Length <= 0) { return(SiteHelper.GetJsonFromHashTable(null, "faild", "参数不完整")); } else { uid = res["UID"].ToString().Trim(); vid = res["VID"].ToString().Trim(); VehicleManager vm = new VehicleManager(); Hashtable vehicle_ht = vm.GetVehicleInfoByID(vid); if (vehicle_ht == null) { return(SiteHelper.GetJsonFromHashTable(null, "faild", "未找到相关车辆信息")); } Hashtable ht = new Hashtable(); ht["ID"] = vehicle_ht["ID"]; ht["Electricity"] = 100; bool isSuccess = vm.AddOrEditVehicleInfo(ht, vehicle_ht["ID"].ToString()); if (!isSuccess) { return(SiteHelper.GetJsonFromHashTable(null, "faild", "车辆电池更换失败")); } else { OPUserManager hum = new OPUserManager(); Hashtable userOperateHT = new Hashtable(); userOperateHT["ID"] = CommonHelper.GetGuid; userOperateHT["VehicleID"] = vid; userOperateHT["UserID"] = uid; userOperateHT["OperateType"] = 8; userOperateHT["OperateTypeText"] = "更换电池"; userOperateHT["Remark"] = ""; userOperateHT["OperateTime"] = SiteHelper.GetWebServerCurrentTime(); hum.AddUserOperate(userOperateHT); return(SiteHelper.GetJsonFromHashTable(null, "success", "车辆电池更换成功")); } } }
public string Execute(Hashtable params_ht) { Hashtable res = params_ht; if (res["UID"] == null || res["VID"] == null || res["Opr"] == null || res["UID"].ToString().Trim().Length <= 0 || res["VID"].ToString().Trim().Length <= 0 || res["Opr"].ToString().Trim().Length <= 0) { Hashtable result = new Hashtable(); result["ErrCode"] = "00";//服务器异常 return(SiteHelper.GetJsonFromHashTable(result, "faild", "参数不完整")); } else { uid = res["UID"].ToString().Trim(); vid = res["VID"].ToString().Trim(); //opr,0:开1:关 opr = res["Opr"].ToString().Trim(); VehicleManager vm = new VehicleManager(); Hashtable ht = vm.GetVehicleInfoByID(vid); if (ht == null) { Hashtable result = new Hashtable(); result["ErrCode"] = "01";//车辆未找到 return(SiteHelper.GetJsonFromHashTable(result, "faild", "未找到相关车辆信息")); } else { //客户占用车辆时禁止操作 if (ht["USESTATE"].ToString() == VehicleUseState.Order.GetHashCode().ToString() || ht["USESTATE"].ToString() == VehicleUseState.Reservation.GetHashCode().ToString()) { Hashtable result = new Hashtable(); result["ErrCode"] = "02";//车辆已被占用 return(SiteHelper.GetJsonFromHashTable(result, "faild", "指令发送失败,车辆已被客户占用")); } string gpsnum = SiteHelper.GetHashTableValueByKey(ht, "VehicleGPSNum"); bool isSuccess = false; if (opr == "0") { isSuccess = vm.OpenVehicle(vid); } else { isSuccess = vm.CloseVehicle(vid); } if (!isSuccess) { Hashtable result = new Hashtable(); result["ErrCode"] = "04";//指令发送失败 return(SiteHelper.GetJsonFromHashTable(result, "faild", "指令发送失败")); } else { Hashtable vht = new Hashtable(); vht["ID"] = vid; vht["UseState"] = opr == "0" ? 4 : 1; vm.AddOrEditVehicleInfo(vht, vid); OPUserManager hum = new OPUserManager(); Hashtable userOperateHT = new Hashtable(); userOperateHT["ID"] = CommonHelper.GetGuid; userOperateHT["VehicleID"] = vid; userOperateHT["UserID"] = uid; userOperateHT["OperateType"] = opr == "0" ? 1 : 2; userOperateHT["OperateTypeText"] = opr == "0" ? "开车" : "锁车"; userOperateHT["Remark"] = ""; userOperateHT["OperateTime"] = SiteHelper.GetWebServerCurrentTime(); hum.AddUserOperate(userOperateHT); return(SiteHelper.GetJsonFromHashTable(null, "success", "指令发送成功")); } } } }