public CheckDisplayDto(ICheckDisplay check) { IsLoading = check.IsLoading(); IsPaused = check.IsPaused(); HasError = check.HasError(); IsTriggered = check.IsTriggered(); Result = check.GetResult(); Status = check.GetStatus(); Error = check.GetError(); Location = check.GetLocation(); CheckType = check.GetCheckType(); TabName = check.GetTab(); }
public void Update(ICheckDisplay check) { try { if (_mainForm == null) { throw new Exception("The form has not yet been created"); } else { TabDisplay myTab = null; //must be outside of lock lock (_tabs) { myTab = _tabs.FirstOrDefault(t => t.GetName() == check.GetTab()); if (myTab == null) { myTab = new TabDisplay(check.GetTab()); _mainForm.AddTab(check.GetTab()); _tabs = _tabs.Where(t => t != null).Concat(myTab).ToArray(); } } if (myTab.AddCheck(check)) { lock (_mainForm) { _mainForm.DrawTable(myTab.GetName(), myTab.GetLocations(), myTab.GetTypes()); } for (int i = 0; i < myTab.GetTypes().Count; i++) { for (int j = 0; j < myTab.GetLocations().Count; j++) { var cell = myTab.GetTable()[i, j]; if (cell != null) { string mouseOverText; System.Drawing.Color cellColour; if (cell.IsTriggered()) { cellColour = System.Drawing.Color.Red; mouseOverText = cell.GetStatus(); } else if (cell.HasError()) { cellColour = System.Drawing.Color.Yellow; mouseOverText = cell.GetError(); } else if (cell.IsPaused()) { cellColour = System.Drawing.Color.LightBlue; mouseOverText = cell.GetStatus(); } else { cellColour = System.Drawing.Color.White; mouseOverText = cell.GetStatus(); } lock (_mainForm) { var result = cell.GetResult(); _mainForm.SetCell(myTab.GetName(), i, j, result, cellColour, mouseOverText); } } else { lock (_mainForm) { _mainForm.SetCell(myTab.GetName(), i, j, "Not Applicable", System.Drawing.Color.Gray, "Not Applicable"); } } } } } else { //just update the cell lock (_mainForm) { System.Drawing.Color cellColour; if (check.IsTriggered()) { cellColour = System.Drawing.Color.Red; } else if (check.HasError()) { cellColour = System.Drawing.Color.Yellow; } else if (check.IsPaused()) { cellColour = System.Drawing.Color.LightBlue; } else { cellColour = System.Drawing.Color.White; } _mainForm.SetCell(myTab.GetName(), myTab.LastRow, myTab.LastColumn, check.GetResult(), cellColour, check.GetStatus()); } } } } catch (Exception e) { Log.Error(e, "Update failed"); } }