private void InitializeListbox(bool retainSelection) { CrashIncident[] incidents = CrashIncident.GetAll(); FormattedListBoxItem selectedItem = (retainSelection ? listBox.SelectedItem : null) as FormattedListBoxItem; CrashIncident selectedIncident = ((selectedItem != null) ? selectedItem.ReferenceObject : null) as CrashIncident; selectedItem = null; listBox.Items.Clear(); foreach (CrashIncident incident in incidents) { Customer customer = Customer.Get(incident.CustomerId); FormattedListBoxItem listItem = new FormattedListBoxItem(incident, customer.BusinessName + Environment.NewLine + incident.When, true); if ((selectedIncident != null) && (selectedIncident.Id == incident.Id)) { selectedItem = listItem; } listBox.Items.Add(listItem); } if (selectedItem != null) { selectedItem.IsSelected = true; listBox.SelectedItem = selectedItem; } }
private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { FormattedListBoxItem selectedItem = listBox.SelectedItem as FormattedListBoxItem; if (selectedItem == null) { buttonDeleteIncident.IsEnabled = false; return; } buttonDeleteIncident.IsEnabled = true; ClearException(); CrashIncident crashIncident = selectedItem.ReferenceObject as CrashIncident; CrashReport crashReport = CrashReport.Get(crashIncident.TopLevelCrashReportId); while (crashReport != null) { PrintCrashReport(crashReport); PrintLine(""); if (crashReport.InnerExceptionCrashReportId == null) { break; } crashReport = CrashReport.Get(crashReport.InnerExceptionCrashReportId.Value); } }
private void buttonDeleteIncident_Click(object sender, RoutedEventArgs e) { FormattedListBoxItem selectedItem = listBox.SelectedItem as FormattedListBoxItem; buttonDeleteIncident.IsEnabled = false; if (selectedItem == null) { return; } CrashIncident crashIncident = selectedItem.ReferenceObject as CrashIncident; crashIncident.Delete(); listBox.Items.Remove(selectedItem); listBox.SelectedItem = null; ClearException(); }
static void server_ReceivedCrashException(object sender, ExceptionEventArgs args) { Srp6ServerSocket socket = sender as Srp6ServerSocket; byte[] identityHash = socket.IdentityHash; License license = License.Find(identityHash); Customer customer = Customer.Get(license.CustomerId); CrashIncident crashIncident = CrashIncident.Add(customer.Id); CrashReport rootCrashReport = CrashReport.Add(crashIncident.Id, args.Exception); if (rootCrashReport != null) { crashIncident.SetTopLevelCrashReportId(rootCrashReport.Id); crashIncident.Update(); } if (NewCrashIncident != null) { NewCrashIncident.Invoke(sender, new EventArgs()); } }