Add activate statistics

This commit is contained in:
qianlifeng
2015-01-23 21:52:46 +08:00
parent 42d86fab8e
commit 4379145231
15 changed files with 83 additions and 56 deletions

View File

@@ -6,6 +6,7 @@ using Newtonsoft.Json;
using Wox.Infrastructure.Storage; using Wox.Infrastructure.Storage;
using Wox.Plugin; using Wox.Plugin;
using System.Drawing; using System.Drawing;
using System.Reflection;
namespace Wox.Core.UserSettings namespace Wox.Core.UserSettings
{ {
@@ -14,6 +15,10 @@ namespace Wox.Core.UserSettings
[JsonProperty] [JsonProperty]
public bool DontPromptUpdateMsg { get; set; } public bool DontPromptUpdateMsg { get; set; }
[JsonProperty]
public int ActivateTimes { get; set; }
[JsonProperty] [JsonProperty]
public bool EnableUpdateLog { get; set; } public bool EnableUpdateLog { get; set; }
@@ -140,15 +145,7 @@ namespace Wox.Core.UserSettings
protected override string ConfigFolder protected override string ConfigFolder
{ {
get get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); }
{
string userProfilePath = Environment.GetEnvironmentVariable("USERPROFILE");
if (userProfilePath == null)
{
throw new ArgumentException("Environment variable USERPROFILE is empty");
}
return Path.Combine(Path.Combine(userProfilePath, ".Wox"), "Config");
}
} }
protected override string ConfigName protected override string ConfigName
@@ -156,6 +153,15 @@ namespace Wox.Core.UserSettings
get { return "config"; } get { return "config"; }
} }
public void IncreaseActivateTimes()
{
ActivateTimes++;
if (ActivateTimes % 15 == 0)
{
Save();
}
}
protected override UserSettingStorage LoadDefault() protected override UserSettingStorage LoadDefault()
{ {
DontPromptUpdateMsg = false; DontPromptUpdateMsg = false;

View File

@@ -83,8 +83,8 @@
<Compile Include="Plugin\PluginInstaller.cs" /> <Compile Include="Plugin\PluginInstaller.cs" />
<Compile Include="Plugin\QueryDispatcher\IQueryDispatcher.cs" /> <Compile Include="Plugin\QueryDispatcher\IQueryDispatcher.cs" />
<Compile Include="Plugin\QueryDispatcher\QueryDispatcher.cs" /> <Compile Include="Plugin\QueryDispatcher\QueryDispatcher.cs" />
<Compile Include="Plugin\QueryDispatcher\UserPluginQueryDispatcher.cs" /> <Compile Include="Plugin\QueryDispatcher\RegularPluginQueryDispatcher.cs" />
<Compile Include="Plugin\QueryDispatcher\SystemPluginQueryDispatcher.cs" /> <Compile Include="Plugin\QueryDispatcher\WildcardPluginQueryDispatcher.cs" />
<Compile Include="Plugin\JsonRPCPlugin.cs" /> <Compile Include="Plugin\JsonRPCPlugin.cs" />
<Compile Include="Plugin\JsonRPCPluginLoader.cs" /> <Compile Include="Plugin\JsonRPCPluginLoader.cs" />
<Compile Include="Plugin\CSharpPluginLoader.cs" /> <Compile Include="Plugin\CSharpPluginLoader.cs" />

View File

@@ -6,6 +6,7 @@ using System.Reflection;
using System.Runtime.Serialization.Formatters; using System.Runtime.Serialization.Formatters;
using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Serialization.Formatters.Binary;
using System.Text; using System.Text;
using System.Threading;
using Wox.Infrastructure.Logger; using Wox.Infrastructure.Logger;
namespace Wox.Infrastructure.Storage namespace Wox.Infrastructure.Storage
@@ -18,6 +19,7 @@ namespace Wox.Infrastructure.Storage
[Serializable] [Serializable]
public abstract class BinaryStorage<T> : BaseStorage<T> where T : class, IStorage, new() public abstract class BinaryStorage<T> : BaseStorage<T> where T : class, IStorage, new()
{ {
private static object syncObject = new object();
protected override string FileSuffix protected override string FileSuffix
{ {
get { return ".dat"; } get { return ".dat"; }
@@ -87,25 +89,31 @@ namespace Wox.Infrastructure.Storage
protected override void SaveInternal() protected override void SaveInternal()
{ {
try ThreadPool.QueueUserWorkItem(o =>
{ {
FileStream fileStream = new FileStream(ConfigPath, FileMode.Create); lock (syncObject)
BinaryFormatter binaryFormatter = new BinaryFormatter
{ {
AssemblyFormat = FormatterAssemblyStyle.Simple try
}; {
binaryFormatter.Serialize(fileStream, serializedObject); FileStream fileStream = new FileStream(ConfigPath, FileMode.Create);
fileStream.Close(); BinaryFormatter binaryFormatter = new BinaryFormatter
} {
catch (Exception e) AssemblyFormat = FormatterAssemblyStyle.Simple
{ };
Log.Error(e.Message); binaryFormatter.Serialize(fileStream, serializedObject);
fileStream.Close();
}
catch (Exception e)
{
Log.Error(e);
#if (DEBUG) #if (DEBUG)
{ {
throw; throw;
} }
#endif #endif
} }
}
});
} }
} }
} }

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace Wox.Infrastructure.Storage namespace Wox.Infrastructure.Storage
@@ -12,6 +13,7 @@ namespace Wox.Infrastructure.Storage
/// </summary> /// </summary>
public abstract class JsonStrorage<T> : BaseStorage<T> where T : class, IStorage, new() public abstract class JsonStrorage<T> : BaseStorage<T> where T : class, IStorage, new()
{ {
private static object syncObject = new object();
protected override string FileSuffix protected override string FileSuffix
{ {
get { return ".json"; } get { return ".json"; }
@@ -39,8 +41,14 @@ namespace Wox.Infrastructure.Storage
protected override void SaveInternal() protected override void SaveInternal()
{ {
string json = JsonConvert.SerializeObject(serializedObject, Formatting.Indented); ThreadPool.QueueUserWorkItem(o =>
File.WriteAllText(ConfigPath, json); {
lock (syncObject)
{
string json = JsonConvert.SerializeObject(serializedObject, Formatting.Indented);
File.WriteAllText(ConfigPath, json);
}
});
} }
} }
} }

View File

@@ -6,15 +6,16 @@
ResizeMode="NoResize" ResizeMode="NoResize"
Loaded="ActionKeyword_OnLoaded" Loaded="ActionKeyword_OnLoaded"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"
Height="200" Width="674.766"> Height="200" Width="600">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition></RowDefinition> <RowDefinition></RowDefinition>
<RowDefinition></RowDefinition> <RowDefinition></RowDefinition>
<RowDefinition></RowDefinition> <RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="200"></ColumnDefinition> <ColumnDefinition Width="170"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition> <ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock Margin="10" FontSize="14" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Text="{DynamicResource oldActionKeyword}"></TextBlock> <TextBlock Margin="10" FontSize="14" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Text="{DynamicResource oldActionKeyword}"></TextBlock>
@@ -24,8 +25,10 @@
<StackPanel Grid.Row="1" Orientation="Horizontal" Grid.Column="1" > <StackPanel Grid.Row="1" Orientation="Horizontal" Grid.Column="1" >
<TextBox x:Name="tbAction" Margin="10" Width="400" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBox> <TextBox x:Name="tbAction" Margin="10" Width="400" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBox>
</StackPanel> </StackPanel>
<TextBlock Grid.Row="2" Grid.ColumnSpan="1" Grid.Column="1" Padding="5" Foreground="Gray" Text="{DynamicResource actionkeyword_tips}"></TextBlock>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="2" Grid.Column="1"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="3" Grid.Column="1">
<Button x:Name="btnCancel" Click="BtnCancel_OnClick" Margin="10 0 10 0" Width="80" Height="25" Content="{DynamicResource cancel}"></Button> <Button x:Name="btnCancel" Click="BtnCancel_OnClick" Margin="10 0 10 0" Width="80" Height="25" Content="{DynamicResource cancel}"></Button>
<Button x:Name="btnDone" Margin="10 0 10 0" Width="80" Height="25" Click="btnDone_OnClick"> <Button x:Name="btnDone" Margin="10 0 10 0" Width="80" Height="25" Click="btnDone_OnClick">
<TextBlock x:Name="lblAdd" Text="{DynamicResource done}"></TextBlock> <TextBlock x:Name="lblAdd" Text="{DynamicResource done}"></TextBlock>

View File

@@ -57,7 +57,7 @@ namespace Wox
} }
//check new action keyword didn't used by other plugin //check new action keyword didn't used by other plugin
if (PluginManager.AllPlugins.Exists(o => o.Metadata.ActionKeyword == tbAction.Text.Trim())) if (tbAction.Text.Trim() != PluginManager.ActionKeywordWildcard && PluginManager.AllPlugins.Exists(o => o.Metadata.ActionKeyword == tbAction.Text.Trim()))
{ {
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("newActionKeywordHasBeenAssigned")); MessageBox.Show(InternationalizationManager.Instance.GetTranslation("newActionKeywordHasBeenAssigned"));
return; return;

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Text; using System.Text;
using Wox.Infrastructure.Storage; using Wox.Infrastructure.Storage;
@@ -16,15 +17,7 @@ namespace Wox.ImageLoader
protected override string ConfigFolder protected override string ConfigFolder
{ {
get get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); }
{
string userProfilePath = Environment.GetEnvironmentVariable("USERPROFILE");
if (userProfilePath == null)
{
throw new ArgumentException("Environment variable USERPROFILE is empty");
}
return Path.Combine(Path.Combine(userProfilePath, ".Wox"), "Config");
}
} }
protected override string ConfigName protected override string ConfigName

View File

@@ -8,6 +8,7 @@
<!--Setting General--> <!--Setting General-->
<system:String x:Key="woxsettings">Wox Settings</system:String>
<system:String x:Key="general">General</system:String> <system:String x:Key="general">General</system:String>
<system:String x:Key="startWoxOnSystemStartup">Start Wox on system startup</system:String> <system:String x:Key="startWoxOnSystemStartup">Start Wox on system startup</system:String>
<system:String x:Key="hideWoxWhenLoseFocus">Hide Wox when loses focus</system:String> <system:String x:Key="hideWoxWhenLoseFocus">Hide Wox when loses focus</system:String>
@@ -61,6 +62,7 @@
<system:String x:Key="about">About</system:String> <system:String x:Key="about">About</system:String>
<system:String x:Key="website">Website</system:String> <system:String x:Key="website">Website</system:String>
<system:String x:Key="version">Version</system:String> <system:String x:Key="version">Version</system:String>
<system:String x:Key="about_activate_times">You have activated Wox {0} times</system:String>
<!--Action Keyword Setting Dialog--> <!--Action Keyword Setting Dialog-->
<system:String x:Key="oldActionKeyword">Old Action Keyword</system:String> <system:String x:Key="oldActionKeyword">Old Action Keyword</system:String>
@@ -71,6 +73,8 @@
<system:String x:Key="newActionKeywordCannotBeEmpty">New Action Keyword can't be empty</system:String> <system:String x:Key="newActionKeywordCannotBeEmpty">New Action Keyword can't be empty</system:String>
<system:String x:Key="newActionKeywordHasBeenAssigned">New ActionKeyword has been assigned to other plugin, please assign another new action keyword</system:String> <system:String x:Key="newActionKeywordHasBeenAssigned">New ActionKeyword has been assigned to other plugin, please assign another new action keyword</system:String>
<system:String x:Key="succeed">Succeed</system:String> <system:String x:Key="succeed">Succeed</system:String>
<system:String x:Key="actionkeyword_tips">Use * if you don't want to specify a action keyword</system:String>
<!--Custom Query Hotkey Dialog--> <!--Custom Query Hotkey Dialog-->
<system:String x:Key="preview">Preview</system:String> <system:String x:Key="preview">Preview</system:String>

View File

@@ -8,6 +8,7 @@
<!--设置,通用--> <!--设置,通用-->
<system:String x:Key="woxsettings">Wox设置</system:String>
<system:String x:Key="general">通用</system:String> <system:String x:Key="general">通用</system:String>
<system:String x:Key="startWoxOnSystemStartup">开机启动</system:String> <system:String x:Key="startWoxOnSystemStartup">开机启动</system:String>
<system:String x:Key="hideWoxWhenLoseFocus">失去焦点时自动隐藏Wox</system:String> <system:String x:Key="hideWoxWhenLoseFocus">失去焦点时自动隐藏Wox</system:String>
@@ -61,7 +62,7 @@
<system:String x:Key="about">关于</system:String> <system:String x:Key="about">关于</system:String>
<system:String x:Key="website">网站</system:String> <system:String x:Key="website">网站</system:String>
<system:String x:Key="version">版本</system:String> <system:String x:Key="version">版本</system:String>
<system:String x:Key="about_activate_times">你已经激活了Wox {0} 次</system:String>
<!--Action Keyword 设置对话框--> <!--Action Keyword 设置对话框-->
<system:String x:Key="oldActionKeyword">旧触发关键字</system:String> <system:String x:Key="oldActionKeyword">旧触发关键字</system:String>
@@ -72,7 +73,8 @@
<system:String x:Key="newActionKeywordCannotBeEmpty">新触发关键字不能为空</system:String> <system:String x:Key="newActionKeywordCannotBeEmpty">新触发关键字不能为空</system:String>
<system:String x:Key="newActionKeywordHasBeenAssigned">新触发关键字已经被指派给其他插件了,请重新选择一个关键字</system:String> <system:String x:Key="newActionKeywordHasBeenAssigned">新触发关键字已经被指派给其他插件了,请重新选择一个关键字</system:String>
<system:String x:Key="succeed">成功</system:String> <system:String x:Key="succeed">成功</system:String>
<system:String x:Key="actionkeyword_tips">如果你不想设置触发关键字,可以使用*代替</system:String>
<!--Custom Query Hotkey 对话框--> <!--Custom Query Hotkey 对话框-->
<system:String x:Key="preview">预览</system:String> <system:String x:Key="preview">预览</system:String>
<system:String x:Key="hotkeyIsNotUnavailable">热键不可用,请选择一个新的热键</system:String> <system:String x:Key="hotkeyIsNotUnavailable">热键不可用,请选择一个新的热键</system:String>

View File

@@ -8,6 +8,7 @@
<!--設置,通用--> <!--設置,通用-->
<system:String x:Key="woxsettings">Wox設置</system:String>
<system:String x:Key="general">通用</system:String> <system:String x:Key="general">通用</system:String>
<system:String x:Key="startWoxOnSystemStartup">開機啟動</system:String> <system:String x:Key="startWoxOnSystemStartup">開機啟動</system:String>
<system:String x:Key="hideWoxWhenLoseFocus">失去焦點時自動隱藏Wox</system:String> <system:String x:Key="hideWoxWhenLoseFocus">失去焦點時自動隱藏Wox</system:String>
@@ -61,7 +62,7 @@
<system:String x:Key="about">關於</system:String> <system:String x:Key="about">關於</system:String>
<system:String x:Key="website">網站</system:String> <system:String x:Key="website">網站</system:String>
<system:String x:Key="version">版本</system:String> <system:String x:Key="version">版本</system:String>
<system:String x:Key="about_activate_times">你已經激活了Wox {0} 次</system:String>
<!--Action Keyword 設置對話框--> <!--Action Keyword 設置對話框-->
<system:String x:Key="oldActionKeyword">舊觸發關鍵字</system:String> <system:String x:Key="oldActionKeyword">舊觸發關鍵字</system:String>
@@ -72,6 +73,7 @@
<system:String x:Key="newActionKeywordCannotBeEmpty">新觸發關鍵字不能為空</system:String> <system:String x:Key="newActionKeywordCannotBeEmpty">新觸發關鍵字不能為空</system:String>
<system:String x:Key="newActionKeywordHasBeenAssigned">新觸發關鍵字已經被指派給其他插件了,請重新選擇一個關鍵字</system:String> <system:String x:Key="newActionKeywordHasBeenAssigned">新觸發關鍵字已經被指派給其他插件了,請重新選擇一個關鍵字</system:String>
<system:String x:Key="succeed">成功</system:String> <system:String x:Key="succeed">成功</system:String>
<system:String x:Key="actionkeyword_tips">如果你不想設置觸發關鍵字,可以使用*代替</system:String>
<!--Custom Query Hotkey 對話框--> <!--Custom Query Hotkey 對話框-->
<system:String x:Key="preview">預覽</system:String> <system:String x:Key="preview">預覽</system:String>

View File

@@ -292,6 +292,7 @@ namespace Wox
if (!IsVisible) if (!IsVisible)
{ {
ShowWox(); ShowWox();
UserSettingStorage.Instance.IncreaseActivateTimes();
} }
else else
{ {

View File

@@ -7,7 +7,7 @@
xmlns:converters="clr-namespace:Wox.Converters" xmlns:converters="clr-namespace:Wox.Converters"
xmlns:userSettings="clr-namespace:Wox.Core.UserSettings;assembly=Wox.Core" xmlns:userSettings="clr-namespace:Wox.Core.UserSettings;assembly=Wox.Core"
Icon="Images\app.png" Icon="Images\app.png"
Title="Wox Settings" Title="{DynamicResource woxsettings}"
ResizeMode="NoResize" ResizeMode="NoResize"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"
Height="600" Width="800"> Height="600" Width="800">
@@ -310,6 +310,7 @@
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="30"></RowDefinition> <RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="30"></RowDefinition> <RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" Margin="6" Text="{DynamicResource website}"></TextBlock> <TextBlock Grid.Column="0" Grid.Row="0" Margin="6" Text="{DynamicResource website}"></TextBlock>
@@ -319,6 +320,8 @@
<StackPanel Grid.Column="1" Grid.Row="1" Orientation="Horizontal"> <StackPanel Grid.Column="1" Grid.Row="1" Orientation="Horizontal">
<TextBlock Margin="6" HorizontalAlignment="Left" x:Name="tbVersion" Text="1.0.0"></TextBlock> <TextBlock Margin="6" HorizontalAlignment="Left" x:Name="tbVersion" Text="1.0.0"></TextBlock>
</StackPanel> </StackPanel>
<TextBlock x:Name="tbActivatedTimes" Grid.Row="2" Margin="6" Grid.ColumnSpan="2" Text="{DynamicResource about_activate_times}"></TextBlock>
</Grid> </Grid>
</TabItem> </TabItem>
</TabControl> </TabControl>

View File

@@ -21,6 +21,7 @@ using Microsoft.Win32;
using Wox.Core.i18n; using Wox.Core.i18n;
using Wox.Core.Theme; using Wox.Core.Theme;
using Wox.Core.UserSettings; using Wox.Core.UserSettings;
using Wox.Core.Version;
namespace Wox namespace Wox
{ {
@@ -216,7 +217,10 @@ namespace Wox
#region About #region About
tbVersion.Text = ConfigurationManager.AppSettings["version"]; tbVersion.Text = VersionManager.Instance.CurrentVersion.ToString();
string activateTimes = string.Format(InternationalizationManager.Instance.GetTranslation("about_activate_times"),
UserSettingStorage.Instance.ActivateTimes);
tbActivatedTimes.Text = activateTimes;
#endregion #endregion

View File

@@ -4,6 +4,7 @@ using Newtonsoft.Json;
using Wox.Infrastructure.Storage; using Wox.Infrastructure.Storage;
using Wox.Plugin; using Wox.Plugin;
using System.IO; using System.IO;
using System.Reflection;
namespace Wox.Storage namespace Wox.Storage
{ {
@@ -14,15 +15,7 @@ namespace Wox.Storage
protected override string ConfigFolder protected override string ConfigFolder
{ {
get get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); }
{
string userProfilePath = Environment.GetEnvironmentVariable("USERPROFILE");
if (userProfilePath == null)
{
throw new ArgumentException("Environment variable USERPROFILE is empty");
}
return Path.Combine(Path.Combine(userProfilePath, ".Wox"), "Config");
}
} }
protected override string ConfigName protected override string ConfigName

View File

@@ -15,7 +15,7 @@ build:
after_test: after_test:
- ps: .\deploy\nuget\pack.ps1 - ps: .\deploy\nuget\pack.ps1
- cmd: .\deploy\UpdateGenerator\build.bat - cmd: .\deploy\UpdateGenerator\build.bat
- cmd: .\deploy\Cleanup.bat #- cmd: .\deploy\Cleanup.bat
deploy: deploy:
provider: NuGet provider: NuGet