Esempio n. 1
0
 //开始工作,下载,解压等
 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 + "无法访问,请联系管理员修复!!");
     }
 }