private void IntoDB_Click(object sender, EventArgs e) { #region 入库 if (this.CheckCookie()) { string templateidlist = DNTRequest.GetString("templateid"); if (templateidlist != "") { if ((templateidlist == "1") || (templateidlist.IndexOf(",1,") >= 0)) { base.RegisterStartupScript("", "<script>alert('选中的模板中含有系统初始化模板,此次提交无法执行');window.location.href='global_templatesgrid.aspx'</script>"); return; } path = Utils.GetMapPath(@"..\..\templates\"); int maxdbtemplateid = TypeConverter.ObjectToInt(Templates.GetValidTemplateList().Rows[Templates.GetValidTemplateList().Rows.Count - 1]["templateid"]); //Response.Write("maxid" + maxdbtemplateid + " templateidlist:" + templateidlist); foreach (string templateid in templateidlist.Split(',')) { if (Utils.StrToInt(templateid, 0) < maxdbtemplateid) { base.RegisterStartupScript("", "<script>alert('选中入库的模板中含有已入库的模板,此次提交无法执行');window.location.href='global_templatesgrid.aspx'</script>"); return; } } foreach (DataRow dr in buildGridData().Select("templateid IN (" + templateidlist + ") AND templateid > " + maxdbtemplateid)) { AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "模板文件入库", dr["name"].ToString().Trim()); try { Templates.CreateTemplate(dr["name"].ToString().Trim(), dr["directory"].ToString().Trim(), dr["copyright"].ToString().Trim(), dr["author"].ToString().Trim(), dr["createdate"].ToString().Trim(), dr["ver"].ToString().Trim(), dr["fordntver"].ToString().Trim()); } catch { base.RegisterStartupScript("", "<script>alert('无法更新数据库');window.location.href='global_templatesgrid.aspx';</script>"); } CreateTemplateByDirectory(dr["directory"].ToString().Trim()); } Discuz.Cache.DNTCache.GetCacheService().RemoveObject("/Forum/TemplateList"); Discuz.Cache.DNTCache.GetCacheService().RemoveObject("/Forum/TemplateIDList"); Discuz.Cache.DNTCache.GetCacheService().RemoveObject("/Forum/UI/TemplateListBoxOptionsForForumIndex"); Discuz.Cache.DNTCache.GetCacheService().RemoveObject("/Forum/UI/TemplateListBoxOptions"); base.RegisterStartupScript("PAGE", "window.location.href='global_templatesgrid.aspx';"); } else { base.RegisterStartupScript("", "<script>alert('您未选中任何选项');window.location.href='global_templatesgrid.aspx';</script>"); } } #endregion }