Exemplo n.º 1
0
        private void SaveAs()
        {
            if (currentBuild != null)
            {
                var saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter          = Serialization.FileDialogFilter;
                saveFileDialog.Title           = "Save log file as";
                saveFileDialog.CheckFileExists = false;
                saveFileDialog.OverwritePrompt = true;
                saveFileDialog.ValidateNames   = true;
                var result = saveFileDialog.ShowDialog(this);
                if (result != true)
                {
                    return;
                }

                logFilePath = saveFileDialog.FileName;
                System.Threading.Tasks.Task.Run(() =>
                {
                    currentBuild.LogFilePath       = logFilePath;
                    currentBuild.Build.LogFilePath = logFilePath;
                    Serialization.Write(currentBuild.Build, logFilePath);
                    Dispatcher.InvokeAsync(() =>
                    {
                        currentBuild.UpdateBreadcrumb(new Message {
                            Text = $"Saved {logFilePath}"
                        });
                    });
                    SettingsService.AddRecentLogFile(logFilePath);
                });
            }
        }
        private async void OpenLogFile(string filePath)
        {
            if (!File.Exists(filePath))
            {
                return;
            }

            DisplayBuild(null);
            this.xmlLogFilePath = filePath;
            SettingsService.AddRecentLogFile(filePath);
            UpdateRecentItemsMenu();
            Title = DefaultTitle + " - " + filePath;

            var progress = new BuildProgress();

            progress.ProgressText = "Opening " + filePath + "...";
            SetContent(progress);
            Build build = await System.Threading.Tasks.Task.Run(() =>
            {
                return(XmlLogReader.ReadFromXml(filePath));
            });

            progress.ProgressText = "Analyzing " + filePath + "...";
            await System.Threading.Tasks.Task.Run(() => BuildAnalyzer.AnalyzeBuild(build));

            DisplayBuild(build);
        }
        private async void OpenLogFile(string filePath)
        {
            if (!File.Exists(filePath))
            {
                return;
            }

            DisplayBuild(null);
            this.logFilePath = filePath;
            SettingsService.AddRecentLogFile(filePath);
            UpdateRecentItemsMenu();
            Title = filePath + " - " + DefaultTitle;

            var progress = new BuildProgress();

            progress.ProgressText = "Opening " + filePath + "...";
            SetContent(progress);

            bool shouldAnalyze = true;

            var stopwatch = Stopwatch.StartNew();

            Build build = await System.Threading.Tasks.Task.Run(() =>
            {
                try
                {
                    return(Serialization.Read(filePath));
                }
                catch (Exception ex)
                {
                    ex            = ExceptionHandler.Unwrap(ex);
                    shouldAnalyze = false;
                    return(GetErrorBuild(filePath, ex.ToString()));
                }
            });

            if (build == null)
            {
                build         = GetErrorBuild(filePath, "");
                shouldAnalyze = false;
            }

            if (shouldAnalyze)
            {
                progress.ProgressText = "Analyzing " + filePath + "...";
                await System.Threading.Tasks.Task.Run(() => BuildAnalyzer.AnalyzeBuild(build));
            }

            progress.ProgressText = "Rendering tree...";
            await Dispatcher.InvokeAsync(() => { }, DispatcherPriority.Loaded); // let the progress message be rendered before we block the UI again

            DisplayBuild(build);

            var elapsed = stopwatch.Elapsed;

            if (currentBuild != null)
            {
                currentBuild.UpdateBreadcrumb($"Load time: {elapsed}");
            }
        }
Exemplo n.º 4
0
        private void SaveAs()
        {
            if (currentBuild != null)
            {
                string currentFilePath = currentBuild.LogFilePath;

                var saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter          = currentFilePath != null && currentFilePath.EndsWith(".binlog", StringComparison.OrdinalIgnoreCase) ? Serialization.BinlogFileDialogFilter : Serialization.FileDialogFilter;
                saveFileDialog.Title           = "Save log file as";
                saveFileDialog.CheckFileExists = false;
                saveFileDialog.OverwritePrompt = true;
                saveFileDialog.ValidateNames   = true;
                var result = saveFileDialog.ShowDialog(this);
                if (result != true)
                {
                    return;
                }

                string newFilePath = saveFileDialog.FileName;
                if (string.IsNullOrEmpty(newFilePath) || string.Equals(currentFilePath, newFilePath, StringComparison.OrdinalIgnoreCase))
                {
                    return;
                }

                logFilePath = saveFileDialog.FileName;

                lock (inProgressOperationLock)
                {
                    InProgressTask = InProgressTask.ContinueWith(t =>
                    {
                        try
                        {
                            if (logFilePath.EndsWith(".binlog", StringComparison.OrdinalIgnoreCase))
                            {
                                File.Copy(currentFilePath, logFilePath, overwrite: true);
                            }
                            else
                            {
                                Serialization.Write(currentBuild.Build, logFilePath);
                            }

                            currentBuild.Build.LogFilePath = logFilePath;

                            Dispatcher.InvokeAsync(() =>
                            {
                                currentBuild.UpdateBreadcrumb(new Message {
                                    Text = $"Saved {logFilePath}"
                                });
                            });
                            SettingsService.AddRecentLogFile(logFilePath);
                        }
                        catch
                        {
                        }
                    });
                }
            }
        }
        private async void OpenLogFile(string filePath)
        {
            if (!File.Exists(filePath))
            {
                return;
            }

            DisplayBuild(null);
            this.logFilePath = filePath;
            SettingsService.AddRecentLogFile(filePath);
            UpdateRecentItemsMenu();
            Title = DefaultTitle + " - " + filePath;

            var progress = new BuildProgress();

            progress.ProgressText = "Opening " + filePath + "...";
            SetContent(progress);

            bool shouldAnalyze = true;

            Build build = await System.Threading.Tasks.Task.Run(() =>
            {
                try
                {
                    return(Serialization.Read(filePath));
                }
                catch (Exception ex)
                {
                    shouldAnalyze = false;
                    build         = new Build()
                    {
                        Succeeded = false
                    };
                    build.AddChild(new Error()
                    {
                        Text = "Error when opening file: " + filePath
                    });
                    build.AddChild(new Error()
                    {
                        Text = ex.ToString()
                    });
                    return(build);
                }
            });

            if (shouldAnalyze)
            {
                progress.ProgressText = "Analyzing " + filePath + "...";
                await System.Threading.Tasks.Task.Run(() => BuildAnalyzer.AnalyzeBuild(build));
            }

            DisplayBuild(build);
        }
Exemplo n.º 6
0
        private async void OpenLogFile(string filePath)
        {
            if (!File.Exists(filePath))
            {
                return;
            }

            DisplayBuild(null);
            this.logFilePath = filePath;
            SettingsService.AddRecentLogFile(filePath);
            UpdateRecentItemsMenu();
            Title = DefaultTitle + " - " + filePath;

            var progress = new BuildProgress();

            progress.ProgressText = "Opening " + filePath + "...";
            SetContent(progress);

            bool shouldAnalyze = true;

            Build build = await System.Threading.Tasks.Task.Run(() =>
            {
                try
                {
                    return(Serialization.Read(filePath));
                }
                catch (Exception ex)
                {
                    ex            = ExceptionHandler.Unwrap(ex);
                    shouldAnalyze = false;
                    return(GetErrorBuild(filePath, ex.ToString()));
                }
            });

            if (build == null)
            {
                build         = GetErrorBuild(filePath, "");
                shouldAnalyze = false;
            }

            if (shouldAnalyze)
            {
                progress.ProgressText = "Analyzing " + filePath + "...";
                await System.Threading.Tasks.Task.Run(() => BuildAnalyzer.AnalyzeBuild(build));
            }

            DisplayBuild(build);
        }