/// <summary> /// If a violation changes, check to see whether we have it. If so, trigger accordingly. /// </summary> /// <param name="Violation"></param> private void UpdateViolation(MM_AlarmViolation Violation) { if (DisplayElements == null) { return; } else if (InvokeRequired)//nataros - crash invistigation { try { Invoke(new SafeUpdateViolation(UpdateViolation), Violation); } catch { } } else if (Violation.ViolatedElement is MM_Node) { MM_OneLine_Node FoundNode; if (DisplayNodes.TryGetValue(Violation.ViolatedElement, out FoundNode)) { pnlElements.Invalidate(FoundNode.Bounds); } } else { MM_OneLine_Element FoundElem; if (DisplayElements.TryGetValue(Violation.ViolatedElement, out FoundElem)) { pnlElements.Invalidate(FoundElem.Bounds); } } }
/// <summary> /// Initialize a new user event tracking window /// </summary> /// <param name="UserName"></param> /// <param name="EventTime"></param> public MM_UserInteraction_Viewer(String UserName, DateTime EventTime) { InitializeComponent(); this.Text = "Event log: " + UserName; lvHistory.ListViewItemSorter = new MM_UserInteraction_Sorter(0, true); ShowInTaskbar = true; lvHistory.FullRowSelect = true; AssociatedEvent = new MM_AlarmViolation(); AssociatedEvent.EventTime = EventTime; AssociatedEvent.New = true; AssociatedEvent.Type = MM_Repository.ViolationTypes["UserAction"]; AssociatedEvent.ViolatedElement = new MM_Element(); AssociatedEvent.ViolatedElement.ElemType = MM_Repository.FindElementType("User"); AssociatedEvent.ViolatedElement.Name = UserName; AssociatedEvent.ViolatedElement.TEID = Data_Integration.GetTEID(); }
/// <summary> /// Return a description for this element /// </summary> /// <returns></returns> public String ElementDescription() { if (this is MM_Line) { if ((this as MM_Line).IsSeriesCompensator) { return("SeriesCompensator " + this.Name + " (" + (this as MM_Line).Substation1.DisplayName() + ")"); } else { return(this.Name + " (" + (this as MM_Line).Substation1.DisplayName() + " / " + (this as MM_Line).Substation2.DisplayName() + ")"); } } else if (this is MM_AlarmViolation) { MM_AlarmViolation Viol = this as MM_AlarmViolation; return(Viol.Type.Name + " " + Viol.ViolatedElement.ToString() + " " + Viol.Text + (Viol.Contingency != null ? " " + (Viol.Contingency.Name.Contains(" ") ? Viol.Contingency.Name.Substring(0, Viol.Contingency.Name.IndexOf(" ")) : Viol.Contingency.Name) : "")); } else if (this is MM_Company) { return((this as MM_Company).Alias + " " + this.Name); } else if (this.ElemType != null && this.ElemType.Name == "User") { return(this.Name); } else if (this is MM_Substation) { return(this.ElemType.Acronym + " " + this.Name); } else if (this.Substation != null) { return(this.Substation.DisplayName() + " " + this.ElemType.Acronym + " " + this.Name); } else if (this is MM_Bus) { return("Bus " + ((MM_Bus)this).BusNumber.ToString()); } else if (this.ElemType == null) { return(this.GetType().Name + " " + this.Name); } else { return(this.ElemType.Acronym + " " + this.Name); } }
/// <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; } } }