private void cmdOK_Click(object sender, EventArgs e) { BizTalkPortAndOrchsCollectorConfigEntry currentConfig = (BizTalkPortAndOrchsCollectorConfigEntry)SelectedEntry; currentConfig.SqlServer = txtSQLServer.Text; currentConfig.MgmtDBName = txtDatabase.Text; currentConfig.AllReceiveLocations = chkAllReceiveLocations.Checked; currentConfig.AllSendPorts = chkAllSendPorts.Checked; currentConfig.AllOrchestrations = chkAllOrchestrations.Checked; currentConfig.ReceiveLocations.Clear(); foreach (string s in lstReceiveLocations.Items) { currentConfig.ReceiveLocations.Add(s); } currentConfig.SendPorts.Clear(); foreach (string s in lstSendPorts.Items) { currentConfig.SendPorts.Add(s); } currentConfig.Orchestrations.Clear(); foreach (string s in lstOrchestrations.Items) { currentConfig.Orchestrations.Add(s); } DialogResult = System.Windows.Forms.DialogResult.OK; Close(); }
private void LoadOrchestrations() { BizTalkPortAndOrchsCollectorConfigEntry currentConfig = (BizTalkPortAndOrchsCollectorConfigEntry)SelectedEntry; StringBuilder sb = new StringBuilder(); lstOrchestrations.Items.Clear(); txtDisplayOrchestrations.Text = ""; foreach (string r in (from s in currentConfig.Orchestrations orderby s select s)) { lstOrchestrations.Items.Add(r); sb.Append(r + ", "); } string output = sb.ToString().Trim(' ', ','); if (output.Length > 1000) { output = output.Substring(0, 1000) + "..."; } if (chkAllOrchestrations.Checked) { txtDisplayOrchestrations.Text = "All"; } else { txtDisplayOrchestrations.Text = output; } }
private void LoadSendPorts() { BizTalkPortAndOrchsCollectorConfigEntry currentConfig = (BizTalkPortAndOrchsCollectorConfigEntry)SelectedEntry; lstSendPorts.Items.Clear(); foreach (string r in (from s in currentConfig.SendPorts orderby s select s)) { lstSendPorts.Items.Add(r); } SetSendPortTextBox(); }
private void LoadReceiveLocations() { BizTalkPortAndOrchsCollectorConfigEntry currentConfig = (BizTalkPortAndOrchsCollectorConfigEntry)SelectedEntry; lstReceiveLocations.Items.Clear(); foreach (string r in (from s in currentConfig.ReceiveLocations orderby s select s)) { lstReceiveLocations.Items.Add(r); } SetReceiveLocationTextBox(); }
public string ToXml() { XmlDocument configXml = new XmlDocument(); BizTalkPortAndOrchsCollectorConfigEntry GroupSettings = (BizTalkPortAndOrchsCollectorConfigEntry)Entries[0]; configXml.LoadXml(GetDefaultOrEmptyXml()); XmlNode root = configXml.DocumentElement.SelectSingleNode("bizTalkGroup"); root.SetAttributeValue("sqlServer", GroupSettings.SqlServer); root.SetAttributeValue("mgmtDb", GroupSettings.MgmtDBName); root.SetAttributeValue("allReceiveLocations", GroupSettings.AllReceiveLocations.ToString()); root.SetAttributeValue("allSendPorts", GroupSettings.AllSendPorts.ToString()); root.SetAttributeValue("allOrchestrations", GroupSettings.AllOrchestrations.ToString()); //Receive locations XmlNode receiveLocationsNode = root.SelectSingleNode("receiveLocations"); receiveLocationsNode.InnerXml = ""; foreach (string rl in GroupSettings.ReceiveLocations) { XmlElement receiveLocationNode = configXml.CreateElement("receiveLocation"); receiveLocationNode.SetAttributeValue("name", rl); receiveLocationsNode.AppendChild(receiveLocationNode); } //Send ports XmlNode sendPortsNode = root.SelectSingleNode("sendPorts"); sendPortsNode.InnerXml = ""; foreach (string s in GroupSettings.SendPorts) { XmlElement sendPortNode = configXml.CreateElement("sendPort"); sendPortNode.SetAttributeValue("name", s); sendPortsNode.AppendChild(sendPortNode); } //Orchestrations XmlNode orchestrationsNode = root.SelectSingleNode("orchestrations"); orchestrationsNode.InnerXml = ""; foreach (string s in GroupSettings.Orchestrations) { XmlElement orchestrationNode = configXml.CreateElement("orchestration"); orchestrationNode.SetAttributeValue("name", s); orchestrationsNode.AppendChild(orchestrationNode); } return(configXml.OuterXml); }
private void cmdRemoveOrchestrations_Click(object sender, EventArgs e) { BizTalkPortAndOrchsCollectorConfigEntry currentConfig = (BizTalkPortAndOrchsCollectorConfigEntry)SelectedEntry; if (MessageBox.Show("Are you sure you want to remove the selected item(s)?", "Remove", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { foreach (int index in (from int i in lstOrchestrations.SelectedIndices orderby i descending select i)) { lstOrchestrations.Items.RemoveAt(index); } SetOrchestrationTextBox(); } }
private void cmdTestDB_Click(object sender, EventArgs e) { BizTalkPortAndOrchsCollectorConfigEntry currentConfig = new BizTalkPortAndOrchsCollectorConfigEntry(); currentConfig.SqlServer = txtSQLServer.Text; currentConfig.MgmtDBName = txtDatabase.Text; if (!currentConfig.TestConnection()) { MessageBox.Show(currentConfig.LastError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Success", "Connection test", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public override List <System.Data.DataTable> GetDetailDataTables() { List <System.Data.DataTable> list = new List <System.Data.DataTable>(); BizTalkPortAndOrchsCollectorConfig currentConfig = (BizTalkPortAndOrchsCollectorConfig)AgentConfig; if (currentConfig.Entries.Count == 1) { BizTalkPortAndOrchsCollectorConfigEntry entry = (BizTalkPortAndOrchsCollectorConfigEntry)currentConfig.Entries[0]; System.Data.DataTable receiveLocationsTable = new System.Data.DataTable(entry.SqlServer + " - Receive locations"); receiveLocationsTable.Columns.Add(new System.Data.DataColumn("Port", typeof(string))); receiveLocationsTable.Columns.Add(new System.Data.DataColumn("Name", typeof(string))); receiveLocationsTable.Columns.Add(new System.Data.DataColumn("State", typeof(string))); System.Data.DataTable sendPortsTable = new System.Data.DataTable(entry.SqlServer + " - Send ports"); sendPortsTable.Columns.Add(new System.Data.DataColumn("Name", typeof(string))); sendPortsTable.Columns.Add(new System.Data.DataColumn("State", typeof(string))); System.Data.DataTable orchestrationsTable = new System.Data.DataTable(entry.SqlServer + " - Orchestrations"); orchestrationsTable.Columns.Add(new System.Data.DataColumn("Name", typeof(string))); orchestrationsTable.Columns.Add(new System.Data.DataColumn("State", typeof(string))); foreach (ReceiveLocationInfo rl in entry.GetReceiveLocationList()) { receiveLocationsTable.Rows.Add(rl.ReceivePortName, rl.ReceiveLocationName, rl.Disabled ? "Disabled" : "Enabled"); } foreach (SendPortInfo sp in entry.GetSendPortList()) { sendPortsTable.Rows.Add(sp.Name, sp.State); } foreach (SendPortInfo orch in entry.GetOrchestrationList()) { orchestrationsTable.Rows.Add(orch.Name, orch.State); } list.Add(receiveLocationsTable); list.Add(sendPortsTable); list.Add(orchestrationsTable); } 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); }
private void cmdRemoveReceiveLocation_Click(object sender, EventArgs e) { BizTalkPortAndOrchsCollectorConfigEntry tmpentry = new BizTalkPortAndOrchsCollectorConfigEntry(); tmpentry.SqlServer = txtSQLServer.Text; tmpentry.MgmtDBName = txtDatabase.Text; if (MessageBox.Show("Are you sure you want to remove the selected item(s)?", "Remove", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { foreach (int index in (from int i in lstReceiveLocations.SelectedIndices orderby i descending select i)) { lstReceiveLocations.Items.RemoveAt(index); } SetReceiveLocationTextBox(); } }
//#region ICollectorConfigEntryEditWindow //public ICollectorConfigEntry SelectedEntry { get; set; } //public QuickMonDialogResult ShowEditEntry() //{ // return (QuickMonDialogResult)ShowDialog(); //} //#endregion #region Form events private void BizTalkPortAndOrchsCollectorEditEntry_Load(object sender, EventArgs e) { if (SelectedEntry == null) { SelectedEntry = new BizTalkPortAndOrchsCollectorConfigEntry(); } BizTalkPortAndOrchsCollectorConfigEntry currentConfig = (BizTalkPortAndOrchsCollectorConfigEntry)SelectedEntry; txtSQLServer.Text = currentConfig.SqlServer; txtDatabase.Text = currentConfig.MgmtDBName; chkAllReceiveLocations.Checked = currentConfig.AllReceiveLocations; chkAllSendPorts.Checked = currentConfig.AllSendPorts; chkAllOrchestrations.Checked = currentConfig.AllOrchestrations; LoadReceiveLocations(); LoadSendPorts(); LoadOrchestrations(); }
private void cmdAddReceiveLocation_Click(object sender, EventArgs e) { try { BizTalkPortAndOrchsCollectorConfigEntry tmpentry = new BizTalkPortAndOrchsCollectorConfigEntry(); tmpentry.SqlServer = txtSQLServer.Text; tmpentry.MgmtDBName = txtDatabase.Text; if (!tmpentry.TestConnection()) { MessageBox.Show(tmpentry.LastError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { BizTalkEditList editList = new BizTalkEditList(); editList.Text = "Receive Locations"; editList.ColumnNames = new List <string>(); editList.ColumnNames.Add("Receive Port"); editList.ColumnNames.Add("Receive Location"); editList.ColumnNames.Add("Host"); editList.ValueColumn = 1; editList.ExcludeItems = new List <string>(); editList.ExcludeItems.AddRange((from string s in lstReceiveLocations.Items orderby s select s).ToArray()); editList.Items = new List <string[]>(); List <ReceiveLocationInfo> list = tmpentry.GetReceiveLocationList(); foreach (var rl in list) { editList.Items.Add(new string[] { rl.ReceivePortName, rl.ReceiveLocationName, rl.HostName }); } if (editList.ShowDialog() == System.Windows.Forms.DialogResult.OK) { lstReceiveLocations.Items.AddRange(editList.SelectedItems.ToArray()); } SetReceiveLocationTextBox(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void FromXml(string configurationString) { XmlDocument config = new XmlDocument(); config.LoadXml(configurationString); XmlNode root = config.DocumentElement.SelectSingleNode("bizTalkGroup"); BizTalkPortAndOrchsCollectorConfigEntry GroupSettings = (BizTalkPortAndOrchsCollectorConfigEntry)Entries[0]; GroupSettings.SqlServer = root.ReadXmlElementAttr("sqlServer", "."); GroupSettings.MgmtDBName = root.ReadXmlElementAttr("mgmtDb", "BizTalkMgmtDb"); GroupSettings.AllReceiveLocations = bool.Parse(root.ReadXmlElementAttr("allReceiveLocations", "True")); GroupSettings.AllSendPorts = bool.Parse(root.ReadXmlElementAttr("allSendPorts", "True")); GroupSettings.AllOrchestrations = bool.Parse(root.ReadXmlElementAttr("allOrchestrations", "True")); GroupSettings.ReceiveLocations = new List <string>(); foreach (XmlElement receiveLocationNode in root.SelectNodes("receiveLocations/receiveLocation")) { string receiveLocationName = receiveLocationNode.ReadXmlElementAttr("name"); if (receiveLocationName.Length > 0) { GroupSettings.ReceiveLocations.Add(receiveLocationName); } } GroupSettings.SendPorts = new List <string>(); foreach (XmlElement sendPortNode in root.SelectNodes("sendPorts/sendPort")) { string sendPortName = sendPortNode.ReadXmlElementAttr("name"); if (sendPortName.Length > 0) { GroupSettings.SendPorts.Add(sendPortName); } } GroupSettings.Orchestrations = new List <string>(); foreach (XmlElement orchestrationNode in root.SelectNodes("orchestrations/orchestration")) { string orchestrationName = orchestrationNode.ReadXmlElementAttr("name"); if (orchestrationName.Length > 0) { GroupSettings.Orchestrations.Add(orchestrationName); } } }
private void cmdAddOrchestration_Click(object sender, EventArgs e) { try { BizTalkPortAndOrchsCollectorConfigEntry currentConfig = (BizTalkPortAndOrchsCollectorConfigEntry)SelectedEntry; if (!currentConfig.TestConnection()) { MessageBox.Show(currentConfig.LastError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { BizTalkEditList editList = new BizTalkEditList(); editList.Text = "Orchestrations"; editList.ColumnNames = new List <string>(); editList.ColumnNames.Add("Orchestrations"); editList.ValueColumn = 1; editList.ExcludeItems = new List <string>(); editList.ExcludeItems.AddRange((from string s in lstOrchestrations.Items orderby s select s).ToArray()); editList.Items = new List <string[]>(); List <SendPortInfo> list = currentConfig.GetOrchestrationList(); foreach (var s in list) { editList.Items.Add(new string[] { s.Name }); } if (editList.ShowDialog() == System.Windows.Forms.DialogResult.OK) { lstOrchestrations.Items.AddRange(editList.SelectedItems.ToArray()); } SetOrchestrationTextBox(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public override MonitorState RefreshState() { MonitorState returnState = new MonitorState(); string lastAction = ""; try { BizTalkPortAndOrchsCollectorConfig currentConfig = (BizTalkPortAndOrchsCollectorConfig)AgentConfig; if (currentConfig.Entries.Count == 1) { BizTalkPortAndOrchsCollectorConfigEntry entry = (BizTalkPortAndOrchsCollectorConfigEntry)currentConfig.Entries[0]; returnState.RawDetails = string.Format("BizTalk Management DB: {0}", entry.Description); returnState.HtmlDetails = string.Format("<b>BizTalk Management DB: {0}</b>", entry.Description); returnState.CurrentValue = "All ok"; lastAction = "Getting Receive Location count"; int receiveLocationCount = entry.AllReceiveLocations ? entry.GetTotalReceiveLocationCount() : entry.ReceiveLocations.Count; lastAction = "Getting Disabled Receive Location count"; int receiveLocationsDisabled = entry.AllReceiveLocations ? entry.GetDisabledReceiveLocationCount(new List <string>()) : entry.GetDisabledReceiveLocationCount(entry.ReceiveLocations); //Now check send ports lastAction = "Getting Send Port count"; int sendPortCount = entry.AllSendPorts ? entry.GetTotalSendPortCount() : entry.SendPorts.Count; lastAction = "Getting Stopped Send Port count"; int sendPortStoppedCount = entry.AllSendPorts ? entry.GetStoppedSendPortCount(new List <string>()) : entry.GetStoppedSendPortCount(entry.SendPorts); //Now check orchestrations lastAction = "Getting Orchestration count"; int orchestrationCount = entry.AllOrchestrations ? entry.GetTotalOrchestrationCount() : entry.Orchestrations.Count; lastAction = "Getting Stopped Orchestration count"; int orchestrationStoppedCount = entry.AllOrchestrations ? entry.GetStoppedOrchestrationCount(new List <string>()) : entry.GetStoppedOrchestrationCount(entry.Orchestrations); if (receiveLocationsDisabled == -1 || sendPortStoppedCount == -1 || orchestrationStoppedCount == -1) { returnState.State = CollectorState.Error; returnState.ForAgent = entry.Description; returnState.CurrentValue = "BizTalk Management database error"; returnState.RawDetails = "An error occured trying to query the BizTalk Management database!"; returnState.HtmlDetails = "An error occured trying to query the BizTalk Management database!"; } else { if ((receiveLocationsDisabled >= receiveLocationCount && (receiveLocationCount > 0)) || (sendPortStoppedCount >= sendPortCount && (sendPortCount > 0)) || (orchestrationStoppedCount >= orchestrationCount && (orchestrationCount > 0))) { returnState.State = CollectorState.Error; returnState.CurrentValue = (sendPortStoppedCount > 0 ? string.Format("SP: {0},", sendPortStoppedCount) : ""); returnState.CurrentValue += (orchestrationStoppedCount > 0 ? string.Format("ORCH: {0},", orchestrationStoppedCount) : ""); returnState.CurrentValue += returnState.CurrentValue.ToString().Trim(','); } else if (receiveLocationsDisabled > 0 || sendPortStoppedCount > 0 || orchestrationStoppedCount > 0) { returnState.State = CollectorState.Warning; returnState.CurrentValue = (sendPortStoppedCount > 0 ? string.Format("SP: {0},", sendPortStoppedCount) : ""); returnState.CurrentValue += (orchestrationStoppedCount > 0 ? string.Format("ORCH: {0},", orchestrationStoppedCount) : ""); returnState.CurrentValue += returnState.CurrentValue.ToString().Trim(','); } else { returnState.State = CollectorState.Good; } if (receiveLocationsDisabled > 0) { MonitorState disabledRL = new MonitorState() { RawDetails = "Disabled receive locations", HtmlDetails = "<b>Disabled receive locations</b>" }; foreach (string rl in entry.GetDisabledReceiveLocationNames()) { disabledRL.ChildStates.Add( new MonitorState() { ForAgent = rl, State = CollectorState.Error, CurrentValue = "Disabled" }); } returnState.ChildStates.Add(disabledRL); } if (sendPortStoppedCount > 0) { MonitorState stoppedSP = new MonitorState() { RawDetails = "Stopped send ports", HtmlDetails = "<b>Stopped send ports</b>" }; foreach (string sp in entry.GetStoppedSendPortNames()) { stoppedSP.ChildStates.Add( new MonitorState() { ForAgent = sp, State = CollectorState.Error, CurrentValue = "Stopped" }); } returnState.ChildStates.Add(stoppedSP); } if (orchestrationStoppedCount > 0) { MonitorState stoppedOrchs = new MonitorState() { RawDetails = "Stopped orchestrations", HtmlDetails = "<b>Stopped orchestrations</b>" }; foreach (string orch in entry.GetStoppedOrchestrationNames()) { stoppedOrchs.ChildStates.Add( new MonitorState() { ForAgent = orch, State = CollectorState.Error, CurrentValue = "Stopped" }); } returnState.ChildStates.Add(stoppedOrchs); } } } 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); }
public override void RefreshDisplayData() { try { if (Collector != null) { BizTalkPortAndOrchsCollectorConfigEntry currentConfig = (BizTalkPortAndOrchsCollectorConfigEntry)((ICollectorConfig)Collector.AgentConfig).Entries[0]; lvwReceiveLocations.BeginUpdate(); lvwReceiveLocations.Items.Clear(); foreach (var item in currentConfig.GetReceiveLocationList()) { if (currentConfig.AllReceiveLocations || currentConfig.ReceiveLocations.Contains(item.ReceiveLocationName)) { ListViewItem lvi = new ListViewItem(item.ReceivePortName); lvi.SubItems.Add(item.ReceiveLocationName); lvi.SubItems.Add(item.Disabled ? "Disabled" : "Enabled"); if (item.Disabled) { lvi.BackColor = Color.LightCoral; } lvi.Tag = item; lvwReceiveLocations.Items.Add(lvi); } } lvwSendPorts.BeginUpdate(); lvwSendPorts.Items.Clear(); foreach (var item in currentConfig.GetSendPortList()) { if (currentConfig.AllSendPorts || currentConfig.SendPorts.Contains(item.Name)) { ListViewItem lvi = new ListViewItem(item.Name); lvi.SubItems.Add(item.State); if (item.State == "Stopped") { lvi.BackColor = Color.LightCoral; } else if (item.State == "Unenlisted") { lvi.BackColor = Color.Yellow; } lvi.Tag = item; lvwSendPorts.Items.Add(lvi); } } lvwOrchestrations.BeginUpdate(); lvwOrchestrations.Items.Clear(); foreach (var item in currentConfig.GetOrchestrationList()) { if (currentConfig.AllOrchestrations || currentConfig.Orchestrations.Contains(item.Name)) { ListViewItem lvi = new ListViewItem(item.Name); lvi.SubItems.Add(item.State); if (item.State == "Stopped") { lvi.BackColor = Color.LightCoral; } else if (item.State == "Unenlisted") { lvi.BackColor = Color.Yellow; } lvi.Tag = item; lvwOrchestrations.Items.Add(lvi); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { lvwReceiveLocations.EndUpdate(); lvwSendPorts.EndUpdate(); lvwOrchestrations.EndUpdate(); } }