Ejemplo n.º 1
0
        private void DblClick(object sender, EventArgs e)
        {
            EventItem evt = (EventItem)lvLatestAlerts.SelectedItems[0].Tag;

            if (evt == null)
            {
                return;
            }

            IndividualAlert ia = new IndividualAlert();

            ia.ShowEvent(evt);
            ia.Show();
        }
Ejemplo n.º 2
0
        private void DisplayNewEvent(EEventRepository r, EventItem e, bool isRealtime)
        {
            try
            {
                if (this.lvLatestAlerts.InvokeRequired)
                {
                    lvLatestAlerts.Invoke(new DisplayNewEventDelegate(DisplayNewEvent), new object[] { r, e, isRealtime });
                }
                else
                {
                    lock (displaylock)
                    {
                        EThreatRiskRating risk      = (EThreatRiskRating)Enum.Parse(typeof(EThreatRiskRating), e.EventRisk, true);
                        Color             riskColor = Color.LightGray;

                        if (displayHighRiskOnly)
                        {
                            if (risk != EThreatRiskRating.HighRisk && risk != EThreatRiskRating.MediumRisk)
                            {
                                return;
                            }
                        }

                        switch (risk)
                        {
                        case EThreatRiskRating.Information:
                            riskColor = Color.LightGray;
                            break;

                        case EThreatRiskRating.LowRisk:
                            riskColor = Color.LightGreen;
                            break;

                        case EThreatRiskRating.MediumRisk:
                            riskColor = Color.Orange;
                            break;

                        case EThreatRiskRating.HighRisk:
                            riskColor = Color.OrangeRed;
                            break;
                        }

                        string date = e.EventDate.ToString().Substring(0, e.EventDate.ToString().IndexOf(' '));
                        string time = e.EventDate.ToString().Substring(e.EventDate.ToString().IndexOf(' ') + 1);

                        ListViewItem lvi = new ListViewItem(new string[] { date, time, e.EventTitle });
                        lvi.BackColor   = riskColor;
                        lvi.Tag         = e;
                        lvi.ToolTipText = string.Format("Date/Time: {0} - {1}\nRisk: {2}\nTitle: {3}\nMessage: {4}\n", date, time, e.EventRisk, e.EventTitle, e.EventMessage);

                        lvLatestAlerts.Items.Insert(0, lvi);

                        if (lvLatestAlerts.Items.Count > 250)
                        {
                            lvLatestAlerts.Items.RemoveAt(250);
                        }

                        if (isRealtime && risk == EThreatRiskRating.HighRisk)
                        {
                            IndividualAlert ia = new IndividualAlert();
                            ia.ShowEvent(e);
                            ia.Show();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }