public ActionResult PhotoList() { string albumID = Request["albumID"]; PhotoListViewModel model = new PhotoListViewModel(); model.SiteID = BlogID; model.PhotoCollection = new List <Entity.blog_tb_Photo>(); Entity.blog_tb_Album album = Utility.AlbumBll.GetEntity(albumID); model.Title = album.Display + "-" + base.Info.blogTitle; List <blog_tb_Photo> list = Utility.PhotoBll.Query(albumID); //是否远程IP地址 2015-6-16 bool isRemote = Utility.IsRemote; foreach (var v in list) { Entity.blog_tb_Photo entity = new Entity.blog_tb_Photo(); entity.ID = v.ID; entity.Display = v.Display; if (String.IsNullOrEmpty(entity.Display)) { entity.Display = v.FileName; } string thumbUrl = v.ThumbUrl; if (isRemote) { thumbUrl = Utility.ReplaceImgOrFileSrc(thumbUrl); } string url = v.Url; if (isRemote) { url = Utility.ReplaceImgOrFileSrc(url); } entity.ThumbUrl = thumbUrl; if (String.IsNullOrEmpty(thumbUrl)) { entity.ThumbUrl = url; } model.PhotoCollection.Add(entity); } return(View("~/Views/Album/" + GetVersion() + "/PhotoList.cshtml", model)); }
public ActionResult Show(string id) { FYJ.Data.DbHelper db = new FYJ.Data.DbHelper("System.Data.SqlClient", "server=.;Uid=sa;Pwd=533533;Database=db_163;"); DataTable albumDt = db.GetDataTable("select * from ZFAVORITE where ZFAVORID=@ID", db.CreateParameter("@ID", id)); if (albumDt.Rows.Count == 0) { return(Content("没有查询到该ID的图片")); } PhotoShowViewModel model = new PhotoShowViewModel(); model.PhotoCollection = new List <Entity.blog_tb_Photo>(); model.Title = albumDt.Rows[0]["ZTITLE"].ToString(); DataTable dt = db.GetDataTable("select * from tb_newspic where NewsID=@NewsID", db.CreateParameter("@NewsID", id)); //是否远程IP地址 2015-6-16 bool isRemote = Utility.IsRemote; foreach (DataRow dr in dt.Rows) { Entity.blog_tb_Photo entity = new Entity.blog_tb_Photo(); entity.ID = dr["ID"].ToString(); entity.Display = ""; entity.ThumbUrl = dr["NewUrl"].ToString(); entity.Url = dr["NewUrl"].ToString(); entity.Exif = dr["note"].ToString().Replace("\n", "<br/>"); model.PhotoCollection.Add(entity); } if (dt.Rows.Count > 0) { model.CurrentThumbUrl = dt.Rows[0]["NewUrl"].ToString(); model.CurrentUrl = dt.Rows[0]["NewUrl"].ToString(); } return(View("~/Views/PhotoNews/PhotoShow.cshtml", model)); }
public override UploadResult Upload(UploadInfo info) { //相册ID string albumID = HttpContext.Current.Request["albumID"]; var album = Utility.AlbumBll.GetEntity(albumID); if (album == null) { throw new CustomException("相册不存在"); } if (album.UserID != UserInfo.UserID) { throw new CustomException("你不是该相册的所有者"); } UploadResult reslut = base.Upload(info); DataTable dt = Utility.PhotoBll.GetPhotoBySha1(reslut.Sha1, UserInfo.UserID); if (dt.Rows.Count > 0) { } else { Blogs.Entity.blog_tb_Photo entity = new Entity.blog_tb_Photo(); entity.ID = Guid.NewGuid().ToString("N"); entity.UserID = UserInfo.UserID; entity.ADD_DATE = DateTime.Now; entity.UPDATE_DATE = DateTime.Now; entity.FileName = reslut.FileName; entity.Size = (int)reslut.Size; entity.Width = reslut.Width; entity.Height = reslut.Height; entity.Url = reslut.Url; entity.Sha1 = reslut.Sha1; entity.ThumbUrl = reslut.ThumbUrl; entity.FromUrl = info.FromUrl; entity.AlbumID = albumID; entity.Exif = reslut.Exif; Blogs.Entity.blog_tb_Exif exif = null; if (reslut.CurrentExif != null) { exif = new Entity.blog_tb_Exif(); exif.ADD_DATE = DateTime.Now; exif.Aperture = reslut.CurrentExif.Aperture; exif.Balance = reslut.CurrentExif.Balance; exif.Camera = reslut.CurrentExif.Camera; exif.Exposure = reslut.CurrentExif.Exposure; exif.Flashlight = reslut.CurrentExif.Flashlight; exif.Focus = reslut.CurrentExif.Focus; exif.ID = Guid.NewGuid().ToString("N"); exif.ISO = reslut.CurrentExif.ISO; exif.Lens = reslut.CurrentExif.Lens; exif.Metering = reslut.CurrentExif.Metering; exif.Mode = reslut.CurrentExif.Mode; exif.PhotoID = entity.ID; exif.ShotDate = reslut.CurrentExif.ShotDate; exif.Shutter = reslut.CurrentExif.Shutter; exif.UPDATE_DATE = DateTime.Now; } Utility.PhotoBll.Add(entity, exif); } return(reslut); }
public ActionResult PhotoShow(string id) { string albumID = id; PhotoShowViewModel model = new PhotoShowViewModel(); model.SiteID = BlogID; model.PhotoCollection = new List <Entity.blog_tb_Photo>(); Entity.blog_tb_Album album = Utility.AlbumBll.GetEntity(albumID); model.Title = album.Display + "-" + base.Info.blogTitle; List <blog_tb_Photo> list = Utility.PhotoBll.Query(albumID); //是否远程IP地址 2015-6-16 bool isRemote = Utility.IsRemote; foreach (var v in list) { Entity.blog_tb_Photo entity = new Entity.blog_tb_Photo(); entity.ID = v.ID; entity.Display = v.Display; if (String.IsNullOrEmpty(entity.Display)) { entity.Display = v.FileName; } string thumbUrl = v.ThumbUrl; if (isRemote) { thumbUrl = Utility.ReplaceImgOrFileSrc(thumbUrl); } string url = v.Url; if (isRemote) { url = Utility.ReplaceImgOrFileSrc(url); } entity.ThumbUrl = thumbUrl; entity.Url = url; entity.Exif = "文件名:" + entity.Display + "<br/>" + v.Exif.Replace("\n", "<br/>"); model.PhotoCollection.Add(entity); } if (list.Count > 0) { string thumbUrl = list.First().ThumbUrl; if (isRemote) { thumbUrl = Utility.ReplaceImgOrFileSrc(thumbUrl); } string url = list.First().Url; if (isRemote) { url = Utility.ReplaceImgOrFileSrc(url); } model.CurrentThumbUrl = thumbUrl; model.CurrentUrl = url; } return(View("~/Views/Album/" + GetVersion() + "/PhotoShow.cshtml", model)); }
public ActionResult ArtilePhotoShow() { string articleID = Request["articleID"]; PhotoShowViewModel model = new PhotoShowViewModel(); model.SiteID = BlogID; model.PhotoCollection = new List <Entity.blog_tb_Photo>(); Entity.blog_tb_article article = Utility.ArticleBll.GetEntity(articleID); model.Title = article.articleTitle + "- 查看图片 -" + base.Info.blogTitle; List <blog_attachment> list = Utility.ArticleBll.GetArticlePhotos(articleID); if (list.Count == 0) { return(Content("没有查询到该文章的图片")); } //是否远程IP地址 2015-6-16 bool isRemote = Utility.IsRemote; foreach (var v in list) { Entity.blog_tb_Photo entity = new Entity.blog_tb_Photo(); entity.ID = v.fileID; entity.Display = v.fileName; string thumbUrl = v.fileThumbUrl; if (isRemote) { thumbUrl = Utility.ReplaceImgOrFileSrc(thumbUrl); } string url = v.fileUrl; if (isRemote) { url = Utility.ReplaceImgOrFileSrc(url); } if (String.IsNullOrEmpty(thumbUrl)) { thumbUrl = url; } entity.ThumbUrl = thumbUrl; entity.Url = url; if (String.IsNullOrEmpty(entity.Display)) { entity.Display = System.IO.Path.GetFileName(entity.Url); } if (!String.IsNullOrEmpty(v.Exif)) { entity.Exif = "文件名:" + entity.Display + "<br/>" + v.Exif.Replace("\n", "<br/>"); } model.PhotoCollection.Add(entity); string currentUri = Server.UrlDecode(Request["uri"]); if (entity.ThumbUrl == currentUri || entity.Url == currentUri) { model.CurrentThumbUrl = thumbUrl; model.CurrentUrl = url; } } if (String.IsNullOrEmpty(model.CurrentThumbUrl)) { model.CurrentThumbUrl = model.PhotoCollection.First().ThumbUrl; } if (String.IsNullOrEmpty(model.CurrentUrl)) { model.CurrentUrl = model.PhotoCollection.First().Url; } return(View("~/Views/Album/" + GetVersion() + "/PhotoShow.cshtml", model)); }