public static Boolean Sign(int type, string mackeyExpress, string pinKeyExpress) { PasswordBLL pwdBLL = new PasswordBLL(); //bool ret = pwdBLL.OpenDevice(SysConfigHelper.readerNode("ZT598Port"), "9600"); //if (!ret) //{ // return false; //} try { bool setMode = true; if (type == 0) { setMode = pwdBLL.SetCryptMode(0); log.Write("设置加密模式返回:" + setMode); if (!setMode) { return(false); } //激活万通主密钥 /* if (!pwdBLL.ActivWorkKey(0, 0)) * { * return false; * }*/ log.Write("下载工作秘钥"); bool pingSuccess = pwdBLL.DownloadWorkKey(0, 0, pinKeyExpress); if (!pingSuccess) { return(false); } bool macSuccess = pwdBLL.DownloadWorkKey(0, 1, mackeyExpress); if (!macSuccess) { return(false); } SysBLL.RebuildBatchNo(); } else if (type == 1) { setMode = pwdBLL.SetCryptMode(1); log.Write("设置加密模式返回:" + setMode); if (!setMode) { return(false); } //激活万通主密钥 /*if(!pwdBLL.ActivWorkKey(1, 0)) * { * return false; * }*/ log.Write("开始下载工作秘钥" + ",pinKeyExpress:" + pinKeyExpress); bool pingSuccess = pwdBLL.DownloadWorkKey(1, 2, pinKeyExpress); log.Write("下载工作秘钥返回::" + pingSuccess + ",pinKeyExpress:" + pinKeyExpress); if (!pingSuccess) { return(false); } log.Write("开始下载工作秘钥" + ",mackeyExpress:" + mackeyExpress); bool macSuccess = pwdBLL.DownloadWorkKey(1, 3, mackeyExpress); log.Write("下载工作秘钥返回::" + macSuccess + ",mackeyExpress:" + mackeyExpress); if (!macSuccess) { return(false); } } pwdBLL.closeKey(); return(true); } catch (Exception ex) { log.Write("error:Sign():" + ex.Message + ex.InnerException); return(false); } }