示例#1
0
        /****************************************************************************************************************************
         * FunctionName:SetTemplateToDat
         * Parameters In:Size,PIN,FingerID,Valid,Template
         * Parameters Out:DataBuf
         * Return Value:void
         * Device Used:template.dat in Black&White screen devices using 9.0 arithmetic
         * Function:To convert the independent parameters to bytes arrays DataBuf according to the class Template
         * Explanation:To write according to the max finger templage 602bytes
         * Auther:Darcy
         * Date:Oct.23, 2009
         *****************************************************************************************************************************/
        public void SetTemplateToDat(out byte[] DataBuf, int Size, int PIN, int FingerID, int Valid, string Template)
        {
            DataBuf = new byte[608];
            byte[] TemplateBuf = new byte[602];

            Templates9 tmp = new Templates9();

            tmp.Size     = (ushort)Size;
            tmp.PIN      = (ushort)PIN;
            tmp.FingerID = (byte)FingerID;
            tmp.Valid    = (byte)Valid;

            Template = Template.Replace(" ", "");
            if (Template.Length <= 0)
            {
                Template = "";
            }
            byte[] TemplateBytes = new byte[Template.Length / 2];
            for (int i = 0; i < Template.Length; i += 2)
            {
                if (!byte.TryParse(Template.Substring(i, 2), NumberStyles.HexNumber, null, out TemplateBytes[i / 2]))
                {
                    TemplateBytes[i / 2] = 0;
                }
            }
            string TemplateFromHex = ASCIIEncoding.Default.GetString(TemplateBytes);

            TemplateBuf = System.Text.Encoding.Default.GetBytes(TemplateFromHex);

            Array.Copy(TemplateBuf, tmp.Template, TemplateFromHex.Length);

            Array.Copy(Raw.RawSerialize(tmp), DataBuf, 608);
        }
示例#2
0
        /****************************************************************************************************************************
         * FunctionName:GetTemplateFromDat
         * Parameters In:DataBuf
         * Parameters Out:Size,PIN,FingerID,Valid,Template
         * Return Value:void
         * Device Used:template.dat in Black&White screen devices using 9.0 arithmetic
         * Function:To parse the bytes arrays from template.dat according to the class Template and get out the independent parameters
         * Explanation:To parse according to the max finger templage 602bytes
         * Auther:Darcy
         * Date:Oct.23, 2009
         *****************************************************************************************************************************/
        public void GetTemplateFromDat(byte[] DataBuf, out int Size, out int PIN, out int FingerID, out int Valid, out string Template)
        {
            byte[] TemplateBuf = new byte[602];

            Templates9 tmp = new Templates9();

            tmp = (Templates9)Raw.RawDeserialize(DataBuf, typeof(Templates9));

            Size     = tmp.Size;
            PIN      = tmp.PIN;
            FingerID = tmp.FingerID;
            Valid    = tmp.Valid;

            Array.Copy(DataBuf, 6, TemplateBuf, 0, 602);
            Template = BitConverter.ToString(TemplateBuf).Replace("-", "");//Str to Hex
        }
示例#3
0
        /****************************************************************************************************************************
        * FunctionName:SetTemplateToDat
        * Parameters In:Size,PIN,FingerID,Valid,Template
        * Parameters Out:DataBuf
        * Return Value:void
        * Device Used:template.dat in Black&White screen devices using 9.0 arithmetic
        * Function:To convert the independent parameters to bytes arrays DataBuf according to the class Template
        * Explanation:To write according to the max finger templage 602bytes
        * Auther:Darcy
        * Date:Oct.23, 2009
        *****************************************************************************************************************************/
        public void SetTemplateToDat(out byte[] DataBuf,int Size, int PIN, int FingerID, int Valid, string Template)
        {
            DataBuf=new byte[608];
            byte[] TemplateBuf = new byte[602];

            Templates9 tmp = new Templates9();

            tmp.Size = (ushort)Size;
            tmp.PIN = (ushort)PIN;
            tmp.FingerID = (byte)FingerID;
            tmp.Valid = (byte)Valid;

            Template = Template.Replace(" ", "");
            if (Template.Length <= 0)
            {
                Template = "";
            }
            byte[] TemplateBytes = new byte[Template.Length / 2];
            for (int i = 0; i < Template.Length; i += 2)
            {
                if (!byte.TryParse(Template.Substring(i, 2), NumberStyles.HexNumber, null, out TemplateBytes[i / 2]))
                {
                    TemplateBytes[i / 2] = 0;
                }
            }
            string TemplateFromHex=ASCIIEncoding.Default.GetString(TemplateBytes);
            TemplateBuf = System.Text.Encoding.Default.GetBytes(TemplateFromHex);

            Array.Copy(TemplateBuf, tmp.Template, TemplateFromHex.Length);

            Array.Copy(Raw.RawSerialize(tmp), DataBuf, 608);
        }
示例#4
0
        /****************************************************************************************************************************
        * FunctionName:GetTemplateFromDat
        * Parameters In:DataBuf
        * Parameters Out:Size,PIN,FingerID,Valid,Template
        * Return Value:void
        * Device Used:template.dat in Black&White screen devices using 9.0 arithmetic
        * Function:To parse the bytes arrays from template.dat according to the class Template and get out the independent parameters
        * Explanation:To parse according to the max finger templage 602bytes
        * Auther:Darcy
        * Date:Oct.23, 2009
        *****************************************************************************************************************************/
        public void GetTemplateFromDat(byte[] DataBuf, out int Size, out int PIN, out int FingerID, out int Valid, out string Template)
        {
            byte[] TemplateBuf = new byte[602];

            Templates9 tmp = new Templates9();
            tmp = (Templates9)Raw.RawDeserialize(DataBuf, typeof(Templates9));

            Size = tmp.Size;
            PIN = tmp.PIN;
            FingerID = tmp.FingerID;
            Valid = tmp.Valid;

            Array.Copy(DataBuf, 6, TemplateBuf, 0, 602);
            Template = BitConverter.ToString(TemplateBuf).Replace("-", "");//Str to Hex
        }