protected void btnNext_Click(object sender, EventArgs e) { if (tpuId > 0 && !string.IsNullOrEmpty(path)) { string imagePath = monitor.GetImgPathByTPUId(tpuId); string[] arrImgPath = imagePath.Split('|'); string thumbnailImgPath = string.Empty; for (int i = 0; i < arrImgPath.Length; i++) { var arrPath = arrImgPath[i].Split('.'); if (arrPath.Length > 1) { thumbnailImgPath += (arrPath[0] + "s." + arrPath[1] + "|"); } } if (hfImagePath.Value == "," || string.IsNullOrEmpty(hfImagePath.Value)) { imagePath = imagePath.Replace(path + "|", "").Replace(path, ""); thumbnailImgPath = thumbnailImgPath.Replace(path.Substring(0, path.LastIndexOf('.')) + "s" + path.Substring(path.LastIndexOf('.')) + "|", "").Replace(path.Substring(0, path.LastIndexOf('.')) + "s" + path.Substring(path.LastIndexOf('.')), ""); monitor.DeleteImageDetail(path); } else { imagePath = imagePath.Replace(path, path + "|" + hfImagePath.Value); thumbnailImgPath = thumbnailImgPath.Replace(path.Substring(0, path.LastIndexOf('.')) + "s" + path.Substring(path.LastIndexOf('.')), path.Substring(0, path.LastIndexOf('.')) + "s" + path.Substring(path.LastIndexOf('.')) + "|" + (hfImagePath.Value.Substring(0, path.LastIndexOf('.')) + "s" + hfImagePath.Value.Substring(path.LastIndexOf('.')))); string rootImage = ConfigurationManager.AppSettings["RootRadioSmartImage"] + System.IO.Path.DirectorySeparatorChar + hfImagePath.Value;//上传目录 Exif exif = new Exif(rootImage); string ShootPosition = ConvertDegreesToDigital(exif.GPSLongitude) + "," + ConvertDegreesToDigital(exif.GPSLatitude); if (!string.IsNullOrEmpty(exif.GPSLongitude) && !string.IsNullOrEmpty(exif.GPSLatitude)) { monitor.UpdateShootPosition(ShootPosition, tpuId); } string exportImgPath = monitor.GetIdByTPUId(tpuId) + "_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + hfImagePath.Value.Substring(hfImagePath.Value.LastIndexOf('.')); monitor.AddImageDetail(tpuId, hfImagePath.Value, hfImagePath.Value.Substring(0, hfImagePath.Value.LastIndexOf('.')) + "s" + hfImagePath.Value.Substring(hfImagePath.Value.LastIndexOf('.')), arrImgPath.Length, exportImgPath); } monitor.UpdateImagePath(imagePath.Trim('|'), thumbnailImgPath.Trim('|'), tpuId); Response.Redirect("ViewImage.aspx?tpuid=" + tpuId); } else { ScriptHelper.ShowCustomScript(this, "effect.Dialog.alert('操作出错!')"); Response.Redirect("ViewImage.aspx?tpuid=" + tpuId); } }
protected void btnNext_Click(object sender, EventArgs e) { if (tpId == 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>effect.Dialog.alert('错误操作!');</script>"); return; } int userId = monitor.GetUserIdByCusId(base.Profile.CusId); //if (base.Profile.CustomerType == 2 && userId == 0) //{ // Page.ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>effect.Dialog.alert('该账号未绑定微信!');</script>"); // return; //} string imagePath = hfImagePath.Value; if (imagePath == "," || string.IsNullOrEmpty(imagePath)) { Page.ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>effect.Dialog.alert('请上传图片文件!');</script>"); return; } string rootImage = ConfigurationManager.AppSettings["RootRadioSmartImage"];//上传目录 string[] imagePaths = hfImagePath.Value.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); string thumbnailImgPaths = string.Empty, thumbnailImgPath = string.Empty, ShootPosition = string.Empty; DateTime ShootDate = new DateTime(); DataTable dt; if (userId > 0) { dt = monitor.GetTaskProjectUserRelation(tpId, userId, Profile.CusId); } else { dt = monitor.GetTaskProjectUserRelation(tpId); } if (dt.Rows.Count > 0) { for (int i = 0; i < imagePaths.Length; i++) { Exif exif = new Exif(rootImage + System.IO.Path.DirectorySeparatorChar + imagePaths[i]); string[] dtParts = exif.DateTime.Split(new string[2] { " ", ":" }, StringSplitOptions.RemoveEmptyEntries); if (dtParts.Length > 0) { if (Convert.ToInt32(dtParts[0]) > 0) { //有拍照日期 ShootDate = new DateTime(Convert.ToInt32(dtParts[0]), Convert.ToInt32(dtParts[1]), Convert.ToInt32(dtParts[2]), Convert.ToInt32(dtParts[3]), Convert.ToInt32(dtParts[4]), Convert.ToInt32(dtParts[5]), DateTimeKind.Local); } } if (!string.IsNullOrEmpty(exif.GPSLongitude) && !string.IsNullOrEmpty(exif.GPSLatitude)) { ShootPosition = ConvertDegreesToDigital(exif.GPSLongitude) + "," + ConvertDegreesToDigital(exif.GPSLatitude); } var arrPath = imagePaths[i].Split('.'); if (arrPath.Length > 1) { thumbnailImgPath = arrPath[0] + "s." + arrPath[1]; string exportImgPath = monitor.GetIdByTPUId(ConvertHelper.GetInteger(dt.Rows[0]["TPUId"])) + "_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + imagePaths[i].Substring(imagePaths[i].LastIndexOf('.')); monitor.AddImageDetail(ConvertHelper.GetInteger(dt.Rows[0]["TPUId"]), imagePaths[i], thumbnailImgPath, i + 1, exportImgPath); thumbnailImgPaths += thumbnailImgPath + "|"; } } imagePath = imagePath.Trim('|'); thumbnailImgPaths = thumbnailImgPaths.Trim('|'); if (userId == 0) { userId = ConvertHelper.GetInteger(dt.Rows[0]["UserId"]); } imagePath += "|" + dt.Rows[0]["ImgPath"]; thumbnailImgPaths += "|" + dt.Rows[0]["ThumbnailImgPath"]; if (ShootDate.Year == 1) { ShootDate = ConvertHelper.GetDateTime(dt.Rows[0]["ShootTime"]).Year == 1 ? DateTime.Now : ConvertHelper.GetDateTime(dt.Rows[0]["ShootTime"]); } if (string.IsNullOrEmpty(ShootPosition)) { ShootPosition = dt.Rows[0]["ShootPosition"].ToString(); } monitor.SaveImagePath(tpId, userId, Profile.CusId, imagePath.Trim('|'), thumbnailImgPaths.Trim('|'), ShootDate, ShootPosition); monitor.UpdateAbnormalType(tpId, ConvertHelper.GetInteger(hfAbnormalType.Value)); } if (Profile.CustomerType == 1) { Response.Redirect("ViewPlan.aspx?tid=" + tid); } Response.Redirect(string.Format("MyTaskList.aspx?tid={0}&type={1}&name={2}", tid, type, name)); }