Exemple #1
0
        public ActionResult ModifyPhotoPoint()
        {
            if (!AppData.IsManagerLogin)
            {
                return(HandleResult(false, "您未登录后台或会话已过期"));
            }
            if (PrivilegeBLL.HasNotPrivilege(AppData.SessionUserID, 1002))
            {
                return(HandleResult(false, "您没有执行该操作的权限"));
            }

            Validation vld      = new Validation();
            int        pointID  = vld.GetInt("id", false, "请传入照片编号");
            PhotoBLL   photoBLL = new PhotoBLL();

            PhotoPointObj photoPointObj = photoBLL.GetPhotoPointByID(pointID);

            photoPointObj.X    = vld.GetInt("x", false, "请传入照片X坐标");
            photoPointObj.Y    = vld.GetInt("y", false, "请传入照片Y坐标");
            photoPointObj.Name = vld.Get("name", false, "请填写照片名称");
            photoPointObj.Cap  = vld.Get("cab");

            HttpPostedFileBase pic = Request.Files.Count == 0 ? null : Request.Files[0];

            if (vld.HasError)
            {
                return(HandleResult(false, vld.GetError()));
            }
            if (pic != null && pic.ContentLength != 0)
            {
                string ext = Path.GetExtension(pic.FileName);
                if (!Regex.IsMatch(ext, @"^\.(gif|jpg|jpeg|png)$", RegexOptions.IgnoreCase))
                {
                    return(HandleResult(false, "上传的图片格式不合要求,请上传gif,png,jpg格式的图片"));
                }

                string path    = DateTime.Now.ToString("yyyyMMdd");
                string dirPath = Config.MediaPath + @"\Package\" + path;
                if (!Directory.Exists(dirPath))
                {
                    Directory.CreateDirectory(dirPath);
                }

                string newFileName = DateTime.Now.ToString("yyyyMMddHHmmss_ffff") + ext;
                string savePath    = Path.Combine(dirPath, newFileName);

                System.IO.File.Delete(Config.MediaPath + photoPointObj.Pic.Replace("/", "\\"));

                pic.SaveAs(savePath);
                photoPointObj.Pic = "/Package/" + path + "/" + newFileName;
            }

            photoBLL.ModifyPhotoPoint(photoPointObj);

            return(HandleResult(true, photoPointObj.PhotoID.ToString()));
        }
Exemple #2
0
        public ActionResult DeletePhotoPoint()
        {
            if (!AppData.IsManagerLogin)
            {
                return(Json(new { success = false, msg = "您未登录后台或会话已过期" }));
            }
            if (PrivilegeBLL.HasNotPrivilege(AppData.SessionUserID, 1003))
            {
                return(Json(new { success = false, msg = "您没有执行该操作的权限" }));
            }

            Validation vld     = new Validation();
            int        pointID = vld.GetInt("id", false, "请传入照片编号");

            PhotoBLL      photoBLL      = new PhotoBLL();
            PhotoPointObj photoPointObj = photoBLL.GetPhotoPointByID(pointID);

            System.IO.File.Delete(Config.MediaPath + photoPointObj.Pic.Replace("/", "\\"));

            photoBLL.DeletePhotoPoint(pointID);

            return(Json(new { success = true }));
        }