From b9145aaf47a55883de26fafaea44b096b68bc358 Mon Sep 17 00:00:00 2001 From: happlebao Date: Fri, 20 May 2016 21:16:25 +0100 Subject: [PATCH] Refactoring error report 1. fix #627 2. fix #646 3. remove exceptionless --- Wox.Infrastructure/Logger/Log.cs | 7 +-- Wox.Infrastructure/Wox.cs | 1 + Wox.sln | 14 ------ Wox/CrashReporter.cs | 2 +- Wox/Helper/ErrorReporting.cs | 2 +- Wox/Properties/AssemblyInfo.cs | 4 +- Wox/ReportWindow.xaml | 74 ++++------------------------- Wox/ReportWindow.xaml.cs | 81 +++++++++++++++++--------------- Wox/Wox.csproj | 22 ++++----- Wox/app.manifest | 74 +++++++++++++++++++++++++++++ Wox/packages.config | 1 - 11 files changed, 143 insertions(+), 139 deletions(-) create mode 100644 Wox/app.manifest diff --git a/Wox.Infrastructure/Logger/Log.cs b/Wox.Infrastructure/Logger/Log.cs index 3cbced217..9faff9c49 100644 --- a/Wox.Infrastructure/Logger/Log.cs +++ b/Wox.Infrastructure/Logger/Log.cs @@ -9,10 +9,11 @@ namespace Wox.Infrastructure.Logger { public static class Log { + public const string DirectoryName = "Logs"; + static Log() { - var directoryName = "Logs"; - var path = Path.Combine(Constant.DataDirectory, directoryName, Constant.Version); + var path = Path.Combine(Constant.DataDirectory, DirectoryName, Constant.Version); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); @@ -21,7 +22,7 @@ static Log() var configuration = new LoggingConfiguration(); var target = new FileTarget(); configuration.AddTarget("file", target); - target.FileName = "${specialfolder:folder=ApplicationData}/" + Constant.Wox + "/" + directoryName + "/" + Constant.Version + "/${shortdate}.log"; + target.FileName = "${specialfolder:folder=ApplicationData}/" + Constant.Wox + "/" + DirectoryName + "/" + Constant.Version + "/${shortdate}.log"; var rule = new LoggingRule("*", LogLevel.Info, target); configuration.LoggingRules.Add(rule); LogManager.Configuration = configuration; diff --git a/Wox.Infrastructure/Wox.cs b/Wox.Infrastructure/Wox.cs index 80a6c27b8..796ed1e52 100644 --- a/Wox.Infrastructure/Wox.cs +++ b/Wox.Infrastructure/Wox.cs @@ -19,6 +19,7 @@ public static class Constant public static readonly string PreinstalledDirectory = Path.Combine(ProgramDirectory, Plugins); public static readonly string SettingsPath = Path.Combine(DataDirectory, Settings); public const string Github = "https://github.com/Wox-launcher/Wox"; + public const string Issue = "https://github.com/Wox-launcher/Wox/issues/new"; public static readonly string Version = FileVersionInfo.GetVersionInfo(Assembly.Location).ProductVersion; } } diff --git a/Wox.sln b/Wox.sln index 99ac6946b..0b6934fd1 100644 --- a/Wox.sln +++ b/Wox.sln @@ -52,8 +52,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Url", "Plugins\W EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Color", "Plugins\Wox.Plugin.Color\Wox.Plugin.Color.csproj", "{F35190AA-4758-4D9E-A193-E3BDF6AD3567}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.CrashReporter", "Wox.CrashReporter\Wox.CrashReporter.csproj", "{2FEB2298-7653-4009-B1EA-FFFB1A768BCC}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Everything", "Plugins\Wox.Plugin.Everything\Wox.Plugin.Everything.csproj", "{230AE83F-E92E-4E69-8355-426B305DA9C0}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{FFD651C7-0546-441F-BC8C-D4EE8FD01EA7}" @@ -262,18 +260,6 @@ Global {F35190AA-4758-4D9E-A193-E3BDF6AD3567}.Release|x64.Build.0 = Release|Any CPU {F35190AA-4758-4D9E-A193-E3BDF6AD3567}.Release|x86.ActiveCfg = Release|Any CPU {F35190AA-4758-4D9E-A193-E3BDF6AD3567}.Release|x86.Build.0 = Release|Any CPU - {2FEB2298-7653-4009-B1EA-FFFB1A768BCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2FEB2298-7653-4009-B1EA-FFFB1A768BCC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2FEB2298-7653-4009-B1EA-FFFB1A768BCC}.Debug|x64.ActiveCfg = Debug|Any CPU - {2FEB2298-7653-4009-B1EA-FFFB1A768BCC}.Debug|x64.Build.0 = Debug|Any CPU - {2FEB2298-7653-4009-B1EA-FFFB1A768BCC}.Debug|x86.ActiveCfg = Debug|Any CPU - {2FEB2298-7653-4009-B1EA-FFFB1A768BCC}.Debug|x86.Build.0 = Debug|Any CPU - {2FEB2298-7653-4009-B1EA-FFFB1A768BCC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2FEB2298-7653-4009-B1EA-FFFB1A768BCC}.Release|Any CPU.Build.0 = Release|Any CPU - {2FEB2298-7653-4009-B1EA-FFFB1A768BCC}.Release|x64.ActiveCfg = Release|Any CPU - {2FEB2298-7653-4009-B1EA-FFFB1A768BCC}.Release|x64.Build.0 = Release|Any CPU - {2FEB2298-7653-4009-B1EA-FFFB1A768BCC}.Release|x86.ActiveCfg = Release|Any CPU - {2FEB2298-7653-4009-B1EA-FFFB1A768BCC}.Release|x86.Build.0 = Release|Any CPU {230AE83F-E92E-4E69-8355-426B305DA9C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {230AE83F-E92E-4E69-8355-426B305DA9C0}.Debug|Any CPU.Build.0 = Debug|Any CPU {230AE83F-E92E-4E69-8355-426B305DA9C0}.Debug|x64.ActiveCfg = Debug|Any CPU diff --git a/Wox/CrashReporter.cs b/Wox/CrashReporter.cs index ff06c57e3..793cbed6d 100644 --- a/Wox/CrashReporter.cs +++ b/Wox/CrashReporter.cs @@ -1,6 +1,6 @@ using System; -namespace Wox.CrashReporter +namespace Wox { public class CrashReporter { diff --git a/Wox/Helper/ErrorReporting.cs b/Wox/Helper/ErrorReporting.cs index 1bc9fb1ff..56153af74 100644 --- a/Wox/Helper/ErrorReporting.cs +++ b/Wox/Helper/ErrorReporting.cs @@ -11,7 +11,7 @@ public static class ErrorReporting public static void Report(Exception e) { Log.Fatal(e); - new CrashReporter.CrashReporter(e).Show(); + new CrashReporter(e).Show(); } public static void UnhandledExceptionHandle(object sender, UnhandledExceptionEventArgs e) diff --git a/Wox/Properties/AssemblyInfo.cs b/Wox/Properties/AssemblyInfo.cs index 68eaa6796..3ce943af6 100644 --- a/Wox/Properties/AssemblyInfo.cs +++ b/Wox/Properties/AssemblyInfo.cs @@ -1,10 +1,8 @@ using System.Reflection; using System.Windows; -using Exceptionless.Configuration; [assembly: AssemblyTitle("Wox")] [assembly: ThemeInfo( ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly -)] -[assembly: Exceptionless("e0b256fbe9384498ba89aae2a6b7f8ab")] \ No newline at end of file +)] \ No newline at end of file diff --git a/Wox/ReportWindow.xaml b/Wox/ReportWindow.xaml index c9f7a92ff..fd53b0182 100644 --- a/Wox/ReportWindow.xaml +++ b/Wox/ReportWindow.xaml @@ -1,4 +1,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + diff --git a/Wox/ReportWindow.xaml.cs b/Wox/ReportWindow.xaml.cs index bcfddc5f3..6a365e46c 100644 --- a/Wox/ReportWindow.xaml.cs +++ b/Wox/ReportWindow.xaml.cs @@ -1,63 +1,66 @@ using System; -using System.Threading; -using System.Threading.Tasks; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Text; +using System.Linq; using System.Windows; using System.Windows.Documents; -using Exceptionless; -using Wox.Core.Resource; using Wox.Infrastructure; +using Wox.Infrastructure.Logger; -namespace Wox.CrashReporter +namespace Wox { internal partial class ReportWindow { - private Exception exception; - public ReportWindow(Exception exception) { - this.exception = exception; InitializeComponent(); + ErrorTextbox.Document.Blocks.FirstBlock.Margin = new Thickness(0); SetException(exception); } private void SetException(Exception exception) { - tbSummary.AppendText(exception.Message); - tbVersion.Text = Infrastructure.Constant.Version; - tbDatetime.Text = DateTime.Now.ToString(); - tbStackTrace.AppendText(exception.StackTrace); - tbSource.Text = exception.Source; - tbType.Text = exception.GetType().ToString(); - } + string path = Path.Combine(Constant.DataDirectory, Log.DirectoryName, Constant.Version); + var directory = new DirectoryInfo(path); + var log = directory.GetFiles().OrderByDescending(f => f.LastWriteTime).First(); - private void btnSend_Click(object sender, RoutedEventArgs e) - { - string sendingMsg = InternationalizationManager.Instance.GetTranslation("reportWindow_sending"); - tbSendReport.Content = sendingMsg; - btnSend.IsEnabled = false; - SendReport(); - } + var paragraph = Hyperlink("Please open new issue in: " , Constant.Issue); + paragraph.Inlines.Add($"1. upload log file: {log.FullName}\n"); + paragraph.Inlines.Add($"2. copy below exception message"); + ErrorTextbox.Document.Blocks.Add(paragraph); - private void SendReport() - { - Hide(); - Task.Run(() => - { - string reproduceSteps = new TextRange(tbReproduceSteps.Document.ContentStart, tbReproduceSteps.Document.ContentEnd).Text; - exception.ToExceptionless() - .SetUserDescription(reproduceSteps) - .Submit(); - ExceptionlessClient.Current.ProcessQueue(); - Dispatcher.Invoke(() => - { - Close(); - }); - }); + StringBuilder content = new StringBuilder(); + content.AppendLine($"Wox version: {Constant.Version}"); + content.AppendLine($"OS Version: {Environment.OSVersion.VersionString}"); + content.AppendLine($"Date: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}"); + content.AppendLine("Exception:"); + content.AppendLine(exception.Source); + content.AppendLine(exception.GetType().ToString()); + content.AppendLine(exception.Message); + content.AppendLine(exception.StackTrace); + paragraph = new Paragraph(); + paragraph.Inlines.Add(content.ToString()); + ErrorTextbox.Document.Blocks.Add(paragraph); } - private void btnCancel_Click(object sender, RoutedEventArgs e) + private Paragraph Hyperlink(string textBeforeUrl, string url) { - Close(); + var paragraph = new Paragraph(); + paragraph.Margin = new Thickness(0); + + var link = new Hyperlink {IsEnabled = true}; + link.Inlines.Add(url); + link.NavigateUri = new Uri(url); + link.RequestNavigate += (s, e) => Process.Start(e.Uri.ToString()); + link.Click += (s, e) => Process.Start(url); + + paragraph.Inlines.Add(textBeforeUrl); + paragraph.Inlines.Add(link); + paragraph.Inlines.Add("\n"); + + return paragraph; } } } diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index 289ae6df8..46082766a 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -59,6 +59,9 @@ Wox.App + + app.manifest + ..\packages\DeltaCompressionDotNet.1.0.0\lib\net45\DeltaCompressionDotNet.dll @@ -72,14 +75,6 @@ ..\packages\DeltaCompressionDotNet.1.0.0\lib\net45\DeltaCompressionDotNet.PatchApi.dll True - - ..\packages\Exceptionless.1.5.2121\lib\net45\Exceptionless.dll - True - - - ..\packages\Exceptionless.1.5.2121\lib\net45\Exceptionless.Models.dll - True - ..\packages\squirrel.windows.1.4.0\lib\Net45\ICSharpCode.SharpZipLib.dll True @@ -157,9 +152,11 @@ Properties\SolutionAssemblyInfo.cs + + ResultListBox.xaml @@ -209,6 +206,7 @@ MSBuild:Compile + MSBuild:Compile Designer @@ -273,6 +271,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -352,10 +354,6 @@ {B749F0DB-8E75-47DB-9E5E-265D16D0C0D2} Wox.Core - - {2FEB2298-7653-4009-B1EA-FFFB1A768BCC} - Wox.CrashReporter - {4fd29318-a8ab-4d8f-aa47-60bc241b8da3} Wox.Infrastructure diff --git a/Wox/app.manifest b/Wox/app.manifest new file mode 100644 index 000000000..52d1c3932 --- /dev/null +++ b/Wox/app.manifest @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Wox/packages.config b/Wox/packages.config index d828900ca..9d8eda65a 100644 --- a/Wox/packages.config +++ b/Wox/packages.config @@ -1,7 +1,6 @@  -