Newer
Older
IRIS_REFACTOR / fingerPrint / FingerPrintZkMgr.cs
using irisHelper;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;

namespace fingerPrint
{

    public class FingerPrintZkMgr
    {
        // 用户指纹信息的列表
        private Dictionary<int, JObject> userFingerList;

        public FingerPrintZkMgr() 
        {
            userFingerList = new Dictionary<int, JObject>();
        }

        public void CreateList(DataSet ds)
        {
            userFingerList.Clear();
            DataRowCollection dataRows = ds.Tables[0].Rows;
            for (int iCounter = 0; iCounter < dataRows.Count; iCounter++)
            {
                JObject item = new JObject();

                object idObj = dataRows[iCounter]["ID"];
                object personIdObj = dataRows[iCounter]["PERSON_ID"];
                object templateObj = dataRows[iCounter]["FINGER_TEMPLATE"];
                object tempLenObj = dataRows[iCounter]["FINGER_Length"];

                item.Add("id", idObj.ToString());
                item.Add("personId", personIdObj.ToString());

                if (System.DBNull.Value != templateObj)
                {
                    int length = Int16.Parse(tempLenObj.ToString());
                    byte[] template = new byte[length];
                    Array.Copy((byte[])templateObj, template, length);

                    item.Add("template", Convert.ToBase64String(template));
                    item.Add("lenth", length);
                }

                userFingerList.Add(Int16.Parse(idObj.ToString()), item);
            }
        }

        public Dictionary<int, JObject> UserFingerList { get => userFingerList; set => userFingerList = value; }
    }
}