コード例 #1
0
    protected void btnRemove_Click(object sender, EventArgs e)
    {
        string artifactType = string.Empty;
        string artifactName = string.Empty;

        foreach (GridViewRow row in gridNotifView.Rows)
        {
            CheckBox cb = (CheckBox)row.FindControl("chkBoxNotify");

            if (cb != null && cb.Checked)
            {
                Label lblType = row.FindControl("lblArtifactType") as Label;
                artifactType = lblType.Text;
                Label lblName = row.FindControl("lblArtifactName") as Label;
                artifactName = lblName.Text;

                try
                {
                    BCCMonitoringDataAccess da = new BCCMonitoringDataAccess();
                    da.MonitoringEntryMarkedForDeletion((BCC.Core.WMI.BizTalk.ArtifactType)Enum.Parse(typeof(BCC.Core.WMI.BizTalk.ArtifactType), artifactType), artifactName);

                    new ActivityHelper().RaiseAuditEvent(this, lblCaption.Text, "removed " + artifactName, 103);
                    PopulateGrid(sortExpression, lastDirection);
                    AddAnnoucement("You can also disable monitoring of BizTalk artifacts instead of removing them.");
                    AddAnnoucement("The BCC agent takes 60 seconds to register new or changes to the BizTalk artifacts for monitoring.");
                }
                catch (Exception ex)
                {
                    DisplayError(ex.Message);
                }
            }
        }
    }
コード例 #2
0
 protected void btnMonitor_Click(object sender, EventArgs e)
 {
     foreach (ListItem liEventCat in eventLogList.Items)
     {
         if (liEventCat.Selected)
         {
             try
             {
                 BCCMonitoringDataAccess da = new BCCMonitoringDataAccess();
                 da.CreateMonitoringEntry(ArtifactType.EventLog, liEventCat.Value);
                 new ActivityHelper().RaiseAuditEvent(this, lblCaption.Text, " setup monitoring for " + liEventCat.Value + " event log", 401);
             }
             catch (Exception ex)
             {
                 System.Diagnostics.Debug.Write(ex.Message + ex.StackTrace);
             }
         }
     }
 }
コード例 #3
0
    private void DisplayChart(string artifactType, string artifactName, Frequency frequency)
    {
        string[] daysOfWeek = new string[7];
        string[] monthsInAnYear = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "July", "Aug", "Sept", "Oct", "Nov", "Dec" };
        List<BCCMonitoringReportEntry> list = null;
        Series series = null;
        BCC.Core.WMI.BizTalk.ArtifactType enumArtifactType = (BCC.Core.WMI.BizTalk.ArtifactType)Enum.Parse(typeof(BCC.Core.WMI.BizTalk.ArtifactType), artifactType);
        BCCMonitoringDataAccess da = new BCCMonitoringDataAccess();
        ArrayList seriesList = new ArrayList();

        switch (frequency)
        {
            case Frequency.DAILY:
        #region Daily
                list = da.MonitoringDataReport(enumArtifactType, artifactName, DateTime.UtcNow.Date, DateTime.UtcNow.Date.AddDays(1));

                // Build series based on the data received!
                foreach (BCCMonitoringReportEntry entry in list)
                {
                    // Create a new series in case you notice a new Artifact status
                    if (!(seriesList.Contains(entry.ArtifactStatus)))
                    {
                        // Add it to the series list before creating new series
                        seriesList.Add(entry.ArtifactStatus);

                        series = new Series();
                        series.Name = entry.ArtifactStatus;
                        series.ChartType = SeriesChartType.StackedColumn;
                        series.LegendText = entry.ArtifactStatus;
                        series.LegendToolTip = entry.ArtifactStatus;
                        series.XValueType = ChartValueType.Time;
                        series.YValueType = ChartValueType.Int32;
                        series.IsValueShownAsLabel = true;
                        series["DrawingStyle"] = "Emboss";

                        artifactReport.Series.Add(series);
                    }
                }

                // Build series based on the data received!
                foreach (BCCMonitoringReportEntry entry in list)
                {
                    object reportedDate = String.Format("{0:T}", entry.ReportedDate);

                    artifactReport.Series[entry.ArtifactStatus].Points.AddXY(reportedDate, 1);
                }

        #endregion
                break;

            case Frequency.WEEKLY:
        #region Weekly

                int[] seriesData = new int[daysOfWeek.Length];
                Hashtable htSeries = null;
                // Dynamically constructed days of week list based on today. (Today must be on the right most side)
                for (int count = 0; count < daysOfWeek.Length; count++)
                {
                    daysOfWeek[count] = DateTime.UtcNow.Subtract(new TimeSpan(6 - count, 0, 0, 0)).DayOfWeek.ToString();
                    // Initializing series data.
                    seriesData[count] = 0;
                }

                // Get the data for a week, starting from (6 days from today) until today.
                list = da.MonitoringDataReport(enumArtifactType, artifactName, DateTime.UtcNow.Subtract(new TimeSpan(6, 0, 0, 0)), DateTime.UtcNow.AddDays(1));

                htSeries = new Hashtable();
                // Build series based on the data received!
                foreach (BCCMonitoringReportEntry entry in list)
                {
                    // Create a new series in case you notice a new Artifact status
                    if (!(seriesList.Contains(entry.ArtifactStatus)))
                    {
                        // Add it to the series list before creating new series
                        seriesList.Add(entry.ArtifactStatus);

                        series = new Series();
                        series.Name = entry.ArtifactStatus;
                        series.ChartType = SeriesChartType.StackedColumn;
                        series.LegendText = entry.ArtifactStatus;
                        series.LegendToolTip = entry.ArtifactStatus;
                        series.XValueType = ChartValueType.String;
                        series.YValueType = ChartValueType.Int32;
                        series["DrawingStyle"] = "Emboss";
                        //series.IsValueShownAsLabel = true;
                        // Refer - http://blogs.msdn.com/b/alexgor/archive/2008/11/11/microsoft-chart-control-how-to-using-keywords.aspx
                        series.ToolTip = "On #VALX\nArtifact was #SERIESNAME #VALY time(s).";

                        // Add the series to the chart!
                        artifactReport.Series.Add(series);

                        //artifactReport.AlignDataPointsByAxisLabel(series.Name, PointSortOrder.Ascending);
                    }

                    if (seriesList.Contains(entry.ArtifactStatus))
                    {
                            object htData = htSeries[entry.ArtifactStatus];

                            if (htData != null)
                            {
                                // Get the data from hashtable and update it.
                                int[] htSeriesData = (int[]) htData;

                                for (int index = 0; index < daysOfWeek.Length; index++)
                                {
                                    if (entry.ReportedDate.DayOfWeek == DateTime.UtcNow.Subtract(new TimeSpan(index, 0, 0, 0)).DayOfWeek)
                                    {
                                        // Increment by 1.
                                        htSeriesData[(daysOfWeek.Length - 1) - index] += 1;
                                        break;
                                    }
                                }

                                htSeries.Remove(entry.ArtifactStatus);
                                htSeries.Add(entry.ArtifactStatus, htSeriesData.Clone() );
                            }
                            else
                            {
                                for (int index = 0; index < daysOfWeek.Length; index++)
                                {
                                    if (entry.ReportedDate.DayOfWeek == DateTime.UtcNow.Subtract(new TimeSpan(index, 0, 0, 0)).DayOfWeek)
                                    {
                                        // Initialize to 1.
                                        seriesData[(daysOfWeek.Length - 1) - index] = 1;
                                        // Hashtable holds the series data
                                        htSeries.Add(entry.ArtifactStatus, seriesData.Clone());
                                        // Reset the value
                                        seriesData[(daysOfWeek.Length - 1) - index] = 0;
                                        break;
                                    }
                                }

                            }
                    }
                }

                for (int count = 0; count < htSeries.Count; count++)
                {
                    seriesData = (int[]) htSeries[seriesList[count]];
                    artifactReport.Series[count].Points.DataBindXY(daysOfWeek, seriesData);
                }
        #endregion
                break;

            case Frequency.MONTHLY:
        #region Monthly

                int[] monthlySeriesData = new int[monthsInAnYear.Length];
                Hashtable htYrSeries = null;

                for (int count = 0; count < monthsInAnYear.Length; count++)
                {
                    // Initializing series data.
                    monthlySeriesData[count] = 0;
                }

                // Get the data for a year, starting from (365 days from today) until today.
                list = da.MonitoringDataReport(enumArtifactType, artifactName, DateTime.UtcNow.Subtract(new TimeSpan(365, 0, 0, 0)), DateTime.UtcNow.AddDays(1));

                htYrSeries = new Hashtable();

                // Build series based on the data received!
                foreach (BCCMonitoringReportEntry entry in list)
                {
                    // Create a new series in case you notice a new Artifact status
                    if (!(seriesList.Contains(entry.ArtifactStatus)))
                    {
                        // Add it to the series list before creating new series
                        seriesList.Add(entry.ArtifactStatus);

                        series = new Series();
                        series.Name = entry.ArtifactStatus;
                        series.ChartType = SeriesChartType.StackedColumn;
                        series.LegendText = entry.ArtifactStatus;
                        series.LegendToolTip = entry.ArtifactStatus;
                        series.XValueType = ChartValueType.String;
                        series.YValueType = ChartValueType.Int32;
                        series["DrawingStyle"] = "Emboss";
                        //series.IsValueShownAsLabel = true;
                        // Refer - http://blogs.msdn.com/b/alexgor/archive/2008/11/11/microsoft-chart-control-how-to-using-keywords.aspx
                        series.ToolTip = "In #VALX\nArtifact was #SERIESNAME #VALY time(s).";

                        // Add the series to the chart!
                        artifactReport.Series.Add(series);
                    }

                    if (seriesList.Contains(entry.ArtifactStatus))
                    {
                        object htData = htYrSeries[entry.ArtifactStatus];

                            if (htData != null)
                            {
                                // Get the data from hashtable and update it.
                                int[] htSeriesData = (int[]) htData;

                                for (int index = 0; index < monthsInAnYear.Length; index++)
                                {
                                    if (entry.ReportedDate.Month == (index + 1))
                                    {
                                        // Increment by 1.
                                        htSeriesData[index] += 1;
                                        break;
                                    }
                                }

                                htYrSeries.Remove(entry.ArtifactStatus);
                                htYrSeries.Add(entry.ArtifactStatus, htSeriesData.Clone());
                            }
                            else
                            {
                                for (int index = 0; index < monthsInAnYear.Length; index++)
                                {
                                    if (entry.ReportedDate.Month == (index + 1))
                                    {
                                        // Initialize to 1.
                                        monthlySeriesData[index] = 1;
                                        // Hashtable holds the series data
                                        htYrSeries.Add(entry.ArtifactStatus, monthlySeriesData.Clone());
                                        // Reset the value
                                        monthlySeriesData[index] = 0;
                                        break;
                                    }
                                }

                            }
                    }
                }

                for (int count = 0; count < htYrSeries.Count; count++)
                {
                    monthlySeriesData = (int[])htYrSeries[seriesList[count]];
                    artifactReport.Series[count].Points.DataBindXY(monthsInAnYear, monthlySeriesData);
                }
        #endregion
                break;

        }
    }
コード例 #4
0
    private void Monitor()
    {
        string sendPortName = string.Empty;

        // Iterate through the Gridview Rows property
        foreach (GridViewRow row in gridSendPort.Rows)
        {
            sendPortName = row.Cells[1].Text;
            // Access the CheckBox
            CheckBox cb = (CheckBox)row.FindControl("chkBoxSendPort");

            if (cb != null && cb.Checked)
            {
                try
                {
                    BCCMonitoringDataAccess da = new BCCMonitoringDataAccess();
                    da.CreateMonitoringEntry(ArtifactType.SendPort, sendPortName);
                    new ActivityHelper().RaiseAuditEvent(this, lblCaption.Text, " setup monitoring for send port " + sendPortName, 205);
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.Write(e.Message + e.StackTrace);
                }
            }
        }
    }
コード例 #5
0
    private void Monitor()
    {
        string hostName = string.Empty;

        // Iterate through the Gridview Rows property
        foreach (GridViewRow row in gridHost.Rows)
        {
            hostName = row.Cells[2].Text;
            // Access the CheckBox
            CheckBox cb = (CheckBox)row.FindControl(CONTROL_NAME);

            if (cb != null && cb.Checked)
            {
                try
                {
                    BCCMonitoringDataAccess da = new BCCMonitoringDataAccess();
                    da.CreateMonitoringEntry(ArtifactType.HostInstance, hostName);
                    new ActivityHelper().RaiseAuditEvent(this, lblCaption.Text, " setup monitoring for host instance " + hostName, 202);
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.Write(e.Message + e.StackTrace);
                }
            }
        }
    }
コード例 #6
0
        private void PurgeControlCenterData()
        {
            try
            {
                int mdaDaysToKeep = 30;
                int pcdaDaysToKeep = 7;
                int webAuditDaysToKeep = 30;

                BCCManageConfigData configData = new BCCManageConfigData();
                configData.Speedcode = BCC_AGENT_CONFIG_SPEEDCODE;
                configData.Query();

                NameValuePairSet configSet = configData.ConfigurationData;

                foreach (NameValuePair nvPair in configSet)
                {
                    if (nvPair.Name.Equals(BCCUIHelper.Constants.DAYS_TO_KEEP_PERFDATA))
                    {
                        Int32.TryParse(nvPair.Value, out pcdaDaysToKeep);
                    }
                    else
                        if (nvPair.Name.Equals(BCCUIHelper.Constants.DAYS_TO_KEEP_USRAVT))
                        {
                            Int32.TryParse(nvPair.Value, out webAuditDaysToKeep);
                        }
                        else
                            if (nvPair.Name.Equals(BCCUIHelper.Constants.DAYS_TO_KEEP_USRNTF))
                            {
                                Int32.TryParse(nvPair.Value, out mdaDaysToKeep);
                            }
                }

                BCCMonitoringDataAccess mda = new BCCMonitoringDataAccess();
                mda.PurgeMonitoringData(mdaDaysToKeep);

                BCCPerfCounterDataAccess pcda = new BCCPerfCounterDataAccess();
                pcda.PurgePerformanceCounterData(pcdaDaysToKeep);

                BCCWebAudit.PurgeWebAuditEvents(webAuditDaysToKeep);
            }
            catch (Exception exception)
            {
                WriteToEventLog(exception.Message + exception.StackTrace);
            }
        }
コード例 #7
0
        /// <summary>
        /// Event handler for WMI events
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void monitor_ArtifactStatusChanged(object sender, ArtifactMonitoringEventArgs e)
        {
            try
            {
                int smtp_email_port = 25;
                bool smtp_email_ssl = false;
                string smtp_email_host = string.Empty;
                string smtp_email_username = string.Empty;
                string smtp_email_userpwd = string.Empty;
                string smtp_email_subject = string.Empty;
                string smtp_email_rcpnt = string.Empty;
                string smtp_email_title = "BizTalk Control Center (BCC) - Alert Notification";
                string mailSubject = "BCC Agent notification [" + Environment.MachineName + "]";

                string mailMessage = HtmlEmailHelper.FormatContent(e, smtp_email_title);

                if (!IsLocalEmailFlag)
                {
                    try
                    {
                        // Read monitoring list
                        BCCMonitoringDataAccess da = new BCCMonitoringDataAccess();

                        // Receive Port
                        if (e.ArtifactType == ArtifactType.ReceivePort)
                        {
                            da.LogMonitoringData(e.ArtifactType, e.ReceiveLocationName, e.ArtifactStatus);
                        }
                        // Host Instance
                        else if (e.ArtifactType == ArtifactType.HostInstance)
                        {
                            da.LogMonitoringData(e.ArtifactType, e.HostName, e.ArtifactStatus);
                        }
                        // Service Instance
                        else if (e.ArtifactType == ArtifactType.ServiceInstance)
                        {
                            da.LogMonitoringData(e.ArtifactType, e.ServerName, e.ArtifactStatus);
                        }
                        // Send Port
                        else
                        {
                            da.LogMonitoringData(e.ArtifactType, e.ArtifactName, e.ArtifactStatus);
                        }
                    }
                    catch (Exception exception)
                    {
                        WriteToEventLog(exception.Message + exception.StackTrace);
                    }

                    // Send email
                    EmailHelper helper = new EmailHelper(BCC_AGENT_CONFIG_SPEEDCODE);

                    mailMessage = HtmlEmailHelper.FormatContent(e, helper.EmailTitle);
                    mailSubject = helper.EmailSubject.Replace("$machineName", Environment.MachineName);

                    helper.SendMail(mailSubject, mailMessage, false);

                    WriteToEventLog("Mail message:" + mailMessage);
                }
                else // Use local SMTP settings
                {
                    SmtpSection smtpSection = ConfigurationManager.GetSection("system.net/mailSettings/smtp") as SmtpSection;

                    // Get the from email of the config file
                    smtp_email_username = smtpSection.From;
                    // Get the to address from the app settings
                    smtp_email_rcpnt = ConfigurationManager.AppSettings["EmailRecipients"].ToString();
                    // Get the host name from the smtp section
                    smtp_email_host = smtpSection.Network.Host;

                    EmailHelper helper = new EmailHelper(smtp_email_port, smtp_email_ssl, smtp_email_host, smtp_email_username, smtp_email_userpwd, smtp_email_rcpnt, smtp_email_title, false);
                    helper.SendMail(mailSubject, mailMessage, true);
                }
            }
            catch (Exception exception)
            {
                WriteToEventLog(exception.Message + exception.StackTrace);
            }
        }
コード例 #8
0
        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);
            }
        }
コード例 #9
0
    private void Monitor()
    {
        string machineName = System.Environment.MachineName;

        try
        {
            BCCMonitoringDataAccess da = new BCCMonitoringDataAccess();
            da.CreateMonitoringEntry(ArtifactType.ServiceInstance, machineName);
            new ActivityHelper().RaiseAuditEvent(this, lblCaption.Text, " setup monitoring for service instance on '" + machineName + "'", 204);
        }
        catch (Exception e)
        {
            System.Diagnostics.Debug.Write(e.Message + e.StackTrace);
        }
    }