private void button2_Click(object sender, EventArgs e) { //string excep = "insert into CARD_BNK_EXCEPTION(SWIM_ID, RECORD_SEQ, ARN, CARD_NUMBER, ACCOUNT_NUMBER, ACCOUNT_CURRENCY, TXNAMT," + // " TXN_CURRENCY, BILLING_AMT, BILLING_CURRENCY, TXN_CODE, MERCHANT_NAME, TRANSACTION_DATETIME, AUTHOYN, ACQID, REVERSALYN, FILE_RECORD, error_type, error_message) values"; //string excep1 = ""; // SU DUNG DOAN NAY string lvnstt, lvnseqpayment; int templvnstt; string sfilename = ""; string text = ""; string lvschecksum = ""; string lvskey = Businessbp.executedb.paymentKey; bool check; int succ = 0, unsucc = 0; string sqlexcept = ""; CheckMD5 a = new CheckMD5(); try { if (tbFileName.Text != "") { string name = " " + Businessbp.executedb.owner + "proc_InputPayment"; string[] InParaName = new string[4] { "instt", "inseqpayment", "infilename", "inmsg" }; string[] OutParaName = new string[1] { "outret" }; OleDbType[] InParaType = new OleDbType[4] { OleDbType.Numeric, OleDbType.Numeric, OleDbType.VarChar, OleDbType.VarChar }; OleDbType[] OutParaType = new OleDbType[1] { OleDbType.Numeric }; //string[] InParaValues = new string[1] { tbFileName.Text }; // CHUA GAN HET 4 GIA TRI string[] OutParaValues = new string[1]; for (int i = 0; i < 1; i++) OutParaValues[i] = ""; int[] OutParaSize = new int[1] { 0 }; sfilename = tbFileName.Text; string err = ""; // Doc file FileStream ft = new FileStream(tbFileName.Text.Trim(), FileMode.Open, FileAccess.Read); StreamReader trr = new StreamReader(ft); // HEADER FILE lvnstt = "0"; lvnseqpayment = "0"; text = trr.ReadLine(); string[] InParaValues = new string[4] { lvnstt, lvnseqpayment, sfilename, text }; Businessbp.executedb.ExecuteProcELECTRA(name, InParaName, InParaType, InParaValues, OutParaName, OutParaType, OutParaSize, ref OutParaValues, ref err); if (err != "") MessageBox.Show(err); else { if (OutParaValues[0].ToString() == "-1") { MessageBox.Show("Occur error during import", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (OutParaValues[0].ToString() == "1") { MessageBox.Show("File already import", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } if (lvnstt == "0") lvnseqpayment = OutParaValues[0].ToString(); lvnstt = "1"; // DETAIL FILE while((text = trr.ReadLine()) != null) { if (text.Substring(0, 3) == "002") // detail { lvschecksum = text.Substring(347, 32); check = a.verifyCS(text.Substring(0, 347), lvschecksum, lvskey); } else // text.Substring(0, 3) == "009" -- footer { lvschecksum = text.Substring(27, 32); check = a.verifyCS(text.Substring(0, 27), lvschecksum, lvskey); } // sau moi lan doc dong moi, thi gan lai InParaValues InParaValues[0] = lvnstt; InParaValues[1] = lvnseqpayment; InParaValues[2] = sfilename; InParaValues[3] = text; if (check == true) { Businessbp.executedb.ExecuteProcELECTRA(name, InParaName, InParaType, InParaValues, OutParaName, OutParaType, OutParaSize, ref OutParaValues, ref err); { if (err != "") { unsucc += 1; // insert vao table banknet_import_reject dong hien tai : ghi chu "loi he thong" err = ""; sqlexcept = "insert into banknet_import_reject(strdata,ghichu) values('" + text + "'," + "'system error'" + " )"; Businessbp.executedb.ExecuteDML(sqlexcept, ref err); } else // nguoc lai proc thuc thi finish nhung tra ra nhung gia tri sau { if (OutParaValues[0].ToString() == "-1") { unsucc += 1; // insert vao table banknet_import_reject dong hien tai : ghi chu "loi database" err = ""; sqlexcept = "insert into banknet_import_reject(strdata,ghichu) values('" + text + "'," + "'database error'" + " )"; Businessbp.executedb.ExecuteDML(sqlexcept, ref err); } else// OutParaValues[0].ToString() tra ra gia tri la payment_number -> success succ += 1; } } } else { // insert vao table banknet_import_reject dong hien tai: ghi chu "loi checksum" unsucc += 1; // insert vao table banknet_import_reject dong hien tai : ghi chu "loi database" err = ""; sqlexcept = "insert into banknet_import_reject(strdata,ghichu) values('" + text + "'," + "'checksum error'" + " )"; Businessbp.executedb.ExecuteDML(sqlexcept, ref err); } templvnstt = Convert.ToInt32(lvnstt) + 1; lvnstt = Convert.ToString(templvnstt); } trr.Close(); ft.Close(); } this.Cursor = Cursors.Default; MessageBox.Show("Inported: " + succ.ToString() + "." + Environment.NewLine + "Rejected: " + unsucc.ToString() + "."); if (unsucc < 1) tbStatus.Text = "Import complete without rejects."; else tbStatus.Text = "Import complete with rejects."; //button2.Enabled = false; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public static bool CheckMD5(string F64_Pri, string F64_Hash) { CheckMD5 a = new CheckMD5(); return a.verifyCS(F64_Pri, F64_Hash, Key); }
public static bool Varify_F128(string F128_Pri, string F128_Hash) { CheckMD5 a = new CheckMD5(); if (a.verifyCS(F128_Pri, F128_Hash, Key)) { return true; } return false; }