Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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));
        }