Skip to content

Commit 72b2ce9

Browse files
author
zeng-github01
committed
Fix CDK validation
1 parent a48d907 commit 72b2ce9

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

CDK/DatabaseManager.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ private bool KeyVailed(CDKData cdk)
4242
{
4343
if(cdk.Amount == string.Empty && cdk.Items != string.Empty)
4444
{
45+
var list = cdk.Items.Split(',').ToList();
46+
for (int i = 0; i < list.Count; i++)
47+
{
48+
if (!ushort.TryParse(list[i], out ushort res))
49+
{
50+
Logger.LogError(String.Format("CDK:{0} has id in Items not a ushort!", cdk.CDK));
51+
return false;
52+
}
53+
}
4554
return true;
4655
}
4756
List<string> listitem = cdk.Items.Split(',').ToList();
@@ -56,7 +65,7 @@ private bool KeyVailed(CDKData cdk)
5665

5766
for (int i = 0; i < listitem.Count; i++)
5867
{
59-
if (!ushort.TryParse(cdk.Items[i].ToString(), out ushort id))
68+
if (!ushort.TryParse(listitem[i], out ushort id))
6069
{
6170
Logger.LogError(String.Format("CDK:{0} has id in Items not a ushort!", cdk.CDK));
6271
return false;
@@ -65,7 +74,7 @@ private bool KeyVailed(CDKData cdk)
6574

6675
for (int i = 0; i < listamount.Count; i++)
6776
{
68-
if (!byte.TryParse(cdk.Amount[i].ToString(), out byte am))
77+
if (!byte.TryParse(listamount[i], out byte am))
6978
{
7079
Logger.LogError(String.Format("CDK:{0} has amount in Amount not a byte. MAX 255!", cdk.CDK));
7180
return false;

CDK/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
3333
//通过使用 "*",如下所示:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("3.3.1.2")]
36-
[assembly: AssemblyFileVersion("3.3.1.2")]
35+
[assembly: AssemblyVersion("3.3.1.3")]
36+
[assembly: AssemblyFileVersion("3.3.1.3")]

0 commit comments

Comments
 (0)