diff --git a/MainWindow.xaml b/MainWindow.xaml
index 272a31e..b82bd17 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -217,12 +217,12 @@
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/ViewModel/MainWindowViewModel.cs b/ViewModel/MainWindowViewModel.cs
index e2d0955..cb073c6 100644
--- a/ViewModel/MainWindowViewModel.cs
+++ b/ViewModel/MainWindowViewModel.cs
@@ -88,41 +88,58 @@ namespace formula_manage.ViewModel
string SN_KEY;
private void CDkey_()
- {
- string id_1 = SN_ID.Substring(5, 1) + SN_ID.Substring(0, 1) + SN_ID.Substring(4, 1) + SN_ID.Substring(1, 1) + SN_ID.Substring(3, 1) + SN_ID.Substring(2, 1);
- if ((id_1 == SN_KEY.Substring(0, 6)) && (SN_KEY.Length == 16))
- {
- if (CRCcheck16.ToCRC16(CRCcheck16.StringToHexByte(SN_KEY.Substring(0, 12)), true) == SN_KEY.Substring(12, 4)) //校验key的crc校验值
- {
- string Y = (2255 - StrToInt.To16Convert10(SN_KEY.Substring(6, 2))).ToString();
- string M = (255 - StrToInt.To16Convert10(SN_KEY.Substring(8, 2))).ToString();
- string D = (255 - StrToInt.To16Convert10(SN_KEY.Substring(10, 2))).ToString();
-
- string YY = DateTime.Now.ToString("yyyy");
- string MM = DateTime.Now.ToString("MM");
- string DD = DateTime.Now.ToString("dd");
-
- Cdk_time = "Expires time: " + Y +"/"+ M +"/"+ D;
-
- if (string.Compare(Y, YY) < 0)
- {
- if (string.Compare(M, MM) < 0)
+ {
+ try
+ {
+ string id_1 = SN_ID.Substring(5, 1) + SN_ID.Substring(0, 1) + SN_ID.Substring(4, 1) + SN_ID.Substring(1, 1) + SN_ID.Substring(3, 1) + SN_ID.Substring(2, 1);
+ if ((id_1 == SN_KEY.Substring(0, 6)) && (SN_KEY.Length == 16))
+ {
+ if (CRCcheck16.ToCRC16(CRCcheck16.StringToHexByte(SN_KEY.Substring(0, 12)), true) == SN_KEY.Substring(12, 4)) //校验key的crc校验值
+ {
+ string Y = (2255 - StrToInt.To16Convert10(SN_KEY.Substring(6, 2))).ToString();
+ string M = (255 - StrToInt.To16Convert10(SN_KEY.Substring(8, 2))).ToString();
+ string D = (255 - StrToInt.To16Convert10(SN_KEY.Substring(10, 2))).ToString();
+
+ string YY = DateTime.Now.ToString("yyyy");
+ string MM = DateTime.Now.ToString("MM");
+ string DD = DateTime.Now.ToString("dd");
+
+ Cdk_time = "注册到期时间: " + Y + "/" + M + "/" + D;
+
+ if (string.Compare(Y, YY) < 0)
{
- if (string.Compare(D, DD) < 0)
- {
- Cdk_page = "Visible";
- //cdk_pageT_T = -1; //防止触发倒计时
- }
- else if ((int.Parse(D) - int.Parse(DD)) <= 3)//提前三天提醒
- {
- Cdk_page = "Visible";
- cdk_pageT_T = 60; //页面关闭倒计时30秒
- }
- }
- }
-
+ if (string.Compare(M, MM) < 0)
+ {
+ if (string.Compare(D, DD) < 0)
+ {
+ Cdk_page = "Visible";
+ //cdk_pageT_T = -1; //防止触发倒计时
+ }
+ else if ((int.Parse(D) - int.Parse(DD)) <= 10)//提前三天提醒
+ {
+ Cdk_page = "Visible";
+ cdk_pageT_T = 180; //页面关闭倒计时30秒
+ }
+ }
+ }
+ }
+ else
+ {
+ Cdk_page = "Visible";
+ Cdk_time = "许可证安全校验错误请重新激活";
+ } }
+ else
+
+ {
+ Cdk_page = "Visible";
+ Cdk_time = "计算机信息变更当前许可证失效";
}
}
+ catch (Exception)
+ {
+ Cdk_page = "Visible";
+ Cdk_time = "许可证安全校验错误请重新激活";
+ }
}
private async void Sql_()
diff --git a/Windows/CDKEY.xaml.cs b/Windows/CDKEY.xaml.cs
index 7b53c66..08bbab0 100644
--- a/Windows/CDKEY.xaml.cs
+++ b/Windows/CDKEY.xaml.cs
@@ -43,11 +43,14 @@ namespace formula_manage.Windows
UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath);//生效配置读取
cdk.Text = Configini.IniReadvalue("SN", "SN1"); //读配置文件
- string Y = (2255 - StrToInt.To16Convert10(cdk.Text.Substring(6, 2))).ToString();
- string M = (255 - StrToInt.To16Convert10(cdk.Text.Substring(8, 2))).ToString();
- string D = (255 - StrToInt.To16Convert10(cdk.Text.Substring(10, 2))).ToString();
- sn_time.Text = "CDkeyDueTime: " + Y + "-" + M + "-" + D;
-
+ try
+ {
+ string Y = (2255 - StrToInt.To16Convert10(cdk.Text.Substring(6, 2))).ToString();
+ string M = (255 - StrToInt.To16Convert10(cdk.Text.Substring(8, 2))).ToString();
+ string D = (255 - StrToInt.To16Convert10(cdk.Text.Substring(10, 2))).ToString();
+ sn_time.Text = "注册有效时间: " + Y + "-" + M + "-" + D;
+ }
+ catch (Exception ex) { }
// 获取CPU序列号
cpuSerialNumber = HardwareSN.GetCPUSerialNumber();
// 获取主板序列号
@@ -56,8 +59,8 @@ namespace formula_manage.Windows
//string hardDiskSerialNumber = HardwareSN.GetHardDiskSerialNumber();
// 获取网卡地址
//string netCardMACAddress = HardwareSN.GetNetCardMACAddress();
+ sn_id.Text = MD5check.MD5Encrypt16(cpuSerialNumber+ biosSerialNumber);//生成id基于硬件值的md5校验
- sn_id.Text = MD5check.MD5Encrypt16(cpuSerialNumber+ biosSerialNumber);//生成id基于硬件值的md5校验
}
private void Button_Click_2(object sender, RoutedEventArgs e) //cdk确认按钮
@@ -83,8 +86,8 @@ namespace formula_manage.Windows
{
if (string.Compare(D, DD) >= 0)
{
- System.Windows.MessageBox.Show("CDKEY: OK","KEY",MessageBoxButton.OK,MessageBoxImage.Asterisk);
- sn_time.Text = "CDkeyDueTime: " + Y + "-" + M + "-" + D;
+ System.Windows.MessageBox.Show("CDKEY: 注册成功,请重启软件", "KEY",MessageBoxButton.OK,MessageBoxImage.Asterisk);
+ sn_time.Text = "注册有效时间: " + Y + "-" + M + "-" + D;
UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath);
Configini.IniWritevalue("SN", " SN1", cdk.Text);
@@ -92,8 +95,8 @@ namespace formula_manage.Windows
}
else if (string.Compare(M, MM) > 0)
{
- System.Windows.MessageBox.Show("CDKEY: OK", "KEY", MessageBoxButton.OK, MessageBoxImage.Asterisk);
- sn_time.Text = "CDkeyDueTime: " + Y + "-" + M + "-" + D;
+ System.Windows.MessageBox.Show("CDKEY: 注册成功,请重启软件", "KEY", MessageBoxButton.OK, MessageBoxImage.Asterisk);
+ sn_time.Text = "注册有效时间: " + Y + "-" + M + "-" + D;
UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath);
Configini.IniWritevalue("SN", " SN1", cdk.Text);
@@ -101,18 +104,18 @@ namespace formula_manage.Windows
}
else
{
- System.Windows.MessageBox.Show("CDKEY: Overdue", "WARNING", MessageBoxButton.OK, MessageBoxImage.Warning);
+ System.Windows.MessageBox.Show("CDKEY: 注册码过期", "WARNING", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
else
{
- System.Windows.MessageBox.Show("CDKEY: Overdue", "WARNING", MessageBoxButton.OK, MessageBoxImage.Warning);
+ System.Windows.MessageBox.Show("CDKEY: 注册码过期", "WARNING", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
else if (string.Compare(Y, YY) > 0)
{
- System.Windows.MessageBox.Show("CDKEY: OK", "KEY", MessageBoxButton.OK, MessageBoxImage.Asterisk);
- sn_time.Text = "CDkeyDueTime: " + Y + "-" + M + "-" + D;
+ System.Windows.MessageBox.Show("CDKEY: 注册成功,请重启软件", "KEY", MessageBoxButton.OK, MessageBoxImage.Asterisk);
+ sn_time.Text = "注册有效时间: " + Y + "-" + M + "-" + D;
UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath);
Configini.IniWritevalue("SN", " SN1", cdk.Text);
@@ -120,17 +123,17 @@ namespace formula_manage.Windows
}
else
{
- System.Windows.MessageBox.Show("CDKEY: Overdue","WARNING",MessageBoxButton.OK,MessageBoxImage.Warning);
+ System.Windows.MessageBox.Show("CDKEY: 注册码过期","WARNING",MessageBoxButton.OK,MessageBoxImage.Warning);
}
}
else
{
- System.Windows.MessageBox.Show("CDKEY: Linvalid", "ERR", MessageBoxButton.OK, MessageBoxImage.Error);
+ System.Windows.MessageBox.Show("CDKEY: 无效注册码", "ERR", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
else
{
- System.Windows.MessageBox.Show("CDKEY: Linvalid","ERR" , MessageBoxButton.OK,MessageBoxImage.Error);
+ System.Windows.MessageBox.Show("CDKEY: 无效注册码", "ERR" , MessageBoxButton.OK,MessageBoxImage.Error);
}
}