private void creatSite_Click(object sender, EventArgs e) { if (SiteInfo.Current.IVersion < IISVersion.IIS6) { MessageBox.Show("你的IIS版本太低,无法创建站点", "IIS管理器", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (serverComment.Text == "") { MessageBox.Show("网站描述不能为空", "IIS管理器", MessageBoxButtons.OK, MessageBoxIcon.Warning); serverComment.Focus(); } else if (ip.Text == "") { MessageBox.Show("无效的IP地址", "IIS管理器", MessageBoxButtons.OK, MessageBoxIcon.Warning); ip.Focus(); } else if (serverBindings.Text == "") { MessageBox.Show("无效的端口号", "IIS管理器", MessageBoxButtons.OK, MessageBoxIcon.Warning); serverBindings.Focus(); } else if (webPath.Text == "") { MessageBox.Show("请选择路径", "IIS管理器", MessageBoxButtons.OK, MessageBoxIcon.Warning); browser1.Focus(); } else { SiteInfo.Current.ServerComment = serverComment.Text.Trim(); SiteInfo.Current.IP = ip.Text.Trim(); SiteInfo.Current.Port = serverBindings.Text.Trim(); SiteInfo.Current.Host = host.Text.Trim(); SiteInfo.Current.WebPath = webPath.Text.Trim(); SiteInfo.Current.DefaultDoc = "Default.aspx,Default.html,index.aspx,index.html"; SiteInfo.Current.AppPool = "bbsmax_" + Guid.NewGuid().ToString().Substring(0, 8); try { UserSet();//IIS帐户设置 IISManager.CreateWebsite(); serverComment.Text = ""; host.Text = ""; webPath.Text = ""; MessageBox.Show("创建网站成功,直接点下一步进行安装。", "IIS管理器", MessageBoxButtons.OK); ListIIS(); Step2_Next.Enabled = true; Step2_Next.Focus(); } catch (Exception ex) { MessageBox.Show("创建网站失败:" + ex.Message, "IIS管理器", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (IISManager.IsIISRegistered() && (int)IISManager.GetIISVersion() >= (int)IISVersion.IIS5) { Application.Run(new MainForm()); } else { MessageBox.Show("您的机器还没有安装IIS或版本低于5.0", "bbsMax安装向导", MessageBoxButtons.OK); } }
private void Init() { #if SQLSERVER DataBase_SqlServer.Visible = true; DataBase_Sqlite.Visible = false; #endif #if SQLITE DataBase_SqlServer.Visible = false; DataBase_Sqlite.Visible = true; #endif Settings.Current.RootPath = Globals.RootPath(); SiteInfo.Current.DomainName = IISManager.GetHostName(); SiteInfo.Current.IP = IISManager.GetHostIP(); SiteInfo.Current.IVersion = IISManager.GetIISVersion(); }
private void createVirtual_Click(object sender, EventArgs e) { if (iisList.SelectedNode == null || iisList.SelectedNode.Text == SiteInfo.Current.DomainName) { MessageBox.Show("请指定一个站点或虚拟目录", "IIS管理器", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (virtualName.Text.Trim() == "") { virtualName.Focus(); MessageBox.Show("虚拟目录名称不能为空", "IIS管理器", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (webPath1.Text.Trim() == "") { webPath1.Focus(); MessageBox.Show("请选择路径", "IIS管理器", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { SiteInfo.Current.AppPool = "bbsmax_" + Guid.NewGuid().ToString().Substring(0, 8); SiteInfo.Current.VirPath = iisList.SelectedNode.Name; try { SiteInfo.Current.CurrentSite = new DirectoryEntry(SiteInfo.Current.VirPath); SiteInfo.Current.DefaultDoc = "Default.aspx,Default.html,index.aspx,index.html"; SiteInfo.Current.VirtualName = virtualName.Text.Trim(); SiteInfo.Current.WebPath = webPath1.Text.Trim(); try { UserSet();//IIS帐户设置 IISManager.CreateVirtual(); virtualName.Text = ""; webPath1.Text = ""; MessageBox.Show("创建虚拟目录成功。", "IIS管理器", MessageBoxButtons.OK); Step2_Next.Enabled = true; Step2_Next.Focus(); ListIIS();//刷新treeView并选中当前目录 } catch (Exception ex) { MessageBox.Show("创建虚拟目录失败:" + ex.Message, "IIS管理器", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch { MessageBox.Show("当前路径有错,创建失败。", "IIS管理器", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
private void Step2_Next_Click(object sender, EventArgs e) { Step2_Next.Enabled = false; Step2_Prev.Enabled = false; step3_Next.Enabled = true; step3_Prev.Enabled = true; string error = string.Empty; string path = string.Empty; if (radioButton3.Checked) { try { path = iisList.SelectedNode.Name; } catch { path = null; } if (!string.IsNullOrEmpty(path) && path != SiteInfo.Current.DomainName) { IISManager.SetSiteInfo(path); } else { error = "请选择一个站点或虚拟目录"; } } else if (SiteInfo.Current.WebPath == "") { error = "请先建立一个站点"; } //设置文件夹权限 if (string.IsNullOrEmpty(error)) { ChangePathPurview(SiteInfo.Current.WebPath, SiteInfo.Current.UserName_iusr, "ReadOnly"); ChangePathPurview(SiteInfo.Current.WebPath, SiteInfo.Current.UserName_iwam, "FullControl"); this.tabControl1.SelectedIndex = 2; address.Focus(); } else { MessageBox.Show(error, "bbsMax安装向导", MessageBoxButtons.OK, MessageBoxIcon.Warning); Step2_Prev.Enabled = true; } }
private void deleteVirtual_Click(object sender, EventArgs e) { if (MessageBox.Show("确定要删除吗?", "IIS管理器", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { if (iisList.SelectedNode != null) { try { IISManager.DeleteSiteVirtual(iisList.SelectedNode.Name); MessageBox.Show("删除成功", "IIS管理器", MessageBoxButtons.OK); ListIIS(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("请选择要删除的站点或虚拟目录", "IIS管理器", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }