protected void Page_Load(object sender, EventArgs e) { if (this.IsPostBack) { if (RequestSession.GetSessionUser().UserName != null) { if (this.fileUpload.PostedFile != null && this.fileUpload.PostedFile.ContentLength > 0) { //按日期归类保存 string virtual_path = SiteHelper.GetAppsetString("UploadImagePath") + DateTime.Now.ToString("yyyyMMdd") + "/"; string path = Server.MapPath(virtual_path); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string fileName = Path.GetFileName(this.fileUpload.PostedFile.FileName); string oldFileName = fileName; fileName = DateTime.Now.ToString("yyyyMMddhhmmss") + "_" + fileName; string fileid = CommonHelper.GetGuid; int bufferSize = 1; byte[] buffer = new byte[bufferSize]; //string filedataid = ""; string imgurl = Path.Combine(path, fileName); int uploadedLength = 0; int contentLength = this.fileUpload.PostedFile.ContentLength; using (FileStream fs = new FileStream(Path.Combine(path, fileName), FileMode.Create)) { while (uploadedLength < contentLength) { int bytes = this.fileUpload.PostedFile.InputStream.Read(buffer, 0, bufferSize); fs.Write(buffer, 0, bytes); uploadedLength += bytes; } } #region 入库 try { Hashtable ht = new Hashtable(); ht["ID"] = fileid; ht["ImageName"] = fileName; ht["RelationID"] = Request["relationID"].ToString(); ht["Category"] = Request["Category"].ToString(); ht["ImageUrl"] = virtual_path + fileName; ht["Type"] = Request["Type"].ToString(); ht["CreateTime"] = DateTime.Now; imgurl = ht["ImageUrl"].ToString(); SystemImagesManager imagesManager = new SystemImagesManager(); imagesManager.AddOrEditImageInfo(ht, string.Empty); } catch (Exception ex) { fileid = ex.Message.ToString(); } #endregion const string js = "window.parent.onComplete('success', '上传成功,请继续上传或关闭 {0} ','{1}','{2}','{3}');"; //string filePath = Path.Combine(path, fileName); //string view = "<a href=\'" + filePath + "\' target=\'_blank\'>预览</a>"; ScriptManager.RegisterStartupScript(this, typeof(upload), "progress", string.Format(js, "", fileid, imgurl, oldFileName), true);// "" fileName } else { const string js = "window.parent.onComplete('error', '上传文件出错','');"; ScriptManager.RegisterStartupScript(this, typeof(upload), "progress", js, true); } } else { const string js = "window.parent.onComplete('error', '权限不足','');"; ScriptManager.RegisterStartupScript(this, typeof(upload), "progress", js, true); } } }
public string Execute(Hashtable params_ht) { Hashtable res = params_ht; if (res["UID"] == null || res["UID"].ToString().Trim().Length <= 0) { return(SiteHelper.GetJsonFromHashTable(null, "faild", "参数不完整")); } else { uid = res["UID"].ToString().Trim(); VehicleManager vm = new VehicleManager(); SystemImagesManager sim = new SystemImagesManager(); OPUserManager opUserManager = new OPUserManager(); Hashtable vehicle = opUserManager.GetVehicleInfoByOperator(uid); OrdersManager om = new OrdersManager(); string thumbImg = string.Empty; string detailsImg = string.Empty; if (vehicle == null || vehicle.Keys.Count <= 0) { return(SiteHelper.GetJsonFromHashTable(null, "faild", "车辆数据为空")); } else { DataTable dt = sim.GetImagesByVehicleID(vehicle["ID"].ToString()); if (dt != null) { foreach (DataRow dr in dt.Rows) { if (dr["Type"].ToString().Trim() == ((int)ImagesType.Thumbnail).ToString().Trim()) { thumbImg += SiteHelper.GetFileServer() + dr["ImageUrl"].ToString().Trim() + ";"; } if (dr["Type"].ToString().Trim() == ((int)ImagesType.Details).ToString().Trim()) { detailsImg += SiteHelper.GetFileServer() + dr["ImageUrl"].ToString().Trim() + ";"; } } } vehicle["THUMBIMG"] = thumbImg; vehicle["DETAILSIMG"] = detailsImg; string lng = vehicle["LONGITUDE"].ToString(); string lat = vehicle["LATITUDE"].ToString(); if (!string.IsNullOrEmpty(lng) && !string.IsNullOrEmpty(lat)) { LatLng latlng = new LatLng(double.Parse(lat), double.Parse(lng)); latlng = SiteHelper.TransformFromWGSToGCJ(latlng); if (latlng != null) { vehicle["LATITUDE"] = latlng.latitude; vehicle["LONGITUDE"] = latlng.longitude; if (vehicle["ADDRESS"].ToString().Length <= 0) { vehicle["ADDRESS"] = SiteHelper.GetLocationByGPS(vehicle["LONGITUDE"].ToString(), vehicle["LATITUDE"].ToString(), "gcj02ll"); } } } decimal electricity = 0; decimal.TryParse(vehicle["ELECTRICITY"].ToString(), out electricity); int dianliang = Decimal.ToInt32(electricity); vehicle["ELECTRICITY"] = dianliang + "%"; Hashtable order_ht = om.GetLatestUserByVehicleID(vehicle["ID"].ToString()); if (order_ht != null && order_ht.Keys.Count > 0) { vehicle["OrderUserName"] = order_ht["REALNAME"]; vehicle["OrderUserTel"] = order_ht["BINDPHONE"]; vehicle["HeadPortrait"] = SiteHelper.GetFileServer() + order_ht["HEADPORTRAIT"]; vehicle["OrderState"] = order_ht["ORDERSTATE"]; vehicle["UserType"] = order_ht["USERTYPE"]; } else { vehicle["OrderUserName"] = ""; vehicle["OrderUserTel"] = ""; vehicle["HeadPortrait"] = ""; vehicle["OrderState"] = ""; vehicle["UserType"] = ""; } return(SiteHelper.GetJsonFromHashTable(vehicle, "success", "获取数据成功", "GetCurrentVehicle")); } } }
public string Execute(Hashtable params_ht) { Hashtable res = params_ht; if (res["VehicleID"] == null || res["Latitude"] == null || res["Longitude"] == null || res["VehicleID"].ToString().Trim().Length <= 0 || res["Latitude"].ToString().Trim().Length <= 0 || res["Longitude"].ToString().Trim().Length <= 0) { return(SiteHelper.GetJsonFromHashTable(null, "faild", "参数不完整")); } else { vehicleID = res["VehicleID"].ToString().Trim(); weidu = res["Latitude"].ToString().Trim(); jingdu = res["Longitude"].ToString().Trim(); VehicleManager vm = new VehicleManager(); SystemImagesManager sim = new SystemImagesManager(); //如何扫码内容为url地址则从地址中取出车辆id if (vehicleID != null && (vehicleID.StartsWith("http://") || vehicleID.StartsWith("https://"))) { //http://api.qingniaokeji.cn/download/app.aspx?no=xxxxxxxxxxxxx Uri uri = new Uri(vehicleID); System.Collections.Specialized.NameValueCollection coll = System.Web.HttpUtility.ParseQueryString(uri.Query); vehicleID = coll.Get("no"); } Hashtable vehicle = vm.GetVehicleInfoByID(vehicleID, weidu, jingdu); if (vehicle == null || vehicle.Keys.Count <= 0) { vehicle = vm.GetVehicleInfoByName(vehicleID, weidu, jingdu); } string thumbImg = string.Empty; string detailsImg = string.Empty; if (vehicle == null || vehicle.Keys.Count <= 0) { return(SiteHelper.GetJsonFromHashTable(null, "faild", "车辆数据为空")); } else { DataTable dt = sim.GetImagesByVehicleID(vehicleID); if (dt != null) { foreach (DataRow dr in dt.Rows) { if (dr["Type"].ToString().Trim() == ((int)ImagesType.Thumbnail).ToString().Trim()) { thumbImg += SiteHelper.GetFileServer() + dr["ImageUrl"].ToString().Trim() + ";"; } if (dr["Type"].ToString().Trim() == ((int)ImagesType.Details).ToString().Trim()) { detailsImg += SiteHelper.GetFileServer() + dr["ImageUrl"].ToString().Trim() + ";"; } } } vehicle["THUMBIMG"] = thumbImg; vehicle["DETAILSIMG"] = detailsImg; string lng = vehicle["LONGITUDE"].ToString(); string lat = vehicle["LATITUDE"].ToString(); if (!string.IsNullOrEmpty(lng) && !string.IsNullOrEmpty(lat)) { LatLng latlng = new LatLng(double.Parse(lat), double.Parse(lng)); if (res["Client"] != null && "iOS" == res["Client"].ToString()) { latlng = new LatLng(double.Parse(lat), double.Parse(lng)); latlng = SiteHelper.TransformFromWGSToGCJ(latlng); vehicle["LONGITUDE"] = latlng.longitude; vehicle["LATITUDE"] = latlng.latitude; } else { /*latlng = SiteHelper.GetBaiduByGPS(lat, lng); * if (latlng != null) * { * vehicle["LATITUDE"] = latlng.latitude; * vehicle["LONGITUDE"] = latlng.longitude; * if (vehicle["ADDRESS"].ToString().Length <= 0) * { * vehicle["ADDRESS"] = SiteHelper.GetLocationByGPS(vehicle["LATITUDE"].ToString(), vehicle["LONGITUDE"].ToString()); * } * }*/ latlng = new LatLng(double.Parse(lat), double.Parse(lng)); latlng = SiteHelper.TransformFromWGSToGCJ(latlng); vehicle["LONGITUDE"] = latlng.longitude; vehicle["LATITUDE"] = latlng.latitude; string citycode = "", cityname = ""; vehicle["ADDRESS"] = SiteHelper.GetAddressInfoByGPS(latlng.longitude.ToString(), latlng.latitude.ToString(), out citycode, out cityname); } } decimal electricity = 0; decimal.TryParse(vehicle["ELECTRICITY"].ToString(), out electricity); int dianliang = Decimal.ToInt32(electricity); vehicle["ELECTRICITY"] = dianliang + "%"; vehicle["PRICESYSTEM"] = SiteHelper.GetFileServer() + "/AppPage/BusinessInfo.aspx?id=" + SiteHelper.GetHashTableValueByKey(vehicle, "ID") + "&type=" + BusinessType.Vehicle.GetHashCode() + "&field=" + BusinessFieldType.PRICESYSTEM.GetHashCode(); vehicle["VEHICLEREMARK"] = SiteHelper.GetFileServer() + "/AppPage/BusinessInfo.aspx?id=" + SiteHelper.GetHashTableValueByKey(vehicle, "ID") + "&type=" + BusinessType.Vehicle.GetHashCode() + "&field=" + BusinessFieldType.VEHICLEREMARK.GetHashCode(); vehicle["TRANSPORTINFORMATION"] = SiteHelper.GetFileServer() + "/AppPage/BusinessInfo.aspx?id=" + SiteHelper.GetHashTableValueByKey(vehicle, "ID") + "&type=" + BusinessType.Vehicle.GetHashCode() + "&field=" + BusinessFieldType.TRANSPORTINFORMATION.GetHashCode(); return(SiteHelper.GetJsonFromHashTable(vehicle, "success", "获取数据成功", "VehicleInfo")); } } }
/// <summary> /// 获取附近车辆详细信息 /// </summary> /// <param name="context"></param> private void GetVehicleByID(HttpContext context) { string vehicleID = string.Empty; string weidu = string.Empty; string jingdu = string.Empty; if (context.Request["VehicleID"] == null || context.Request["Latitude"] == null || context.Request["Longitude"] == null || context.Request["VehicleID"].ToString().Trim().Length <= 0 || context.Request["Latitude"].ToString().Trim().Length <= 0 || context.Request["Longitude"].ToString().Trim().Length <= 0) { context.Response.Write(SiteHelper.GetJsonFromHashTable(null, "faild", "参数不完整")); context.Response.End(); } else { vehicleID = context.Request["VehicleID"].ToString().Trim(); weidu = context.Request["Latitude"].ToString().Trim(); jingdu = context.Request["Longitude"].ToString().Trim(); VehicleManager vm = new VehicleManager(); SystemImagesManager sim = new SystemImagesManager(); Hashtable vehicle = vm.GetVehicleInfoByID(vehicleID, weidu, jingdu); string thumbImg = string.Empty; string detailsImg = string.Empty; if (vehicle == null || vehicle.Keys.Count <= 0) { context.Response.Write(SiteHelper.GetJsonFromHashTable(null, "faild", "车辆数据为空")); } else { DataTable dt = sim.GetImagesByVehicleID(vehicleID); if (dt != null) { foreach (DataRow dr in dt.Rows) { if (dr["Type"].ToString().Trim() == ((int)ImagesType.Thumbnail).ToString().Trim()) { thumbImg += SiteHelper.GetFileServer() + dr["ImageUrl"].ToString().Trim() + ";"; } if (dr["Type"].ToString().Trim() == ((int)ImagesType.Details).ToString().Trim()) { detailsImg += SiteHelper.GetFileServer() + dr["ImageUrl"].ToString().Trim() + ";"; } } } vehicle["THUMBIMG"] = thumbImg; vehicle["DETAILSIMG"] = detailsImg; string lng = vehicle["LONGITUDE"].ToString(); string lat = vehicle["LATITUDE"].ToString(); if (!string.IsNullOrEmpty(lng) && !string.IsNullOrEmpty(lat)) { /*LatLng latlng = SiteHelper.GetBaiduByGPS(lat, lng); * vehicle["LATITUDE"] = latlng.latitude; * vehicle["LONGITUDE"] = latlng.longitude; * if (vehicle["ADDRESS"].ToString().Length <= 0) * { * vehicle["ADDRESS"] = SiteHelper.GetLocationByGPS(vehicle["LONGITUDE"].ToString(), vehicle["LATITUDE"].ToString()); * }*/ LatLng latlng = new LatLng(double.Parse(lat), double.Parse(lng)); latlng = SiteHelper.TransformFromWGSToGCJ(latlng); vehicle["LATITUDE"] = latlng.latitude; vehicle["LONGITUDE"] = latlng.longitude; } decimal electricity = 0; decimal.TryParse(vehicle["ELECTRICITY"].ToString(), out electricity); int dianliang = Decimal.ToInt32(electricity); vehicle["ELECTRICITY"] = dianliang + "%"; vehicle["PRICESYSTEM"] = SiteHelper.GetFileServer() + "/AppPage/BusinessInfo.aspx?id=" + SiteHelper.GetHashTableValueByKey(vehicle, "ID") + "&type=" + BusinessType.Vehicle.GetHashCode() + "&field=" + BusinessFieldType.PRICESYSTEM.GetHashCode(); vehicle["VEHICLEREMARK"] = SiteHelper.GetFileServer() + "/AppPage/BusinessInfo.aspx?id=" + SiteHelper.GetHashTableValueByKey(vehicle, "ID") + "&type=" + BusinessType.Vehicle.GetHashCode() + "&field=" + BusinessFieldType.VEHICLEREMARK.GetHashCode(); vehicle["TRANSPORTINFORMATION"] = SiteHelper.GetFileServer() + "/AppPage/BusinessInfo.aspx?id=" + SiteHelper.GetHashTableValueByKey(vehicle, "ID") + "&type=" + BusinessType.Vehicle.GetHashCode() + "&field=" + BusinessFieldType.TRANSPORTINFORMATION.GetHashCode(); context.Response.Write(SiteHelper.GetJsonFromHashTable(vehicle, "success", "获取数据成功", "VehicleInfo")); } } }
public string Execute(Hashtable params_ht) { Hashtable res = params_ht; if (res["VehicleID"] == null || res["VehicleID"].ToString().Trim().Length <= 0) { return(SiteHelper.GetJsonFromHashTable(null, "faild", "参数不完整")); } else { vehicleID = res["VehicleID"].ToString().Trim(); VehicleManager vm = new VehicleManager(); SystemImagesManager sim = new SystemImagesManager(); //如何扫码内容为url地址则从地址中取出车辆id if (vehicleID != null && (vehicleID.StartsWith("http://") || vehicleID.StartsWith("https://"))) { //http://api.qingniaokeji.cn/download/app.aspx?no=xxxxxxxxxxxxx Uri uri = new Uri(vehicleID); System.Collections.Specialized.NameValueCollection coll = System.Web.HttpUtility.ParseQueryString(uri.Query); vehicleID = coll.Get("no"); } Hashtable vehicle = vm.GetVehicleInfoByIDORNumber(vehicleID); OrdersManager om = new OrdersManager(); string thumbImg = string.Empty; string detailsImg = string.Empty; if (vehicle == null || vehicle.Keys.Count <= 0) { return(SiteHelper.GetJsonFromHashTable(null, "faild", "车辆数据为空")); } else { DataTable dt = sim.GetImagesByVehicleID(vehicleID); if (dt != null) { foreach (DataRow dr in dt.Rows) { if (dr["Type"].ToString().Trim() == ((int)ImagesType.Thumbnail).ToString().Trim()) { thumbImg += SiteHelper.GetFileServer() + dr["ImageUrl"].ToString().Trim() + ";"; } if (dr["Type"].ToString().Trim() == ((int)ImagesType.Details).ToString().Trim()) { detailsImg += SiteHelper.GetFileServer() + dr["ImageUrl"].ToString().Trim() + ";"; } } } vehicle["THUMBIMG"] = thumbImg; vehicle["DETAILSIMG"] = detailsImg; string lng = vehicle["LONGITUDE"].ToString(); string lat = vehicle["LATITUDE"].ToString(); if (!string.IsNullOrEmpty(lng) && !string.IsNullOrEmpty(lat)) { LatLng latlng = new LatLng(double.Parse(lat), double.Parse(lng)); latlng = SiteHelper.TransformFromWGSToGCJ(latlng); if (latlng != null) { vehicle["LATITUDE"] = latlng.latitude; vehicle["LONGITUDE"] = latlng.longitude; if (vehicle["ADDRESS"].ToString().Length <= 0) { vehicle["ADDRESS"] = SiteHelper.GetLocationByGPS(vehicle["LONGITUDE"].ToString(), vehicle["LATITUDE"].ToString(), "gcj02ll"); } } } decimal electricity = 0; decimal.TryParse(vehicle["ELECTRICITY"].ToString(), out electricity); int dianliang = Decimal.ToInt32(electricity); vehicle["ELECTRICITY"] = dianliang + "%"; vehicle["AbnormalState"] = 0; Hashtable abht = null;// vm.GetAbnormalVehicle(vehicle["ID"].ToString()); if (abht != null && abht.Keys.Count > 0) { vehicle["AbnormalState"] = 1; vehicle["AlarmType"] = SiteHelper.GetHashTableValueByKey(abht, "AlarmType"); vehicle["AlarmTime"] = SiteHelper.GetHashTableValueByKey(abht, "AlarmTime"); } vehicle["ChargeBeginTime"] = ""; Hashtable chargeht = vm.GetVehicleChargingInfo(vehicle["ID"].ToString()); if (chargeht != null && chargeht.Keys.Count > 0) { vehicle["ChargeBeginTime"] = chargeht["BEGINTIME"].ToString(); } Hashtable order_ht = om.GetLatestUserByVehicleID(vehicle["ID"].ToString()); if (order_ht != null && order_ht.Keys.Count > 0) { vehicle["OrderUserName"] = order_ht["REALNAME"]; vehicle["OrderUserTel"] = order_ht["BINDPHONE"]; //vehicle["HeadPortrait"] = SiteHelper.GetFileServer() + order_ht["HEADPORTRAIT"]; vehicle["HeadPortrait"] = ""; vehicle["OrderState"] = order_ht["ORDERSTATE"]; vehicle["UserType"] = order_ht["USERTYPE"]; vehicle["OrderTime"] = order_ht["CREATETIME"]; } else { vehicle["OrderUserName"] = ""; vehicle["OrderUserTel"] = ""; vehicle["HeadPortrait"] = ""; vehicle["OrderState"] = ""; vehicle["UserType"] = ""; vehicle["OrderTime"] = ""; } return(SiteHelper.GetJsonFromHashTable(vehicle, "success", "获取数据成功", "VehicleInfo")); } } }