Browse Source

许可证安全检查逻辑调整

master
sc 2 years ago
parent
commit
d3a021dcf0
  1. 12
      MainWindow.xaml
  2. 59
      ViewModel/MainWindowViewModel.cs
  3. 37
      Windows/CDKEY.xaml.cs

12
MainWindow.xaml

@ -217,12 +217,12 @@
<ContentControl x:Name="Deputy"/>
</Grid>
<Grid Grid.Column="1" Margin="0,0,0,0" Background="White" Opacity="0.8" Visibility="{Binding Cdk_page}">
<TextBlock Height="50" Margin="0,0,0,300" TextWrapping="Wrap" Text="The registration code expires" Width="500" FontSize="34" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Height="50" Margin="0,0,0,200" TextWrapping="Wrap" Text="{Binding Cdk_time}" Width="500" FontSize="34" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Height="50" Margin="0,0,0,100" TextWrapping="Wrap" Text="Contact SUNLIGHT Reactivate" Width="500" FontSize="34" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Button Content="Reactivate" HorizontalAlignment="Center" Height="50" Margin="200,100,0,0" VerticalAlignment="Center" Width="150" FontSize="24" BorderBrush="{x:Null}" Background="#FFDFDFDF" Click="CDKEY_SET"/>
<Button Content="Contact" HorizontalAlignment="Center" Height="50" Margin="0,100,200,0" VerticalAlignment="Center" Width="150" FontSize="24" BorderBrush="{x:Null}" Background="#FFDFDFDF" Click="HELP"/>
<Grid Grid.Column="1" Margin="0,0,0,0" Background="White" Visibility="{Binding Cdk_page}" Opacity="0.8">
<TextBlock Height="150" Margin="0,0,0,300" TextWrapping="Wrap" Text="注册信息到期,处理注册信息预计需要3个工作日,为避免影响系统使用请及时提交注册信息!" Width="500" FontSize="34" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Height="50" Margin="0,0,0,100" TextWrapping="Wrap" Text="{Binding Cdk_time}" Width="500" FontSize="34" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Red"/>
<TextBlock Height="50" Margin="0,0,0,0" TextWrapping="Wrap" Text="请联系 SUNLIGHT" Width="300" FontSize="34" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Button Content="激活" HorizontalAlignment="Center" Height="50" Margin="200,100,0,-100" VerticalAlignment="Center" Width="150" FontSize="24" BorderBrush="{x:Null}" Background="#FFDFDFDF" Click="CDKEY_SET"/>
<Button Content="帮助" HorizontalAlignment="Center" Height="50" Margin="0,100,200,-100" VerticalAlignment="Center" Width="150" FontSize="24" BorderBrush="{x:Null}" Background="#FFDFDFDF" Click="HELP"/>
<TextBlock Height="50" Margin="0,0,0,0" TextWrapping="Wrap" Text="{Binding Cdk_pageT}" Width="500" FontSize="34" HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
</Grid>

59
ViewModel/MainWindowViewModel.cs

@ -89,40 +89,57 @@ namespace formula_manage.ViewModel
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))
try
{
if (CRCcheck16.ToCRC16(CRCcheck16.StringToHexByte(SN_KEY.Substring(0, 12)), true) == SN_KEY.Substring(12, 4)) //校验key的crc校验值
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))
{
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();
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");
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;
Cdk_time = "注册到期时间: " + Y + "/" + M + "/" + D;
if (string.Compare(Y, YY) < 0)
{
if (string.Compare(M, MM) < 0)
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)//提前三天提醒
if (string.Compare(M, MM) < 0)
{
Cdk_page = "Visible";
cdk_pageT_T = 60; //页面关闭倒计时30秒
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_()

37
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校验
}
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);
}
}

Loading…
Cancel
Save