private void SetIsShow() { int id = RequestHelper.GetFormInt("id"); BLL.course_info bll = new BLL.course_info(); Model.course_info model = bll.GetModel(id); if (model != null) { if (model.is_show == (int)EnumCollection.course_is_show.是) { model.is_show = (int)EnumCollection.course_is_show.否; } else { model.is_show = (int)EnumCollection.course_is_show.是; } bll.Update(model); HttpContext.Current.Response.Write("1"); HttpContext.Current.Response.End(); } else { HttpContext.Current.Response.Write("0"); HttpContext.Current.Response.End(); } }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("_course_list", EnumCollection.ActionEnum.Delete.ToString()); //检查权限 int sucCount = 0; int errorCount = 0; BLL.course_info bll = new BLL.course_info(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { if (bll.Delete(id)) { DBUtility.DbHelperSQL.ExecuteSql(" delete from ybd_course_chapter where group_id = 1 and course_id = " + id); sucCount += 1; } else { errorCount += 1; } } } AddAdminLog(EnumCollection.ActionEnum.Delete.ToString(), "删除课程信息" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("course_list.aspx", "keywords={0}&type={1}", this.keywords, this.type + "")); }
private bool DoAdd() { BLL.course_info bll = new BLL.course_info(); Model.course_info model = new Model.course_info(); model.group_id = (int)EnumCollection.course_group.精品微课; model.category_id = Convert.ToInt32(this.ddlCategory.SelectedValue); model.name = Convert.ToString(txtname.Text); model.cover = Convert.ToString(txtcover.Text); model.info = Convert.ToString(txtinfo.Text); model.qrcode = ""; model.qrcode_logo = Convert.ToString(txtqrcode_logo.Text); model.user_id = admin_info.id; model.is_show = (int)EnumCollection.course_is_show.是; model.add_time = System.DateTime.Now; int id = bll.Add(model); if (id > 0) { model.id = id; model.qrcode = "/QrCode.aspx?type=course&id=" + id; bll.Update(model); AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加课程信息,主键:" + id); //记录日志 return(true); } else { return(false); } }
private void BindData() { #region 组装查询条件 string whereStr = " 1 = 1 "; string _keywords = keywords.Replace("'", ""); if (!string.IsNullOrEmpty(_keywords)) { if (Utils.IsSafeSqlString(_keywords)) { whereStr += " and (name like '%" + _keywords + "%')"; } else { JscriptMsg("搜索关键词中包含危险字符,检索终止!", Utils.CombUrlTxt("recommend_course.aspx", "keywords={0}", "")); return; } } #endregion this.page = RequestHelper.GetQueryInt("page", 1); txtKeywords.Text = this.keywords; BLL.course_info bll = new BLL.course_info(); this.rptList.DataSource = bll.GetListByPage("*", "View_RecommendCourse", whereStr, "ad_sort_id asc", this.page, this.pageSize); this.rptList.DataBind(); this.totalCount = bll.GetRecordCount("View_RecommendCourse", whereStr); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("recommend_course.aspx", "keywords={0}&page={1}", this.keywords, "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
private void BindData() { #region 组装查询条件 string whereStr = " group_id = " + (int)EnumCollection.examination_group.心理测试 + " and parent_id = " + this.chapter; //string whereStr = " 1 = 1 "; string _keywords = keywords.Replace("'", ""); if (!string.IsNullOrEmpty(_keywords)) { if (Utils.IsSafeSqlString(_keywords)) { whereStr += " and (name like '%" + _keywords + "%')"; } else { JscriptMsg("搜索关键词中包含危险字符,检索终止!", Utils.CombUrlTxt("questionnaire_list.aspx", "keywords={0}", "")); return; } } //if (this.chapter > 0) //{ // whereStr += " parent_id = " + this.chapter; //} #endregion Model.course_chapter ccModel = new BLL.course_chapter().GetModel(chapter); if (ccModel != null) { chapter_name = ccModel.name; Model.course_info course = new BLL.course_info().GetModel(ccModel.course_id); if (course != null) { course_name = course.name; } else { JscriptMsg("传递参数错误", "back"); return; } } else { JscriptMsg("传递参数错误", "back"); return; } this.page = RequestHelper.GetQueryInt("page", 1); txtKeywords.Text = this.keywords; BLL.common_examination bll = new BLL.common_examination(); this.rptList.DataSource = bll.GetListByPage(whereStr, "ID DESC", this.page, this.pageSize); this.rptList.DataBind(); this.totalCount = bll.GetRecordCount(whereStr); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("questionnaire_list.aspx", "keywords={0}&page={1}&chapter={2}", this.keywords, "__id__", this.chapter + ""); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
//保存 protected void btnSubmit_Click(object sender, EventArgs e) { ChkAdminLevel("_ybd_course_info", EnumCollection.ActionEnum.Modify.ToString()); //检查权限 BLL.course_info bll = new BLL.course_info(); Model.course_info model = bll.GetModel(this.id); model.group_id = Convert.ToInt32(txtgroup_id.Text); model.category_id = Convert.ToInt32(txtcategory_id.Text); model.name = Convert.ToString(txtname.Text); model.cover = Convert.ToString(txtcover.Text); model.info = Convert.ToString(txtinfo.Text); model.notice = Convert.ToString(txtnotice.Text); model.qrcode = Convert.ToString(txtqrcode.Text); model.qrcode_logo = Convert.ToString(txtqrcode_logo.Text); model.user_id = Convert.ToInt32(txtuser_id.Text); model.is_show = Convert.ToInt32(txtis_show.Text); model.add_time = Convert.ToDateTime(txtadd_time.Text); if (bll.Update(model)) { AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改课程信息信息,主键:" + id); //记录日志 JscriptMsg("修改课程信息信息成功!", "Manage.aspx"); } else { JscriptMsg("保存过程中发生错误!", ""); } }
protected void Page_Load(object sender, EventArgs e) { this.keywords = RequestHelper.GetQueryString("keywords"); this.pageSize = GetPageSize(10); //每页数量 this.chapter = RequestHelper.GetQueryInt("chapter"); this.group = RequestHelper.GetQueryInt("group"); this.type = RequestHelper.GetQueryInt("type"); if (this.chapter == 0) { JscriptMsg("没有此章节", "back"); return; } Model.course_chapter chapterModel = new BLL.course_chapter().GetModel(this.chapter); if (chapterModel != null) { chapter_name = chapterModel.name; Model.course_info course = new BLL.course_info().GetModel(chapterModel.course_id); if (course != null) { course_name = course.name; } } if (!Page.IsPostBack) { ChkAdminLevel("_common_questions", EnumCollection.ActionEnum.View.ToString()); //检查权限 BindSelect(); BindData(); } }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("_recommend_course", EnumCollection.ActionEnum.Delete.ToString()); //检查权限 int sucCount = 0; int errorCount = 0; BLL.course_info bll = new BLL.course_info(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { if (bll.Delete(id)) { sucCount += 1; } else { errorCount += 1; } } } AddAdminLog(EnumCollection.ActionEnum.Delete.ToString(), "删除推荐课程信息" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("recommend_course.aspx", "keywords={0}", this.keywords)); }
private void BindData() { #region 组装查询条件 string whereStr = " group_id = " + (int)EnumCollection.article_group.精品微课问题讨论 + " and category_id = " + this.chapter; string _keywords = keywords.Replace("'", ""); if (!string.IsNullOrEmpty(_keywords)) { if (Utils.IsSafeSqlString(_keywords)) { whereStr += " and (Title like '%" + _keywords + "%')"; } else { JscriptMsg("搜索关键词中包含危险字符,检索终止!", Utils.CombUrlTxt("discuss_list.aspx", "keywords={0}", "")); return; } } Model.course_chapter ccModel = new BLL.course_chapter().GetModel(chapter); if (ccModel != null) { chapter_name = ccModel.name; Model.course_info course = new BLL.course_info().GetModel(ccModel.course_id); if (course != null) { course_name = course.name; } else { JscriptMsg("传递参数错误", "back"); return; } } else { JscriptMsg("传递参数错误", "back"); return; } #endregion this.page = RequestHelper.GetQueryInt("page", 1); txtKeywords.Text = this.keywords; BLL.common_article bll = new BLL.common_article(); this.rptList.DataSource = bll.GetListByPage("*", "View_CourseArticle", whereStr, "add_time desc", this.page, this.pageSize); this.rptList.DataBind(); this.totalCount = bll.GetRecordCount("View_CourseArticle", whereStr); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("discuss_list.aspx", "keywords={0}&page={1}&chapter={2}", this.keywords, "__id__", this.chapter + ""); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
protected string ReturnCourseName(int id) { Model.course_chapter chapter = new BLL.course_chapter().GetModel(id); if (chapter != null) { Model.course_info course = new BLL.course_info().GetModel(chapter.course_id); if (course != null) { return(course.name); } } return(""); }
protected void Page_Load(object sender, EventArgs e) { string _action = RequestHelper.GetQueryString("action"); this.chapter = RequestHelper.GetQueryInt("chapter"); this.page = RequestHelper.GetQueryInt("page", 1); if (this.chapter == 0) { JscriptMsg("没有此章节", "back"); return; } Model.course_chapter ccModel = new BLL.course_chapter().GetModel(chapter); if (ccModel != null) { chapter_name = ccModel.name; Model.course_info course = new BLL.course_info().GetModel(ccModel.course_id); if (course != null) { course_name = course.name; } } if (!string.IsNullOrEmpty(_action) && _action == EnumCollection.ActionEnum.Modify.ToString()) { this.action = EnumCollection.ActionEnum.Modify.ToString();//修改类型 this.id = RequestHelper.GetQueryInt("id"); if (this.id == 0) { JscriptMsg("传输参数不正确!", "back"); return; } if (!new BLL.common_questions().Exists(this.id)) { JscriptMsg("信息不存在或已被删除!", "back"); return; } } if (!Page.IsPostBack) { ChkAdminLevel("_common_questions", EnumCollection.ActionEnum.Modify.ToString()); //检查权限 BindSelect(); if (action == EnumCollection.ActionEnum.Modify.ToString()) //修改 { ShowInfo(); } } }
protected Model.sys_manager admin_info; //管理员信息 protected void Page_Load(object sender, EventArgs e) { admin_info = GetAdminInfo(); this.action = RequestHelper.GetQueryString("action"); this.id = RequestHelper.GetQueryInt("id"); this.chapter = RequestHelper.GetQueryInt("chapter"); this.page = RequestHelper.GetQueryInt("page", 1); this.course_id = RequestHelper.GetQueryInt("course_id", 0); if (this.id > 0) { if (!new BLL.common_resource().Exists(this.id)) { JscriptMsg("记录不存在或已被删除!", "back"); return; } } if (this.chapter > 0) { Model.course_chapter model = new BLL.course_chapter().GetModel(this.chapter); if (model == null) { JscriptMsg("没有此章节!", "back"); return; } else { this.chapter_name = model.name; Model.course_info course = new BLL.course_info().GetModel(model.course_id); if (course != null) { this.course_name = course.name; } } } if (!Page.IsPostBack) { ChkAdminLevel("_resource_list", EnumCollection.ActionEnum.View.ToString()); //检查权限 BindSelect(); this.txtpath.Attributes.Add("readonly", "true"); if (action == EnumCollection.ActionEnum.Modify.ToString()) //修改 { ShowInfo(this.id); } } }
protected void Page_Load(object sender, EventArgs e) { this.action = RequestHelper.GetQueryString("action"); this.id = RequestHelper.GetQueryInt("id"); this.chapter = RequestHelper.GetQueryInt("chapter"); if (this.id > 0) { if (!new BLL.common_examination().Exists(this.id)) { JscriptMsg("记录不存在或已被删除!", "back"); return; } } if (this.chapter > 0) { Model.course_chapter model = new BLL.course_chapter().GetModel(this.chapter); if (model == null) { JscriptMsg("没有此章节!", "back"); return; } else { this.lblChapterName.Text = model.name; Model.course_info course = new BLL.course_info().GetModel(model.course_id); if (course != null) { this.lblCourseName.Text = course.name; } else { JscriptMsg("没有此课程!", "back"); return; } } } if (!Page.IsPostBack) { ChkAdminLevel("_examination_list", EnumCollection.ActionEnum.View.ToString()); //检查权限 if (action == EnumCollection.ActionEnum.Modify.ToString()) //修改 { addrow = this.id; ShowInfo(this.id); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int id = RequestHelper.GetQueryInt("id"); Model.course_info model = new BLL.course_info().GetModel(id); if (model == null) { contents = ""; } else { contents = model.info; } } }
protected void Page_Load(object sender, EventArgs e) { this.action = RequestHelper.GetQueryString("action"); this.id = RequestHelper.GetQueryInt("id"); this.chapter = RequestHelper.GetQueryInt("chapter"); this.page = RequestHelper.GetQueryInt("page", 1); if (this.id > 0) { if (!new BLL.common_article().Exists(this.id)) { JscriptMsg("记录不存在或已被删除!", "back"); return; } } if (this.chapter > 0) { Model.course_chapter model = new BLL.course_chapter().GetModel(this.chapter); if (model == null) { JscriptMsg("没有此章节!", "back"); return; } else { this.chapter_name = model.name; Model.course_info course = new BLL.course_info().GetModel(model.course_id); if (course != null) { this.course_name = course.name; } } } if (!Page.IsPostBack) { ChkAdminLevel("_course_discuss", EnumCollection.ActionEnum.View.ToString()); //检查权限 if (action == EnumCollection.ActionEnum.Modify.ToString()) //修改 { ShowInfo(this.id); } } }
private void ShowInfo(int _id) { BLL.course_info bll = new BLL.course_info(); Model.course_info model = bll.GetModel(this.id); if (model == null) { JscriptMsg("信息不存在或已被删除!", "back"); return; } this.ddlCategory.SelectedValue = model.category_id + ""; this.txtname.Text = model.name + ""; this.txtcover.Text = model.cover + ""; this.txtinfo.Text = model.info + ""; this.txtqrcode_logo.Text = model.qrcode_logo + ""; //this.qrcodeview.Value = model.qrcode + ""; }
private void BindInfo() { BLL.course_info bll = new BLL.course_info(); Model.course_info model = bll.GetModel(this.id); if (model == null) { JscriptMsg("信息不存在或已被删除!", "back"); return; } txtgroup_id.Text = model.group_id + ""; txtcategory_id.Text = model.category_id + ""; txtname.Text = model.name + ""; txtcover.Text = model.cover + ""; txtinfo.Text = model.info + ""; txtnotice.Text = model.notice + ""; txtqrcode.Text = model.qrcode + ""; txtqrcode_logo.Text = model.qrcode_logo + ""; txtuser_id.Text = model.user_id + ""; txtis_show.Text = model.is_show + ""; txtadd_time.Text = model.add_time + ""; }
private void BindData() { #region 组装查询条件 string whereStr = " 1 = 1 "; string _keywords = keywords.Replace("'", ""); if (!string.IsNullOrEmpty(_keywords)) { if (Utils.IsSafeSqlString(_keywords)) { whereStr += " and (name like '%" + _keywords + "%')"; } else { JscriptMsg("搜索关键词中包含危险字符,检索终止!", Utils.CombUrlTxt("unselected_course.aspx", "keywords={0}&group={1}&exaid={2}", "", this.group + "", this.exaid + "")); return; } } if (this.type > 0) { whereStr += " and category_id = " + this.type; this.ddlCategory.SelectedValue = this.type + ""; } #endregion this.page = RequestHelper.GetQueryInt("page", 1); txtKeywords.Text = this.keywords; BLL.course_info bll = new BLL.course_info(); this.rptList.DataSource = bll.GetListByPage("*", "View_CourseList", whereStr, "ID DESC", this.page, this.pageSize); this.rptList.DataBind(); this.totalCount = bll.GetRecordCount("View_CourseList", whereStr); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("unselected_course.aspx", "keywords={0}&page={1}&group={2}&exaid={3}", this.keywords, "__id__", this.group + "", this.exaid + ""); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
private bool DoEdit(int id) { BLL.course_info bll = new BLL.course_info(); Model.course_info model = bll.GetModel(id); model.group_id = (int)EnumCollection.course_group.精品微课; model.category_id = Convert.ToInt32(this.ddlCategory.SelectedValue); model.name = Convert.ToString(txtname.Text); model.cover = Convert.ToString(txtcover.Text); model.info = Convert.ToString(txtinfo.Text); model.qrcode = "/QrCode.aspx?type=course&id=" + model.id; model.qrcode_logo = Convert.ToString(txtqrcode_logo.Text); if (bll.Update(model)) { AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改课程信息,主键:" + model.id); //记录日志 return(true); } else { return(false); } }
private void GetQrCode(string type) { string str = string.Empty; string id = Request.QueryString["id"]; string logopath = string.Empty; bool is_logo = true; Model.course_info course = null; switch (type) { case "course": //课程 is_logo = true; course = new BLL.course_info().GetModel(Convert.ToInt32(id)); if (course != null) { str = WebPath + "/html/course_details.html?id=" + id; logopath = course.qrcode_logo; } else { return; } break; case "re": //资源 is_logo = true; Model.common_resource resource = new BLL.common_resource().GetModel(Convert.ToInt32(id)); if (resource != null) { course = new BLL.course_info().GetModel(" id = (select course_id from ybd_course_chapter where id = " + resource.data_id + ")"); if (course != null) { logopath = course.qrcode_logo; } switch (resource.type) { case (int)Appoa.Common.EnumCollection.resource_type.图文资源: if (resource.from_id == (int)EnumCollection.resource_from.精品微课) { str = WebPath + "/html/article_details.html?id=" + id; } else { str = WebPath + "/html/knowledge_details.html?id=" + id; } break; case (int)Appoa.Common.EnumCollection.resource_type.文档资源: resource.path = resource.path.Substring(0, resource.path.LastIndexOf('.')); //str = WebPath + resource.path + ".html"; str = WebPath + "/html/doc_detail.html?id=" + id; break; case (int)Appoa.Common.EnumCollection.resource_type.音频资源: str = WebPath + "/html/video_details.html?id=" + id; break; case (int)Appoa.Common.EnumCollection.resource_type.视频资源: str = WebPath + "/html/video_details.html?id=" + id; break; case (int)Appoa.Common.EnumCollection.resource_type.英文发音: str = WebPath + "/html/voice_detail.html?id=" + id; break; case (int)Appoa.Common.EnumCollection.resource_type.维模型: str = WebPath + "/html/3d.html?id=" + id; break; } } else { return; } break; case "test": //测验 Model.common_examination exam = new BLL.common_examination().GetModel(Convert.ToInt32(id)); if (exam != null) { str = WebPath + "/html/test.html?id=" + id; is_logo = true; //course = new BLL.course_info().GetModel(" id = (select course_id from ybd_course_chapter where id = " + exam.parent_id + ")"); //if (course != null) //{ // logopath = course.qrcode_logo; //} } else { return; } break; case "talk": //讨论 Model.common_article article = new BLL.common_article().GetModel(Convert.ToInt32(id)); if (article != null) { str = WebPath + "/html/discuss_details.html?id=" + id; is_logo = true; //course = new BLL.course_info().GetModel(" id = (select course_id from ybd_course_chapter where user_id = 0 and id = " + article.category_id + ")"); //if (course != null) //{ // logopath = course.qrcode_logo; //} } else { return; } break; case "quest": //心理测试 str = WebPath + "/html/questionnaire.html?id=" + id; break; case "classroom": //课堂 str = WebPath + "/html/join_class.html?id=" + id; break; } QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(); qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE; qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M; qrCodeEncoder.QRCodeVersion = 0; qrCodeEncoder.QRCodeScale = 13; //将字符串生成二维码图片 Bitmap image = qrCodeEncoder.Encode(str, Encoding.Default); //保存为PNG到内存流 MemoryStream ms = new MemoryStream(); image.Save(ms, ImageFormat.Png); if (is_logo) { if (string.IsNullOrEmpty(logopath)) { Model.common_albums defaultlogo = new BLL.common_albums().GetModel(" group_id = " + (int)Appoa.Common.EnumCollection.img_group.系统默认二维码logo); if (defaultlogo != null) { logopath = defaultlogo.original_path; } else { logopath = "/html/images/Logo.png"; } } //logopath = "/html/images/Logo.png"; MemoryStream ms1 = new MemoryStream(); CombinImage(image, Server.MapPath("~" + logopath), 80).Save(ms1, System.Drawing.Imaging.ImageFormat.Png); //输出二维码图片 Response.ClearContent(); Response.ContentType = "image/Png"; Response.BinaryWrite(ms1.ToArray()); ms.Dispose(); ms1.Dispose(); Response.Flush(); Response.End(); } else { //输出二维码图片 Response.ClearContent(); Response.ContentType = "image/Png"; Response.BinaryWrite(ms.ToArray()); ms.Dispose(); Response.Flush(); Response.End(); } }
private void DownCourseQrCode() { var Server = HttpContext.Current.Server; int course_id = RequestHelper.GetFormInt("course_id"); string WebPath = System.Configuration.ConfigurationManager.AppSettings["WebPath"]; string webApi_address = WebPath + "/QrCode.aspx"; BLL.course_info bll = new BLL.course_info(); Model.course_info course = bll.GetModel(course_id); if (course != null) { string course_name = course.name.Trim(); //1、生成书籍的二维码文件夹 string virualRootPath = string.Format("/tempDown/{0}", course.name.Trim()); string tempRootPath = Server.MapPath(string.Format("/tempDown/{0}", course_name)).Trim(); if (Directory.Exists(tempRootPath)) { Directory.Delete(tempRootPath, true); } if (!Directory.Exists(tempRootPath)) { Directory.CreateDirectory(tempRootPath); } if (string.IsNullOrWhiteSpace(webApi_address)) { writeMsgError(-1, "没有配置WebPath地址!"); return; } string bookQrCodePath = System.IO.Path.Combine(tempRootPath, string.Format("{0}_书籍资源.png", course_name)).Trim(); string course_qrcode = string.Format("{0}/html/course_details.html?id={1}", WebPath, course.id); //要根据各个的生成规则生成二维码 string logoPath = course.qrcode_logo; //二维码logo if (string.IsNullOrEmpty(logoPath)) { Model.common_albums defaultlogo = new BLL.common_albums().GetModel(" group_id = " + (int)Appoa.Common.EnumCollection.img_group.系统默认二维码logo); if (defaultlogo != null) { logoPath = defaultlogo.original_path; } else { logoPath = "/html/images/Logo.png"; } } using (var ms = new MemoryStream()) { QrCodeHelper.GetRQCodeCombin(course_qrcode, ms, bookQrCodePath, Server.MapPath(logoPath)); } //2、生成章的文件夹 BLL.course_chapter ccBll = new BLL.course_chapter(); BLL.common_resource crBll = new BLL.common_resource(); List <Model.course_chapter> firstChapterList = ccBll.GetModelList(" group_id = 1 and chapter_level = 1 and course_id = " + course.id); foreach (Model.course_chapter chapter in firstChapterList) { string chapterPath = System.IO.Path.Combine(tempRootPath, string.Format("章_{0}", chapter.name)).Trim(); if (Directory.Exists(chapterPath)) { Directory.Delete(chapterPath, true); } if (!Directory.Exists(chapterPath)) { Directory.CreateDirectory(chapterPath); } //3、生成节的文件夹 //List<Model.course_chapter> secondChapterList = ccBll.GetModelList(" group_id = 1 and chapter_level = 2 and course_id = " + course.id + " and parent_id = " + chapter.id); //foreach (Model.course_chapter part in secondChapterList) //{ // string partPath = System.IO.Path.Combine(chapterPath, string.Format("节_{0}", part.name)).Trim(); // if (Directory.Exists(partPath)) // { // Directory.Delete(partPath, true); // } // if (!Directory.Exists(partPath)) // { // Directory.CreateDirectory(partPath); // } //4、生成章下所有资源二维码图片 List <Model.common_resource> resourceList = crBll.GetModelList(" is_del = 0 and from_id = " + (int)EnumCollection.resource_from.精品微课 + " and data_id = " + chapter.id); foreach (Model.common_resource item in resourceList) { string resCode = string.Empty; switch (item.type) { case (int)EnumCollection.resource_type.图文资源: if (item.from_id == (int)EnumCollection.resource_from.精品微课) { resCode = WebPath + "/html/article_details.html?id=" + item.id; } else { resCode = WebPath + "/html/knowledge_details.html?id=" + item.id; } break; case (int)EnumCollection.resource_type.文档资源: item.path = item.path.Substring(0, item.path.LastIndexOf('.')); //resCode = WebPath + item.path + ".html"; resCode = "/html/doc_detail.html?id=" + item.id; break; case (int)EnumCollection.resource_type.音频资源: resCode = WebPath + "/html/video_details.html?id=" + item.id; break; case (int)EnumCollection.resource_type.视频资源: resCode = WebPath + "/html/video_details.html?id=" + item.id; break; case (int)EnumCollection.resource_type.英文发音: resCode = WebPath + "/html/voice_detail.html?id=" + item.id; break; case (int)EnumCollection.resource_type.维模型: resCode = WebPath + "/html/3d.html?id=" + item.id; break; } //生成明细资源 //string resPath = System.IO.Path.Combine(partPath, string.Format("{0}_{1}_资源_{2}.png", chapter.name, part.name, item.title.Trim())).Trim(); string resPath = System.IO.Path.Combine(chapterPath, item.title.Trim() + ".png").Trim(); using (var ms = new MemoryStream()) { QrCodeHelper.GetRQCodeCombin(resCode, ms, resPath, Server.MapPath(logoPath)); } } //} } //打包—下载 FastZip fz = new FastZip(); fz.CreateEmptyDirectories = true; fz.CreateZip(string.Format("{0}.zip", tempRootPath), tempRootPath, true, ""); // ZFiles.DownLoadFile(Server.MapPath(string.Format("{0}.zip", virualRootPath))); ZFiles.DownloadFile(System.Web.HttpContext.Current, Server.MapPath(string.Format("{0}.zip", virualRootPath)), 1024 * 50); } }
//保存 protected void btnSubmit_Click(object sender, EventArgs e) { ChkAdminLevel("_ybd_course_info", EnumCollection.ActionEnum.Add.ToString()); //检查权限 #region string strError = string.Empty; if (txtgroup_id.Text.Trim() == "" || txtgroup_id.Text.Trim().Length > 4) { strError += "分组ID 1公共资源 2学校资源为空或超出长度![br]"; } if (txtcategory_id.Text.Trim() == "" || txtcategory_id.Text.Trim().Length > 4) { strError += "分类ID为空或超出长度![br]"; } if (txtname.Text.Trim() == "" || txtname.Text.Trim().Length > 50) { strError += "名称为空或超出长度![br]"; } if (txtcover.Text.Trim() == "" || txtcover.Text.Trim().Length > 255) { strError += "封面图为空或超出长度![br]"; } if (txtinfo.Text.Trim() == "" || txtinfo.Text.Trim().Length > 4000) { strError += "简介为空或超出长度![br]"; } if (txtnotice.Text.Trim() == "" || txtnotice.Text.Trim().Length > 4000) { strError += "公告为空或超出长度![br]"; } if (txtqrcode.Text.Trim() == "" || txtqrcode.Text.Trim().Length > 500) { strError += "二维码图片为空或超出长度![br]"; } if (txtqrcode_logo.Text.Trim() == "" || txtqrcode_logo.Text.Trim().Length > 500) { strError += "二维码logo为空或超出长度![br]"; } if (txtuser_id.Text.Trim() == "" || txtuser_id.Text.Trim().Length > 4) { strError += "发布者id为空或超出长度![br]"; } if (txtis_show.Text.Trim() == "" || txtis_show.Text.Trim().Length > 4) { strError += "是否显示为空或超出长度![br]"; } if (txtadd_time.Text.Trim() == "" || txtadd_time.Text.Trim().Length > 8) { strError += "添加时间为空或超出长度![br]"; } if (strError != string.Empty) { JscriptMsg(strError, "", "Error"); return; } #endregion Model.course_info model = new Model.course_info(); BLL.course_info bll = new BLL.course_info(); model.group_id = Convert.ToInt32(txtgroup_id.Text); model.category_id = Convert.ToInt32(txtcategory_id.Text); model.name = Convert.ToString(txtname.Text); model.cover = Convert.ToString(txtcover.Text); model.info = Convert.ToString(txtinfo.Text); model.notice = Convert.ToString(txtnotice.Text); model.qrcode = Convert.ToString(txtqrcode.Text); model.qrcode_logo = Convert.ToString(txtqrcode_logo.Text); model.user_id = Convert.ToInt32(txtuser_id.Text); model.is_show = Convert.ToInt32(txtis_show.Text); model.add_time = Convert.ToDateTime(txtadd_time.Text); int id = bll.Add(model); if (id > 0) { AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加课程信息信息,主键:" + id); //记录日志 JscriptMsg("添加课程信息信息成功!", "Manage.aspx", ""); } else { JscriptMsg("保存过程中发生错误!", ""); } }