Skip to content

Commit a3c3041

Browse files
committed
fix(uwp): kvp UNIQUE id
1 parent e26e4a4 commit a3c3041

4 files changed

Lines changed: 31 additions & 24 deletions

File tree

src/Lavcode.Service.Sqlite/ConService.cs

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
using HTools;
22
using Lavcode.IService;
33
using Lavcode.Service.Sqlite.Entities;
4-
using Newtonsoft.Json.Linq;
54
using SQLite;
65
using System;
7-
using System.Diagnostics;
86
using System.Linq;
97
using System.Threading.Tasks;
108

@@ -22,22 +20,14 @@ public async Task<bool> Connect(object args)
2220
_args = args;
2321

2422
var filePath = DynamicHelper.ToExpandoObject(args).FilePath as string;
25-
try
26-
{
27-
Connection?.Dispose();
28-
Connection = new SQLiteConnection(filePath);
29-
await TaskExtend.Run(() =>
30-
{
31-
CreateTables();
32-
TryUpdateKvpId();
33-
});
34-
return true;
35-
}
36-
catch (Exception ex)
23+
Connection?.Dispose();
24+
Connection = new SQLiteConnection(filePath);
25+
await TaskExtend.Run(() =>
3726
{
38-
Debug.Write(ex);
39-
return false;
40-
}
27+
TryUpdateKvpId();
28+
CreateTables();
29+
});
30+
return true;
4131
}
4232

4333
public virtual async Task<bool> Refresh()
@@ -67,12 +57,15 @@ private void TryUpdateKvpId()
6757
{
6858
if (!IsKvpIdNeedUpdate()) return;
6959

70-
var kvps = Connection.Table<KeyValuePairEntity>().ToArray();
71-
foreach (var kvp in kvps)
60+
var index = 1;
61+
var kvps = Connection.Table<BeforeKeyValuePairEntity>().ToArray().Select(item => new KeyValuePairEntity()
7262
{
7363
// fix 合并冲突
74-
kvp.Id = kvp.Id + kvp.PasswordId;
75-
}
64+
Id = item.Id + item.SourceId + index++,
65+
PasswordId = item.SourceId,
66+
Key = item.Key,
67+
Value = item.Value,
68+
});
7669
Connection.RunInTransaction(() =>
7770
{
7871
Connection.Execute("drop table [KeyValuePair]");
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using SQLite;
2+
3+
namespace Lavcode.Service.Sqlite.Entities
4+
{
5+
[Table("KeyValuePair")]
6+
public class BeforeKeyValuePairEntity
7+
{
8+
public virtual int Id { get; set; }
9+
public virtual string SourceId { get; set; }
10+
public virtual string Key { get; set; }
11+
public virtual string Value { get; set; }
12+
}
13+
}

src/Lavcode.Uwp/Lavcode.Uwp.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
<PropertyGroup>
55
<LangVersion>9.0</LangVersion>
66
<GenerateTemporaryStoreCertificate>True</GenerateTemporaryStoreCertificate>
7-
<PackageCertificateThumbprint>2F4003FF881CEE581F179666C77E123DDA351ACC</PackageCertificateThumbprint>
7+
<PackageCertificateThumbprint>
8+
</PackageCertificateThumbprint>
89
<DefaultLanguage>zh-CN</DefaultLanguage>
910
</PropertyGroup>
1011
<PropertyGroup>
@@ -28,7 +29,7 @@
2829
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
2930
<GenerateTestArtifacts>True</GenerateTestArtifacts>
3031
<AppxBundle>Always</AppxBundle>
31-
<AppxBundlePlatforms>x86|x64|arm|arm64</AppxBundlePlatforms>
32+
<AppxBundlePlatforms>x64</AppxBundlePlatforms>
3233
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
3334
<PackageCertificateKeyFile>Lavcode.Uwp_TemporaryKey.pfx</PackageCertificateKeyFile>
3435
</PropertyGroup>

src/Lavcode.Uwp/Package.appxmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<Identity
1212
Name="524473F72DB2F.Lavcode"
1313
Publisher="CN=72C1148F-5C2B-4F28-9B8C-891A63D2777E"
14-
Version="1.2.1.0" />
14+
Version="1.2.3.0" />
1515

1616
<mp:PhoneIdentity PhoneProductId="cda4abc7-39a4-4c92-8937-e609f1c9fb70" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
1717

0 commit comments

Comments
 (0)