private void button2_Click(object sender, EventArgs e) { ret = Function.Genuserkey();//产生用户密钥对 if (ret > 0) { MajorLog.Debug("产生用户密钥对--成功"); } else { MajorLog.Debug("产生用户密钥对--失败"); } textBox1.Text = "产生用户密钥对--成功"; }
private void button8_Click(object sender, EventArgs e) { string strGet2 = textBox1.Text; ret = Function.Importcert(strGet2); if (ret > 0) { MajorLog.Debug("写入用户证书--成功"); } else { MajorLog.Debug("写入用户证书--失败"); } }
private void button3_Click(object sender, EventArgs e) { ret = Function.Genrootp10(ref s[0], downCmdRoot);//产生根证书P10 if (ret > 0) { MajorLog.Debug("产生根证书P10--成功"); } else { MajorLog.Debug("产生根证书P10--失败"); } string strGet2 = System.Text.Encoding.Default.GetString(s, 0, s.Length); textBox1.Text = strGet2; }
private void button5_Click(object sender, EventArgs e) { ret = Function.Genrootcer(ref s[0], "FEDCBA9876543210", "20170101000000", "20270101000000", "CN=USER,O=TEST,C=CN", 1); // ret = Function.Genrootcer(ref s[0], CertInfo.OnlyID, startday, endday, downCmdRoot, 1);//产生根证书 if (ret > 0) { MajorLog.Debug("产生根证书--成功"); } else { MajorLog.Debug("产生根证书--失败"); } string strGet2 = System.Text.Encoding.Default.GetString(s, 0, s.Length); textBox1.Text = strGet2; }
private void MainForm_Load(object sender, EventArgs e) { MajorLog.Debug("这是一个Debug日志"); label_age.Visible = false; Function.UseDataBase = int.Parse(ConfigurationManager.AppSettings["UseDataBase"]); if (int.Parse(ConfigurationManager.AppSettings["UseCertForm"]) == 1) { button2.Visible = true; } else { button2.Visible = false; } //MySQLPath SQLClass.connsql = @"" + ConfigurationManager.AppSettings["MySQLPath"]; //SQLClass.connsql = @"server=" + ConfigurationManager.AppSettings["SQLIP"] + // ";Database=dmkeybase;uid=" + ConfigurationManager.AppSettings["SQLNAME"] + // ";pwd=" + ConfigurationManager.AppSettings["SQLPSWD"] + // ";SslMode="+ ConfigurationManager.AppSettings["SSLMODE"]; dateTimePicker_valid_start.Text = (System.DateTime.Now).ToString("yyyy-MM-dd"); dateTimePicker_valid_end.Text = (System.DateTime.Now.AddYears(3)).ToString("yyyy-MM-dd"); textBox_name.Text = ConfigurationManager.AppSettings["name"]; textBox_age.Text = ConfigurationManager.AppSettings["age"]; textBox_phone.Text = ConfigurationManager.AppSettings["phone"]; textBox_id.Text = ConfigurationManager.AppSettings["id"]; textBox_mail.Text = ConfigurationManager.AppSettings["mail"]; textBox_project_name.Text = ConfigurationManager.AppSettings["project_name"]; textBox_appid.Text = ConfigurationManager.AppSettings["appid"]; textBox_appkey.Text = ConfigurationManager.AppSettings["appkey"]; textBox_company_name.Text = ConfigurationManager.AppSettings["company_name"]; textBox_company_phone.Text = ConfigurationManager.AppSettings["company_phone"]; textBox_company_address.Text = ConfigurationManager.AppSettings["company_address"]; textBox_belong_company.Text = ConfigurationManager.AppSettings["company_belong"]; }
private void button1_Click(object sender, EventArgs e) { MajorLog.Debug("点击确认并制证"); if (button1.Text == "确认并制证") { #region 制证 try { MajorLog.Debug("开始制证"); string downCmd = "CN=USER,O=" + CertInfo.OnlyID + ",C=CN"; // string downCmdRoot = "CN=ROOT,O=TEST,C=CN"; byte[] s = new byte[1024]; int ret = 0; ret = Function.Genuserkey();//产生用户密钥对 if (ret == -1) { return; } MajorLog.Info("产生用户密钥对"); ret = Function.Genuserp10(ref s[0], downCmd);//产生用户P10 if (ret == -1) { return; } MajorLog.Info("产生用户P10"); ret = Function.Genusercer(ref s[0], "FEDCBA9876543210", "20170101000000", "20270101000000", downCmd, 1);//产生用户证书 MajorLog.Info("产生用户证书"); string strGet2 = System.Text.Encoding.Default.GetString(s, 0, s.Length); // int len = strGet2.Length; // string downStr = strGet2.Substring(0, len); ret = Function.Importcert(strGet2); if (ret > 0) { MajorLog.Debug("写入证书--成功"); } else { MajorLog.Debug("写入证书--失败"); } timer1.Enabled = true; } catch (Exception ex) { MessageBox.Show(ex.Message); MajorLog.Debug(ex.ToString()); } #endregion CertInfo.state = "0"; string CmdStr = "insert into tableall(姓名,性别,年龄,手机号,身份证号,邮箱账号,证书类型,设备类型,发证日期,证书有效期,项目名称,APPID,APP密码,所属单位名称,所属单位电话,所属单位地址,备注,证书编号,状态,设备所属单位) " + "values(@name,@gender, @age, @phone, @id,@mail,@issue_type,@install_type,@issue_day,@valid_period,@project_name,@appid,@appkey,@company_name,@company_phone,@company_address,@remarks,@OnlyID,@state,@belong)"; if (Function.UseDataBase != 0) { using (MySqlConnection con = new MySqlConnection(SQLClass.connsql)) using (MySqlCommand cmd = new MySqlCommand(CmdStr, con)) { try { cmd.Parameters.AddWithValue("@name", CertInfo.name); cmd.Parameters.AddWithValue("@gender", CertInfo.gender); cmd.Parameters.AddWithValue("@age", CertInfo.age); cmd.Parameters.AddWithValue("@phone", CertInfo.phone); cmd.Parameters.AddWithValue("@id", CertInfo.id); cmd.Parameters.AddWithValue("@mail", CertInfo.email); cmd.Parameters.AddWithValue("@issue_type", CertInfo.issue_type); cmd.Parameters.AddWithValue("@install_type", CertInfo.install_type); cmd.Parameters.AddWithValue("@issue_day", CertInfo.issue_day); cmd.Parameters.AddWithValue("@valid_period", CertInfo.cert_validity_period); cmd.Parameters.AddWithValue("@project_name", CertInfo.project_name); cmd.Parameters.AddWithValue("@appid", CertInfo.appid); cmd.Parameters.AddWithValue("@appkey", CertInfo.appkey); cmd.Parameters.AddWithValue("@company_name", CertInfo.company_name); cmd.Parameters.AddWithValue("@company_phone", CertInfo.company_phone); cmd.Parameters.AddWithValue("@company_address", CertInfo.company_address); cmd.Parameters.AddWithValue("@remarks", CertInfo.remarks); cmd.Parameters.AddWithValue("@OnlyID", CertInfo.OnlyID); cmd.Parameters.AddWithValue("@State", CertInfo.state); cmd.Parameters.AddWithValue("@Belong", CertInfo.company_belong); con.Open(); cmd.ExecuteNonQuery(); con.Close(); button1.Text = "制证中..."; button1.BackColor = Color.Green; } catch (MySqlException ex) { MessageBox.Show(ex.Message); } } } else { MajorLog.Debug("未使用数据库"); } } else { MessageBox.Show("制证已完成,请关闭此窗口!"); } }