跳到主要内容

github/tai

公开

Tai · Windows 软件与网站使用时长统计。上游 Planshit/Tai 的源码镜像,非灵栈原创;MIT 许可。来源:https://github.com/Planshit/Tai 。本次为手动同步,暂不提供安装包。

提交记录
修改Core/Core.csproj+5 −0看文件
@@ -65,6 +65,9 @@
6565 <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
6666 <HintPath>..\packages\EntityFramework.6.3.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
6767 </Reference>
68新增: <Reference Include="Microsoft.Win32.TaskScheduler, Version=2.10.1.0, Culture=neutral, PublicKeyToken=e25603a88b3aa7da, processorArchitecture=MSIL">
69新增: <HintPath>..\packages\TaskScheduler.2.10.1\lib\net452\Microsoft.Win32.TaskScheduler.dll</HintPath>
70新增: </Reference>
6871 <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
6972 <HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
7073 </Reference>
@@ -85,6 +88,7 @@
8588 <HintPath>..\packages\System.Data.SQLite.Linq.1.0.115.5\lib\net46\System.Data.SQLite.Linq.dll</HintPath>
8689 </Reference>
8790 <Reference Include="System.Drawing" />
91新增: <Reference Include="System.IO.Compression, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL" />
8892 <Reference Include="System.Management" />
8993 <Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
9094 <HintPath>..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll</HintPath>
@@ -116,6 +120,7 @@
116120 <Compile Include="Librarys\SQLite\SQLiteBuilder.cs" />
117121 <Compile Include="Librarys\SQLite\SQLiteConfiguration.cs" />
118122 <Compile Include="Librarys\SQLite\TaiDbContext.cs" />
123新增: <Compile Include="Librarys\SystemCommon.cs" />
119124 <Compile Include="Librarys\Time.cs" />
120125 <Compile Include="Librarys\Win32API.cs" />
121126 <Compile Include="Models\AppModel.cs" />
新增Core/Librarys/SystemCommon.cs+51 −0看文件
@@ -0,0 +1,51 @@
1新增:using Microsoft.Win32;
2新增:using Microsoft.Win32.TaskScheduler;
3新增:using System;
4新增:using System.Collections.Generic;
5新增:using System.IO;
6新增:using System.Linq;
7新增:using System.Text;
8新增:using System.Threading.Tasks;
9新增:
10新增:namespace Core.Librarys
11新增:{
12新增: public class SystemCommon
13新增: {
14新增: /// <summary>
15新增: /// 设置开机启动
16新增: /// </summary>
17新增: /// <param name="startup"></param>
18新增: /// <returns></returns>
19新增: public static bool SetStartup(bool startup = true)
20新增: {
21新增: string TaskName = "Tai task";
22新增: var logonUser = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
23新增: string tai = Path.Combine(
24新增: AppDomain.CurrentDomain.BaseDirectory,
25新增: "Tai.exe");
26新增: string taskDescription = "Tai开机自启服务";
27新增:
28新增: using (var taskService = new TaskService())
29新增: {
30新增: var tasks = taskService.RootFolder.GetTasks(new System.Text.RegularExpressions.Regex(TaskName));
31新增: foreach (var t in tasks)
32新增: {
33新增: taskService.RootFolder.DeleteTask(t.Name);
34新增: }
35新增:
36新增: if (startup)
37新增: {
38新增: var task = taskService.NewTask();
39新增: task.RegistrationInfo.Description = taskDescription;
40新增: task.Triggers.Add(new LogonTrigger { UserId = logonUser });
41新增: task.Principal.RunLevel = TaskRunLevel.Highest;
42新增: task.Actions.Add(new ExecAction(tai, null, AppDomain.CurrentDomain.BaseDirectory));
43新增: taskService.RootFolder.RegisterTaskDefinition(TaskName, task);
44新增: }
45新增: }
46新增: return false;
47新增: }
48新增:
49新增:
50新增: }
51新增:}
修改Core/Servicers/Instances/Main.cs+4 −2看文件
@@ -114,7 +114,7 @@ namespace Core.Servicers.Instances
114114 if (oldConfig != newConfig)
115115 {
116116 // 处理开机自启
117删除: Shortcut.SetStartup(newConfig.General.IsStartatboot);
117新增: SystemCommon.SetStartup(newConfig.General.IsStartatboot);
118118
119119 // 更新忽略规则
120120 UpdateConfigIgnoreProcess();
@@ -360,11 +360,13 @@ namespace Core.Servicers.Instances
360360 HandleLinks(activeProcess, seconds, time);
361361 }
362362
363新增: Logger.Info("status:" + sleepStatus + ",process:" + activeProcess + ",seconds:" + seconds + ",start:" + activeStartTime.ToString() + ",end:" + DateTime.Now.ToString());
364新增:
363365 activeStartTime = DateTime.Now;
364366
365367 OnUpdateTime?.Invoke(this, null);
366368
367删除: Logger.Info("【" + sleepStatus + "】进程:" + activeProcess + " 更新时间:" + seconds + ",开始时间:" + activeStartTime.ToString() + ",当前时间:" + DateTime.Now.ToString());
369新增:
368370 }
369371 }
370372
修改Core/packages.config+1 −0看文件
@@ -12,4 +12,5 @@
1212 <package id="System.Memory" version="4.5.3" targetFramework="net461" />
1313 <package id="System.Numerics.Vectors" version="4.4.0" targetFramework="net461" />
1414 <package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net461" />
15新增: <package id="TaskScheduler" version="2.10.1" targetFramework="net461" />
1516</packages>
文件末尾没有换行
新增UI/Properties/app.manifest+73 −0看文件
@@ -0,0 +1,73 @@
1新增:<?xml version="1.0" encoding="utf-8"?>
2新增:<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
3新增: <assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
4新增: <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
5新增: <security>
6新增: <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
7新增: <!-- UAC 清单选项
8新增: 如果想要更改 Windows 用户帐户控制级别,请使用
9新增: 以下节点之一替换 requestedExecutionLevel 节点。
10新增:
11新增: <requestedExecutionLevel level="asInvoker" uiAccess="false" />
12新增: <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
13新增: <requestedExecutionLevel level="highestAvailable" uiAccess="false" />
14新增:
15新增: 指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。
16新增: 如果你的应用程序需要此虚拟化来实现向后兼容性,则移除此
17新增: 元素。
18新增: -->
19新增: <requestedExecutionLevel level="asInvoker" uiAccess="false" />
20新增: </requestedPrivileges>
21新增: <applicationRequestMinimum>
22新增: <PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
23新增: <defaultAssemblyRequest permissionSetReference="Custom" />
24新增: </applicationRequestMinimum>
25新增: </security>
26新增: </trustInfo>
27新增: <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
28新增: <application>
29新增: <!-- 设计此应用程序与其一起工作且已针对此应用程序进行测试的
30新增: Windows 版本的列表。取消评论适当的元素,
31新增: Windows 将自动选择最兼容的环境。 -->
32新增: <!-- Windows Vista -->
33新增: <!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
34新增: <!-- Windows 7 -->
35新增: <!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
36新增: <!-- Windows 8 -->
37新增: <!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
38新增: <!-- Windows 8.1 -->
39新增: <!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
40新增: <!-- Windows 10 -->
41新增: <!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
42新增: </application>
43新增: </compatibility>
44新增: <!-- 指示该应用程序可感知 DPI 且 Windows 在 DPI 较高时将不会对其进行
45新增: 自动缩放。Windows Presentation Foundation (WPF)应用程序自动感知 DPI,无需
46新增: 选择加入。选择加入此设置的 Windows 窗体应用程序(面向 .NET Framework 4.6)还应
47新增: 在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"。
48新增:
49新增: 将应用程序设为感知长路径。请参阅 https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
50新增: <!--
51新增: <application xmlns="urn:schemas-microsoft-com:asm.v3">
52新增: <windowsSettings>
53新增: <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
54新增: <longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
55新增: </windowsSettings>
56新增: </application>
57新增: -->
58新增: <!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -->
59新增: <!--
60新增: <dependency>
61新增: <dependentAssembly>
62新增: <assemblyIdentity
63新增: type="win32"
64新增: name="Microsoft.Windows.Common-Controls"
65新增: version="6.0.0.0"
66新增: processorArchitecture="*"
67新增: publicKeyToken="6595b64144ccf1df"
68新增: language="*"
69新增: />
70新增: </dependentAssembly>
71新增: </dependency>
72新增: -->
73新增:</assembly>
文件末尾没有换行
修改UI/UI.csproj+11 −0看文件
@@ -72,6 +72,15 @@
7272 <ErrorReport>prompt</ErrorReport>
7373 <Prefer32Bit>true</Prefer32Bit>
7474 </PropertyGroup>
75新增: <PropertyGroup>
76新增: <TargetZone>LocalIntranet</TargetZone>
77新增: </PropertyGroup>
78新增: <PropertyGroup>
79新增: <GenerateManifests>false</GenerateManifests>
80新增: </PropertyGroup>
81新增: <PropertyGroup>
82新增: <ApplicationManifest>app.manifest</ApplicationManifest>
83新增: </PropertyGroup>
7584 <ItemGroup>
7685 <Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
7786 <HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.6.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
@@ -405,7 +414,9 @@
405414 <Generator>ResXFileCodeGenerator</Generator>
406415 <LastGenOutput>Resources.Designer.cs</LastGenOutput>
407416 </EmbeddedResource>
417新增: <None Include="app.manifest" />
408418 <None Include="packages.config" />
419新增: <None Include="Properties\app.manifest" />
409420 <None Include="Properties\Settings.settings">
410421 <Generator>SettingsSingleFileGenerator</Generator>
411422 <LastGenOutput>Settings.Designer.cs</LastGenOutput>
新增UI/app.manifest+73 −0看文件
@@ -0,0 +1,73 @@
1新增:<?xml version="1.0" encoding="utf-8"?>
2新增:<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
3新增: <assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
4新增: <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
5新增: <security>
6新增: <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
7新增: <!-- UAC 清单选项
8新增: 如果想要更改 Windows 用户帐户控制级别,请使用
9新增: 以下节点之一替换 requestedExecutionLevel 节点。
10新增:
11新增: <requestedExecutionLevel level="asInvoker" uiAccess="false" />
12新增: <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
13新增: <requestedExecutionLevel level="highestAvailable" uiAccess="false" />
14新增:
15新增: 指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。
16新增: 如果你的应用程序需要此虚拟化来实现向后兼容性,则移除此
17新增: 元素。
18新增: -->
19新增: <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
20新增: </requestedPrivileges>
21新增: <applicationRequestMinimum>
22新增: <PermissionSet Unrestricted="true" ID="Custom" SameSite="site" />
23新增: <defaultAssemblyRequest permissionSetReference="Custom" />
24新增: </applicationRequestMinimum>
25新增: </security>
26新增: </trustInfo>
27新增: <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
28新增: <application>
29新增: <!-- 设计此应用程序与其一起工作且已针对此应用程序进行测试的
30新增: Windows 版本的列表。取消评论适当的元素,
31新增: Windows 将自动选择最兼容的环境。 -->
32新增: <!-- Windows Vista -->
33新增: <!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
34新增: <!-- Windows 7 -->
35新增: <!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
36新增: <!-- Windows 8 -->
37新增: <!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
38新增: <!-- Windows 8.1 -->
39新增: <!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
40新增: <!-- Windows 10 -->
41新增: <!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
42新增: </application>
43新增: </compatibility>
44新增: <!-- 指示该应用程序可感知 DPI 且 Windows 在 DPI 较高时将不会对其进行
45新增: 自动缩放。Windows Presentation Foundation (WPF)应用程序自动感知 DPI,无需
46新增: 选择加入。选择加入此设置的 Windows 窗体应用程序(面向 .NET Framework 4.6)还应
47新增: 在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"。
48新增:
49新增: 将应用程序设为感知长路径。请参阅 https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
50新增: <!--
51新增: <application xmlns="urn:schemas-microsoft-com:asm.v3">
52新增: <windowsSettings>
53新增: <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
54新增: <longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
55新增: </windowsSettings>
56新增: </application>
57新增: -->
58新增: <!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -->
59新增: <!--
60新增: <dependency>
61新增: <dependentAssembly>
62新增: <assemblyIdentity
63新增: type="win32"
64新增: name="Microsoft.Windows.Common-Controls"
65新增: version="6.0.0.0"
66新增: processorArchitecture="*"
67新增: publicKeyToken="6595b64144ccf1df"
68新增: language="*"
69新增: />
70新增: </dependentAssembly>
71新增: </dependency>
72新增: -->
73新增:</assembly>
文件末尾没有换行