public void FromXml(string configurationString) { XmlDocument config = new XmlDocument(); config.LoadXml(configurationString); XmlNode root = config.DocumentElement.SelectSingleNode("bizTalkGroup"); BizTalkSuspendedCountCollectorConfigEntry BizTalkGroup = (BizTalkSuspendedCountCollectorConfigEntry)Entries[0]; BizTalkGroup.SqlServer = root.ReadXmlElementAttr("sqlServer", "."); BizTalkGroup.MgmtDBName = root.ReadXmlElementAttr("mgmtDb", "BizTalkMgmtDb"); BizTalkGroup.InstancesWarning = int.Parse(root.ReadXmlElementAttr("instancesWarning", "1")); BizTalkGroup.InstancesError = int.Parse(root.ReadXmlElementAttr("instancesError", "1")); BizTalkGroup.ShowLastXDetails = int.Parse(root.ReadXmlElementAttr("showLastXDetails", "0")); BizTalkGroup.AllAppsHosts = bool.Parse(root.ReadXmlElementAttr("allHostsApps", "True")); foreach (XmlElement host in root.SelectNodes("hosts/host")) { string hostName = host.ReadXmlElementAttr("name"); if (hostName.Length > 0) { BizTalkGroup.Hosts.Add(hostName); } } foreach (XmlElement app in root.SelectNodes("apps/app")) { string appName = app.ReadXmlElementAttr("name"); if (appName.Length > 0) { BizTalkGroup.Apps.Add(app.Attributes.GetNamedItem("name").Value); } } }
private void cmdOK_Click(object sender, EventArgs e) { if (SelectedEntry == null) { SelectedEntry = new BizTalkSuspendedCountCollectorConfigEntry(); } BizTalkSuspendedCountCollectorConfigEntry currentConfig = (BizTalkSuspendedCountCollectorConfigEntry)SelectedEntry; currentConfig.SqlServer = txtSQLServer.Text; currentConfig.MgmtDBName = txtDatabase.Text; currentConfig.InstancesWarning = (int)nudMsgsWarning.Value; currentConfig.InstancesError = (int)nudMsgsError.Value; currentConfig.AllAppsHosts = chkAllHostsApps.Checked; currentConfig.ShowLastXDetails = (int)nudShowTopXEntries.Value; currentConfig.Apps = new List <string>(); foreach (string appName in lstApps.Items) { currentConfig.Apps.Add(appName); } currentConfig.Hosts = new List <string>(); foreach (string hostName in lstHosts.Items) { currentConfig.Hosts.Add(hostName); } SelectedEntry = currentConfig; DialogResult = DialogResult.OK; Close(); }
public override List <System.Data.DataTable> GetDetailDataTables() { List <System.Data.DataTable> list = new List <System.Data.DataTable>(); BizTalkSuspendedCountCollectorConfig currentConfig = (BizTalkSuspendedCountCollectorConfig)AgentConfig; if (currentConfig.Entries.Count == 1) { System.Data.DataTable suspendedTable = new System.Data.DataTable(Name); suspendedTable.Columns.Add(new System.Data.DataColumn("Host", typeof(string))); suspendedTable.Columns.Add(new System.Data.DataColumn("Application", typeof(string))); suspendedTable.Columns.Add(new System.Data.DataColumn("Message type", typeof(string))); suspendedTable.Columns.Add(new System.Data.DataColumn("Server", typeof(string))); suspendedTable.Columns.Add(new System.Data.DataColumn("Time", typeof(string))); suspendedTable.Columns.Add(new System.Data.DataColumn("URI", typeof(string))); suspendedTable.Columns.Add(new System.Data.DataColumn("Adapter", typeof(string))); suspendedTable.Columns.Add(new System.Data.DataColumn("Info", typeof(string))); BizTalkSuspendedCountCollectorConfigEntry entry = (BizTalkSuspendedCountCollectorConfigEntry)currentConfig.Entries[0]; foreach (SuspendedInstance si in entry.GetTopXSuspendedInstanced(100)) { suspendedTable.Rows.Add(si.Host, si.Application, si.MessageType, si.PublishingServer, si.SuspendTime.ToString("yyyy-MM-dd HH:mm:ss"), si.Uri, si.Adapter, si.AdditionalInfo); } list.Add(suspendedTable); } else { System.Data.DataTable dt = new System.Data.DataTable(Name); dt.Columns.Add(new System.Data.DataColumn("Error", typeof(string))); dt.Rows.Add("Configuration error."); list.Add(dt); } return(list); }
public override MonitorState GetState() { MonitorState returnState = new MonitorState(); StringBuilder plainTextDetails = new StringBuilder(); StringBuilder htmlTextTextDetails = new StringBuilder(); string lastAction = "Getting Suspended counts"; int instancesSuspended = 0; try { BizTalkSuspendedCountCollectorConfigEntry currentConfig = (BizTalkSuspendedCountCollectorConfigEntry)((ICollectorConfig)AgentConfig).Entries[0]; lastAction = string.Format("Getting BizTalk Ports and Orchestration Details for {0}.{1}", currentConfig.SqlServer, currentConfig.MgmtDBName); instancesSuspended = currentConfig.GetSuspendedMsgsCount(); if (instancesSuspended < currentConfig.InstancesWarning) { returnState.State = CollectorState.Good; } else if (instancesSuspended >= currentConfig.InstancesError) { returnState.State = CollectorState.Error; } else { returnState.State = CollectorState.Warning; } if (instancesSuspended > 0) { plainTextDetails.AppendLine(string.Format("Total suspended count: {0}\r\n", instancesSuspended)); htmlTextTextDetails.AppendLine(string.Format("<b>Total suspended count:</b> {0}<hr />\r\n", instancesSuspended)); if (returnState.State != CollectorState.Good && currentConfig.ShowLastXDetails > 0) { AgentMultiFormatInfoMsg info = currentConfig.GetLastXDetails(); plainTextDetails.AppendLine(info.RawText); htmlTextTextDetails.AppendLine(info.HTMLText); } } else { plainTextDetails.AppendLine("No suspended instances"); htmlTextTextDetails.AppendLine("No suspended instances"); } returnState.RawDetails = plainTextDetails.ToString().TrimEnd('\r', '\n'); returnState.HtmlDetails = htmlTextTextDetails.ToString(); returnState.CurrentValue = instancesSuspended; } catch (Exception ex) { returnState.RawDetails = string.Format("Last step: '{0}\r\n{1}", lastAction, ex.Message); returnState.HtmlDetails = string.Format("<blockquote>Last step: '{0}<br />{1}</blockquote>", lastAction, ex.Message); returnState.State = CollectorState.Error; } return(returnState); }
//#region ICollectorConfigEntryEditWindow //public ICollectorConfigEntry SelectedEntry { get; set; } //public QuickMonDialogResult ShowEditEntry() //{ // return (QuickMonDialogResult)ShowDialog(); //} //#endregion private void BizTalkSuspendedCountCollectorEditEntry_Load(object sender, EventArgs e) { if (SelectedEntry == null) { SelectedEntry = new BizTalkSuspendedCountCollectorConfigEntry(); } BizTalkSuspendedCountCollectorConfigEntry currentConfig = (BizTalkSuspendedCountCollectorConfigEntry)SelectedEntry; txtSQLServer.Text = currentConfig.SqlServer; txtDatabase.Text = currentConfig.MgmtDBName; if (currentConfig.InstancesWarning > 0) { nudMsgsWarning.Value = currentConfig.InstancesWarning; } if (currentConfig.InstancesError > 0) { nudMsgsError.Value = currentConfig.InstancesError; } chkAllHostsApps.Checked = currentConfig.AllAppsHosts; if (currentConfig.ShowLastXDetails > 0) { nudShowTopXEntries.Value = currentConfig.ShowLastXDetails; } foreach (string hostName in currentConfig.Hosts) { if (hostName.Length > 0) { lstHosts.Items.Add(hostName); } } foreach (string appName in currentConfig.Apps) { if (appName.Length > 0) { lstApps.Items.Add(appName); } } }
public string ToXml() { XmlDocument config = new XmlDocument(); config.LoadXml(GetDefaultOrEmptyXml()); XmlNode btsSuspendedInstances = config.SelectSingleNode("config/bizTalkGroup"); BizTalkSuspendedCountCollectorConfigEntry BizTalkGroup = (BizTalkSuspendedCountCollectorConfigEntry)Entries[0]; btsSuspendedInstances.Attributes.GetNamedItem("sqlServer").Value = BizTalkGroup.SqlServer; btsSuspendedInstances.Attributes.GetNamedItem("mgmtDb").Value = BizTalkGroup.MgmtDBName; btsSuspendedInstances.Attributes.GetNamedItem("instancesWarning").Value = BizTalkGroup.InstancesWarning.ToString(); btsSuspendedInstances.Attributes.GetNamedItem("instancesError").Value = BizTalkGroup.InstancesError.ToString(); btsSuspendedInstances.Attributes.GetNamedItem("allHostsApps").Value = BizTalkGroup.AllAppsHosts.ToString(); btsSuspendedInstances.Attributes.GetNamedItem("showLastXDetails").Value = BizTalkGroup.ShowLastXDetails.ToString(); XmlNode hostsNode = config.SelectSingleNode("config/bizTalkGroup/hosts"); for (int i = 0; i < BizTalkGroup.Hosts.Count; i++) { XmlElement host = config.CreateElement("host"); XmlAttribute hostName = config.CreateAttribute("name"); hostName.Value = BizTalkGroup.Hosts[i]; host.Attributes.Append(hostName); hostsNode.AppendChild(host); } XmlNode appsNode = config.SelectSingleNode("config/bizTalkGroup/apps"); for (int i = 0; i < BizTalkGroup.Apps.Count; i++) { XmlElement app = config.CreateElement("app"); XmlAttribute appName = config.CreateAttribute("name"); appName.Value = BizTalkGroup.Apps[i].ToString(); app.Attributes.Append(appName); appsNode.AppendChild(app); } return(config.OuterXml); }
public override MonitorState RefreshState() { MonitorState returnState = new MonitorState(); string lastAction = ""; int instancesSuspended = 0; try { BizTalkSuspendedCountCollectorConfig currentConfig = (BizTalkSuspendedCountCollectorConfig)AgentConfig; if (currentConfig.Entries.Count == 1) { BizTalkSuspendedCountCollectorConfigEntry entry = (BizTalkSuspendedCountCollectorConfigEntry)currentConfig.Entries[0]; returnState.RawDetails = string.Format("BizTalk Managament DB: {0}", entry.Description); returnState.HtmlDetails = string.Format("<b>BizTalk Managament DB: {0}</b>", entry.Description); returnState.CurrentValue = "None"; instancesSuspended = entry.GetSuspendedMsgsCount(); if (instancesSuspended < entry.InstancesWarning) { returnState.State = CollectorState.Good; } else if (instancesSuspended >= entry.InstancesError) { returnState.State = CollectorState.Error; } else { returnState.State = CollectorState.Warning; } if (instancesSuspended > 0) { returnState.ForAgent = entry.Description; returnState.CurrentValue = instancesSuspended; MonitorState suspendedIstancesState = new MonitorState() { RawDetails = "Suspended instances", HtmlDetails = "<b>Suspended instances</b>" }; foreach (SuspendedInstance si in entry.GetTopXSuspendedInstanced()) { suspendedIstancesState.ChildStates.Add( new MonitorState() { RawDetails = si.ToString(), HtmlDetails = si.ToString(true) }); } returnState.ChildStates.Add(suspendedIstancesState); } } else { returnState.State = CollectorState.Error; returnState.RawDetails = "Configuration not set"; returnState.HtmlDetails = "Configuration not set"; } } catch (Exception ex) { returnState.RawDetails = ex.Message; returnState.HtmlDetails = string.Format("<p><b>Last action:</b> {0}</p><blockquote>{1}</blockquote>", lastAction, ex.Message); returnState.State = CollectorState.Error; } return(returnState); }