public override void RefreshDisplayData() { try { System.Windows.Forms.Cursor.Current = Cursors.WaitCursor; lvwEntries.BeginUpdate(); foreach (ListViewGroup lvgMachine in lvwEntries.Groups) { IISAppPoolMachine serviceDefinition = (IISAppPoolMachine)lvgMachine.Tag; try { List <IISAppPoolStateInfo> sourceList = serviceDefinition.GetIISAppPoolStates(); foreach (ListViewItem lviAppPool in lvgMachine.Items) { IISAppPoolEntry entry = (IISAppPoolEntry)lviAppPool.Tag; IISAppPoolStateInfo currentAppPool = (from ap in sourceList where ap.DisplayName == entry.Description select ap).FirstOrDefault(); if (currentAppPool == null || currentAppPool.Status == AppPoolStatus.Unknown) { lviAppPool.ImageIndex = 0; } else if (currentAppPool.Status == AppPoolStatus.Started) { lviAppPool.ImageIndex = 1; } else if (currentAppPool.Status == AppPoolStatus.Stopped) { lviAppPool.ImageIndex = 2; } else { lviAppPool.ImageIndex = 3; } } } catch (UnauthorizedAccessException unauthEx) { MessageBox.Show(string.Format("Cannot update the application pool list for {0} due to 'Unauthorized Access' error. Please restart this application in 'Admin' mode.\r\nDetails: {1}", serviceDefinition.MachineName, unauthEx.Message), "Unauthorized Access", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } catch (Exception ex) { MessageBox.Show(string.Format("Error updating application pool states of {0}\r\n{1}", serviceDefinition.MachineName, ex.ToString()), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } lvwEntries.EndUpdate(); System.Windows.Forms.Cursor.Current = Cursors.Default; toolStripStatusLabelDetails.Text = "Last updated " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); }
private void IISAppPoolCollectorEditEntry_Load(object sender, EventArgs e) { if (SelectedEntry != null) { IISAppPoolMachine selectedEntry = (IISAppPoolMachine)SelectedEntry; txtComputer.Text = selectedEntry.MachineName; chkUsePerfCounters.Checked = selectedEntry.UsePerfCounter; foreach (var appPoolEntry in selectedEntry.SubItems) { lstAppPools.Items.Add(appPoolEntry.Description); } ImportCheckTimer.Enabled = false; ImportCheckTimer.Enabled = true; } }
private void cmdImportSM_Click(object sender, EventArgs e) { DialogResult choice = System.Windows.Forms.DialogResult.No; if (lstAppPools.Items.Count > 0) { choice = MessageBox.Show("Do you want to clear any existing entries?", "Import", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); } try { Cursor.Current = Cursors.WaitCursor; if (System.Net.Dns.GetHostAddresses(txtComputer.Text).Count() > 0) { IISAppPoolMachine tmpIISAppPoolMachine = new IISAppPoolMachine(); tmpIISAppPoolMachine.MachineName = txtComputer.Text; tmpIISAppPoolMachine.UsePerfCounter = chkUsePerfCounters.Checked; List <IISAppPoolStateInfo> appPools = tmpIISAppPoolMachine.GetSourceIISAppPoolStates(); if (choice == System.Windows.Forms.DialogResult.Yes) { lstAppPools.Items.Clear(); } foreach (var appPool in appPools) { if (!lstAppPools.Items.Contains(appPool.DisplayName)) { lstAppPools.Items.Add(appPool.DisplayName); } } } CheckOkEnabled(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } Cursor.Current = Cursors.Default; }
private void cmdOK_Click(object sender, EventArgs e) { if (SelectedEntry == null) { SelectedEntry = new IISAppPoolMachine(); } IISAppPoolMachine selectedEntry = (IISAppPoolMachine)SelectedEntry; selectedEntry.MachineName = txtComputer.Text; selectedEntry.UsePerfCounter = chkUsePerfCounters.Checked; selectedEntry.SubItems = new List <ICollectorConfigSubEntry>(); foreach (string appPoolName in lstAppPools.Items) { selectedEntry.SubItems.Add(new IISAppPoolEntry() { Description = appPoolName }); } DialogResult = System.Windows.Forms.DialogResult.OK; Close(); }
public void ReadConfiguration(string configurationString) { XmlDocument config = new XmlDocument(); config.LoadXml(configurationString); Entries.Clear(); XmlElement root = config.DocumentElement; foreach (XmlElement machine in root.SelectNodes("machine")) { IISAppPoolMachine serviceStateDefinition = new IISAppPoolMachine(); serviceStateDefinition.MachineName = machine.ReadXmlElementAttr("name", ""); serviceStateDefinition.UsePerfCounter = machine.ReadXmlElementAttr("usePerfCounter", false); serviceStateDefinition.SubItems = new List <ICollectorConfigSubEntry>(); foreach (XmlElement service in machine.SelectNodes("appPool")) { serviceStateDefinition.SubItems.Add(new IISAppPoolEntry() { Description = service.Attributes.GetNamedItem("name").Value }); } Entries.Add(serviceStateDefinition); } }