Example #1
0
        public JsonResult AddOrderFilter(int OrderID)
        {
            if (Request.Files.Count > 0)
            {
                string ImageName = CombHelper.GenerateOrderNumber() + ".png";
                //传过来的图片
                var    file  = Request.Files[0];
                string fPath = "/File/" + OrderID.ToString() + "/Filter/";//+"/" + ImageName
                //保存到本地或服务器

                if (!Directory.Exists(System.Web.HttpContext.Current.Server.MapPath(fPath)))
                {
                    FileHelper.CreateDirectory(System.Web.HttpContext.Current.Server.MapPath(fPath));
                }
                var    uploadsPath = Path.Combine(fPath, CombHelper.GenerateNumber());
                string extraName   = file.FileName.Substring(file.FileName.LastIndexOf(".") + 1);
                string fName       = file.FileName;
                string filepath    = uploadsPath + "." + extraName;
                file.SaveAs(System.Web.HttpContext.Current.Server.MapPath(filepath));


                return(Json(new { R = true }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { R = false, ID = 0 }, JsonRequestBehavior.AllowGet));
            }
        }
Example #2
0
        public JsonResult AddOrderPhoto(int OrderID, string PhotoPath, string EqupID)
        {
            if (Request.Files.Count > 0)
            {
                string ImageName = CombHelper.GenerateOrderNumber() + ".png";
                //传过来的图片
                var    file  = Request.Files[0];
                string fPath = "/File/" + OrderID.ToString(); //+"/" + ImageName
                //保存到本地或服务器

                if (!Directory.Exists(System.Web.HttpContext.Current.Server.MapPath(fPath)))
                {
                    FileHelper.CreateDirectory(System.Web.HttpContext.Current.Server.MapPath(fPath));
                }
                var    uploadsPath = Path.Combine(fPath, CombHelper.GenerateNumber());
                string extraName   = file.FileName.Substring(file.FileName.LastIndexOf(".") + 1);
                string fName       = file.FileName;
                string filepath    = uploadsPath + "." + extraName;
                file.SaveAs(System.Web.HttpContext.Current.Server.MapPath(filepath));

                OrderPhoto odphoto = new OrderPhoto();
                odphoto.OrderID         = OrderID.ToString();
                odphoto.PhotoPath       = PhotoPath;
                odphoto.PhotoServerPath = ConfigHelper.GetConfigString("HttpUlr") + fPath;
                odphoto.CreatDate       = DateTime.Now.ToString();
                odphoto.EqID            = EqupID;
                unitOfWork.DOrderPhoto.Insert(odphoto);
                var isSave = unitOfWork.SaveRMsg();
                if (isSave == "True")
                {
                    return(Json(new { R = true, ID = odphoto.ID }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { R = false, ID = 0 }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(Json(new { R = false, ID = 0 }, JsonRequestBehavior.AllowGet));
            }
        }