mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-13 19:19:23 +08:00
Add Wox.CrashReporter
This commit is contained in:
parent
f20b4d570e
commit
5be6511529
BIN
Doc/app.psd
BIN
Doc/app.psd
Binary file not shown.
BIN
Doc/app_error.png
Normal file
BIN
Doc/app_error.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
BIN
Doc/app_error.psd
Normal file
BIN
Doc/app_error.psd
Normal file
Binary file not shown.
@ -1,144 +1,144 @@
|
||||
<?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>{403B57F2-1856-4FC7-8A24-36AB346B763E}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Wox.Plugin.WebSearch</RootNamespace>
|
||||
<AssemblyName>Wox.Plugin.WebSearch</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\Plugins\Wox.Plugin.WebSearch\</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\Plugins\Wox.Plugin.WebSearch\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="log4net">
|
||||
<HintPath>..\..\packages\log4net.2.0.3\lib\net35-full\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.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="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SuggestionSources\Baidu.cs" />
|
||||
<Compile Include="SuggestionSources\Google.cs" />
|
||||
<Compile Include="SuggestionSources\ISuggestionSource.cs" />
|
||||
<Compile Include="SuggestionSources\SuggestionSourceFactory.cs" />
|
||||
<Compile Include="WebSearchesSetting.xaml.cs">
|
||||
<DependentUpon>WebSearchesSetting.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="WebSearchPlugin.cs" />
|
||||
<Compile Include="WebSearchSetting.xaml.cs">
|
||||
<DependentUpon>WebSearchSetting.xaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Languages\en.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Include="Languages\zh-cn.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Languages\zh-tw.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<Page Include="WebSearchesSetting.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="WebSearchSetting.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Service References\" />
|
||||
</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>
|
||||
<None Include="packages.config" />
|
||||
<None Include="plugin.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Images\web_search.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Images\websearch\google.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Images\websearch\wiki.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</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>
|
||||
-->
|
||||
<?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>{403B57F2-1856-4FC7-8A24-36AB346B763E}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Wox.Plugin.WebSearch</RootNamespace>
|
||||
<AssemblyName>Wox.Plugin.WebSearch</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\Plugins\Wox.Plugin.WebSearch\</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\Plugins\Wox.Plugin.WebSearch\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="log4net">
|
||||
<HintPath>..\..\packages\log4net.2.0.3\lib\net35-full\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.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="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SuggestionSources\Baidu.cs" />
|
||||
<Compile Include="SuggestionSources\Google.cs" />
|
||||
<Compile Include="SuggestionSources\ISuggestionSource.cs" />
|
||||
<Compile Include="SuggestionSources\SuggestionSourceFactory.cs" />
|
||||
<Compile Include="WebSearchesSetting.xaml.cs">
|
||||
<DependentUpon>WebSearchesSetting.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="WebSearchPlugin.cs" />
|
||||
<Compile Include="WebSearchSetting.xaml.cs">
|
||||
<DependentUpon>WebSearchSetting.xaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Languages\en.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Include="Languages\zh-cn.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Languages\zh-tw.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<Page Include="WebSearchesSetting.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="WebSearchSetting.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Service References\" />
|
||||
</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>
|
||||
<None Include="packages.config" />
|
||||
<None Include="plugin.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Images\web_search.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Images\websearch\google.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Images\websearch\wiki.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</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>
|
14
Wox.Core/APIServer.cs
Normal file
14
Wox.Core/APIServer.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Wox.Core
|
||||
{
|
||||
public static class APIServer
|
||||
{
|
||||
private static string BaseAPIURL = "http://api.getwox.com";
|
||||
public static string ErrorReportURL = BaseAPIURL + "/error/";
|
||||
public static string LastestReleaseURL = BaseAPIURL + "/release/latest/";
|
||||
}
|
||||
}
|
99
Wox.Core/Version/SemanticVersion.cs
Normal file
99
Wox.Core/Version/SemanticVersion.cs
Normal file
@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Wox.Core.Exception;
|
||||
|
||||
namespace Wox.Core.Version
|
||||
{
|
||||
public class SemanticVersion : IComparable
|
||||
{
|
||||
public int MAJOR { get; set; }
|
||||
public int MINOR { get; set; }
|
||||
public int PATCH { get; set; }
|
||||
|
||||
public SemanticVersion(System.Version version)
|
||||
{
|
||||
MAJOR = version.Major;
|
||||
MINOR = version.Minor;
|
||||
PATCH = version.Build;
|
||||
}
|
||||
|
||||
public SemanticVersion(int major, int minor, int patch)
|
||||
{
|
||||
MAJOR = major;
|
||||
MINOR = minor;
|
||||
PATCH = patch;
|
||||
}
|
||||
|
||||
public SemanticVersion(string version)
|
||||
{
|
||||
var strings = version.Split('.');
|
||||
if (strings.Length != 3)
|
||||
{
|
||||
throw new WoxException("Invalid semantic version");
|
||||
}
|
||||
MAJOR = int.Parse(strings[0]);
|
||||
MINOR = int.Parse(strings[1]);
|
||||
PATCH = int.Parse(strings[2]);
|
||||
}
|
||||
|
||||
public static bool operator >(SemanticVersion v1, SemanticVersion v2)
|
||||
{
|
||||
return v1.CompareTo(v2) > 0;
|
||||
}
|
||||
|
||||
public static bool operator <(SemanticVersion v1, SemanticVersion v2)
|
||||
{
|
||||
return v1.CompareTo(v2) < 0;
|
||||
}
|
||||
|
||||
public static bool operator ==(SemanticVersion v1, SemanticVersion v2)
|
||||
{
|
||||
if (ReferenceEquals(v1, null))
|
||||
{
|
||||
return ReferenceEquals(v2, null);
|
||||
}
|
||||
if (ReferenceEquals(v2, null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return v1.Equals(v2);
|
||||
}
|
||||
|
||||
public static bool operator !=(SemanticVersion v1, SemanticVersion v2)
|
||||
{
|
||||
return !(v1 == v2);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0}.{1}.{2}", MAJOR, MINOR, PATCH);
|
||||
}
|
||||
|
||||
public override bool Equals(object version)
|
||||
{
|
||||
var v2 = (SemanticVersion)version;
|
||||
return MAJOR == v2.MAJOR && MINOR == v2.MINOR && PATCH == v2.PATCH;
|
||||
}
|
||||
|
||||
public int CompareTo(object version)
|
||||
{
|
||||
var v2 = (SemanticVersion)version;
|
||||
if (MAJOR == v2.MAJOR)
|
||||
{
|
||||
if (MINOR == v2.MINOR)
|
||||
{
|
||||
if (PATCH == v2.PATCH)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return PATCH - v2.PATCH;
|
||||
}
|
||||
return MINOR - v2.MINOR;
|
||||
}
|
||||
return MAJOR - v2.MAJOR;
|
||||
}
|
||||
}
|
||||
}
|
36
Wox.Core/Version/VersionManager.cs
Normal file
36
Wox.Core/Version/VersionManager.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace Wox.Core.Version
|
||||
{
|
||||
public class VersionManager
|
||||
{
|
||||
private static VersionManager versionManager;
|
||||
private static SemanticVersion currentVersion;
|
||||
|
||||
public static VersionManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (versionManager == null)
|
||||
{
|
||||
versionManager = new VersionManager();
|
||||
}
|
||||
return versionManager;
|
||||
}
|
||||
}
|
||||
|
||||
private VersionManager() { }
|
||||
|
||||
public SemanticVersion CurrentVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
if (currentVersion == null)
|
||||
{
|
||||
currentVersion = new SemanticVersion(Assembly.GetExecutingAssembly().GetName().Version);
|
||||
}
|
||||
return currentVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -53,6 +53,7 @@
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="APIServer.cs" />
|
||||
<Compile Include="Exception\ExceptionFormatter.cs" />
|
||||
<Compile Include="Exception\WoxCritialException.cs" />
|
||||
<Compile Include="Exception\WoxException.cs" />
|
||||
@ -89,6 +90,8 @@
|
||||
<Compile Include="UserSettings\PluginHotkey.cs" />
|
||||
<Compile Include="UserSettings\UserSettingStorage.cs" />
|
||||
<Compile Include="UserSettings\WebSearch.cs" />
|
||||
<Compile Include="Version\SemanticVersion.cs" />
|
||||
<Compile Include="Version\VersionManager.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Plugin\README.md" />
|
||||
|
25
Wox.CrashReporter/CrashReporter.cs
Normal file
25
Wox.CrashReporter/CrashReporter.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
BIN
Wox.CrashReporter/Images/app_error.png
Normal file
BIN
Wox.CrashReporter/Images/app_error.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
BIN
Wox.CrashReporter/Images/crash_go.png
Normal file
BIN
Wox.CrashReporter/Images/crash_go.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
Wox.CrashReporter/Images/crash_stop.png
Normal file
BIN
Wox.CrashReporter/Images/crash_stop.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
Wox.CrashReporter/Images/crash_warning.png
Normal file
BIN
Wox.CrashReporter/Images/crash_warning.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
36
Wox.CrashReporter/Properties/AssemblyInfo.cs
Normal file
36
Wox.CrashReporter/Properties/AssemblyInfo.cs
Normal 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")]
|
78
Wox.CrashReporter/ReportWindow.xaml
Normal file
78
Wox.CrashReporter/ReportWindow.xaml
Normal 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>
|
62
Wox.CrashReporter/ReportWindow.xaml.cs
Normal file
62
Wox.CrashReporter/ReportWindow.xaml.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
112
Wox.CrashReporter/Wox.CrashReporter.csproj
Normal file
112
Wox.CrashReporter/Wox.CrashReporter.csproj
Normal 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>
|
4
Wox.CrashReporter/packages.config
Normal file
4
Wox.CrashReporter/packages.config
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="log4net" version="2.0.3" targetFramework="net35" />
|
||||
</packages>
|
@ -53,6 +53,60 @@ namespace Wox.Infrastructure.Http
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log.Error(e);
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public static string Post(string url, string jsonData, IHttpProxy proxy)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url)) return string.Empty;
|
||||
|
||||
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
|
||||
request.Method = "POST";
|
||||
request.ContentType = "text/json";
|
||||
request.Timeout = 10 * 1000;
|
||||
if (proxy != null && proxy.Enabled && !string.IsNullOrEmpty(proxy.Server))
|
||||
{
|
||||
if (string.IsNullOrEmpty(proxy.UserName) || string.IsNullOrEmpty(proxy.Password))
|
||||
{
|
||||
request.Proxy = new WebProxy(proxy.Server, proxy.Port);
|
||||
}
|
||||
else
|
||||
{
|
||||
request.Proxy = new WebProxy(proxy.Server, proxy.Port)
|
||||
{
|
||||
Credentials = new NetworkCredential(proxy.UserName, proxy.Password)
|
||||
};
|
||||
}
|
||||
}
|
||||
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
|
||||
{
|
||||
streamWriter.Write(jsonData);
|
||||
streamWriter.Flush();
|
||||
streamWriter.Close();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
|
||||
if (response != null)
|
||||
{
|
||||
Stream stream = response.GetResponseStream();
|
||||
if (stream != null)
|
||||
{
|
||||
using (StreamReader reader = new StreamReader(stream, Encoding.GetEncoding("UTF-8")))
|
||||
{
|
||||
return reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log.Error(e);
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,11 @@ namespace Wox.Infrastructure.Logger
|
||||
fileLogger.Error(msg);
|
||||
}
|
||||
|
||||
public static void Error(Exception e)
|
||||
{
|
||||
fileLogger.Error(e.Message + "\r\n" + e.StackTrace);
|
||||
}
|
||||
|
||||
public static void Debug(string msg)
|
||||
{
|
||||
fileLogger.Debug(msg);
|
||||
|
27
Wox.Test/SemanticVersionTest.cs
Normal file
27
Wox.Test/SemanticVersionTest.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
using Wox.Core.Version;
|
||||
|
||||
namespace Wox.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class SemanticVersionTest
|
||||
{
|
||||
[Test]
|
||||
public void CompareTest()
|
||||
{
|
||||
SemanticVersion v1 = new SemanticVersion(1, 1, 0);
|
||||
SemanticVersion v2 = new SemanticVersion(1, 2, 0);
|
||||
SemanticVersion v3 = new SemanticVersion(1, 1, 0);
|
||||
SemanticVersion v4 = new SemanticVersion("1.1.0");
|
||||
Assert.IsTrue(v1 < v2);
|
||||
Assert.IsTrue(v2 > v1);
|
||||
Assert.IsTrue(v1 == v3);
|
||||
Assert.IsTrue(v1.Equals(v3));
|
||||
Assert.IsTrue(v1 == v4);
|
||||
}
|
||||
}
|
||||
}
|
@ -50,6 +50,7 @@
|
||||
<Compile Include="Plugins\PluginInitTest.cs" />
|
||||
<Compile Include="QueryTest.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SemanticVersionTest.cs" />
|
||||
<Compile Include="UrlPluginTest.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
8
Wox.sln
8
Wox.sln
@ -1,7 +1,7 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.21005.1
|
||||
VisualStudioVersion = 12.0.30723.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Test", "Wox.Test\Wox.Test.csproj", "{FF742965-9A80-41A5-B042-D6C7D3A21708}"
|
||||
EndProject
|
||||
@ -37,6 +37,8 @@ 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
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -107,6 +109,10 @@ Global
|
||||
{F35190AA-4758-4D9E-A193-E3BDF6AD3567}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F35190AA-4758-4D9E-A193-E3BDF6AD3567}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F35190AA-4758-4D9E-A193-E3BDF6AD3567}.Release|Any CPU.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}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2FEB2298-7653-4009-B1EA-FFFB1A768BCC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -3,9 +3,6 @@
|
||||
<configSections>
|
||||
<section name="log4net" type="System.Configuration.IgnoreSectionHandler"/>
|
||||
</configSections>
|
||||
<appSettings>
|
||||
<add key="version" value="1.1.1"/>
|
||||
</appSettings>
|
||||
<log4net>
|
||||
<appender name="LogFileAppender" type="log4net.Appender.FileAppender">
|
||||
<file type="log4net.Util.PatternString">
|
||||
@ -36,4 +33,4 @@
|
||||
<!--http://stackoverflow.com/questions/186854/how-to-prevent-an-exception-in-a-background-thread-from-terminating-an-applicati-->
|
||||
<legacyUnhandledExceptionPolicy enabled="1" />
|
||||
</runtime>
|
||||
</configuration>
|
||||
</configuration>
|
@ -5,7 +5,6 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using Wox.CommandArgs;
|
||||
using Wox.Helper;
|
||||
using Wox.Helper.ErrorReporting;
|
||||
using Application = System.Windows.Application;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
using StartupEventArgs = System.Windows.StartupEventArgs;
|
||||
|
35
Wox/Helper/ErrorReporting.cs
Normal file
35
Wox/Helper/ErrorReporting.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Threading;
|
||||
using Wox.Core.Exception;
|
||||
using Wox.Infrastructure.Logger;
|
||||
|
||||
namespace Wox.Helper
|
||||
{
|
||||
public static class ErrorReporting
|
||||
{
|
||||
private static void Report(Exception e)
|
||||
{
|
||||
//if (Debugger.IsAttached) return;
|
||||
Log.Error(ExceptionFormatter.FormatExcpetion(e));
|
||||
new CrashReporter.CrashReporter(e).Show();
|
||||
}
|
||||
|
||||
public static void UnhandledExceptionHandle(object sender, UnhandledExceptionEventArgs e)
|
||||
{
|
||||
Report((Exception)e.ExceptionObject);
|
||||
}
|
||||
|
||||
public static void DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
||||
{
|
||||
Report(e.Exception);
|
||||
}
|
||||
|
||||
public static void ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
|
||||
{
|
||||
Report(e.Exception);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Threading;
|
||||
using System.Xml;
|
||||
using Microsoft.Win32;
|
||||
using Wox.Core.Exception;
|
||||
using Wox.Infrastructure.Logger;
|
||||
|
||||
namespace Wox.Helper.ErrorReporting
|
||||
{
|
||||
public static class ErrorReporting
|
||||
{
|
||||
public static void UnhandledExceptionHandle(object sender, System.UnhandledExceptionEventArgs e)
|
||||
{
|
||||
if (Debugger.IsAttached) return;
|
||||
|
||||
string error = ExceptionFormatter.FormatExcpetion(e.ExceptionObject);
|
||||
//e.IsTerminating is always true in most times, so try to avoid use this property
|
||||
//http://stackoverflow.com/questions/10982443/what-causes-the-unhandledexceptioneventargs-isterminating-flag-to-be-true-or-fal
|
||||
Log.Error(error);
|
||||
TryShowErrorMessageBox(error, e.ExceptionObject);
|
||||
}
|
||||
|
||||
public static void DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
||||
{
|
||||
if (Debugger.IsAttached) return;
|
||||
|
||||
e.Handled = true;
|
||||
string error = ExceptionFormatter.FormatExcpetion(e.Exception);
|
||||
|
||||
Log.Error(error);
|
||||
TryShowErrorMessageBox(error, e.Exception);
|
||||
}
|
||||
|
||||
public static void ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
|
||||
{
|
||||
if (Debugger.IsAttached) return;
|
||||
|
||||
string error = ExceptionFormatter.FormatExcpetion(e.Exception);
|
||||
|
||||
Log.Fatal(error);
|
||||
TryShowErrorMessageBox(error, e.Exception);
|
||||
}
|
||||
|
||||
public static bool TryShowErrorMessageBox(string error, object exceptionObject)
|
||||
{
|
||||
var title = "Wox - Unhandled Exception";
|
||||
|
||||
try
|
||||
{
|
||||
ShowWPFDialog(error, title, exceptionObject);
|
||||
return true;
|
||||
}
|
||||
catch { }
|
||||
|
||||
error = "Wox has occured an error that can't be handled. " + Environment.NewLine + Environment.NewLine + error;
|
||||
|
||||
try
|
||||
{
|
||||
ShowWPFMessageBox(error, title);
|
||||
return true;
|
||||
}
|
||||
catch { }
|
||||
|
||||
try
|
||||
{
|
||||
ShowWindowsFormsMessageBox(error, title);
|
||||
return true;
|
||||
}
|
||||
catch { }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void ShowWPFDialog(string error, string title, object exceptionObject)
|
||||
{
|
||||
var dialog = new WPFErrorReportingDialog(error, title, exceptionObject);
|
||||
dialog.ShowDialog();
|
||||
}
|
||||
|
||||
private static void ShowWPFMessageBox(string error, string title)
|
||||
{
|
||||
System.Windows.MessageBox.Show(error, title, MessageBoxButton.OK, MessageBoxImage.Error,
|
||||
MessageBoxResult.OK, System.Windows.MessageBoxOptions.None);
|
||||
}
|
||||
|
||||
private static void ShowWindowsFormsMessageBox(string error, string title)
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show(error, title, MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
<Window x:Class="Wox.Helper.ErrorReporting.WPFErrorReportingDialog"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="ErrorReportingDialog" WindowStartupLocation="CenterScreen">
|
||||
<DockPanel>
|
||||
<TextBlock Margin="10" TextWrapping="Wrap" DockPanel.Dock="Top" Text="Wox has occured an error that can't be handled. "/>
|
||||
<TextBox x:Name="tbErrorReport" IsReadOnly="True" IsUndoEnabled="False" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" />
|
||||
</DockPanel>
|
||||
</Window>
|
@ -1,32 +0,0 @@
|
||||
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.Shapes;
|
||||
|
||||
namespace Wox.Helper.ErrorReporting
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for WPFErrorReportingDialog.xaml
|
||||
/// </summary>
|
||||
public partial class WPFErrorReportingDialog : Window
|
||||
{
|
||||
private object exceptionObject;
|
||||
|
||||
public WPFErrorReportingDialog(string error, string title, object exceptionObject)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.tbErrorReport.Text = error;
|
||||
this.Title = title;
|
||||
this.exceptionObject = exceptionObject;
|
||||
}
|
||||
}
|
||||
}
|
17
Wox/Helper/WoxLog4netPathConverter.cs
Normal file
17
Wox/Helper/WoxLog4netPathConverter.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Wox.Helper
|
||||
{
|
||||
public class WoxLog4netPathConverter : log4net.Util.PatternConverter
|
||||
{
|
||||
protected override void Convert(TextWriter writer, object state)
|
||||
{
|
||||
string userProfilePath = Environment.GetEnvironmentVariable("USERPROFILE");
|
||||
writer.Write(Path.Combine(userProfilePath, ".Wox"));
|
||||
}
|
||||
}
|
||||
}
|
@ -12,19 +12,17 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using Wox.Core.Version;
|
||||
|
||||
namespace Wox.Update
|
||||
{
|
||||
/// <summary>
|
||||
/// NewVersionWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class NewVersionWindow : Window
|
||||
{
|
||||
public NewVersionWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
tbCurrentVersion.Text = ConfigurationManager.AppSettings["version"];
|
||||
tbCurrentVersion.Text = VersionManager.Instance.CurrentVersion.ToString();
|
||||
Release newRelease = new UpdateChecker().CheckUpgrade();
|
||||
if (newRelease == null)
|
||||
{
|
||||
|
@ -6,7 +6,9 @@ using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using Wox.Core;
|
||||
using Wox.Core.UserSettings;
|
||||
using Wox.Core.Version;
|
||||
using Wox.Helper;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Infrastructure.Http;
|
||||
@ -15,7 +17,6 @@ namespace Wox.Update
|
||||
{
|
||||
public class UpdateChecker
|
||||
{
|
||||
private const string updateURL = "https://api.getwox.com/release/latest/";
|
||||
private static Release newRelease;
|
||||
private static bool checkedUpdate = false;
|
||||
|
||||
@ -27,7 +28,7 @@ namespace Wox.Update
|
||||
public Release CheckUpgrade(bool forceCheck = false)
|
||||
{
|
||||
if (checkedUpdate && !forceCheck) return newRelease;
|
||||
string json = HttpRequest.Get(updateURL,HttpProxy.Instance);
|
||||
string json = HttpRequest.Get(APIServer.LastestReleaseURL,HttpProxy.Instance);
|
||||
if (string.IsNullOrEmpty(json)) return null;
|
||||
|
||||
try
|
||||
@ -48,46 +49,7 @@ namespace Wox.Update
|
||||
{
|
||||
if (release == null) return false;
|
||||
|
||||
string currentVersion = ConfigurationManager.AppSettings["version"];
|
||||
return CompareVersion(release.version, currentVersion) > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// if version1 > version2 return 1
|
||||
/// else -1
|
||||
/// </summary>
|
||||
/// <param name="version1"></param>
|
||||
/// <param name="version2"></param>
|
||||
/// <returns></returns>
|
||||
private int CompareVersion(string version1, string version2)
|
||||
{
|
||||
if (version1 == version2) return 0;
|
||||
if (string.IsNullOrEmpty(version1) || string.IsNullOrEmpty(version2)) return 0;
|
||||
|
||||
//semantic version, e.g. 1.1.0
|
||||
List<int> version1List = version1.Split('.').Select(int.Parse).ToList();
|
||||
List<int> version2List = version2.Split('.').Select(int.Parse).ToList();
|
||||
|
||||
if (version1List[0] > version2List[0])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (version1List[0] == version2List[0])
|
||||
{
|
||||
if (version1List[1] > version2List[1])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (version1List[1] == version2List[1])
|
||||
{
|
||||
if (version1List[2] > version2List[2])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
return new SemanticVersion(release.version) > VersionManager.Instance.CurrentVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -132,10 +132,7 @@
|
||||
<Compile Include="CommandArgs\QueryCommandArg.cs" />
|
||||
<Compile Include="CommandArgs\ReloadPluginCommandArg.cs" />
|
||||
<Compile Include="Helper\DataWebRequestFactory.cs" />
|
||||
<Compile Include="Helper\ErrorReporting\ErrorReporting.cs" />
|
||||
<Compile Include="Helper\ErrorReporting\WPFErrorReportingDialog.xaml.cs">
|
||||
<DependentUpon>WPFErrorReportingDialog.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Helper\ErrorReporting.cs" />
|
||||
<Compile Include="ImageLoader\ImageLoader.cs" />
|
||||
<Compile Include="Helper\SingleInstance.cs" />
|
||||
<Compile Include="Helper\SyntaxSugars.cs" />
|
||||
@ -164,10 +161,6 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Helper\ErrorReporting\WPFErrorReportingDialog.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="CustomQueryHotkeySetting.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@ -278,6 +271,10 @@
|
||||
<Project>{B749F0DB-8E75-47DB-9E5E-265D16D0C0D2}</Project>
|
||||
<Name>Wox.Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Wox.CrashReporter\Wox.CrashReporter.csproj">
|
||||
<Project>{2FEB2298-7653-4009-B1EA-FFFB1A768BCC}</Project>
|
||||
<Name>Wox.CrashReporter</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Wox.Infrastructure\Wox.Infrastructure.csproj">
|
||||
<Project>{4fd29318-a8ab-4d8f-aa47-60bc241b8da3}</Project>
|
||||
<Name>Wox.Infrastructure</Name>
|
||||
|
Loading…
Reference in New Issue
Block a user