protected void Page_Load(object sender, EventArgs e) { //http://update.z01.com/Template/Bear/view.jpg if (function.isAjax()) { string action = Request.Form["action"]; string value = Request.Form["value"]; int userID = buser.GetLogin().UserID; Response.Clear(); switch (action) { case "getTempP": Response.Write(ZipClass.GetPercent(Convert.ToInt64(Application[userID + "downTempT"]), Convert.ToInt64(Application[userID + "downTempP"]))); break; case "setdefault": string tempdir = @"/Template/" + value; SiteConfig.SiteOption.TemplateDir = tempdir; SiteConfig.SiteOption.CssDir = tempdir + "/style"; SiteConfig.Update(); Response.Write(""); break; } Response.End(); } //EC.GetRemoteObj remote = new EC.GetRemoteObj(); //remote.Urlutf8("" + serverdomain + "/api/gettemplate.aspx?menu=getprojectinfodir&proname=" + Server.UrlEncode(proname)); if (!IsPostBack) { Panel1.Visible = true; LblTitle.Text = ProName + "[作者:" + GetAuthor() + "]"; tempname.Text = ProName; string prodir = "/template/" + ProDir + "/"; tempimg.Text = "<a class=\"lightbox\" href=\"" + serverdomain + prodir + "view.jpg\"><img src=\"" + serverdomain + prodir + "View.jpg\"></a>"; DownFile dw = DownFileWork; string TempUrl = serverdomain + "/template/" + ProDir + ".zip"; string TempZipFile = SiteConfig.SiteMapath() + "\\template\\" + ProDir + ".zip"; TempUrl = TempUrl.Replace(@"\\", @"\"); TempZipFile = TempZipFile.Replace("/", @"\").Replace(@"\\", @"\"); //function.WriteErrMsg(TempZipFile + "||||" + TempUrl); Application[buser.GetLogin().UserID + "downTempT"] = GetFileSize(TempUrl); dw.BeginInvoke(buser.GetLogin().UserID, HttpContext.Current, TempUrl, TempZipFile, null, null, null); Call.SetBreadCrumb(Master, "<li><a href='" + customPath2 + "Main.aspx'>工作台</a></li><li><a href='TemplateSetOfficial.aspx'>方案设置</a></li><li class=\"active\">下载方案</li>"); } }
//开始工作,下载,解压等 public void BeginWork(IISWebSite site) { if (!string.IsNullOrEmpty(StationGroup.CodeSourceUrl) && GetFileSize(StationGroup.CodeSourceUrl) != -1)//未配置下载地址,则不允许操作 { IdentityAnalogue ia = new IdentityAnalogue(); if (!ia.CheckEnableSA(false)) { dataInfo.InnerText = "错误800,请联系管理员!!!"; CreateExLog("创建失败,未正确配置管理员信息,请联系管理员!!!"); return; } if (!iisHelper.CreateSite(site)) { dataInfo.InnerText = "错误801,请联系管理员!!!"; CreateExLog("站点创建失败,站点同名或" + site.Port + "端口被占用,请联系管理员!!!"); return; } dbMod.SiteName = site.SiteName; dbMod.SiteID = DataConverter.CLng(iisHelper.GetSiteModel(dbMod.SiteName).SiteID); dbMod.Status = 1; dbMod.UserID = buser.GetLogin().UserID; dbMod.UserName = buser.GetLogin().UserName; dbMod.CreateTime = DateTime.Now; dbMod.Remind = site.DomainName; #region 创建数据库 if (StationGroup.AutoCreateDB) { if (!string.IsNullOrEmpty(StationGroup.DBManagerName) && !string.IsNullOrEmpty(StationGroup.DBManagerPasswd))//配置了数据库信息才会创建 { DBModHelper dbHelper = new DBModHelper(StationGroup.DBManagerName, StationGroup.DBManagerPasswd); M_UserInfo userInfo = buser.GetLogin(); string dbName = "Zdb_" + site.dbName; string dbUserName = dbName + "_" + userInfo.UserName; string dbPasswd = function.GeneratePasswd(); //下载地址不可用,则终止,数据库创建失败,则仍继续, try { if (dbHelper.DBIsExist(dbName) == 0) { dbHelper.CreateDatabase(dbName); dbHelper.CreateDatabaseUser(dbUserName, dbPasswd); dbHelper.CreateUserMap(dbName, dbUserName); dataInfo.InnerText = "创建独立数据库成功:" + dbName + " 用户名:" + dbUserName + " 密码:" + dbPasswd; dbMod.DBName = dbName; dbMod.DBUser = dbUserName; dbMod.DBInitPwd = dbPasswd; } else { dataInfo.InnerText = "错误代码901:数据库未创建,请联系管理员!!!";//"创建独立数据库失败:" + dbName + "原因:数据库已存在,请联系管理员!!!" CreateExLog("创建独立数据库失败:" + dbName + "原因:数据库已存在!!!"); } } catch (Exception ex) { dataInfo.InnerText = "错误代码902:数据库未创建,请联系管理员!!!"; CreateExLog("创建独立数据库失败:" + dbName + "原因:" + ex.Message); } } } else { dataInfo.InnerText = "管理员未许可自动创建数据库,请联系管理员创建对应数据库!!!"; } #endregion DownFile dw = DownFileWork; Application[buser.GetLogin().UserID + "downCodeT"] = GetFileSize(StationGroup.CodeSourceUrl); Application[buser.GetLogin().UserID + "downTempT"] = GetFileSize(site.TempUrl); dw.BeginInvoke(buser.GetLogin().UserID, HttpContext.Current, StationGroup.CodeSourceUrl, @site.PhysicalPath + "SourceCode.zip", site, null, null); dbBll.Insert(dbMod); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "beginCheck('getCodeP');", true); } else { function.WriteErrMsg("下载地址:" + StationGroup.CodeSourceUrl + "无法访问,请联系管理员修复!!"); } }