protected void btnDemo_Click(object sender, EventArgs e) { x = new BCCMonitoring(ArtifactType.HostInstance, "IHS_Receive", 10); //BCCMonitoring x = new BCCMonitoring(ArtifactType.ServiceInstance, "BizTalk Application 1", 10); x.EnableMonitoring(); x.ArtifactStatusChanged += new ArtifactMonitoringEventHandler(x_PortStatusChanged); }
private void ActivateBizTalkArtifactMonitoring() { try { // Read monitoring list BCCMonitoringDataAccess da = new BCCMonitoringDataAccess(); // Get the monitoring list from the database List<BCCMonitoringEntry> list = da.MonitoringEntryList(); // Reference monitor instance BCCMonitoring monitor = null; // Setup monitoring and enable events foreach (BCCMonitoringEntry entry in list) { // Get the monitor instance from masterMonitoringList. monitor = masterMonitoringList.Find(item => item.ArtifactName == entry.ArtifactName); if (monitor != null) { if (!entry.IsEnabled || (entry.IsEnabled && entry.IsMarkedForDelete)) // Entry is disabled. { monitor.DisableMonitoring(); // remove the monitor from the master monitoring list. masterMonitoringList.Remove(monitor); WriteToEventLog("Monitoring disabled for " + monitor.ArtifactName); } } else // Master monitoring list DOES NOT contain and hence add it. { if (entry.IsEnabled) { try { // Create a new monitor instance from the monitoring entry monitor = new BCCMonitoring(entry.ArtifactType, entry.ArtifactName, entry.PollingInterval); // Add the monitor to master monitor list. monitor.ArtifactStatusChanged += new ArtifactMonitoringEventHandler(monitor_ArtifactStatusChanged); monitor.EnableMonitoring(); masterMonitoringList.Add(monitor); WriteToEventLog("Monitoring enabled for " + entry.ArtifactType + "::" + monitor.ArtifactName); } catch (Exception ex) { WriteToEventLog(ex.Message + ex.StackTrace); } } } if (entry.IsMarkedForDelete) { da.RemoveMonitoringEntry(entry.ArtifactType, entry.ArtifactName); WriteToEventLog("Monitoring deleted for " + monitor.ArtifactName); } } } catch (Exception exception) { WriteToEventLog(exception.Message + exception.StackTrace); } }