我想就如何改进我的 C# 代码以进行 Digital Persona SDK 验证提出一些建议。我注意到当我在数据库中达到 3000 条 blob 记录并将它们全部放在一个 DPFP.Template[] 模板数组中时。它只是运行得很慢。
有一个更好的方法吗?
这是我的代码:
foreach (DPFP.Template template in templateArr)
{
count--;
String my_id = empids[count].ToString();
// Get template from storage.
// Compare feature set with particular template.
ver.Verify(features, template, ref res); // This code loops for all 3000 records and causes the verification to slow down.
if (res.Verified)
{
SetPrompt("You Have ");
MakeReport("LOGGED IN!");
getEmployeeData(my_id);
getStatus(my_id);
break; // success
}
}
if (!res.Verified)
{
SetPrompt("Please ");
MakeReport("TRY AGAIN!");
}
这是我从数据库中捕获并放置所有这些 blob 保存的模板的代码: public DPFP.Template[] templateArray() {
//String strSQL = "SELECT emp_id, fpt_template FROM tbl_employees WHERE fpt_template != ''";
String strSQL = "SELECT emp_id, finger_template FROM tbl_fingers WHERE finger_template != ''";
DataTable dt;
DPFP.Template myTemplate;
dt = this.QueryDataTable(strSQL);
object objByte;
byte[] bytData;
//*** Bind Rows ***//
if (dt.Rows.Count > 0)
{
DPFP.Template[] arrTemplate = new DPFP.Template[dt.Rows.Count];
Int32 counter = dt.Rows.Count;
foreach (DataRow dr in dt.Rows)
{
//Object fpt_template = dr["fpt_template"];
Object fpt_template = dr["finger_template"];
objByte = (byte[])(fpt_template);
bytData = (byte[])objByte;
// Convert Blob data to object and then byte
System.IO.MemoryStream ms = new System.IO.MemoryStream(bytData);
myTemplate = new DPFP.Template(ms);
arrTemplate[counter - 1] = myTemplate;
counter--;
}
return arrTemplate;
}
this.Close();
return null;
}
顺便说一句,我正在使用 C# 和 MySQL 提前谢谢你!