예제 #1
0
        public ActionResult GetBookList(int num, int page)
        {
            List <pagedata>      list     = new List <pagedata>();
            Random               rand     = new Random();
            IList <Inpinke_Book> bookList = DBBookBLL.GetUserBooks(UserSession.CurrentUser.ID);

            if (bookList != null)
            {
                foreach (Inpinke_Book b in bookList)
                {
                    pagedata p = new pagedata()
                    {
                        img   = b.BookCover,
                        title = b.BookName
                    };
                    list.Add(p);
                }
            }

            System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(list.GetType());
            using (MemoryStream ms = new MemoryStream())
            {
                serializer.WriteObject(ms, list);
                return(Content(Encoding.UTF8.GetString(ms.ToArray())));
            }
        }
예제 #2
0
        public ActionResult GetUserImages(int num, int p)
        {
            if (UserSession.CurrentUser == null)
            {
                return(Content(""));
            }

            IList <Inpinke_Image> list = DBImageBLL.GetUserImages(PageInfo, UserSession.CurrentUser.ID);

            if (list != null)
            {
                List <pagedata> photoList = new List <pagedata>();
                foreach (Inpinke_Image i in list)
                {
                    pagedata d = new pagedata()
                    {
                        id     = i.ID,
                        bigImg = "/userfile/" + UserSession.CurrentUser.ID + "/" + i.ImageName + "_edit.jpg",
                        img    = i.Path,
                        title  = string.IsNullOrEmpty(i.Remark) ? "" : i.Remark,
                    };
                    string imgPath = Server.MapPath(d.img);
                    d.img = "/userfile/" + UserSession.CurrentUser.ID + "/" + i.ImageName + "_view.jpg";
                    string vimgPath = Server.MapPath(d.img);
                    if (!System.IO.File.Exists(imgPath))
                    {
                        continue;
                    }
                    if (!System.IO.File.Exists(vimgPath))
                    {
                        System.Drawing.Image originalImage = System.Drawing.Image.FromFile(imgPath);
                        if (originalImage != null)
                        {
                            Bitmap bitmap = new Bitmap(originalImage);
                            ImageProcessBLL.CreateStaticScaleImage(bitmap, 220, 1, 1000, vimgPath);
                        }
                        else
                        {
                            continue;
                        }
                    }
                    photoList.Add(d);
                }
                System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(photoList.GetType());
                using (MemoryStream ms = new MemoryStream())
                {
                    serializer.WriteObject(ms, photoList);
                    return(Content(Encoding.UTF8.GetString(ms.ToArray())));
                }
            }
            else
            {
                return(Content(""));
            }
        }