Exemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.QueryString["bookName"] != null)
     {
         string bookName = Request.QueryString["bookName"].ToString();
         User   user     = (User)Session["user"];
         adminbook.name = bookName;
         CorSelfBookTableAdapter ta_adminbook = new CorSelfBookTableAdapter();
         DataTable dt_adminbook = ta_adminbook.GetSelfBookByNameCorId(bookName, user.corporation_id);
         adminbook.author   = dt_adminbook.Rows[0]["author"].ToString();
         adminbook.keyword  = dt_adminbook.Rows[0]["keyword"].ToString();
         adminbook.score    = Convert.ToInt32(dt_adminbook.Rows[0]["score"].ToString());
         adminbook.star     = Convert.ToInt32(dt_adminbook.Rows[0]["star"].ToString());
         adminbook.booktype = dt_adminbook.Rows[0]["booktype"].ToString();
     }
 }
Exemplo n.º 2
0
        private void AddTree(int Pid, TreeNode PNode)
        {
            Corporation corporation = (Corporation)Session["corporation"];
            CorSelfBooktypeTableAdapter ta_fatype = new CorSelfBooktypeTableAdapter();
            CorSelfBookTableAdapter     ta_book   = new CorSelfBookTableAdapter();
            DataTable dt_fa   = ta_fatype.GetSelfMenu(corporation.id);
            DataTable dt_book = ta_book.GetMenuBook(corporation.id);

            dt_fa.Merge(dt_book);
            if (dt_fa.Rows.Count > 0)
            {
                DataView dv = new DataView(dt_fa);
                //过滤ParentID,得到当前的所有子节点 ParentID为父节点ID
                dv.RowFilter = "[parent_id] = " + Pid;
                //循环递归
                foreach (DataRowView Row in dv)
                {
                    //声明节点
                    TreeNode Node = new TreeNode();
                    //绑定超级链接
                    //Node.NavigateUrl = String.Format("javascript:show('{0}')", Row["name"].ToString());
                    //开始递归
                    if (PNode == null)
                    {
                        //添加根节点
                        Node.Text  = Row["name"].ToString();
                        Node.Value = Row["id"].ToString();
                        name       = Node.Text;
                        tree.Nodes.Add(Node);
                        Node.Expanded = false;                            //节点状态收缩
                        AddTree(Int32.Parse(Row["id"].ToString()), Node); //再次递归
                    }
                    else
                    {
                        //添加当前节点的子节点
                        Node.Text  = Row["name"].ToString();
                        Node.Value = Row["id"].ToString();
                        name       = Node.Text;
                        PNode.ChildNodes.Add(Node);
                        Node.Expanded = false;                            //节点状态收缩
                        AddTree(Int32.Parse(Row["id"].ToString()), Node); //再次递归
                    }
                }
            }
        }
Exemplo n.º 3
0
        protected void btn_submit_Click(object sender, EventArgs e)
        {
            string      book_path;
            Corporation corporation = (Corporation)Session["corporation"];

            if (this.tree.SelectedNode == null)
            {
                lab_tip.Text = "<script>alert('没有选中目录项'); window.location.href='addbook.aspx'</script>";
            }
            else
            {
                Boolean b1 = lbl_selectednode.Text.EndsWith(".doc");
                Boolean b2 = lbl_selectednode.Text.EndsWith(".pdf");
                Boolean b3 = lbl_selectednode.Text.EndsWith(".txt");
                Boolean b4 = lbl_selectednode.Text.EndsWith(".ppt");
                Boolean b5 = lbl_selectednode.Text.EndsWith(".cad");

                if (b1 || b2 || b3 || b4 || b5)
                {
                    lab_tip.Text = "<script>alert('不能在书籍下面添加书籍'); window.location.href='addbook.aspx'</script>";
                }
                else
                {
                    CorSelfBookTableAdapter ta_corselfbook = new CorSelfBookTableAdapter();
                    CorSelfBook             book           = new CorSelfBook();
                    book.name     = txt_name.Text;
                    book.author   = txt_author.Text;
                    book.keyword  = txt_keyword.Text;
                    book.score    = Convert.ToInt32(txt_score.Text);
                    book.star     = Convert.ToInt32(ddl_star.SelectedItem.Value);
                    book.filetype = ddl_type.SelectedItem.Value;
                    book.name     = book.name + "." + book.filetype;
                    book_path     = "~/corporation/upload/" + corporation.name + "/";
                    if (file_book.HasFile)
                    {
                        string filename = file_book.FileName.ToLower();
                        file_book.SaveAs(Server.MapPath(book_path) + filename);
                        book.url = "corporation/upload/" + corporation.name + "/" + filename;

                        /*if (filename.EndsWith(".doc"))
                         * {
                         *  file_book.SaveAs(Server.MapPath("~/upload/bookfile/") + filename + ".doc" );
                         *  book.Bookway = "/upload/bookfile/" + filename + ".doc";
                         * }
                         * if (filename.EndsWith(".pdf"))
                         * {
                         *  file_book.SaveAs(Server.MapPath("~/upload/bookfile/") + filename + ".pdf");
                         *  book.Bookway = "/upload/bookfile/" + filename + ".pdf";
                         * }
                         * if (filename.EndsWith(".epub"))
                         * {
                         *  file_book.SaveAs(Server.MapPath("~/upload/bookfile/") + book.Id.ToString() + ".epub");
                         *  book.Bookway = "/upload/bookfile/" + book.Id.ToString() + ".epub";
                         * }*/
                    }
                    ta_corselfbook.InsertSelfBook(book.name, book.url, book.star, book.author, book.keyword, book.score, book.filetype, corporation.id);
                    DataTable             dt_adminBook = ta_corselfbook.GetSelfBookByName(book.name, corporation.id);
                    int                   book_id      = Convert.ToInt32(dt_adminBook.Rows[0]["id"]);
                    int                   booktype_id  = Convert.ToInt32(this.tree.SelectedNode.Value);
                    CorSelfBTTableAdapter ta_adminBT   = new CorSelfBTTableAdapter();
                    ta_adminBT.InsertCorSelfBT(book_id, booktype_id, corporation.id);
                    lab_tip.Text = "<script>alert('添加成功'); window.location.href='addbook.aspx'</script>";
                }
            }
        }
Exemplo n.º 4
0
        protected void rep_adminlist_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName.Equals("read"))
            {
                string      cbook_path;
                Corporation corporation = (Corporation)Session["corporation"];
                cbook_path = "~/corporation/upload/" + corporation.name + "\\";
                CorSelfBookTableAdapter ta_book = new CorSelfBookTableAdapter();
                string   book_name     = ta_book.GetSelfBookById(Convert.ToInt32(e.CommandArgument), corporation.id).Rows[0]["name"].ToString();
                string   fileName      = book_name;
                string   fileExtention = fileName.Substring(fileName.LastIndexOf(".") + 1);
                string   pdfFileName;
                bool     fileOK            = false;
                String[] allowedExtensions =
                { "doc", "ppt", "xls", "docx", "html" }; //允许上传的文件格式
                for (int i = 0; i < allowedExtensions.Length; i++)
                {
                    if (fileExtention == allowedExtensions[i])
                    {
                        fileOK = true;
                        break;
                    }
                }
                if (fileOK == true)
                {
                    string filePath = HttpContext.Current.Server.MapPath("~/attachment\\") + fileName;
                    //上传选中文件到attachment文件夹
                    string admin_bookpath = HttpContext.Current.Server.MapPath(cbook_path) + fileName;
                    if (!File.Exists(filePath))
                    {
                        FileInfo adminway = new FileInfo(admin_bookpath);
                        adminway.CopyTo(filePath);
                    }
                    //将office文件转换成PDF,保存到PDF文件夹下
                    pdfFileName = fileName.Substring(0, fileName.LastIndexOf(".")) + ".pdf";
                    string fileOutPath = HttpContext.Current.Server.MapPath("~/pdf\\") + pdfFileName;
                    ExportPdf(filePath, fileOutPath);
                }

                else
                {
                    string filePath = HttpContext.Current.Server.MapPath("~/pdf\\") + fileName;

                    string admin_bookpath = HttpContext.Current.Server.MapPath(cbook_path) + fileName;
                    if (!File.Exists(filePath))
                    {
                        FileInfo adminway = new FileInfo(admin_bookpath);
                        adminway.CopyTo(filePath);
                    }

                    pdfFileName = fileName.Substring(0, fileName.LastIndexOf(".")) + ".pdf";
                }
                //切记,使用pdf2swf.exe 打开的文件名之间不能有空格,否则会失败
                string cmdStr      = HttpContext.Current.Server.MapPath("~/SWFTools/pdf2swf.exe");
                string savePath    = HttpContext.Current.Server.MapPath("~/pdf/");
                string saveSWFPath = HttpContext.Current.Server.MapPath("~/SWF/");
                //将PDF文件转换成SWF格式文件
                //要转换的pdf文件路径
                string sourcePath = @"""" + savePath + pdfFileName + @"""";

                //转换之后swf文件存放的目标路径
                string targetPath = @"""" + saveSWFPath + pdfFileName.Substring(0, pdfFileName.LastIndexOf(".")) + ".swf" + @"""";
                //@"""" 四个双引号得到一个双引号,如果你所存放的文件所在文件夹名有空格的话,要在文件名的路径前后加上双引号,才能够成功
                // -t 源文件的路径
                // -s 参数化(也就是为pdf2swf.exe 执行添加一些窗外的参数(可省略))
                string argsStr = "  -t " + sourcePath + " -s flashversion=9 -o " + targetPath;

                //执行pdf到swf的转换
                ExcutedCmd(cmdStr, argsStr);

                Response.Redirect("../viewer.aspx?id=" + HttpUtility.HtmlEncode(fileName.Substring(0, fileName.LastIndexOf(".")) + ".swf"));
            }
        }
Exemplo n.º 5
0
        protected void Select_Change(Object sender, EventArgs e)
        {
            lbl_selectednode.Text = this.tree.SelectedNode.Text;
            url = url + lbl_selectednode.Text;
            if (lbl_selectednode.Text != null)
            {
                Boolean b1 = lbl_selectednode.Text.EndsWith(".doc");
                Boolean b2 = lbl_selectednode.Text.EndsWith(".pdf");
                Boolean b3 = lbl_selectednode.Text.EndsWith(".txt");
                Boolean b4 = lbl_selectednode.Text.EndsWith(".ppt");
                Boolean b5 = lbl_selectednode.Text.EndsWith(".cad");

                if (b1 || b2 || b3 || b4 || b5)
                {
                    //在此控制两个div是否显示
                    selectbook.Visible = false;
                    content.Visible    = true;
                    addinfo.Visible    = true;

                    User   user     = (User)Session["user"];
                    string bookName = lbl_selectednode.Text;
                    adminbook.name = bookName;
                    CorSelfBookTableAdapter ta_adminbook = new CorSelfBookTableAdapter();
                    DataTable dt_adminbook = ta_adminbook.GetSelfBookByNameCorId(bookName, user.corporation_id);
                    adminbook.id       = Convert.ToInt32(dt_adminbook.Rows[0]["id"]);
                    adminbook.author   = dt_adminbook.Rows[0]["author"].ToString();
                    adminbook.keyword  = dt_adminbook.Rows[0]["keyword"].ToString();
                    adminbook.score    = Convert.ToInt32(dt_adminbook.Rows[0]["score"].ToString());
                    adminbook.star     = Convert.ToInt32(dt_adminbook.Rows[0]["star"].ToString());
                    adminbook.booktype = dt_adminbook.Rows[0]["booktype"].ToString();
                    lab_tip.Text       = "";

                    /*因为数据库不想设计得太复杂,我就不记录自家书籍的浏览记录了*/
                    //添加历史阅读记录
                    //CorVisitRecordTableAdapter ta_record = new CorVisitRecordTableAdapter();
                    //ta_record.InsertCorVisitRecord(DateTime.Now, 1, null, corporation.id, adminbook.id);

                    //实现阅读书籍功能
                    string addpath = HttpContext.Current.Server.MapPath("~/swf\\") + bookName.Substring(0, bookName.LastIndexOf(".")) + ".swf";
                    if (!File.Exists(addpath))
                    {
                        string cbook_path;
                        cbook_path = "~/corporation/upload/" + user.corporation_name + "\\";
                        string fileName      = lbl_selectednode.Text.ToString();
                        string fileExtention = fileName.Substring(fileName.LastIndexOf(".") + 1);
                        string pdfFileName;
                        //判断文件名
                        bool     fileOK            = false;
                        String[] allowedExtensions =
                        { "doc", "ppt", "xls", "docx", "html" }; //允许上传的文件格式
                        for (int i = 0; i < allowedExtensions.Length; i++)
                        {
                            if (fileExtention == allowedExtensions[i])
                            {
                                fileOK = true;
                                break;
                            }
                        }
                        if (fileOK == true)
                        {
                            string filePath = HttpContext.Current.Server.MapPath("~/attachment\\") + fileName;
                            //上传选中文件到attachment文件夹
                            string admin_bookpath = HttpContext.Current.Server.MapPath(cbook_path) + fileName;
                            if (!File.Exists(filePath))
                            {
                                FileInfo adminway = new FileInfo(admin_bookpath);
                                adminway.CopyTo(filePath);
                            }
                            //将office文件转换成PDF,保存到PDF文件夹下
                            pdfFileName = fileName.Substring(0, fileName.LastIndexOf(".")) + ".pdf";
                            string fileOutPath = HttpContext.Current.Server.MapPath("~/pdf\\") + pdfFileName;
                            ExportPdf(filePath, fileOutPath);
                        }

                        else
                        {
                            string filePath = HttpContext.Current.Server.MapPath("~/pdf\\") + fileName;

                            string admin_bookpath = HttpContext.Current.Server.MapPath(cbook_path) + fileName;
                            if (!File.Exists(filePath))
                            {
                                FileInfo adminway = new FileInfo(admin_bookpath);
                                adminway.CopyTo(filePath);
                            }

                            pdfFileName = fileName.Substring(0, fileName.LastIndexOf(".")) + ".pdf";
                        }
                        //切记,使用pdf2swf.exe 打开的文件名之间不能有空格,否则会失败
                        string cmdStr      = HttpContext.Current.Server.MapPath("~/SWFTools/pdf2swf.exe");
                        string savePath    = HttpContext.Current.Server.MapPath("~/pdf/");
                        string saveSWFPath = HttpContext.Current.Server.MapPath("~/SWF/");
                        //将PDF文件转换成SWF格式文件
                        //要转换的pdf文件路径
                        string sourcePath = @"""" + savePath + pdfFileName + @"""";

                        //转换之后swf文件存放的目标路径
                        string targetPath = @"""" + saveSWFPath + pdfFileName.Substring(0, pdfFileName.LastIndexOf(".")) + ".swf" + @"""";
                        //@"""" 四个双引号得到一个双引号,如果你所存放的文件所在文件夹名有空格的话,要在文件名的路径前后加上双引号,才能够成功
                        // -t 源文件的路径
                        // -s 参数化(也就是为pdf2swf.exe 执行添加一些窗外的参数(可省略))
                        string argsStr = "  -t " + sourcePath + " -s flashversion=9 -o " + targetPath;

                        //执行pdf到swf的转换
                        ExcutedCmd(cmdStr, argsStr);

                        FileURL = fileName.Substring(0, fileName.LastIndexOf(".")) + ".swf";
                    }
                    else
                    {
                        FileURL = bookName.Substring(0, bookName.LastIndexOf(".")) + ".swf";
                    }
                }
                else
                {
                    //本应该在这里进行如果是选中的是目录的话,我们就进行将目录下的书进行显示这一功能,但是我们在
                    //page_load那里已经实现了
                }
            }
            else
            {
                lab_tip.Text = "未选中书籍";
            }
        }