protected void Page_Load(object sender, EventArgs e) { url = "http://" + Request.Url.Authority; if (FileExists(HttpContext.Current.Server.MapPath(KSCMS.GetInstallDir() + "install/install.lock"))) { JS.AlertDoFun("安装程序已运行过了,如果要重新安装,请先删除install/install.lock文件!", "location.href='/';"); } else { if (KSCMS.S("action") == "install") { Response.Cache.SetCacheability(HttpCacheability.NoCache); //禁止缓存 beginInstall(); KSCMS.Die(); } else if (KSCMS.S("action") == "finish") { BtnStep3Next_Click(null, null); } } }
private void beginInstall() { /* * string dbname = this.TxtDBName.Text; * string dbuser = this.TxtDBUser.Text; * string dbpass = this.TxtDBPass.Text; * string dbserver = this.TxtDBService.Text; */ dbserver = KSCMS.S("dbserver"); dbuser = KSCMS.S("dbuser"); dbname = KSCMS.S("dbname"); dbpass = KSCMS.S("dbpass"); int fulldata = Utils.StrToInt(KSCMS.S("fulldata")); if (string.IsNullOrEmpty(dbname)) { tips("请输入数据库名称!"); } if (string.IsNullOrEmpty(dbserver)) { tips("请输入服务器名称!"); } string dbSqlPath = HttpContext.Current.Server.MapPath("~/install/DBStructure.sql"); if (File.Exists(dbSqlPath)) { connStr = string.Format("data source={0};user id={1};password={2};persist security info=false;", dbserver, dbuser, dbpass); try { #region 创建数据库 ExecuteSql(connStr, "master", "IF Not EXISTS (select name from master.dbo.sysdatabases where name = N'" + dbname + "') CREATE DATABASE " + dbname + " COLLATE Chinese_PRC_CI_AS"); #endregion } catch (Exception ex) { tips(ex.Message); } #region 运行创建表脚本 doSql(connStr, dbname, dbSqlPath); //创建结构 if (fulldata == 1) //完整体验包 { dbSqlPath = HttpContext.Current.Server.MapPath("~/install/fulldata.sql"); //导入初始数据 } else { dbSqlPath = HttpContext.Current.Server.MapPath("~/install/basedata.sql"); //导入初始数据 } doSql(connStr, dbname, dbSqlPath); #endregion BaseConfigInfo __configinfo = BaseConfigManage.Deserialize(Server.MapPath(KSCMS.GetInstallDir() + "conn.config")); __configinfo.SqlConnStr = string.Format(@"Data Source={0};User ID={1};Password={2};Initial Catalog={3};Pooling=true;", dbserver, dbuser, dbpass, dbname); BaseConfigManage.Serialiaze(__configinfo, Server.MapPath(KSCMS.GetInstallDir() + "conn.config")); tips("success"); } else { tips("数据库脚本文件不存在!"); } }
protected void Page_Load(object sender, EventArgs e) { KSSecurity.CheckPermissions(); templateId = Utils.StrToInt(KSCMS.S("templateId")); if (templateId > 0) { Session["currTemplateId"] = templateId.ToString(); } if (Session["currTemplateId"] != null) { int templateType = Utils.StrToInt(DataFactory.GetOnlyValue("select templateType From KS_Template Where TemplateID=" + Session["currTemplateId"].ToString())); switch (templateType) { case 1: TemplateDir = MyCache.GetCacheConfig(85); //手机模板总目录 break; case 2: TemplateDir = MyCache.GetCacheConfig(86); //机构模板总目录 break; case 3: TemplateDir = MyCache.GetCacheConfig(87); //个人空间模板 break; default: TemplateDir = MyCache.GetCacheConfig(84); //所有模板的总目录 break; } if (string.IsNullOrEmpty(TemplateDir)) { TemplateDir = "Template"; } using (DataTable dt = DataFactory.GetDataTable("select top 1 * From KS_Template Where TemplateId=" + Utils.StrToInt(Session["currTemplateId"].ToString()))) { if (dt.Rows.Count > 0) { _MainTemplatePath = KSCMS.GetInstallDir() + TemplateDir + "/" + dt.Rows[0]["templateEname"].ToString() + "/"; templateName = "当前风格:" + dt.Rows[0]["templateName"].ToString(); } } } else { JS.Alert("参数出错!"); } xmldoc = new XmlDocument(); xmldoc.Load(Server.MapPath(_MainTemplatePath + "config/pagestyle.config")); FieldsXML = XmlObject.XMLToString(ref xmldoc); if (KSCMS.S("action").Equals("Add")) { this.ListPannel.Visible = false; this.PanAdd.Visible = true; } else { if (!IsPostBack) { initialList(1); } } }