public Program(string[] args) { Console.Title = "安装IIS"; IntPtr ParenthWnd = new IntPtr(0); IntPtr et = new IntPtr(0); ParenthWnd = FindWindow(null, "安装IIS"); ShowWindow(ParenthWnd, 0);//隐藏本dos窗体, 0: 后台执行;1:正常启动;2:最小化到任务栏;3:最大化 //作自己的事情 IIISInstaller installer = IISManagerFactory.New().CreateIISInstaller(); if (args.Length >= 1 && args[0] == "-u") //卸载 { if (!installer.IsFullyInstalled()) { installer.UninstallIIS(); } } else { System.Console.WriteLine("正在安装IIS,请稍候..."); if (!installer.IsFullyInstalled()) { installer.InstallIIS(); } } Console.Write("Exit"); }
void LicenseAcceptControl_NextEvent(object sender, EventArgs e) { #region 判断服务器上是否存在ibas网站(IIS未安装,同样认为是不存在ibas网站) bool existsIbasSite = false; try { var manager = IISManagerFactory.New().CreateIISManager(); var list = manager.GetSiteNames(); if (list.Count > 0) { existsIbasSite = true; } } catch (Exception) { } #endregion if (existsIbasSite) { this.ShellControl.SetCurrentControl(ControlTypes.InstallationOptions); } else { var code = NewInstallService.SERVICECODE; if (this.ShellControl.installService == null || //服务未创建 !this.ShellControl.installService.ServiceCode.Equals(code)) //上一步至此页面,服务被更改 { this.ShellControl.installService = Install4ibas.Tools.Services.ServicesFactory.New().GetService(code); } this.ShellControl.SetCurrentControl(ControlTypes.ModulesChoose); } }
public override void Excute() { //TODO:添加逻辑代码 var manager = IISManagerFactory.New().CreateIISManager(); manager.CreateSite(this.AppSetting.SiteName, Convert.ToInt32(this.AppSetting.IISPort), this.AppSetting.InstallDiraddress, "http"); manager.CreateApplicationPool(this.AppSetting.SiteName, "v4.0", Microsoft.Web.Administration.ManagedPipelineMode.Integrated); }
private void loadSitesInfo() { this.cmb_Sites.Items.Clear(); this.cmb_Sites.Items.Add(""); var manager = IISManagerFactory.New().CreateIISManager(); var list = manager.GetSiteNames(); foreach (var item in list) { this.cmb_Sites.Items.Add(item); } if (this.cmb_Sites.Items.Count == 1) { throw new Exception("当前服务器未找到已部署的ibas网站,无法执行此操作."); } }
public override void Excute() { //TODO:添加逻辑代码 var manager = IISManagerFactory.New().CreateIISManager(); Site site = manager.GetSite(this.AppSetting.SiteName); if (site == null) { throw new Exception("网站未找到"); } foreach (var item in this.AppSetting.InstallModules .Where(c => c.Checked && c.Status != Tools.Core.emInstallStatus.Installed && !string.IsNullOrEmpty(c.ModuleInstallPath))) { site = manager.GetSite(this.AppSetting.SiteName); manager.CreateApplication(item.ModuleName, site, string.Format("/{0}", item.ModuleName), Path.Combine(this.AppSetting.InstallDiraddress, item.ModuleName), this.AppSetting.SiteName); } }
public override void Excute() { if (System.Environment.Is64BitProcess) { IIISInstaller installer = IISManagerFactory.New().CreateIISInstaller(); if (!installer.IsFullyInstalled()) { installer.InstallIIS(); } } else { var proc = new Process(); proc.StartInfo.FileName = Path.Combine(System.Environment.CurrentDirectory, "Install4IIS.exe"); proc.StartInfo.WorkingDirectory = System.Environment.CurrentDirectory; // proc.StartInfo.Arguments = string.Format("10");//this is argument proc.StartInfo.CreateNoWindow = false; proc.StartInfo.UseShellExecute = true; proc.Start(); proc.WaitForExit(); } }
public void LoadSiteInfo() { if (String.IsNullOrEmpty(this.SiteName)) { this.IISAddress = string.Format("http://{0}", System.Net.Dns.GetHostName()); this.IISPort = "8000"; this.B1Server = "127.0.0.1:30000"; this.cmbLanguage = SAPbobsCOM.BoSuppLangs.ln_Chinese.ToString(); this.DatabaseType = "MSSQL"; } else { Site site = IISManagerFactory.New().CreateIISManager().GetSite(this.SiteName);; if (site == null) { return; } System.Configuration.Configuration cfg = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/", this.SiteName); //设置appsetting AppSettingsSection appSetting = cfg.AppSettings; //使用Site信息对AppSetting赋值 #region 数据库相关 //public emPlatform Platform //public string B1User //public string B1Password this.DatabaseType = GetValue(appSetting, "DatabaseType"); this.DBServer = GetValue(appSetting, "DataSource"); this.DBName = GetValue(appSetting, "InitialCatalog"); this.DBUser = GetValue(appSetting, "UserID"); this.DBPassword = GetValue(appSetting, "Password"); this.B1Type = GetValue(appSetting, "B1Type"); this.B1Server = GetValue(appSetting, "B1Server"); this.cmbLanguage = SAPbobsCOM.BoSuppLangs.ln_Chinese.ToString(); #endregion #region IIS相关 this.InstallDiraddress = site.Applications["/"].VirtualDirectories["/"].PhysicalPath; if (site.Bindings.Count > 0) { var binding = site.Bindings[0]; var endPoint = binding.EndPoint; //public string IISAddress this.IISAddress = GetValue(appSetting, "IISAddress"); //public string IISPort this.IISPort = endPoint.Port.ToString(); } this.LoadDefaultModules(); foreach (var item in site.Applications) { if (item.Path == "/") { continue; } var module = this.InstallModules.FirstOrDefault(c => item.Path.Equals(string.Format("/{0}", c.ModuleName))); if (module != null) { module.Status = emInstallStatus.Installed; } else { module = new ibasModule(); module.Type = emModuleType.other; module.ModuleName = item.Path.Substring(1); module.ModuleDescription = module.ModuleName; module.Status = emInstallStatus.Installed; } } #endregion #region Licences相关 this.UpdateLicense(); #endregion } }