private void btnAdd_Click(object sender, EventArgs e) { if (localWeb1.dgvWeb.SelectedRows.Count == 0) { MessageBox.Show("没选择网站"); return; } IISConfig.Metabase metabase = new IISConfig.Metabase(); metabase.OpenLocalMachine(); IISConfig.Record record = new IISConfig.Record(); record.DataType = IISConfig.Record.DataTypes.String; record.UserType = IISConfig.Record.UserTypes.Server; record.Identifier = 9101; record.ChangeAttribute(IISConfig.Record.AttributeList.Inherit, true); foreach (DataGridViewRow item in localWeb1.dgvWeb.SelectedRows) { record.Data = AppPoolId2.Text; metabase.GetKeyFromPath("/LM/W3SVC/" + item.Cells["Id"].Value + "/root").SetRecord(record); } metabase.Close(); Comm.MetaBaseSave(); localWeb1.FillWeb(); Changed = true; }
public static void MetaBaseBackup(string name) { Comm.MetaBaseSave(); DirectoryEntry dir = new DirectoryEntry("IIS://localhost"); dir.Invoke("Backup", new object[3] { name, 1, 1 }); }
public static List <string> GetAppPoolsUsed() { Comm.MetaBaseSave(); List <string> list = new List <string>(); string MetaBase = File.ReadAllText(Comm.MetaBasePath()); foreach (Match item in Regex.Matches(MetaBase, @"AppPoolId=""(.+?)""")) { if (!list.Contains(item.Groups[1].Value)) { list.Add(item.Groups[1].Value); } } return(list); }
private void btnDeleteAllNoUsed_Click(object sender, EventArgs e) { Comm.MetaBaseSave(); List <string> listUsed = Comm.GetAppPoolsUsed(); List <string> listNow = Comm.GetAppPools(); IISConfig.Metabase metabase = new IISConfig.Metabase(); metabase.OpenLocalMachine(); foreach (var item in listNow) { if (!listUsed.Contains(item) && item != "DefaultAppPool") { metabase.GetKeyFromPath("/LM/W3SVC/AppPools").DeleteSubkey(item); } } metabase.Close(); Fill(); }
private void IIS_Configs_Load(object sender, EventArgs e) { Comm.MetaBaseSave(); XmlDocument doc = new XmlDocument(); doc.Load(Comm.MetaBasePath()); XmlNamespaceManager xnm = new XmlNamespaceManager(doc.NameTable); xnm.AddNamespace("mxh", "urn:microsoft-catalog:XML_Metabase_V64_0"); XmlNode NowNode = doc.SelectSingleNode("/mxh:configuration/mxh:MBProperty/mxh:IIsWebService", xnm); AspMaxRequestEntityAllowed.Text = NowNode.Attributes["AspMaxRequestEntityAllowed"].Value; DefaultDoc.Text = NowNode.Attributes["DefaultDoc"].Value; LogFileDirectory.Text = NowNode.Attributes["LogFileDirectory"].Value; AspEnableParentPaths.Checked = Convert.ToBoolean(NowNode.Attributes["AspEnableParentPaths"].Value); ScriptMaps.SelectedItem = Regex.Match(NowNode.Attributes["ScriptMaps"].Value, @"Framework\\(.+?)\\aspnet", RegexOptions.IgnoreCase).Groups[1].Value; NowNode = doc.SelectSingleNode("/mxh:configuration/mxh:MBProperty/mxh:IIsCompressionSchemes", xnm); if ( Convert.ToBoolean(NowNode.Attributes["HcDoDynamicCompression"].Value) && Convert.ToBoolean(NowNode.Attributes["HcDoOnDemandCompression"].Value) && Convert.ToBoolean(NowNode.Attributes["HcDoStaticCompression"].Value) ) { GZIP.Checked = true; } else { GZIP.Checked = false; } txtGzipPath.Text = NowNode.Attributes["HcCompressionDirectory"].Value; NowNode = doc.SelectSingleNode("/mxh:configuration/mxh:MBProperty/mxh:IIsComputer", xnm); EnableEditWhileRunning.Checked = NowNode.Attributes["EnableEditWhileRunning"].Value == "1" ? true : false; NowNode = doc.SelectSingleNode("/mxh:configuration/mxh:MBProperty/mxh:IIsMimeMap", xnm); FLV.Checked = NowNode.Attributes["MimeMap"].Value.ToLower().Contains(".flv,"); }
private void btnSaveMetabase_Click(object sender, EventArgs e) { Comm.MetaBaseSave(); MessageBox.Show("OK"); }