Skip to content

Commit b371e60

Browse files
committed
feat: support cli parameters #427
1 parent bbec594 commit b371e60

File tree

6 files changed

+36
-30
lines changed

6 files changed

+36
-30
lines changed

Installer/Package.appxmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<Identity
1212
Name="16536Shawn.V.Workshop.PRemoteM"
1313
Publisher="CN=72AC6E85-B8C4-48F8-A07B-9A985863E628"
14-
Version="1.0.76.0" />
14+
Version="1.0.77.0" />
1515

1616
<Properties>
1717
<DisplayName>1Remote</DisplayName>

Ui/Service/AppStartupHelper.cs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public static void Init(string[] args)
5858
}
5959

6060
#region DESKTOP_SHORTCUT
61+
#if !FOR_MICROSOFT_STORE_ONLY
6162
if (_args.Contains(DESKTOP_SHORTCUT_INSTALL))
6263
{
6364
InstallDesktopShortcut(true);
@@ -66,6 +67,7 @@ public static void Init(string[] args)
6667
{
6768
InstallDesktopShortcut(false);
6869
}
70+
#endif
6971
if (_args.Contains(DESKTOP_SHORTCUT_INSTALL)) _args.Remove(DESKTOP_SHORTCUT_INSTALL);
7072
if (_args.Contains(DESKTOP_SHORTCUT_UNINSTALL)) _args.Remove(DESKTOP_SHORTCUT_UNINSTALL);
7173
#endregion
@@ -128,7 +130,7 @@ public static void ProcessWhenDataLoaded()
128130
NamedPipeHelper.OnMessageReceived += message =>
129131
{
130132
SimpleLogHelper.Debug("NamedPipeServerStream get: " + message);
131-
var strings = new HashSet<string>(message.Split(new []{ Separator }, StringSplitOptions.RemoveEmptyEntries).Distinct());
133+
var strings = new HashSet<string>(message.Split(new[] { Separator }, StringSplitOptions.RemoveEmptyEntries).Distinct());
132134
ProcessArg(strings);
133135
};
134136
}
@@ -163,9 +165,9 @@ private static void ProcessArg(ICollection<string> args)
163165
}
164166
}
165167
}
166-
else if (arg.StartsWith("id:", StringComparison.OrdinalIgnoreCase))
168+
else if (arg.StartsWith("ULID:", StringComparison.OrdinalIgnoreCase))
167169
{
168-
var id = arg.Substring(3);
170+
var id = arg.Substring("ULID:".Length).Trim();
169171
var server = IoC.Get<GlobalData>().VmItemList.FirstOrDefault(x => string.Equals(x.Id, id, StringComparison.CurrentCultureIgnoreCase));
170172
if (server != null && servers.Contains(server.Server) == false)
171173
{
@@ -199,12 +201,12 @@ private static void InstallDesktopShortcut(bool isInstall)
199201
{
200202
var desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
201203
var shortcutPath = System.IO.Path.Combine(desktopPath, Assert.APP_DISPLAY_NAME + ".lnk");
204+
if (System.IO.File.Exists(shortcutPath))
205+
{
206+
System.IO.File.Delete(shortcutPath);
207+
}
202208
if (isInstall)
203209
{
204-
if (System.IO.File.Exists(shortcutPath))
205-
{
206-
System.IO.File.Delete(shortcutPath);
207-
}
208210
var shortcut = new IWshRuntimeLibrary.WshShell().CreateShortcut(shortcutPath);
209211
shortcut.IconLocation =
210212
shortcut.TargetPath = Process.GetCurrentProcess().MainModule!.FileName!;
@@ -213,13 +215,6 @@ private static void InstallDesktopShortcut(bool isInstall)
213215
shortcut.Description = Assert.APP_DISPLAY_NAME;
214216
shortcut.Save();
215217
}
216-
else
217-
{
218-
if (System.IO.File.Exists(shortcutPath))
219-
{
220-
System.IO.File.Delete(shortcutPath);
221-
}
222-
}
223218
}
224219
#endif
225220

Ui/Service/ConfigurationService.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
using System.IO;
55
using System.Linq;
66
using System.Text;
7+
using System.Threading.Tasks;
78
using System.Windows.Input;
89
using _1RM.Model;
910
using Newtonsoft.Json;
1011
using _1RM.Service.DataSource;
1112
using _1RM.Service.DataSource.Model;
1213
using _1RM.Utils;
14+
using Microsoft.WindowsAPICodePack.Shell.PropertySystem;
1315
using Shawn.Utils;
1416
using Shawn.Utils.Wpf;
1517
using VariableKeywordMatcher.Provider.DirectMatch;
@@ -297,7 +299,7 @@ public static bool IsSelfStart()
297299
{
298300

299301
#if FOR_MICROSOFT_STORE_ONLY
300-
return SetSelfStartingHelper.IsSelfStartByStartupTask(Assert.AppName);
302+
return SetSelfStartingHelper.IsSelfStartByStartupTask(Assert.AppName).Result;
301303
#else
302304
return SetSelfStartingHelper.IsSelfStartByRegistryKey(Assert.APP_NAME);
303305
#endif

Ui/Service/DataSource/DAO/Dapper/DapperDataBase.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Data;
4-
using System.Data.SQLite;
5-
using System.Diagnostics;
64
using System.Linq;
75
using Dapper;
8-
using _1RM.Model.Protocol;
96
using _1RM.Model.Protocol.Base;
10-
using _1RM.Service;
7+
using Microsoft.Data.Sqlite;
118
using MySql.Data.MySqlClient;
129
using NUlid;
1310
using Shawn.Utils;
1411
using _1RM.Utils;
15-
using System.Windows;
16-
using Stylet;
1712

1813
// ReSharper disable InconsistentNaming
1914

@@ -33,10 +28,6 @@ public override void CloseConnection()
3328
lock (this)
3429
{
3530
_dbConnection?.Close();
36-
if (DatabaseType == DatabaseType.Sqlite)
37-
{
38-
SQLiteConnection.ClearAllPools();
39-
}
4031
}
4132
}
4233

@@ -87,7 +78,7 @@ protected virtual Result OpenConnection(string actionInfo = "")
8778
_dbConnection = DatabaseType switch
8879
{
8980
DatabaseType.MySql => new MySqlConnection(_connectionString),
90-
DatabaseType.Sqlite => new SQLiteConnection(_connectionString),
81+
DatabaseType.Sqlite => new SqliteConnection(_connectionString),
9182
DatabaseType.SqlServer => throw new NotImplementedException(DatabaseType.ToString() + " not supported!"),
9283
DatabaseType.PostgreSQL => throw new NotImplementedException(DatabaseType.ToString() + " not supported!"),
9384
DatabaseType.Oracle => throw new NotImplementedException(DatabaseType.ToString() + " not supported!"),

Ui/Service/DataSource/DAO/IDataBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public static class DbExtensions
197197
{
198198
public static string GetSqliteConnectionString(string dbPath)
199199
{
200-
return $"Data Source={dbPath}; Pooling=true;Min Pool Size=1";
200+
return $"Data Source={dbPath};";
201201
}
202202
public static string GetMysqlConnectionString(string host, int port, string dbName, string user, string password, int connectTimeOutSeconds)
203203
{

Ui/Ui.csproj

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
System.Data.SQLite from NuGet, interop dll not copied to output directory
4343
https://stackoverflow.com/questions/26768005/system-data-sqlite-from-nuget-interop-dll-not-copied-to-output-directory-->
4444
<ContentSQLiteInteropFiles>true</ContentSQLiteInteropFiles>
45-
<CopySQLiteInteropFiles>true</CopySQLiteInteropFiles>
45+
<CopySQLiteInteropFiles>false</CopySQLiteInteropFiles>
4646
<CleanSQLiteInteropFiles>false</CleanSQLiteInteropFiles>
4747
<CollectSQLiteInteropFiles>false</CollectSQLiteInteropFiles>
4848
</PropertyGroup>
@@ -162,14 +162,14 @@
162162
<PackageReference Include="FluentFTP" Version="37.0.2" />
163163
<PackageReference Include="JsonKnownTypes" Version="0.5.4" />
164164
<PackageReference Include="Markdig.Wpf" Version="0.5.0.1" />
165+
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="7.0.7" PrivateAssets="none" />
165166
<PackageReference Include="MySql.Data" Version="8.0.30" />
166167
<PackageReference Include="Microsoft.AppCenter.Analytics" Version="5.0.1" />
167168
<PackageReference Include="Microsoft.AppCenter.Crashes" Version="5.0.1" />
168169
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
169170
<PackageReference Include="NUlid" Version="1.7.1" />
170171
<PackageReference Include="SSH.NET" Version="2020.0.2" />
171172
<PackageReference Include="Stylet" Version="1.3.6" />
172-
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.117" />
173173
<PackageReference Include="System.Diagnostics.Process" Version="4.3.0" />
174174
<PackageReference Include="VariableKeywordMatcherIn1" Version="1.0.11" />
175175
<PackageReference Include="VirtualizingWrapPanel" Version="1.5.7" />
@@ -517,4 +517,22 @@
517517
<EmbedInteropTypes>true</EmbedInteropTypes>
518518
</COMReference>
519519
</ItemGroup>
520+
521+
<ItemGroup>
522+
<Content Update="E:\NuGetCached\packages\sqlitepclraw.lib.e_sqlite3\2.1.0\buildTransitive\net461\..\..\runtimes\win-arm\native\e_sqlite3.dll">
523+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
524+
</Content>
525+
</ItemGroup>
526+
527+
<ItemGroup>
528+
<Content Update="E:\NuGetCached\packages\sqlitepclraw.lib.e_sqlite3\2.1.0\buildTransitive\net461\..\..\runtimes\win-x64\native\e_sqlite3.dll">
529+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
530+
</Content>
531+
</ItemGroup>
532+
533+
<ItemGroup>
534+
<Content Update="E:\NuGetCached\packages\sqlitepclraw.lib.e_sqlite3\2.1.0\buildTransitive\net461\..\..\runtimes\win-x86\native\e_sqlite3.dll">
535+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
536+
</Content>
537+
</ItemGroup>
520538
</Project>

0 commit comments

Comments
 (0)