public bool Login(bool bool_1, string string_2) { //逻辑修改:无Key调试时需要把TaxCard登录校验屏蔽掉 if (InternetWare.Config.Constants.IsTest) { string_2 = "管理员"; this.method_1(string_2); } else { #region bool flag = false; LoginForm form = new LoginForm(); if (bool_1) { flag = false; return(true); } if (form.ShowDialog() == DialogResult.OK) { flag = true; string_2 = form.method_1(); } if (!bool_1 && !flag) { return(false); } TaxCardFactory.CardType = CTaxCardType.const_7; TaxCard card = TaxCardFactory.CreateTaxCard(); card.CustomMessageBox += new TaxCard.CustomMsgBox(this.method_0); Label_010F: if (!card.TaxCardOpen(form.method_4()) && (card.RetCode != 0)) { if (card.RetCode == -1111) { ChangeCertPass pass = new ChangeCertPass(); pass.method_2(form.method_4()); pass.method_3().Enabled = false; pass.method_4(form.method_1()); if (pass.ShowDialog() != DialogResult.OK) { MessageBoxHelper.Show("取消证书默认口令修改,退出系统!", "系统登录", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return(false); } if (form.method_3()) { PropertyUtil.SetValue("Login_" + BitConverter.ToString(ToolUtil.GetBytes(form.method_1())).Replace("-", ""), form.method_2() + "-" + pass.method_5()); } else { PropertyUtil.SetValue("Login_" + BitConverter.ToString(ToolUtil.GetBytes(form.method_1())).Replace("-", ""), string.Empty); } MessageBoxHelper.Show("证书口令修改成功,请重新登录系统!", "系统登录", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); card.CloseDevice(); Process.Start(Assembly.GetExecutingAssembly().Location); return(false); } if (!card.ErrCode.StartsWith("CA_")) { MessageManager.ShowMsgBox(card.ErrCode); return(false); } int num4 = Convert.ToInt32(card.ErrCode.Split(new char[] { '_' })[1]); switch (num4) { case 0x3810002a: MessageBoxHelper.Show("证书口令长度不足8个字符", "证书登录错误", MessageBoxButtons.OK, MessageBoxIcon.Hand); return(false); case 0x381063c0: MessageBoxHelper.Show("证书密码被锁死,请解锁后重新登录", "证书登录错误", MessageBoxButtons.OK, MessageBoxIcon.Hand); return(false); default: { if ((num4 >= 0x381063cf) || (num4 <= 0x381063c0)) { MessageManager.ShowMsgBox(card.ErrCode); return(false); } int num5 = num4 - 0x381063c0; CertLogin login = new CertLogin(num5); if (login.ShowDialog() != DialogResult.OK) { MessageBoxHelper.Show("取消证书登录,退出系统!", "系统登录", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return(false); } card.CloseDevice(); form.method_5(login.method_1()); goto Label_010F; } } } MessageHelper.MsgWait("正在更新发票上传标志,不要插拔金税盘或关闭电源,请耐心等待..."); ilog_0.Error("开始更新上传标志##########..."); List <ClearCardInfo> list = card.UpdateUpLoadFlag(); if (list != null) { ilog_0.Error("UpdateUpLoadFlag返回结果个数#############:" + list.Count); } if ((list != null) && (list.Count > 0)) { foreach (ClearCardInfo info in list) { try { ilog_0.Error("金税盘RetCode##########:" + info.CSTime.ToString()); if (info.CSTime != "") { string str2 = string.Format("【{0}】 抄报清卡", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); string str = "update XXFP set BSZT = 1, BSBZ = 1, BSRZ = '" + str2 + "' where BSQ = " + info.InvPeriod.ToString() + " and SSYF = " + info.CSTime.ToString(); if (card.SubSoftVersion == "Linux") { str = "update XXFP set BSBZ = 1, BSRZ = '" + str2 + "' where BSQ = " + info.InvPeriod.ToString() + " and SSYF = " + info.CSTime.ToString(); } switch (info.InvKind) { case 0x29: case 0x33: case 12: str = str + " and (FPZL = 'j' or FPZL = 'p' or FPZL = 'q')"; if (card.QYLX.ISJDC || card.QYLX.ISPTFPDZ) { PropertyUtil.SetValue(AttributeName.JDCQKDateName, this.method_2(12, info.CSTime)); } if (card.QYLX.ISPTFPJSP) { PropertyUtil.SetValue(AttributeName.JSPQKDateName, this.method_2(0x29, info.CSTime)); } break; case 0: case 2: str = str + " and (FPZL = 's' or FPZL = 'c')"; if (card.QYLX.ISPTFP || card.QYLX.ISZYFP) { PropertyUtil.SetValue(AttributeName.ZPQKDateName, this.method_2(0, info.CSTime)); } break; case 11: str = str + " and FPZL = 'f'"; if (card.QYLX.ISHY) { PropertyUtil.SetValue(AttributeName.HYQKDateName, this.method_2(11, info.CSTime)); } break; } BaseDAOSQLite baseDAOSQLite = BaseDAOFactory.GetBaseDAOSQLite() as BaseDAOSQLite; if (baseDAOSQLite != null) { baseDAOSQLite.method_1(str); } else { MessageBoxHelper.Show("获取数据库实例失败。"); } continue; } ilog_0.Error("更新发票上传标志接口返回时间错误:" + info.CSTime); } catch (Exception exception) { MessageBoxHelper.Show(exception.Message); ilog_0.Error(exception.ToString()); } } } ilog_0.Error("结束更新上传标志##########..."); MessageHelper.MsgWait(); string regionCode = card.RegionCode; if (string.Equals(card.SoftVersion, "FWKP_V2.0_Svr_Client")) { PropertyUtil.SetValue("MAIN_CODE", card.TaxCode); PropertyUtil.SetValue("MAIN_MACHINE", card.Machine.ToString()); PropertyUtil.SetValue("MAIN_ORGCODE", card.CorpCode.Substring(0, 6)); } if (!string.Equals(card.SoftVersion, "FWKP_V2.0_Svr_Client")) { if ((regionCode != null) && (regionCode.Length > 2)) { string str4 = regionCode.Substring(0, 2); if (str4 == "91") { str4 = "50"; } regionCode = str4 + regionCode.Substring(2); } if (((card.TaxMode == CTaxCardMode.tcmHave) && (card.TaxCode.Length > 15)) && (RegisterManager.SetupOrgCode != regionCode)) { ilog_0.Info("注册表中地区编号:" + RegisterManager.SetupOrgCode); ilog_0.Info("金税设备中地区编号:" + regionCode); MessageBoxHelper.Show("安装时输入的地区编号和金税设备中不一致,请重新安装!"); return(false); } if (RegisterManager.SetupTaxCode != card.TaxCode) { MessageBoxHelper.Show("安装时输入的税号和金税设备中不一致,请重新安装!"); return(false); } if (RegisterManager.SetupMachine != card.Machine) { MessageBoxHelper.Show("安装时输入的开票机号和金税设备中不一致,请重新安装!"); return(false); } if (!RegisterManager.PreMakeInvoice()) { MessageBoxHelper.Show("开票注册文件验证失败!"); } } #endregion } return(true); }
public bool Login(string string_2, string string_3) { try { new LoginForm(); TaxCardFactory.CardType = CTaxCardType.const_7; TaxCard card = TaxCardFactory.CreateTaxCard(); card.CustomMessageBox += new TaxCard.CustomMsgBox(this.method_0); if (!card.TaxCardOpen(string_3)) { return(false); } MessageHelper.MsgWait("正在更新发票上传标志,不要插拔金税盘或关闭电源,请耐心等待..."); ilog_0.Error("开始更新上传标志=========..."); List <ClearCardInfo> list = card.UpdateUpLoadFlag(); if (list != null) { ilog_0.Error("UpdateUpLoadFlag返回结果个数=========:" + list.Count); } if ((list != null) && (list.Count > 0)) { foreach (ClearCardInfo info in list) { ilog_0.Error("taxCard.RetCode=========" + card.RetCode); try { ilog_0.Error("taxCard.RetCode=========" + info.CSTime.ToString()); if (info.CSTime != "") { string str2 = string.Format("【{0}】 抄报清卡", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); string message = "update XXFP set BSZT = 1, BSBZ = 1, BSRZ = '" + str2 + "' where BSQ = " + info.InvPeriod.ToString() + " and SSYF = " + info.CSTime.ToString(); if (card.SubSoftVersion == "Linux") { message = "update XXFP set BSBZ = 1, BSRZ = '" + str2 + "' where BSQ = " + info.InvPeriod.ToString() + " and SSYF = " + info.CSTime.ToString(); } switch (info.InvKind) { case 0x29: case 0x33: case 12: message = message + " and (FPZL = 'j' or FPZL = 'p' or FPZL = 'q')"; if (card.QYLX.ISJDC || card.QYLX.ISPTFPDZ) { PropertyUtil.SetValue(AttributeName.JDCQKDateName, this.method_2(12, info.CSTime)); } if (card.QYLX.ISPTFPJSP) { PropertyUtil.SetValue(AttributeName.JSPQKDateName, this.method_2(0x29, info.CSTime)); } break; case 0: case 2: message = message + " and (FPZL = 's' or FPZL = 'c')"; if (card.QYLX.ISPTFP || card.QYLX.ISZYFP) { PropertyUtil.SetValue(AttributeName.ZPQKDateName, this.method_2(0, info.CSTime)); } break; case 11: message = message + " and FPZL = 'f'"; if (card.QYLX.ISHY) { PropertyUtil.SetValue(AttributeName.HYQKDateName, this.method_2(11, info.CSTime)); } break; } BaseDAOSQLite baseDAOSQLite = BaseDAOFactory.GetBaseDAOSQLite() as BaseDAOSQLite; ilog_0.Error(message); if (baseDAOSQLite != null) { baseDAOSQLite.method_1(message); } else { MessageBoxHelper.Show("获取数据库实例失败。"); } continue; } ilog_0.Error("更新发票上传标志接口返回时间错误:" + info.CSTime); } catch (Exception exception) { MessageBoxHelper.Show(exception.Message); } } } ilog_0.Error("结束更新上传标志=========..."); MessageHelper.MsgWait(); string regionCode = card.RegionCode; if ((regionCode != null) && (regionCode.Length > 2)) { string str4 = regionCode.Substring(0, 2); if (str4 == "91") { str4 = "50"; } regionCode = str4 + regionCode.Substring(2); } if (((card.TaxMode == CTaxCardMode.tcmHave) && (card.TaxCode.Length > 15)) && (RegisterManager.SetupOrgCode != regionCode)) { ilog_0.Info("注册表中地区编号:" + RegisterManager.SetupOrgCode); ilog_0.Info("金税设备中地区编号:" + regionCode); MessageBoxHelper.Show("安装时输入的地区编号和金税设备中不一致,请重新安装!"); return(false); } if (RegisterManager.SetupTaxCode != card.TaxCode) { MessageBoxHelper.Show("安装时输入的税号和金税设备中不一致,请重新安装!"); return(false); } if (RegisterManager.SetupMachine != card.Machine) { MessageBoxHelper.Show("安装时输入的开票机号和金税设备中不一致,请重新安装!"); return(false); } if (!RegisterManager.PreMakeInvoice()) { MessageBoxHelper.Show("开票注册文件验证失败!"); } this.method_1(string_2); return(true); } catch (Exception exception2) { MessageBoxHelper.Show("单点登录失败失败!" + exception2.Message); } return(false); }