/// <summary> /// 99级权限写数据 /// </summary> /// <param name="putApdu">5个字节命令头</param> /// <param name="dataID">数据ID</param> /// <param name="putData">数据</param> private void Level99PramSet(string putApdu, string dataID, string putData) { if (Functions.IsNum(putData)) { if (tbRand2.Text != "" && tbEsamNo.Text != "") { string orginalPsw = Protocol645.Psw; Esam645Service.EsamOptionClient ESAMproxy = new Esam645Service.EsamOptionClient();//要操作时才new try { string macStr = ESAMproxy.Meter_Formal_ParameterUpdate(0, tbRand2.Text, tbDiv.Text, putApdu, putData).MAC; Protocol645.Psw = "00000099";//临时改为99级密码 Protocol645 p645 = new Protocol645(); p645.WriteData(dataID, macStr + putData); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } finally { ESAMproxy.Close(); Protocol645.Psw = orginalPsw;//用完后要改回界面上的密码,否则影响其他功能使用 } } else { MessageBox.Show("请先身份认证!"); return; } } else { MessageBox.Show("请输入数字!"); return; } }
private void btn设认证时效_Click(object sender, EventArgs e) { if (Functions.IsNum(tbRenzhengshixiao.Text) && tbRenzhengshixiao.Text.Length == 4) { if (tbRand2.Text != "" && tbEsamNo.Text != "") { Esam645Service.EsamOptionClient ESAMproxy = new Esam645Service.EsamOptionClient();//要操作时才new try { string putApdu = "04D6822B0E"; string macStr = ESAMproxy.Meter_Formal_ParameterUpdate(0, tbRand2.Text, tbDiv.Text, putApdu, tbRenzhengshixiao.Text).MAC; string putData = macStr + tbRenzhengshixiao.Text; string ret = null; Protocol645 p645 = new Protocol645(); p645.SecurityAuthentication("070001FF", putData, out ret); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } finally { ESAMproxy.Close(); } } else { MessageBox.Show("请先身份认证!"); } } else { MessageBox.Show("请输入4位数字时效!"); } }