コード例 #1
0
ファイル: ExternalDataImporter.cs プロジェクト: peakdot/irts
        public Dictionary <int, Dictionary <int, string> > ParseFingerprintDat(string filename, Dictionary <int, int> userPinDictionary)
        {
            UDisk udisk = new UDisk();

            byte[] byDataBuf = null;
            int    iLength;
            int    iStartIndex;

            int    iSize     = 0;
            int    iPIN      = 0;
            int    fid       = 0;
            int    iValid    = 0;
            string sTemplate = "";

            Dictionary <int, Dictionary <int, string> > dict = new Dictionary <int, Dictionary <int, string> >();

            if (filename != null)
            {
                FileStream stream = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.Read);
                byDataBuf = File.ReadAllBytes(filename);

                iLength = Convert.ToInt32(stream.Length);

                iStartIndex = 0;
                for (int i = 0; i < iLength; i++)
                {
                    iSize = byDataBuf[i] + byDataBuf[i + 1] * 256;//the variable length of the 10.0 arithmetic template
                    byte[] byTmpInfo = new byte[iSize];

                    Array.Copy(byDataBuf, iStartIndex, byTmpInfo, 0, iSize);

                    iStartIndex += iSize;
                    i            = iStartIndex - 1;

                    udisk.GetTmp10FromFp10(byTmpInfo, iSize, out iPIN, out fid, out iValid, out sTemplate);
                    iPIN = userPinDictionary[iPIN];
                    if (!dict.ContainsKey(iPIN))
                    {
                        Dictionary <int, string> fps = new Dictionary <int, string>();
                        fps.Add(fid, sTemplate);
                        dict.Add(iPIN, fps);
                    }
                    else
                    {
                        dict[iPIN].Add(fid, sTemplate);
                    }

                    byTmpInfo = null;
                }
                stream.Close();
            }
            return(dict);
        }
コード例 #2
0
ファイル: ExternalDataImporter.cs プロジェクト: peakdot/irts
        public Dictionary <int, int> ParseUserDat(string filename)
        {
            Dictionary <int, int> dict = new Dictionary <int, int> ();

            UDisk udisk = new UDisk();

            byte[] byDataBuf = null;
            int    iLength;
            int    iCount;//count of users

            int    iPIN       = 0;
            int    iPrivilege = 0;
            string sName      = "";
            string sPassword  = "";
            int    iCard      = 0;
            int    iGroup     = 0;
            string sTimeZones = "";
            string sPIN2      = "";

            if (filename != null)
            {
                FileStream stream = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.Read);
                byDataBuf = File.ReadAllBytes(filename);

                iLength = Convert.ToInt32(stream.Length);
                Console.WriteLine(iLength);
                if (iLength % 72 != 0)
                {
                    MessageBox.Show("Хэрэглэгчийн user.dat файлыг уншихад алдаа гарлаа. Зөв файл оруулсан эсэхээ ахин нягтлана уу.", "Алдаа", MessageBoxButton.OK);
                    return(dict);
                }
                iCount = iLength / 72;

                for (int j = 0; j < iCount; j++)//loop to manage all the users
                {
                    byte[] byUserInfo = new byte[72];
                    for (int i = 0; i < 72; i++)//loop to manage every user's information
                    {
                        byUserInfo[i] = byDataBuf[j * 72 + i];
                    }
                    udisk.GetSSRUserInfoFromDat(byUserInfo, out iPIN, out iPrivilege, out sPassword, out sName, out iCard, out iGroup, out sTimeZones, out sPIN2);
                    dict.Add(iPIN, Int32.Parse(sPIN2));

                    byUserInfo = null;
                }
                stream.Close();
            }
            return(dict);
        }