Exemplo n.º 1
0
        public ComponentExceptionDisplayViewModel(TraceLab.Core.ViewModels.ComponentLogInfo logInfo)
        {
            LogInfo = logInfo;

            if (LogInfo.Exception != null)
            {
                ExceptionType = LogInfo.Exception.GetType().FullName;

                StringBuilder shortStack = new StringBuilder();
                using (StringReader reader = new StringReader(LogInfo.Exception.StackTrace))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        if (line.StartsWith("Server stack trace: "))
                        {
                            shortStack.AppendLine("Exception trace:");
                            continue;
                        }
                        if (line.Trim().StartsWith("at System.Runtime.Remoting.Messaging"))
                        {
                            break;
                        }
                        shortStack.AppendLine(line);
                    }
                }

                ShortStackTrace = shortStack.ToString();
            }
        }
Exemplo n.º 2
0
        private void ViewExceptionButton_Click(object sender, RoutedEventArgs e)
        {
            Button button = (Button)sender;

            TraceLab.Core.ViewModels.ComponentLogInfo logInfo = button.DataContext as TraceLab.Core.ViewModels.ComponentLogInfo;
            if (logInfo != null)
            {
                ComponentExceptionDisplay display = new ComponentExceptionDisplay();
                display.ShowInTaskbar         = false;
                display.ShowActivated         = true;
                display.Owner                 = this.GetParentManager(null).GetParent <MainWindowBase>(null);
                display.WindowStartupLocation = WindowStartupLocation.CenterOwner;

                //create view model
                var exceptionViewModel = new TraceLab.UI.WPF.ViewModels.ComponentExceptionDisplayViewModel(logInfo);

                display.DataContext = exceptionViewModel;

                display.SizeToContent = System.Windows.SizeToContent.WidthAndHeight;
                display.Title         = "Component exception details";

                display.ShowDialog();
            }
        }