示例#1
0
        protected void btn_delete_Click(object sender, EventArgs e)
        {
            Corporation corporation             = (Corporation)Session["corporation"];
            CorVisitRecordTableAdapter ta_visit = new CorVisitRecordTableAdapter();

            ta_visit.DeleteHistorylistByCorId(corporation.id, 1);
            DataInit();
        }
示例#2
0
        private void DataInit()
        {
            AdminBookTableAdapter ta_adminbook = new AdminBookTableAdapter();

            Corporation corporation             = (Corporation)Session["corporation"];
            CorVisitRecordTableAdapter ta_visit = new CorVisitRecordTableAdapter();
            DataTable dt_visit = ta_visit.GetCorVisitRecordByCorId(corporation.id, 1);

            rep_historylist.DataSource = dt_visit;
            rep_historylist.DataBind();
        }
示例#3
0
        protected void Select_Change(Object sender, EventArgs e)
        {
            lbl_selectednode.Text = this.tree.SelectedNode.Text;
            url = url + lbl_selectednode.Text;

            Corporation corporation = (Corporation)Session["corporation"];

            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(".dwg");

                if (b5)
                {
                    selectbook.Visible = false;
                    content.Visible    = false;
                    addinfo.Visible    = true;
                    btn_view.Visible   = true;

                    string bookName = lbl_selectednode.Text;
                    adminbook.name = bookName;
                    AdminBookTableAdapter ta_adminbook = new AdminBookTableAdapter();
                    DataTable             dt_adminbook = ta_adminbook.GetAdminBookAllByName(bookName);
                    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);

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

                        string bookName = lbl_selectednode.Text;
                        adminbook.name = bookName;
                        AdminBookTableAdapter ta_adminbook = new AdminBookTableAdapter();
                        DataTable             dt_adminbook = ta_adminbook.GetAdminBookAllByName(bookName);
                        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/" + 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 = "未选中书籍";
            }
        }