예제 #1
0
        /****************************************************************************************************************************
         * FunctionName: GetFaceFromDat
         * Parameters In:DataBuf
         * Parameters Out: Size,PIN,FaceID,Valid,Reserve,ActiveTime,VfCount,Face
         * Return Value:void
         * Device Used:devices supporting faces registering
         * Function:To parse the bytes arrays from ssrface.dat according to the class FaceTmp and get out the independent parameters
         * Auther:Darcy
         * Date:Oct.23, 2009
         *****************************************************************************************************************************/
        public void GetFaceFromDat(byte[] DataBuf, out int Size, out int PIN, out int FaceID, out int Valid,
                                   out int Reserve, out int ActiveTime, out int VfCount, out string Face)
        {
            byte[] FaceBuf = new byte[2560];

            FaceTmp face = new FaceTmp();

            face = (FaceTmp)Raw.RawDeserialize(DataBuf, typeof(FaceTmp));

            Size       = face.Size;
            PIN        = face.PIN;
            FaceID     = face.FaceID;
            Valid      = face.Valid;
            Reserve    = face.Reserve;
            ActiveTime = (int)face.ActiveTime;
            VfCount    = (int)face.VfCount;

            Array.Copy(DataBuf, 16, FaceBuf, 0, 2560);
            Face = BitConverter.ToString(FaceBuf).Replace("-", "");//Str to Hex
        }
예제 #2
0
        /****************************************************************************************************************************
         * FunctionName: SetFaceToDat
         * Parameters In:Size,PIN,FaceID,Valid,Reserve,ActiveTime,VfCount,Face
         * Parameters Out:DataBuf
         * Return Value:void
         * Device Used:devices supporting faces registering
         * Function:To convert the independent parameters to bytes arrays DataBuf according to the class Template
         * Auther:Darcy
         * Date:Oct.23, 2009
         *****************************************************************************************************************************/
        public void SetFaceToDat(out byte[] DataBuf, int Size, int PIN, int FaceID, int Valid, int Reserve, int ActiveTime, int VfCount, string Face)
        {
            DataBuf = new byte[2576];
            byte[] FaceBuf = new byte[2560];

            FaceTmp face = new FaceTmp();

            face.Size       = (ushort)Size;
            face.PIN        = (ushort)PIN;
            face.FaceID     = (byte)FaceID;
            face.Valid      = (byte)Valid;
            face.Reserve    = (ushort)Reserve;
            face.ActiveTime = (uint)ActiveTime;
            face.VfCount    = (uint)VfCount;

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

            FaceBuf = System.Text.Encoding.Default.GetBytes(FaceFromHex);

            Array.Copy(FaceBuf, face.Face, FaceFromHex.Length);

            Array.Copy(Raw.RawSerialize(face), DataBuf, 2576);
        }