/// <summary>
        /// Add an event to our user space
        /// </summary>
        /// <param name="EventTime"></param>
        /// <param name="Elem"></param>
        /// <param name="Action"></param>
        /// <param name="NewValue"></param>
        /// <param name="OldValue"></param>
        public void AddEvent(DateTime EventTime, MM_Element Elem, String Action, String OldValue, String NewValue)
        {
            if (lvHistory.InvokeRequired)
            {
                lvHistory.Invoke(new SafeAddEvent(AddEvent), EventTime, Elem, Action, OldValue, NewValue);
            }
            else
            {
                lvHistory.Items.Add(new MM_UserInteraction(AssociatedEvent.EventTime = EventTime, Elem, Action, OldValue, NewValue));
                lvHistory.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                AssociatedEvent.Text = (Elem.Substation == null ? "" : Elem.Substation.Name + " ") + Elem.ElemType.Name + " " + Name;
                AssociatedEvent.ViolatedElement.Substation = MM_Repository.Substations[Elem.Substation.Name];
                if (PriorEvent)
                {
                    Data_Integration.UpdateViolation(AssociatedEvent, AssociatedEvent.Text, EventTime);
                }
                //else

                //   Data_Integration.RemoveViolation(AssociatedEvent);
                //AssociatedEvent.ViolatedElement.Substation = MM_Repository.Substations[Station];
                //AssociatedEvent.ViolatedElement.Operator = AssociatedEvent.ViolatedElement.Substation.Operator;
                //AssociatedEvent.ViolatedElement.Owner= AssociatedEvent.ViolatedElement.Substation.Owner;
                Data_Integration.CheckAddViolation(AssociatedEvent);
                PriorEvent = true;
            }
        }
Exemple #2
0
        /// <summary>
        /// Handle the submission of a new violation
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SubmitButton_Click(object sender, EventArgs e)
        {
            if (SelectedElement == null)
            {
                MM_System_Interfaces.MessageBox("Please select an element to be violated.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                try
                {
                    Data_Integration.CheckAddViolation(NewViolation);
                }
                catch (Exception ex)
                {
                    MM_System_Interfaces.MessageBox("Error generating specific alarm: " + ex.Message + "\n" + ex.StackTrace, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            //Now, clear our components and reset our violation
            NewViolation = new MM_AlarmViolation();
            NewViolation.ViolatedElement = SelectedElement;
            foreach (Control ctl in tabViolations.Controls)
            {
                if (ctl is ComboBox)
                {
                    (ctl as ComboBox).SelectedItem = null;
                }
                else if (ctl is TextBox)
                {
                    (ctl as TextBox).Text = "";
                }
                else if (ctl is CheckBox)
                {
                    (ctl as CheckBox).Checked = false;
                }
            }
        }