コード例 #1
0
        private bool DownloadBook(string bookId)
        {
            BookBLL objBll = new BookBLL();

            RailExam.Model.Book obj = objBll.GetBook(Convert.ToInt32(bookId));
            string filename         = Server.MapPath("/RailExamBao/Online/Book/" + bookId + "/");

            if (!Directory.Exists(filename))
            {
                return(false);
            }

            string ZipName = Server.MapPath("/RailExamBao/Online/Book/Book.zip");

            GzipCompress(filename, ZipName);

            FileInfo file = new FileInfo(ZipName.ToString());

            this.Response.Clear();
            this.Response.Buffer          = true;
            this.Response.Charset         = "utf-7";
            this.Response.ContentEncoding = Encoding.UTF7;
            // 添加头信息,为"文件下载/另存为"对话框指定默认文件名

            this.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(obj.bookName) + ".zip");
            // 添加头信息,指定文件大小,让浏览器能够显示下载进度
            this.Response.AddHeader("Content-Length", file.Length.ToString());
            // 指定返回的是一个不能被客户端读取的流,必须被下载
            this.Response.ContentType = "application/ms-word";
            // 把文件流发送到客户端
            this.Response.WriteFile(file.FullName);

            return(true);
        }
コード例 #2
0
        private void BindTree()
        {
            //添加书名
            BookBLL bookBLL = new BookBLL();

            RailExam.Model.Book book = bookBLL.GetBook(Convert.ToInt32(ViewState["BookID"].ToString()));

            TreeViewNode tvn1 = new TreeViewNode();

            tvn1.ID      = "0";
            tvn1.Value   = ViewState["BookID"].ToString();
            tvn1.Text    = book.bookName;
            tvn1.ToolTip = book.bookName;
            tvBookChapter.Nodes.Add(tvn1);

            //添加章节
            BookChapterBLL bookChapterBLL = new BookChapterBLL();

            IList <RailExam.Model.BookChapter> bookChapterList = bookChapterBLL.GetBookChapterByBookID(Convert.ToInt32(ViewState["BookID"].ToString()));

            if (bookChapterList.Count > 0)
            {
                TreeViewNode tvn = null;

                foreach (RailExam.Model.BookChapter bookChapter in bookChapterList)
                {
                    tvn         = new TreeViewNode();
                    tvn.ID      = bookChapter.ChapterId.ToString();
                    tvn.Value   = bookChapter.BookId.ToString();
                    tvn.Text    = bookChapter.ChapterName;
                    tvn.ToolTip = bookChapter.ChapterName;

                    if (bookChapter.ParentId == 0)
                    {
                        //tvBookChapter.Nodes.Add(tvn);
                        tvBookChapter.FindNodeById(bookChapter.ParentId.ToString()).Nodes.Add(tvn);
                    }
                    else
                    {
                        try
                        {
                            tvBookChapter.FindNodeById(bookChapter.ParentId.ToString()).Nodes.Add(tvn);
                        }
                        catch
                        {
                            tvBookChapter.Nodes.Clear();
                            SessionSet.PageMessage = "数据错误!";

                            return;
                        }
                    }
                }
            }

            tvBookChapter.DataBind();
            tvBookChapter.ExpandAll();
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (PrjPub.CurrentLoginUser == null)
                {
                    Response.Redirect("/RailExamBao/Common/Error.aspx?error=Session过期请重新登录本系统!");
                    return;
                }
                string strBookID = Request.QueryString.Get("id");
                ViewState["BookID"] = strBookID;
                if (!string.IsNullOrEmpty(strBookID))
                {
                    hfBookID.Value = strBookID;

                    BookBLL             objbookbill = new BookBLL();
                    RailExam.Model.Book objBook     = objbookbill.GetBook(Convert.ToInt32(hfBookID.Value));

                    if (PrjPub.CurrentLoginUser.SuitRange == 0 && PrjPub.IsServerCenter)
                    {
                        if (PrjPub.CurrentLoginUser.StationOrgID != objBook.publishOrg)
                        {
                            Response.Write("<script>alert('您没有导入当前教材章节试题的权限!');window.close();</script>");
                            return;
                        }
                    }

                    BindTree();
                }

                string strPath = Server.MapPath("../Online/Book/" + ViewState["BookID"].ToString());
                if (!Directory.Exists(strPath))
                {
                    Directory.CreateDirectory(strPath);
                    Directory.CreateDirectory(strPath + "/Upload");
                    CopyTemplate(Server.MapPath("../Online/Book/template/"),
                                 Server.MapPath("../Online/Book/" + ViewState["BookID"].ToString() + "/"));
                }
            }
        }
コード例 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (PrjPub.CurrentLoginUser == null)
                {
                    Response.Redirect("/RailExamBao/Common/Error.aspx?error=Session过期请重新登录本系统!");
                    return;
                }

                string strMode      = Request.QueryString.Get("mode");
                string strBookId    = Request.QueryString.Get("bid");
                string strChapterId = Request.QueryString.Get("cid");

                switch (strMode)
                {
                case "readonly":
                {
                    if (fvItem.CurrentMode != FormViewMode.ReadOnly)
                    {
                        fvItem.ChangeMode(FormViewMode.ReadOnly);
                    }
                    break;
                }

                case "insert":
                {
                    if (PrjPub.CurrentLoginUser.SuitRange == 0 && PrjPub.IsServerCenter)
                    {
                        BookBLL             bookBLL = new BookBLL();
                        RailExam.Model.Book objBook = bookBLL.GetBook(Convert.ToInt32(strBookId));
                        if (PrjPub.CurrentLoginUser.StationOrgID != objBook.publishOrg)
                        {
                            Response.Write("<script>alert('您没有新增当前教材章节试题的权限!');window.close();</script>");
                            return;
                        }
                    }

                    if (fvItem.CurrentMode != FormViewMode.Insert)
                    {
                        fvItem.ChangeMode(FormViewMode.Insert);
                    }

                    if (!string.IsNullOrEmpty(strBookId) && !string.IsNullOrEmpty(strChapterId))
                    {
                        int                       employeeID    = PrjPub.CurrentLoginUser.EmployeeID;
                        ItemConfigBLL             itemConfigBLL = new ItemConfigBLL();
                        RailExam.Model.ItemConfig itemConfig    = itemConfigBLL.GetItemConfig(employeeID);

                        ((DropDownList)fvItem.FindControl("ddlItemTypeInsert")).SelectedValue =
                            itemConfig.DefaultTypeId.ToString();
                        ((DropDownList)fvItem.FindControl("ddlItemDifficultyInsert")).SelectedValue =
                            itemConfig.DefaultDifficultyId.ToString();
                        ((TextBox)fvItem.FindControl("txtDefaultScoreInsert")).Text =
                            itemConfig.DefaultScore.ToString(".00");
                        ((TextBox)fvItem.FindControl("txtCompleteTimeInsert")).Text =
                            CommonTool.ConvertSecondsToTimeString(itemConfig.DefaultCompleteTime);
                        ((TextBox)fvItem.FindControl("txtCreatePersonInsert")).Text =
                            PrjPub.CurrentLoginUser.EmployeeName;
                        ((DropDownList)fvItem.FindControl("ddlAnswerCountInsert")).SelectedValue =
                            itemConfig.DefaultAnswerCount.ToString();
                        ((DropDownList)fvItem.FindControl("ddlStatusInsert")).SelectedValue =
                            itemConfig.DefaultStatusId.ToString();
                        ((DropDownList)fvItem.FindControl("ddlHasPictureInsert")).SelectedValue =
                            itemConfig.HasPicture.ToString();

                        ((HiddenField)fvItem.FindControl("hfBookId")).Value     = strBookId;
                        ((HiddenField)fvItem.FindControl("hfChapterId")).Value  = strChapterId;
                        ((HiddenField)fvItem.FindControl("hfCategoryId")).Value = "-1";

                        BookBLL        objBll        = new BookBLL();
                        string         bookName      = objBll.GetBook(Convert.ToInt32(strBookId)).bookName;
                        BookChapterBLL objChapterBll = new BookChapterBLL();
                        string         chapterName   = objChapterBll.GetBookChapter(Convert.ToInt32(strChapterId)).NamePath;
                        ((TextBox)fvItem.FindControl("txtBookChapterInsert")).Text = bookName + ">>" + chapterName;

                        if (PrjPub.CurrentLoginUser != null && PrjPub.CurrentLoginUser.StationOrgID > 0)
                        {
                            ((HiddenField)fvItem.FindControl("hfOrganizationId")).Value =
                                PrjPub.CurrentLoginUser.StationOrgID.ToString();
                        }

                        if (itemConfig.DefaultOutDateDate != DateTime.MinValue)
                        {
                            ((Date)fvItem.FindControl("dateOutDateDateInsert")).DateValue =
                                itemConfig.DefaultOutDateDate.ToString("yyyy-MM-dd");
                        }

                        ((Date)fvItem.FindControl("dateCreateTimeInsert")).DateValue =
                            DateTime.Today.ToString("yyyy-MM-dd");
                    }
                    break;
                }

                case "edit":
                {
                    //if(PrjPub.CurrentLoginUser.SuitRange == 0 && PrjPub.IsServerCenter)
                    //{
                    //    int itemID = Convert.ToInt32(Request.QueryString.Get("id"));
                    //    ItemBLL itemBLL = new ItemBLL();
                    //    RailExam.Model.Item objItem = itemBLL.GetItem(itemID);
                    //    BookBLL bookBLL = new BookBLL();
                    //    RailExam.Model.Book objBook = bookBLL.GetBook(objItem.BookId);
                    //    if(PrjPub.CurrentLoginUser.StationOrgID != objBook.publishOrg)
                    //    {
                    //        Response.Write("<script>alert('您没有修改该试题的权限!');window.close();</script>");
                    //        return;
                    //    }
                    //}

                    if (fvItem.CurrentMode != FormViewMode.Edit)
                    {
                        fvItem.ChangeMode(FormViewMode.Edit);
                    }

                    break;
                }

                default:
                {
                    break;
                }
                }
            }
        }