Пример #1
0
        public void ResetImage(int userImageID,  string bootPath)
        {
            UserImagesDeleted modelD = Get(userImageID);
            bizUserImages b = new bizUserImages();
            UserImages model = b.Get(userImageID);

            model.Attach();
            model.ImageSmallPath = modelD.ImageSmallPath;
            model.ImagePath = modelD.ImagePath;
            model.ImageSize = modelD.ImageSize;
            model.Width = modelD.Width;
            model.Height = modelD.Height;
            model.Detach();
            b.Update(model);

            string extName = MyText.GetFileExtName(model.ImageSmallPath);

            System.IO.File.Copy(bootPath + "/userfiles/deleted/" + model.UserImageID + "small." + extName,bootPath + model.ImageSmallPath, true);
            System.IO.File.Copy(bootPath + "/userfiles/deleted/" + model.UserImageID + "." + extName, bootPath + model.ImagePath, true);

            System.IO.File.Delete(bootPath + "/userfiles/deleted/" + model.UserImageID + "small." + extName);
            System.IO.File.Delete(bootPath + "/userfiles/deleted/" + model.UserImageID + "." + extName);

            Delete(userImageID);
        }
Пример #2
0
        /// <summary>
        /// 上传论坛中的图片
        /// </summary>
        /// <param name="basePath"></param>
        /// <param name="files"></param>
        /// <param name="fileTypes"></param>
        /// <param name="imagePath"></param>
        /// <returns></returns>
        public static string ImageUpOfBbs(int userID, HttpPostedFileBase files, int userImageTypeID, out string imagePath)
        {
            string basePath = ConfigurationManager.AppSettings["ImagePath"];
            string imageDomain = ConfigurationManager.AppSettings["ImageDomain"];
            imagePath = "";
            if (files == null)
                return "";
            bizUsers b = new bizUsers();
            Users model = b.Get(userID);
            DateTime nowDate = DateTime.Now;
            string extName = MyText.GetFileExtName(files.FileName);
            string fileNameBase = model.UserID.ToString() + nowDate.Hour.ToString() + nowDate.Minute.ToString() + nowDate.Second.ToString() + nowDate.Millisecond.ToString();
            if (bbs.GetLevels(model.OnlineTime) < 5)
            {
                return "你还没到5级,无法上传图片";
            }
            if (MyText.IsImage(extName) == false)
            {
                return "不是符合规定的图片文件";
            }
            if (files.ContentLength > 1024 * 300)
            {
                return "照片已超过300K,不能上传";
            }

            System.Drawing.Image image = System.Drawing.Image.FromStream(files.InputStream);

            try
            {
                //图片的路径
                string filePath = "/userfiles/bbs/" + nowDate.Year + "/" + nowDate.Month + "/" + nowDate.Day;
                string fileSmallName = fileNameBase + "small." + extName; //缩略图的名称
                string fileName = fileNameBase + "." + extName; //图片的名称
                string imageUrl = filePath + "/" + fileName;
                int width = image.Width; //图片的宽度
                int height = image.Height; //图片的高度

                System.IO.Directory.CreateDirectory(basePath + filePath); //创建文件夹

                if (extName.ToLower() != "gif") //如果是gif文件,则不加水印
                    image = PublicHelper.AddWatermarkImage(image, basePath + "/images/shuiyin.gif", "WM_BOTTOM_RIGHT");

                image.Save(basePath + filePath + "/" + fileName);

                ImagePlus imgplus = new ImagePlus(files.InputStream);
                imgplus.MakeThumbnail(120, 120, 1);
                imgplus.SaveAs(basePath + filePath + "/" + fileSmallName, extName);

                UserImages uiModel = new UserImages();
                uiModel.UserID = model.UserID;
                uiModel.UserImageTypeID = userImageTypeID;
                uiModel.ImageName = MyText.GetFileNoExtName(MyText.GetFileName(files.FileName));
                uiModel.ImageSmallPath = imageDomain + filePath + "/" + fileSmallName;
                uiModel.ImagePath = imageDomain + filePath + "/" + fileName;
                uiModel.ImageSize = files.ContentLength / 1024;
                uiModel.Height = height;
                uiModel.Width = width;
                uiModel.AddTime = DateTime.Now;
                bizUserImages bui = new bizUserImages();
                bui.Add(uiModel);
                imagePath = imageDomain+imageUrl;
            }
            catch (Exception e)
            {
                return e.Message;
            }
            return "";
        }
Пример #3
0
        public ActionResult UserImg(int userID,int typeID, int pageNo)
        {
            bizUsers b = new bizUsers();
            Users model = b.Get(userID);
            int pageSize = 16;
            int count;
            string strBar = "";

            bizUserImageType bt = new bizUserImageType();
            bizUserImages bi = new bizUserImages();
            List<UserImages> list = bi.List(model.UserID,typeID, pageSize, pageNo - 1, out count);
            ViewData["PageList"] = Page.GetPageList("/user/img/" + userID + "_"+ typeID +"_$page$.html", count, pageSize, pageNo);
            ViewData["UserImages"] = list;
            if (typeID != 0)
            {
                UserImageType modelType = bt.Get(typeID);
                if (modelType.LookType == 0 && UserID != modelType.UserID && UserCommon.CheckBBSAdminRight(AdminType))
                {
                    return Redirect("/user/imgfolder/" + userID + ".html");
                }

                strBar = MenuBar.Start()
                    .AddMenu("�������", "/user/imgfolder/"+ userID +".html")
                    .AddMenu(modelType.TypeName, "/user/img/"+userID +"_" + modelType.UserImageTypeID + "_1.html")
                    .GetMenuHtml();
            }
            ViewData["Bar"] = strBar;
            return View(model);
        }
Пример #4
0
 public ActionResult SelfImagesFolderDelete(int id)
 {
     int userID = UserID;
     bizUserImageType bt = new bizUserImageType();
     bizUserImages bi = new bizUserImages();
     UserImageType model = bt.Get(id);
     if (model.UserID != userID || model == null)
         return Redirect("/user/index.html");
     if (model.IsDefault == 1)
     {
         TempData["Msg"] = "���������Ĭ�ϵij�ʼ��ᣬ����ɾ��!";
         return RedirectToAction("SelfImagesFolderMod", new { id = id });
     }
     if (bi.Count(userID, id) > 0)
     {
         TempData["Msg"] = "������ﻹ��ͼƬ������ɾ��!";
         return RedirectToAction("SelfImagesFolderMod", new { id = id });
     }
     bt.Delete(id, userID);
     return RedirectToAction("SelfImagesFolder");
 }
Пример #5
0
 public ActionResult SelfImages(int id, int page,FormCollection f)
 {
     bizUserImageType bt = new bizUserImageType();
     bizUserImages bi = new bizUserImages();
     string images = f["Images"];
     int userImageType = int.Parse(f["UserImageType"]);
     string result = bi.ImagesDeal(UserID, images, userImageType);
     if (result != "")
         TempData["Msg"] = result;
     return Redirect("/user/SelfImages/"+id+"_"+page+".html");
 }
Пример #6
0
        public ActionResult SelfImages(int id, int page)
        {
            ViewData["CurrMenu"] = "�������";
            int userID = UserID;
            bizUserImageType bt = new bizUserImageType();
            int pageSize = 16;
            int count;
            string strBar = "";

            bizUserImages bi = new bizUserImages();
            List<UserImages> list = bi.List(userID, id, pageSize, page - 1, out count);
            ViewData["PageList"] = Page.GetPageList("/user/selfimages/"+ id +"_$page$.html", count, pageSize, page);
            if (id != 0)
            {
                UserImageType model = bt.Get(id);
                strBar=MenuBar.Start()
                    .AddMenu("�������", "/user/SelfImagesFolder.html")
                    .AddMenu(model.TypeName, "/user/selfImages/" + model.UserImageTypeID + "_1.html")
                    .GetMenuHtml();
            }
            ViewData["TypeList"] = bt.ListByUser(userID);
            ViewData["Bar"] = strBar;
            ViewData["ID"] = id;
            ViewData["ImageNum"] = Public.UserHelper.GetRemainImageNum(userID);
            return View(list);
        }
Пример #7
0
 public ContentResult ImagesDelete(int id)
 {
     bizUserImages bi = new bizUserImages();
     UserImages model = bi.Get(id);
     if (model == null || model.UserID != UserID)
         return Content("����Ȩɾ����ͼƬ");
     try
     {
         //return Content(Images.GetPhysicsPath(model.ImagePath, ConfigurationManager.AppSettings["ImagePath"]));
         System.IO.File.Delete(Images.GetPhysicsPath(model.ImagePath, ConfigurationManager.AppSettings["ImagePath"]));
         System.IO.File.Delete(Images.GetPhysicsPath(model.ImageSmallPath, ConfigurationManager.AppSettings["ImagePath"]));
         bi.Delete(model.UserImageID);
         return Content("");
     }
     catch { return Content("ɾ��ʧ��"); }
 }
Пример #8
0
 public ActionResult UserImagesDelete(int id)
 {
     bizUserImages bui = new bizUserImages();
     bizUserImagesDeleted buid = new bizUserImagesDeleted();
     UserImages model = bui.Get(id);
     buid.Remove(model, UserName, ConfigurationManager.AppSettings["ImagePath"]);
     return RedirectToAction("UserImages");
 }
Пример #9
0
        public ActionResult UserImages()
        {
            string userName = Request.QueryString["userName"] == null ? "" : Request.QueryString["userName"].ToString();
            string imagePath = Request.QueryString["imagePath"] == null ? "" : Request.QueryString["imagePath"].ToString();
            bizUserImagesCheck buk = new bizUserImagesCheck();
            bizUserImages bui = new bizUserImages();
            List<UserImagesCheck> listCheck = buk.ListNew(20);
            ViewData["CheckList"] = listCheck;
            int pageSize = 100;
            int page = Request.QueryString["page"] == null ? 1 : int.Parse(Request.QueryString["page"].ToString());
            int count;
            List<UserImagesDetail> list = bui.List(userName,imagePath, pageSize, page - 1, out count);
            ViewData["PageList"] = Page.GetPageList("UserImages?userName="******"&imagePath="+imagePath, count, pageSize, page, true);

            return View(list);
        }