private void ButtonValidateHardware_Click(object sender, EventArgs e) { var result = Softdog.ValidateLocal(); if (result.Error) { MessageBox.Show(result.Message); return; } //var result2 = JsonConvert.DeserializeObject<JObject>(result.ToString()); //if (protocol == null) //{ // MessageBox.Show("系统异常"); // return; //} //if (protocol.Error) //{ // MessageBox.Show(protocol.Message); // return; //} MessageBox.Show("验证成功"); }
private void ButtonStart_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; this.Enabled = false; ThreadPool.QueueUserWorkItem(delegate { var result = Softdog.ValidateLocal(); if (result.Success) { this.Invoke(new MethodInvoker(delegate { this.Enabled = true; this.Cursor = Cursors.Default; this.DialogResult = System.Windows.Forms.DialogResult.OK; })); } else { this.Invoke(new MethodInvoker(delegate { this.Enabled = true; this.Cursor = Cursors.Default; MessageBox.Show(result.Message); })); } }); }
/// <summary> /// 解密入口,如果加入局域网解密,此处也要修改; /// </summary> /// <param name="check_network_encryption">是否最后查询网络解密;</param> public void CheckEncryption(bool check_network_encryption) { //加密狗解密尝试 Softdog _softDog = new Softdog(); _isDecoding = _softDog.DogReturn(); if (_isDecoding == DecodingFlag.Fail) { //文件解密尝试 FileDecode filedecode = new FileDecode(); _isDecoding = filedecode.IsFileIdentitySuccess(); //如果解密成功,关闭学生机局域网 if (_isDecoding != DecodingFlag.Fail) { if (_clientEncryption != null) { _clientEncryption.BeforeQuit(); } } if (_isDecoding == DecodingFlag.Fail) { //局域网解密会消耗一些时间,采用协程处理后续试用期和网络解密 StartCoroutine(StartLANEncryption(check_network_encryption)); } } else { //如果解密成功,关闭学生机局域网 if (_clientEncryption != null) { _clientEncryption.BeforeQuit(); } } }