Add Wox.CrashReporter

This commit is contained in:
qianlifeng
2015-01-11 21:52:30 +08:00
parent f20b4d570e
commit 5be6511529
33 changed files with 770 additions and 342 deletions

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Wox.CrashReporter
{
public class CrashReporter
{
private Exception exception;
public CrashReporter(Exception e)
{
exception = e;
}
public void Show()
{
if (exception == null) return;
ReportWindow reportWindow = new ReportWindow(exception);
reportWindow.Show();
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Wox.CrashReporter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Wox.CrashReporter")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("0ea3743c-2c0d-4b13-b9ce-e5e1f85aea23")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,78 @@
<Window x:Class="Wox.CrashReporter.ReportWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
WindowStartupLocation="CenterScreen"
Icon="Images/app_error.png"
Topmost="True"
ResizeMode="NoResize"
Width="600"
Height="450"
d:DesignHeight="300" d:DesignWidth="600" x:ClassModifier="internal">
<StackPanel>
<TabControl >
<TabItem Header="General">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition Width="40"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="80"></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition Height="200"></RowDefinition>
</Grid.RowDefinitions>
<Image Source="Images/crash_warning.png" Width="64"></Image>
<RichTextBox Grid.Row="0" Grid.ColumnSpan="3" Grid.Column="1" IsReadOnly="True" x:Name="tbSummary"></RichTextBox>
<TextBlock Padding="0 5 0 0" Grid.Row="1" Grid.Column="0" Text="Version"></TextBlock>
<TextBlock Padding="0 5 0 0" Grid.Row="1" Grid.Column="1" Text="Version" x:Name="tbVersion"></TextBlock>
<TextBlock Padding="0 5 0 0" Grid.Row="1" Grid.Column="2" Text="Time"></TextBlock>
<TextBlock Padding="0 5 0 0" Grid.Row="1" Grid.Column="3" Text="10201211-21-21" x:Name="tbDatetime"></TextBlock>
<TextBlock Padding="0 5 0 0" Grid.ColumnSpan="4" Grid.Row="2" Grid.Column="0" Text="Please tell us how application crashed so we can fix it"></TextBlock>
<RichTextBox Grid.Row="3" Grid.ColumnSpan="4" Grid.Column="0" Background="#FFFFE1"></RichTextBox>
</Grid>
</TabItem>
<TabItem Header="Exceptions">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="37*"/>
<ColumnDefinition Width="547*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Exception Type" Padding="5" Grid.ColumnSpan="2"></TextBlock>
<TextBox IsReadOnly="True" Grid.Row="1" Padding="5" x:Name="tbType" Grid.ColumnSpan="2"></TextBox>
<TextBlock Grid.Row="2" Text="Source" Padding="5" Grid.ColumnSpan="2"></TextBlock>
<TextBox IsReadOnly="True" Grid.Row="3" Padding="5" x:Name="tbSource" Grid.ColumnSpan="2"></TextBox>
<TextBlock Grid.Row="4" Text="Stack Trace" Padding="5" Grid.ColumnSpan="2"></TextBlock>
<RichTextBox Grid.Row="5" x:Name="tbStackTrace" Height="185" Grid.ColumnSpan="2" Margin="0,0,0,-0.001"></RichTextBox>
</Grid>
</TabItem>
</TabControl>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button x:Name="btnSend" Padding="8 3" Margin="8" Click="btnSend_Click">
<StackPanel Orientation="Horizontal">
<Image Source="Images/crash_go.png" Margin="0 5 5 0"/>
<Label Padding="0" Margin="0 10 0 0" x:Name="tbSendReport">Send Report</Label>
</StackPanel>
</Button>
<Button x:Name="btnCancel" Padding="8 3" Margin="8" Click="btnCancel_Click">
<StackPanel Orientation="Horizontal">
<Image Source="Images/crash_stop.png" Margin="0 5 5 0"/>
<Label Padding="0" Margin="0 10 0 0">Cancel</Label>
</StackPanel>
</Button>
</StackPanel>
</StackPanel>
</Window>

View File

@@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Wox.Core;
using Wox.Core.Exception;
using Wox.Core.UI;
using Wox.Core.UserSettings;
using Wox.Core.Version;
using Wox.Infrastructure.Http;
namespace Wox.CrashReporter
{
internal partial class ReportWindow : IUIResource
{
private Exception exception;
public ReportWindow(Exception exception)
{
this.exception = exception;
InitializeComponent();
SetException(exception);
}
private void SetException(Exception exception)
{
tbSummary.AppendText(exception.Message);
tbVersion.Text = VersionManager.Instance.CurrentVersion.ToString();
tbDatetime.Text = DateTime.Now.ToString();
tbStackTrace.AppendText(exception.StackTrace);
tbSource.Text = exception.Source;
tbType.Text = exception.GetType().ToString();
}
public ResourceDictionary GetResourceDictionary()
{
return null;
}
private void btnSend_Click(object sender, RoutedEventArgs e)
{
tbSendReport.Content = "Sending";
btnSend.IsEnabled = false;
string error = string.Format("{{\"data\":{0}}}", ExceptionFormatter.FormatExcpetion(exception));
string response = HttpRequest.Post(APIServer.ErrorReportURL, error, HttpProxy.Instance);
}
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
Close();
}
}
}

View File

@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{2FEB2298-7653-4009-B1EA-FFFB1A768BCC}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Wox.CrashReporter</RootNamespace>
<AssemblyName>Wox.CrashReporter</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\Output\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\Output\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\log4net.2.0.3\lib\net35-full\log4net.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="CrashReporter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ReportWindow.xaml.cs">
<DependentUpon>ReportWindow.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Page Include="ReportWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Wox.Core\Wox.Core.csproj">
<Project>{B749F0DB-8E75-47DB-9E5E-265D16D0C0D2}</Project>
<Name>Wox.Core</Name>
</ProjectReference>
<ProjectReference Include="..\Wox.Infrastructure\Wox.Infrastructure.csproj">
<Project>{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}</Project>
<Name>Wox.Infrastructure</Name>
</ProjectReference>
<ProjectReference Include="..\Wox.Plugin\Wox.Plugin.csproj">
<Project>{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}</Project>
<Name>Wox.Plugin</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Resource Include="Images\crash_warning.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\crash_go.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
</ItemGroup>
<ItemGroup>
<Resource Include="Images\crash_stop.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
</ItemGroup>
<ItemGroup>
<Resource Include="Images\app_error.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.3" targetFramework="net35" />
</packages>