Exemple #1
0
        //
        // GET: /Show/

        public ActionResult Index(int?id)
        {
            if (id.HasValue)
            {
                Inpinke_Book model = DBBookBLL.GetBookByID(id.Value);
                if (model.ShowStatus == (int)ShowStatus.Pravice)
                {
                    if (UserSession.CurrentUser != null && UserSession.CurrentUser.ID == model.UserID)
                    {
                        ViewBag.ShowBook     = model;
                        ViewBag.ShowBookPage = DBBookBLL.GetBookPage(id.Value);
                        return(View());
                    }
                    else
                    {
                        ViewBag.Msg = "对不起,当前印品不对外展出,您无法查看。";
                        return(View("error"));
                    }
                }
                else
                {
                    ViewBag.ShowBook     = model;
                    ViewBag.ShowBookPage = DBBookBLL.GetBookPage(id.Value);
                    return(View());
                }
            }
            else
            {
                ViewBag.Msg = "对不起,访问出错!";
                return(View("error"));
            }
        }
Exemple #2
0
        //public ActionResult Error(string msg)
        //{
        //    if (string.IsNullOrEmpty(msg))
        //    {
        //        ViewBag.Msg = msg;
        //    }
        //    return View();
        //}

        public ActionResult Random()
        {
            Inpinke_Book model = DBBookBLL.GetRandomShowBook();

            ViewBag.ShowBook     = model;
            ViewBag.ShowBookPage = DBBookBLL.GetBookPage(model.ID);
            return(View("index"));
        }
Exemple #3
0
        /// <summary>
        /// 生成书本pdf
        /// </summary>
        /// <param name="bookid"></param>
        /// <returns></returns>
        public static bool CreateBookPDF(int bookid)
        {
            Inpinke_Book model   = DBBookBLL.GetBookByID(bookid);
            string       pdfname = FilterSpecial(model.BookName);

            pdfname = OutPath + pdfname + "-" + model.ID + "-intime.pdf";
            PDFProcessBLL pdfProcess = new PDFProcessBLL(PageWidth + 2 * TrimLineLength, PageHeight + 2 * TrimLineLength, pdfname);

            try
            {
                IList <Inpinke_Book_Page> pages = DBBookBLL.GetBookPage(bookid);
                pdfProcess.PaintScale = PaintScale;
                if (pages != null)
                {
                    pages = pages.OrderBy(e => e.PageNum).ToList();


                    pdfProcess.doc.Open();
                    float boneWidth = backboneWidth * model.PageCount;
                    pdfProcess.FlodPageWidth    = flodPageWidth;
                    pdfProcess.BackBoneWidth    = boneWidth;
                    pdfProcess.SinglePageWidth  = PageWidth;
                    pdfProcess.SinglePageHeight = PageHeight;
                    for (int i = 0; i <= model.PageCount; i++)
                    {
                        Inpinke_Book_Page p = pages.Where(e => e.PageNum == i).SingleOrDefault();
                        if (p == null)
                        {
                            pdfProcess.PageWidth  = PageWidth + 2 * TrimLineLength;
                            pdfProcess.PageHeight = PageHeight + 2 * TrimLineLength;
                            pdfProcess.doc.SetPageSize(new iTextSharp.text.Rectangle(pdfProcess.PageWidth, pdfProcess.PageHeight));
                            pdfProcess.doc.NewPage();
                            pdfProcess.PaintTirmLine();
                        }
                        else
                        {
                            float pWidth = PageWidth;
                            if (p.IsSkip)
                            {
                                pWidth = PageWidth * 2;
                                if (i != 0)
                                {
                                    i++;
                                }
                            }
                            else if (i != 1 && i != model.PageCount)
                            {
                                pWidth = PageWidth * 2;
                            }
                            if (i == 0)
                            {
                                //封面和封底和折页书脊总宽度
                                pWidth = PageWidth * 2 + flodPageWidth * 2 + boneWidth;
                            }

                            pdfProcess.PageWidth  = pWidth + 2 * TrimLineLength;
                            pdfProcess.PageHeight = PageHeight + 2 * TrimLineLength;
                            pdfProcess.doc.SetPageSize(new iTextSharp.text.Rectangle(pdfProcess.PageWidth, pdfProcess.PageHeight));
                            pdfProcess.doc.NewPage();
                            pdfProcess.PaintTirmLine();
                            PageDataObj pageObj = (PageDataObj)SerializeXmlHelper.DeserializeFromXml(p.PageData, typeof(PageDataObj));
                            pdfProcess.PaintPage(pageObj, 0);
                            if (!p.IsSkip && i != 1 && i != model.PageCount)
                            {
                                p = pages.Where(e => e.PageNum == i + 1).SingleOrDefault();
                                if (p != null)
                                {
                                    pageObj = (PageDataObj)SerializeXmlHelper.DeserializeFromXml(p.PageData, typeof(PageDataObj));
                                    pdfProcess.PaintPage(pageObj, PageWidth);
                                    i++;
                                }
                            }
                        }
                    }
                    pdfProcess.doc.Close();
                }
                return(true);
            }
            catch (Exception ex)
            {
                pdfProcess.doc.Close();
                Logger.Error(string.Format("CreateBookPDF BookID:{0},Error:{1}", bookid, ex.ToString()));
                return(false);
            }
        }