/// <summary> /// 上传图片 /// </summary> /// <returns></returns> public ActionResult Upload() { try { HttpPostedFileBase file = Request.Files["filename"]; string bytes = Request["filename"]; byte[] bytess = Convert.FromBase64String(bytes.Split(',')[1]); string fansId = Request["openid"]; string bendword = Request["bendword"]; string bagword = Request["bagword"]; string smllword = Request["smllword"]; Random ran = new Random(); string Extension = ran.Next(100, 999) + ".jpeg";//Path.GetExtension(file.FileName).ToLower(); Stream st = new MemoryStream(bytess); byte[] data = bytess;//new byte[file.InputStream.Length]; //file.InputStream.Read(data, 0, data.Length); string url = Url.Action("../home/ViewImage"); FILES fileEntity = _conmmon.UploadFile(Extension, "image/jpg", data, url, bendword, bagword, smllword, fansId); return(Json("")); } catch (Exception ex) { return(Json("")); } }
static internal bool testFileAdd(String containerName, String filePath, int currentUser) { if (System.IO.File.Exists(filePath)) { DataContext db = new DataContext(System.Configuration.ConfigurationManager.ConnectionStrings["DSDBDatabaseConnectionString"].ToString()); Table <FILES> Files = db.GetTable <FILES>(); IQueryable <FILES> filePathUniqueQuery = from file in Files where file.file_path == filePath select file; if (filePathUniqueQuery.Count() == 0) { FILES file_add = new FILES(); file_add.container_name = containerName; file_add.file_name = System.IO.Path.GetFileName(filePath); file_add.file_path = filePath; file_add.file_contents = System.IO.File.ReadAllBytes(filePath); file_add.type = Path.GetExtension(filePath); file_add.user_id = currentUser; if (containerName.Equals("") || containerName.ToLower().Equals("public")) { file_add.container_name = "Public"; } Files.InsertOnSubmit(file_add); try { db.SubmitChanges(); return(true); } catch (Exception e) { return(false); } } } return(false); }
public ActionResult AddDonation(DONATION myDonation, IEnumerable <HttpPostedFileBase> image) { DONATION donation = myDonation; List <FILES> myList = new List <FILES>(); if (ModelState.IsValid) { foreach (var item in image) { if (item != null && item.ContentLength > 0) { var myImage = new FILES { FileName = System.IO.Path.GetFileName(item.FileName), ContentType = item.ContentType, DonationId = donation.DonationId, DonorId = donation.DonorId }; using (var reader = new System.IO.BinaryReader(item.InputStream)) { myImage.Content = reader.ReadBytes(item.ContentLength); } myList.Add(myImage); } donation.FILES = myList; } dnRepo.Add(donation); return(RedirectToAction("Details", "DONORs", new { id = donation.DonorId })); } ViewBag.TypeOf = new SelectList(ddlData.TYPEOF, "TypeOf", "TypeOf"); ViewBag.GiftMethod = new SelectList(ddlData.GIFTMETHOD, "GiftMethod", "GiftMethod"); ViewBag.DonorId = new SelectList(ddlData.DONOR, "DONORID", "FNAME", donation.DonorId); ViewBag.Fund = new SelectList(ddlData.FUNDS, "Fund", "Fund"); ViewBag.GL = new SelectList(ddlData.GLS, "GL", "GL"); ViewBag.Department = new SelectList(ddlData.DEPARTMENTS, "Department", "Department"); ViewBag.Program = new SelectList(ddlData.PROGRAMS, "Program", "Program"); ViewBag.Grant = new SelectList(ddlData.GRANTS, "GrantName", "GrantName"); return(View("~/Views/DONATIONs/DonorCreate.cshtml", donation)); }
public ActionResult EditDonation([Bind(Include = "DonationId,DonorId,Amount,TypeOf,DateRecieved,GiftMethod,DateGiftMade,GiftRestrictions,Notes,Fund,GL,Department,Program,GrantS,Appeal")] DONATION dONATION, IEnumerable <HttpPostedFileBase> image) { List <FILES> myList = new List <FILES>(); if (ModelState.IsValid) { foreach (var item in image) { if (item != null && item.ContentLength > 0) { var check = new FILES { FileName = System.IO.Path.GetFileName(item.FileName), ContentType = item.ContentType, DonationId = dONATION.DonationId, DonorId = dONATION.DonorId }; using (var reader = new System.IO.BinaryReader(item.InputStream)) { check.Content = reader.ReadBytes(item.ContentLength); } myList.Add(check); } dONATION.FILES = myList; } dnRepo.SaveDonation(dONATION); return(RedirectToAction("Details", "DONORs", new { id = dONATION.DonorId })); } ViewBag.TypeOf = new SelectList(ddlData.DONATION, "TypeOf", "TypeOf"); ViewBag.GiftMethod = new SelectList(ddlData.DONATION, "GiftMethod", "GiftMethod"); ViewBag.Fund = new SelectList(ddlData.FUNDS, "Fund", "Fund"); ViewBag.DonorId = new SelectList(ddlData.DONOR, "DONORID", "FNAME", dONATION.DonorId); ViewBag.GL = new SelectList(ddlData.GLS, "GL", "GL"); ViewBag.Department = new SelectList(ddlData.DEPARTMENTS, "Department", "Department"); ViewBag.Program = new SelectList(ddlData.PROGRAMS, "Program", "Program"); ViewBag.Grant = new SelectList(ddlData.GRANTS, "GrantName", "GrantName"); return(View(dONATION)); }
public FILES FilesSingle(string loginKey, ref ErrorInfo err, int id) { if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(null); } using (DBEntities db = new DBEntities()) { YL_FILES ent = db.YL_FILES.SingleOrDefault(x => x.ID == id); FILES reEnt = Fun.ClassToCopy <YL_FILES, FILES>(ent); return(reEnt); } }
public FILES UploadFile(string ext, string contentType, byte[] data, string url, string bendword, string bagword, string smllword, string fansId) { FILES fileEntity = null; try { string newName = Guid.NewGuid().ToString("d") + ext; string filePath = string.Concat(AppConfig.UploadTMP, DateTime.Today.ToString("yyyyMMdd"), "\\"); if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } string fullName = filePath + newName; Stream st = new MemoryStream(data); //using (FileStream steam = new FileStream(fullName, FileMode.CreateNew, FileAccess.Write)) //{ // //steam.Write(data, 0, data.Length); //StreamHelper.MakeThumbnail(st, fullName, 20, 20, true); StreamHelper.GetPicThumbnail(st, fullName, 20, 20, 30); //} fileEntity = new FILES(); fileEntity.BEND_WORD = bendword; fileEntity.BAG_WORD = bagword; fileEntity.FANS_ID = int.Parse(string.IsNullOrEmpty(fansId) ? "0" : fansId); fileEntity.SMALL_WORD = smllword; fileEntity.CREATE_TIME = DateTime.Now; fileEntity.CONTENT_TYPE = contentType; fileEntity.FILE_NAME = fullName; fileEntity.FILE_SIZE = data.Length; fileEntity.IS_GOOD = 0; fileEntity.REMARK = fullName.Split('\\')[fullName.Split('\\').Length - 1]; fileEntity.ID = (int)_repo.Insert(fileEntity); fileEntity.FILE_URL = url + "/" + fileEntity.ID; _repo.Update(fileEntity); } catch (Exception ex) { throw new BOException("上传图片发生意外错误,请稍后重试,或联系管理员", ex); } return(fileEntity); }
public FilePathResult ViewImage(int id) { if (id == 0) { string emptyFile = Server.MapPath("~/assets/img/icon/s.gif"); return(new FilePathResult(emptyFile, "image/gif")); } FILES fileEntity = _cservice.GetUploadFile(id); if (fileEntity == null) { throw new FileNotFoundException(); } return(new FilePathResult(fileEntity.FILE_NAME, fileEntity.CONTENT_TYPE)); }
public FILES UploadFile(string ext, string uploadurl, string contentType, byte[] data, string url, string remark) { FILES fileEntity = null; try { string newName = Guid.NewGuid().ToString("d") + ext; string filePath = string.Concat(uploadurl, DateTime.Today.ToString("yyyyMMdd"), "\\"); if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } string fullName = filePath + newName; using (FileStream steam = new FileStream(fullName, FileMode.CreateNew, FileAccess.Write)) { steam.Write(data, 0, data.Length); } fileEntity = new FILES(); fileEntity.CONTENT_TYPE = contentType; fileEntity.FILE_NAME = fullName; fileEntity.FILE_SIZE = data.Length; fileEntity.FILE_URL = "<!--只有图片存放到外部时才有用哦--!>"; if (remark != "") { fileEntity.REMARK = remark; } else { fileEntity.REMARK = fullName.Split('\\')[fullName.Split('\\').Length - 1]; } fileEntity.ID = (int)_set.Insert(fileEntity); fileEntity.FILE_URL = url + "/" + fileEntity.ID; _set.Update(fileEntity); } catch (Exception ex) { throw new BOException("上传图片发生意外错误,请稍后重试,或联系管理员", ex); } return(fileEntity); }
public FILES UploadFile2(string ext, string contentType, byte[] data, string url) { FILES fileEntity = null; try { string newName = Guid.NewGuid().ToString("d") + ext; string filePath = string.Concat(AppConfig.UploadTMP, DateTime.Today.ToString("yyyyMMdd"), "\\"); if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } string fullName = filePath + newName; using (FileStream steam = new FileStream(fullName, FileMode.CreateNew, FileAccess.Write)) { steam.Write(data, 0, data.Length); } fileEntity = new FILES(); fileEntity.CONTENT_TYPE = contentType; fileEntity.FILE_NAME = fullName; fileEntity.FILE_SIZE = data.Length; fileEntity.FILE_URL = "<!--只有图片存放到外部时才有用哦--!>"; fileEntity.IS_GOOD = 0; fileEntity.ID = (int)_repo.Insert(fileEntity); fileEntity.FILE_URL = url + "/" + fileEntity.ID; _repo.Update(fileEntity); } catch (Exception ex) { throw new BOException("上传图片发生意外错误,请稍后重试,或联系管理员", ex); } return(fileEntity); }
public ActionResult UploadImage(FormCollection form) { string state = ""; //判断Request中是否有接收Files文件 if (Request.Files.Count != 0) { HttpPostedFileBase file = Request.Files[0]; state = CheckUpload(file); //保存图片,重命名下文件名 if (string.IsNullOrEmpty(state)) { string Extension = Path.GetExtension(file.FileName).ToLower(); byte[] data = new byte[file.InputStream.Length]; file.InputStream.Read(data, 0, data.Length); string url = Url.Action("ViewImage"); FILES fileEntity = _cservice.UploadFile(Extension, file.ContentType, data, url); if (Request.Form["UID"] != null && Request.Form["UID"].ToString() != "") //保存顾客头像 { //CUST_INFO c = _uservice.GetCustomer(int.Parse(Request.Form["UID"].ToString())); //if (c != null) //{ // c.IMAGE_ID = fileEntity.ID; // _uservice.SaveCustomer(c); //} } return(Content("<script type='text/javascript'>parent.UploadCallback('SUCCESS','" + fileEntity.FILE_URL + "'," + fileEntity.ID + ");</script>")); } } else { state = "请选择文件"; } return(Content(state)); }
public FILES FilesAdd(string loginKey, ref ErrorInfo err, FILES inEnt) { if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) { return(null); } GlobalUser gu = Global.GetUser(loginKey); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(null); } using (DBEntities db = new DBEntities()) { inEnt.ID = Fun.GetSeqID <YL_FILES>(); inEnt.USER_ID = gu.UserId; YL_FILES reEnt = Fun.ClassToCopy <ProInterface.Models.FILES, YL_FILES>(inEnt); reEnt = db.YL_FILES.Add(reEnt); try { db.SaveChanges(); UserWriteLog(loginKey, MethodBase.GetCurrentMethod(), StatusType.UserLogType.Add); inEnt.ID = reEnt.ID; inEnt.UPLOAD_TIME = null; return(inEnt); } catch (Exception e) { err.IsError = true; err.Message = e.Message; err.Excep = e; return(null); } } }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["para"] == null && Request.Files.Count == 0) { //HttpCookie cookie = Request.Cookies["cookiedtgohome"]; //if (cookie == null) //{ // cookie = new HttpCookie("cookiedtgohome"); // cookie.Expires = DateTime.Now.AddDays(3); // cookie.Name = "cookiedtgohome"; // cookie.Value = DateTime.Now.AddDays(3).ToString("yyyy.MM.dd"); // HttpContext.Current.Response.Cookies.Add(cookie); // BaseLoad2(); //} //else //{ // DateTime dt = DateTime.Parse(cookie.Value); // if (dt < DateTime.Now) // { // cookie.Value = DateTime.Now.AddDays(3).ToString("yyyy.MM.dd"); // cookie.Expires = DateTime.Now.AddDays(3); // HttpContext.Current.Response.Cookies.Add(cookie); // BaseLoad2(); // } // else // { // BaseLoad(); // } //} //if ((Request.QueryString["FromUserName"] != null || Session["FromUserName"] != null) && (Request.QueryString["ToUserName"] != null || Session["ToUserName"] != null)) //{ // string user = Request.QueryString["FromUserName"] == null ? Session["FromUserName"].ToString() : Request.QueryString["FromUserName"].ToString(); // string user2 = Request.QueryString["ToUserName"] == null ? Session["ToUserName"].ToString() : Request.QueryString["ToUserName"].ToString(); // Session["FromUserName"] = user; // Session["ToUserName"] = user2; // Pet_JiuZhu_ShenQing sq = nvbo.GetJiuZhuShenQing(user); // if (sq == null) // { // Response.Redirect("sq1.aspx"); // } //} } else if (Request.QueryString["para"] == null && Request.Files.Count > 0 && (Request.Files[0].InputStream.Length > 0 || (Request["pic"] != null && Request["Pic"].Trim() != ""))) { HttpPostedFile file = Request.Files[0]; string Extension = Path.GetExtension(file.FileName).ToLower(); byte[] data = new byte[file.InputStream.Length]; file.InputStream.Read(data, 0, data.Length); string url = "/home/ViewImage.do"; string remark = "";// Request["filename"]; FILES fileEntity = _mservice.UploadFile(Extension, file.ContentType, data, url, remark); fileEntity.REMARK = ConfigurationSettings.AppSettings["WebUrl"] + fileEntity.FILE_URL; Response.Write("{\"url\":\"" + fileEntity.REMARK + "\",\"id\":\"" + fileEntity.ID + "\",\"d\":\"" + fileEntity.FILE_URL + "\"}"); Response.End(); } else if (Request.QueryString["para"] != null && Request.QueryString["para"] == "delete") { FILES f = _mservice.GetUploadFile(int.Parse(Request.QueryString["id"])); if (f != null) { File.Delete(f.FILE_NAME); _mservice.DeleteFiles(f.ID); } Response.Write("ok"); Response.End(); } else if (Request.QueryString["para"] != null && Request.QueryString["para"] == "tj") { //if ((Request.QueryString["FromUserName"] != null || Session["FromUserName"] != null) && (Request.QueryString["ToUserName"] != null || Session["ToUserName"] != null)) //{ // string user = Request.QueryString["FromUserName"] == null ? Session["FromUserName"].ToString() : Request.QueryString["FromUserName"].ToString(); // string user2 = Request.QueryString["ToUserName"] == null ? Session["ToUserName"].ToString() : Request.QueryString["ToUserName"].ToString(); // Session["FromUserName"] = user; // Session["ToUserName"] = user2; string[] pics = Request.Params["pic"].Split('*'); string[] pics2 = Request.Params["pic2"].Split('*'); //Pet_JiuZhu_ShenQing sq = nvbo.GetJiuZhuShenQing(user); //OAauth_Log o = mss.GetOA(user); //if (sq != null && o != null) //{ Pet_JiuZhu_ShenQing sq = new Pet_JiuZhu_ShenQing { FromUserName = Guid.NewGuid().ToString("d"), CreateTime = DateTime.Now, JDName = Request.Params["jd"], Name = Request.Params["xm"], Phone = Request.Params["sj"], WXNo = Request.Params["wx"] }; nvbo.SaveJiuZhuShenQing(sq); Pet_JiuZhu_Info j = new Pet_JiuZhu_Info { CreateTime = DateTime.Now, Detail = Request.Params["xq"], EndTime = DateTime.Now.AddDays(10), FromUserName = sq.FromUserName, Goal = int.Parse(Request.Params["mb"]), NickName = Request.Params["jd"], State = 0, PX = 0, RD = 0, Title = Request.Params["bt"], JZType = int.Parse(Request.Params["jztype"]) }; if (pics.Length > 1) { j.Img1 = pics[0]; } if (pics.Length > 2) { j.Img2 = pics[1]; } if (pics.Length > 3) { j.Img3 = pics[2]; } if (pics.Length > 4) { j.Img4 = pics[3]; } if (pics.Length > 5) { j.Img5 = pics[4]; } if (pics.Length > 6) { j.Img6 = pics[5]; } if (pics.Length > 7) { j.Img7 = pics[6]; } if (pics.Length > 8) { j.Img8 = pics[7]; } if (pics2.Length > 1) { j.HeadImage = WebUrl + pics2[0]; } int id = nvbo.SaveJiuZhuInfo(j); //j.PX = 100 + id; //j.ID = id; //nvbo.SaveJiuZhuInfo(j); //if (j.JZType == 1) // nvbo.Save50Order(id); if (id > 0) { try { j.ID = id; Task.Factory.StartNew(new Action(() => { j.CImg = CutImage2(j.Img1, 1, j.CImg, true, false); //截一张长图,八张方图,一张logo j.SImg1 = CutImage2(j.Img1, 2, j.SImg1); j.SImg2 = CutImage2(j.Img2, 2, j.SImg2); j.SImg3 = CutImage2(j.Img3, 2, j.SImg3); j.SImg4 = CutImage2(j.Img4, 2, j.SImg4); j.SImg5 = CutImage2(j.Img5, 2, j.SImg5); j.SImg6 = CutImage2(j.Img6, 2, j.SImg6); j.SImg7 = CutImage2(j.Img7, 2, j.SImg7); j.SImg8 = CutImage2(j.Img8, 2, j.SImg8); string himg = CutImage2(j.HeadImage, 2, j.HeadImage, true, false); if (himg != j.HeadImage && himg != "") { j.HeadImage = WebUrl + himg; } nvbo.SaveJiuZhuInfo(j); })); } catch (Exception) { } Response.Write("{\"msg\":\"成功\",\"st\":\"1\",\"url\":\"\"}"); Response.End(); } else { Response.Write("{\"msg\":\"失败\",\"st\":\"-1\",\"url\":\"\"}"); Response.End(); } //} //} } }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["para"] == null && Request.Files.Count == 0) { //HttpCookie cookie = Request.Cookies["cookiedtgohome"]; //if (cookie == null) //{ // cookie = new HttpCookie("cookiedtgohome"); // cookie.Expires = DateTime.Now.AddDays(3); // cookie.Name = "cookiedtgohome"; // cookie.Value = DateTime.Now.AddDays(3).ToString("yyyy.MM.dd"); // HttpContext.Current.Response.Cookies.Add(cookie); // BaseLoad2(); //} //else //{ // DateTime dt = DateTime.Parse(cookie.Value); // if (dt < DateTime.Now) // { // cookie.Value = DateTime.Now.AddDays(3).ToString("yyyy.MM.dd"); // cookie.Expires = DateTime.Now.AddDays(3); // HttpContext.Current.Response.Cookies.Add(cookie); // BaseLoad2(); // } // else // { // BaseLoad(); // } //} if ((Request.QueryString["FromUserName"] != null || Session["FromUserName"] != null) && (Request.QueryString["ToUserName"] != null || Session["ToUserName"] != null)) { string user = Request.QueryString["FromUserName"] == null ? Session["FromUserName"].ToString() : Request.QueryString["FromUserName"].ToString(); string user2 = Request.QueryString["ToUserName"] == null ? Session["ToUserName"].ToString() : Request.QueryString["ToUserName"].ToString(); Session["FromUserName"] = user; Session["ToUserName"] = user2; OAauth_Log oa = mss.GetOA(user); if (oa != null && string.IsNullOrEmpty(oa.Phone)) { Response.Redirect("bangphone.aspx?beforeurl2=" + AbsoluteUri.Replace("&", "*")); } else { Pet_JiuZhu_ShenQing sq = nvbo.GetJiuZhuShenQing(user); if (sq != null) { Response.Redirect("sq2.aspx"); } } } } else if (Request.QueryString["para"] == null && Request.Files.Count > 0 && (Request.Files[0].InputStream.Length > 0 || (Request["pic"] != null && Request["Pic"].Trim() != ""))) { HttpPostedFile file = Request.Files[0]; string Extension = Path.GetExtension(file.FileName).ToLower(); byte[] data = new byte[file.InputStream.Length]; file.InputStream.Read(data, 0, data.Length); string url = "/home/ViewImage.do"; string remark = "";// Request["filename"]; FILES fileEntity = _mservice.UploadFile(Extension, file.ContentType, data, url, remark); fileEntity.REMARK = ConfigurationSettings.AppSettings["WebUrl"] + fileEntity.FILE_URL; Response.Write("{\"url\":\"" + fileEntity.REMARK + "\",\"id\":\"" + fileEntity.ID + "\",\"d\":\"" + fileEntity.FILE_URL + "\"}"); Response.End(); } else if (Request.QueryString["para"] != null && Request.QueryString["para"] == "delete") { FILES f = _mservice.GetUploadFile(int.Parse(Request.QueryString["id"])); if (f != null) { File.Delete(f.FILE_NAME); _mservice.DeleteFiles(f.ID); } Response.Write("ok"); Response.End(); } else if (Request.QueryString["para"] != null && Request.QueryString["para"] == "tj") { if ((Request.QueryString["FromUserName"] != null || Session["FromUserName"] != null) && (Request.QueryString["ToUserName"] != null || Session["ToUserName"] != null)) { string user = Request.QueryString["FromUserName"] == null ? Session["FromUserName"].ToString() : Request.QueryString["FromUserName"].ToString(); string user2 = Request.QueryString["ToUserName"] == null ? Session["ToUserName"].ToString() : Request.QueryString["ToUserName"].ToString(); Session["FromUserName"] = user; Session["ToUserName"] = user2; string[] pics1 = Request.Params["pic1"].Split('*'); string[] pics2 = Request.Params["pic2"].Split('*'); Pet_JiuZhu_ShenQing sq = new Pet_JiuZhu_ShenQing { CardNo = Request.Params["cardno"], CreateTime = DateTime.Now, FromUserName = user, JDName = Request.Params["jdname"], Name = Request.Params["name"], Phone = Request.Params["phone"], WXNo = Request.Params["wxno"], State = 0 }; if (pics1.Length > 1) { sq.JDImg1 = pics1[0]; } if (pics1.Length > 2) { sq.JDImg2 = pics1[1]; } if (pics1.Length > 3) { sq.JDImg3 = pics1[2]; } if (pics1.Length > 4) { sq.JDImg4 = pics1[3]; } if (pics1.Length > 5) { sq.JDImg5 = pics1[4]; } if (pics2.Length > 1) { sq.CardNoImg1 = pics2[0]; } if (pics2.Length > 2) { sq.CardNoImg2 = pics2[1]; } int id = nvbo.SaveJiuZhuShenQing(sq); if (id > 0) { Response.Write("{\"msg\":\"您的资料已经提交,我们会在1个工作日进行资料审核。\",\"st\":\"1\",\"url\":\"\"}"); Response.End(); } else { Response.Write("{\"msg\":\"失败\",\"st\":\"-1\",\"url\":\"\"}"); Response.End(); } } } }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["para"] == null && Request.Files.Count == 0) { //HttpCookie cookie = Request.Cookies["cookiedtgohome"]; //if (cookie == null) //{ // cookie = new HttpCookie("cookiedtgohome"); // cookie.Expires = DateTime.Now.AddDays(3); // cookie.Name = "cookiedtgohome"; // cookie.Value = DateTime.Now.AddDays(3).ToString("yyyy.MM.dd"); // HttpContext.Current.Response.Cookies.Add(cookie); // BaseLoad2(); //} //else //{ // DateTime dt = DateTime.Parse(cookie.Value); // if (dt < DateTime.Now) // { // cookie.Value = DateTime.Now.AddDays(3).ToString("yyyy.MM.dd"); // cookie.Expires = DateTime.Now.AddDays(3); // HttpContext.Current.Response.Cookies.Add(cookie); // BaseLoad2(); // } // else // { // BaseLoad(); // } //} if ((Request.QueryString["FromUserName"] != null || Session["FromUserName"] != null) && (Request.QueryString["ToUserName"] != null || Session["ToUserName"] != null)) { string user = Request.QueryString["FromUserName"] == null ? Session["FromUserName"].ToString() : Request.QueryString["FromUserName"].ToString(); string user2 = Request.QueryString["ToUserName"] == null ? Session["ToUserName"].ToString() : Request.QueryString["ToUserName"].ToString(); Session["FromUserName"] = user; Session["ToUserName"] = user2; Pet_JiuZhu_ShenQing sq = nvbo.GetJiuZhuShenQing(user); if (sq == null) { Response.Redirect("sq1.aspx"); } } } else if (Request.QueryString["para"] == null && Request.Files.Count > 0 && (Request.Files[0].InputStream.Length > 0 || (Request["pic"] != null && Request["Pic"].Trim() != ""))) { HttpPostedFile file = Request.Files[0]; string Extension = Path.GetExtension(file.FileName).ToLower(); byte[] data = new byte[file.InputStream.Length]; file.InputStream.Read(data, 0, data.Length); string url = "/home/ViewImage.do"; string remark = "";// Request["filename"]; FILES fileEntity = _mservice.UploadFile(Extension, file.ContentType, data, url, remark); fileEntity.REMARK = ConfigurationSettings.AppSettings["WebUrl"] + fileEntity.FILE_URL; Response.Write("{\"url\":\"" + fileEntity.REMARK + "\",\"id\":\"" + fileEntity.ID + "\",\"d\":\"" + fileEntity.FILE_URL + "\"}"); Response.End(); } else if (Request.QueryString["para"] != null && Request.QueryString["para"] == "delete") { FILES f = _mservice.GetUploadFile(int.Parse(Request.QueryString["id"])); if (f != null) { File.Delete(f.FILE_NAME); _mservice.DeleteFiles(f.ID); } Response.Write("ok"); Response.End(); } else if (Request.QueryString["para"] != null && Request.QueryString["para"] == "tj") { if ((Request.QueryString["FromUserName"] != null || Session["FromUserName"] != null) && (Request.QueryString["ToUserName"] != null || Session["ToUserName"] != null)) { string user = Request.QueryString["FromUserName"] == null ? Session["FromUserName"].ToString() : Request.QueryString["FromUserName"].ToString(); string user2 = Request.QueryString["ToUserName"] == null ? Session["ToUserName"].ToString() : Request.QueryString["ToUserName"].ToString(); Session["FromUserName"] = user; Session["ToUserName"] = user2; string[] pics = Request.Params["pic"].Split('*'); string[] pics2 = Request.Params["pic2"].Split('*'); Pet_JiuZhu_ShenQing sq = nvbo.GetJiuZhuShenQing(user); OAauth_Log o = mss.GetOA(user); if (sq != null && o != null) { Pet_JiuZhu_Info j = new Pet_JiuZhu_Info { CreateTime = DateTime.Now, Detail = Request.Params["xq"], EndTime = DateTime.Parse(Request.Params["endtime"]), FromUserName = user, Goal = int.Parse(Request.Params["mb"]), NickName = sq.JDName, State = 0, PX = 0, RD = 0, JZType = Request.Params["jztype"] == "发起筹粮" ? 1 : 2, Title = Request.Params["bt"] }; if (pics.Length > 1) { j.Img1 = pics[0]; } if (pics.Length > 2) { j.Img2 = pics[1]; } if (pics.Length > 3) { j.Img3 = pics[2]; } if (pics.Length > 4) { j.Img4 = pics[3]; } if (pics.Length > 5) { j.Img5 = pics[4]; } if (pics.Length > 6) { j.Img6 = pics[5]; } if (pics.Length > 7) { j.Img7 = pics[6]; } if (pics.Length > 8) { j.Img8 = pics[7]; } if (pics2.Length > 1) { j.HeadImage = WebUrl + pics2[0]; } int id = nvbo.SaveJiuZhuInfo(j); //j.PX = 100 + id; //j.ID = id; //nvbo.SaveJiuZhuInfo(j); //if (j.JZType == 1) // nvbo.Save50Order(id); if (id > 0) { try { j.ID = id; Task.Factory.StartNew(new Action(() => { j.CImg = CutImage2(j.Img1, 1, j.CImg, true, false); //截一张长图,八张方图,一张logo j.SImg1 = CutImage2(j.Img1, 2, j.SImg1); j.SImg2 = CutImage2(j.Img2, 2, j.SImg2); j.SImg3 = CutImage2(j.Img3, 2, j.SImg3); j.SImg4 = CutImage2(j.Img4, 2, j.SImg4); j.SImg5 = CutImage2(j.Img5, 2, j.SImg5); j.SImg6 = CutImage2(j.Img6, 2, j.SImg6); j.SImg7 = CutImage2(j.Img7, 2, j.SImg7); j.SImg8 = CutImage2(j.Img8, 2, j.SImg8); string himg = CutImage2(j.HeadImage, 2, j.HeadImage, true, false); if (himg != j.HeadImage && himg != "") { j.HeadImage = WebUrl + himg; } nvbo.SaveJiuZhuInfo(j); string token = Token(mjuserid); var temp2 = new { first = new { value = "审核通知", color = "#173177" }, keyword1 = new { value = j.Title, color = "#173177" }, keyword2 = new { value = "审核中", color = "#173177" }, keyword3 = new { value = "审核中", color = "#173177" }, remark = new { value = "\n您提交的信息已进入审核,工作人员将会与您联系。", color = "#CD0000" } }; string message = SendTemplateMessage(token, j.FromUserName, "HRPL3i5IEKvWlHRm846Mf5y2bBJQ7iRv4ats-ZqbaE8", "#FF0000", temp2, WebUrl + "/wechat/order/chou.aspx"); })); } catch (Exception) { } Response.Write("{\"msg\":\"您的项目已经提交,我们会在1个工作日进行资料审核。\",\"st\":\"1\",\"url\":\"\"}"); Response.End(); } else { Response.Write("{\"msg\":\"失败\",\"st\":\"-1\",\"url\":\"\"}"); Response.End(); } } } } //else //{ // Response.Write(""); // Response.End(); //} }
if(!isset($_FILES) && isset($HTTP_POST_FILES)) $_FILES = $HTTP_POST_FILES;
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["para"] == null && Request.Files.Count == 0) { } else if (Request.QueryString["para"] == null && Request.Files.Count > 0 && (Request.Files[0].InputStream.Length > 0 || (Request["pic"] != null && Request["Pic"].Trim() != ""))) { HttpPostedFile file = Request.Files[0]; string Extension = Path.GetExtension(file.FileName).ToLower(); byte[] data = new byte[file.InputStream.Length]; file.InputStream.Read(data, 0, data.Length); string url = "/home/ViewImage.do"; string remark = "";// Request["filename"]; FILES fileEntity = _mservice.UploadFile(Extension, file.ContentType, data, url, remark); fileEntity.REMARK = ConfigurationSettings.AppSettings["WebUrl"] + fileEntity.FILE_URL; Response.Write("{\"url\":\"" + fileEntity.REMARK + "\",\"id\":\"" + fileEntity.ID + "\",\"d\":\"" + fileEntity.FILE_URL + "\"}"); Response.End(); } else if (Request.QueryString["para"] != null && Request.QueryString["para"] == "delete") { FILES f = _mservice.GetUploadFile(int.Parse(Request.QueryString["id"])); if (f != null) { File.Delete(f.FILE_NAME); _mservice.DeleteFiles(f.ID); } Response.Write("ok"); Response.End(); } else if (Request.QueryString["para"] != null && Request.QueryString["para"] == "tj") { if ((Request.QueryString["FromUserName"] != null || Session["FromUserName"] != null) && (Request.QueryString["ToUserName"] != null || Session["ToUserName"] != null)) { string user = Request.QueryString["FromUserName"] == null ? Session["FromUserName"].ToString() : Request.QueryString["FromUserName"].ToString(); string user2 = Request.QueryString["ToUserName"] == null ? Session["ToUserName"].ToString() : Request.QueryString["ToUserName"].ToString(); string[] pics = Request.Params["pic"].Split('*'); Pet_JiuZhu_ZhiYi zy = new Pet_JiuZhu_ZhiYi { CardNo = Request.Params["cardno"], CreateTime = DateTime.Now, Detail = Request.Params["detail"], FromUserName = user, IP = GetLoginIp(), Name = Request.Params["name"], Phone = Request.Params["phone"], JID = int.Parse(Request.Params["jid"]), JNickName = Request.Params["jname"], EMail = Request.Params["email"] }; if (pics.Length > 1) { zy.Img1 = pics[0]; } if (pics.Length > 2) { zy.Img2 = pics[1]; } if (pics.Length > 3) { zy.Img3 = pics[2]; } if (pics.Length > 4) { zy.Img4 = pics[3]; } if (pics.Length > 5) { zy.Img5 = pics[4]; } if (pics.Length > 6) { zy.Img6 = pics[5]; } if (pics.Length > 7) { zy.Img7 = pics[6]; } if (pics.Length > 8) { zy.Img8 = pics[7]; } int id = nvbo.SavePetJiuZhuZhiYi(zy); if (id > 0) { string token = Token(mjuserid); string[] op = new[] { "oloJGv4lWL-TS8yn8uo4Fu1rbVTI", "oloJGvzwelDQjIKMMWC8Z6ngM7gk", "oloJGvx3hLkCNadLGIpAMimz2Xwc" }; foreach (string o in op) { var temp2 = new { first = new { value = "新质疑提醒", color = "#173177" }, keyword1 = new { value = zy.Name, color = "#173177" }, keyword2 = new { value = zy.CreateTime.Value.ToString("yyyy.MM.dd HH:mm"), color = "#173177" }, remark = new { value = "\n天啦噜!居然有人发起了质疑!快去看看吧。", color = "#CD0000" } }; string message = SendTemplateMessage(token, o, "4CzZvg-tcOd5X72hX_H2NNWkhCVh5VFPRblk7c7s-DY", "#FF0000", temp2, WebUrl + "/wechat/order/seezhiyi.aspx?id=" + id); } Response.Write("{\"msg\":\"举报成功,工作人员将对举报内容认真处理。\",\"st\":\"1\",\"url\":\"\"}"); Response.End(); } else { Response.Write("{\"msg\":\"失败\",\"st\":\"-1\",\"url\":\"\"}"); Response.End(); } } //} } }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["para"] == null && Request.Files.Count == 0) { if ((Request.QueryString["FromUserName"] != null || Session["FromUserName"] != null) && (Request.QueryString["ToUserName"] != null || Session["ToUserName"] != null)) { string user = Request.QueryString["FromUserName"] == null ? Session["FromUserName"].ToString() : Request.QueryString["FromUserName"].ToString(); string user2 = Request.QueryString["ToUserName"] == null ? Session["ToUserName"].ToString() : Request.QueryString["ToUserName"].ToString(); if (Request.QueryString["id"] != null) { jz = nvbo.GetJiuZhuInfo(int.Parse(Request.QueryString["id"])); if (user == "oloJGv4lWL-TS8yn8uo4Fu1rbVTI" || user == "oloJGvzwelDQjIKMMWC8Z6ngM7gk" || user == "oloJGvx3hLkCNadLGIpAMimz2Xwc") { } else { Response.Redirect("chou.aspx"); } } } } else if (Request.QueryString["para"] == null && Request.Files.Count > 0 && (Request.Files[0].InputStream.Length > 0 || Request["Pic"].Trim() != "")) { HttpPostedFile file = Request.Files[0]; string Extension = Path.GetExtension(file.FileName).ToLower(); byte[] data = new byte[file.InputStream.Length]; file.InputStream.Read(data, 0, data.Length); string url = "/home/ViewImage.do"; string remark = "";// Request["filename"]; FILES fileEntity = _mservice.UploadFile(Extension, file.ContentType, data, url, remark); fileEntity.REMARK = ConfigurationSettings.AppSettings["WebUrl"] + fileEntity.FILE_URL; Response.Write("{\"url\":\"" + fileEntity.REMARK + "\",\"id\":\"" + fileEntity.ID + "\",\"d\":\"" + fileEntity.FILE_URL + "\"}"); Response.End(); } else if (Request.QueryString["para"] != null && Request.QueryString["para"] == "delete") { FILES f = _mservice.GetUploadFile(int.Parse(Request.QueryString["id"])); if (f != null) { File.Delete(f.FILE_NAME); _mservice.DeleteFiles(f.ID); } Response.Write("ok"); Response.End(); } else if (Request.QueryString["para"] != null && Request.QueryString["para"] == "tj") { if ((Request.QueryString["FromUserName"] != null || Session["FromUserName"] != null) && (Request.QueryString["ToUserName"] != null || Session["ToUserName"] != null)) { string user = Request.QueryString["FromUserName"] == null ? Session["FromUserName"].ToString() : Request.QueryString["FromUserName"].ToString(); string user2 = Request.QueryString["ToUserName"] == null ? Session["ToUserName"].ToString() : Request.QueryString["ToUserName"].ToString(); Session["FromUserName"] = user; Session["ToUserName"] = user2; if (Request.Params["oid"] != null) { Pet_JiuZhu_Info j = nvbo.GetJiuZhuInfo(int.Parse(Request.Params["oid"])); if (j != null && (user == "oloJGv4lWL-TS8yn8uo4Fu1rbVTI" || user == "oloJGvzwelDQjIKMMWC8Z6ngM7gk" || user == "oloJGvx3hLkCNadLGIpAMimz2Xwc")) { string[] pics = Request.Params["pic"].Split('*'); string[] pics2 = Request.Params["pic2"].Split('*'); //Pet_JiuZhu_ShenQing sq = nvbo.GetJiuZhuShenQing(user); //OAauth_Log o = mss.GetOA(user); //if (sq != null && o != null) //{ j.EditTime = DateTime.Now; j.Detail = Request.Params["xq"]; try { j.EndTime = DateTime.Parse(Request.Params["endtime"]); j.BegTime = DateTime.Parse(Request.Params["begtime"]); } catch (Exception) { } //j.FromUserName = user; j.Goal = int.Parse(Request.Params["mb"]); // j.HeadImage = WebUrl + pics2[0]; // j.NickName = sq.JDName; // j.State = 0; //j.PX = 0; //j.RD = 0; j.JZType = Request.Params["jztype"] == "发起筹粮" ? 1 : 2; j.Title = Request.Params["bt"]; if (pics.Length > 1) { j.Img1 = pics[0]; } if (pics.Length > 2) { j.Img2 = pics[1]; } if (pics.Length > 3) { j.Img3 = pics[2]; } if (pics.Length > 4) { j.Img4 = pics[3]; } if (pics.Length > 5) { j.Img5 = pics[4]; } if (pics.Length > 6) { j.Img6 = pics[5]; } if (pics.Length > 7) { j.Img7 = pics[6]; } if (pics.Length > 8) { j.Img8 = pics[7]; } int id = nvbo.SaveJiuZhuInfo(j); // j.PX = 100 + id; //j.ID = id; // nvbo.SaveJiuZhuInfo(j); //if (j.JZType == 1) // nvbo.Save50Order(id); if (id > 0) { try { if (pics.Length > 0 || pics2.Length > 0) { Task.Factory.StartNew(new Action(() => { j.CImg = CutImage2(j.Img1, 1, j.CImg, true, false); //截一张长图,八张方图,一张logo j.SImg1 = CutImage2(j.Img1, 2, j.SImg1); j.SImg2 = CutImage2(j.Img2, 2, j.SImg2); j.SImg3 = CutImage2(j.Img3, 2, j.SImg3); j.SImg4 = CutImage2(j.Img4, 2, j.SImg4); j.SImg5 = CutImage2(j.Img5, 2, j.SImg5); j.SImg6 = CutImage2(j.Img6, 2, j.SImg6); j.SImg7 = CutImage2(j.Img7, 2, j.SImg7); j.SImg8 = CutImage2(j.Img8, 2, j.SImg8); string himg = CutImage2(j.HeadImage, 2, j.HeadImage, true, false); if (himg != j.HeadImage && himg != "") { j.HeadImage = WebUrl + himg; } nvbo.SaveJiuZhuInfo(j); })); } } catch (Exception) { } Response.Write("{\"msg\":\"成功\",\"st\":\"1\",\"url\":\"\"}"); Response.End(); } else { Response.Write("{\"msg\":\"失败\",\"st\":\"-1\",\"url\":\"\"}"); Response.End(); } //} } else { Response.Write("{\"msg\":\"失败\",\"st\":\"-1\",\"url\":\"\"}"); Response.End(); } } else { Response.Write("{\"msg\":\"失败\",\"st\":\"-1\",\"url\":\"\"}"); Response.End(); } } } }