Exemplo n.º 1
0
        /****************************************************************************************************************************
         * FunctionName:SetUDataToDat
         * Parameters In:PIN,SmsID
         * Parameters Out:DataBuf
         * Return Value:void
         * Device Used:For Black&White screen devices. udata.dat
         * Function:To convert imported parameters to the byte array
         * Auther:Darcy
         * Date:Oct.23, 2009
         *****************************************************************************************************************************/
        public void SetUDataToDat(out byte[] DataBuf, int PIN, int SmsID)
        {
            DataBuf = new byte[4];

            UData udata = new UData();

            udata.PIN   = (ushort)PIN;
            udata.SmsID = (ushort)SmsID;
            Array.Copy(Raw.RawSerialize(udata), DataBuf, 4);
        }
Exemplo n.º 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
        }
Exemplo n.º 3
0
        /****************************************************************************************************************************
         * FunctionName:GetSMSFromDat
         * Parameters In:DataBuf
         * Parameters Out:Tag,ID,ValidMinutes,Reserved,StartTime,Content
         * Return Value:void
         * Device Used:Just for Black&White screen devices.sms.dat
         * Function:To parse the short messages byte array to independent parameters
         * Auther:Darcy
         * Date:Oct.23, 2009
         *****************************************************************************************************************************/
        public void GetSMSFromDat(byte[] DataBuf, out int Tag, out int ID, out int ValidMinutes, out int Reserved,
                                  out string StartTime, out string Content)
        {
            byte[] ContentBuf = new byte[UDisk.MAX_SMS_CONTENT_SIZE + 1];

            SMS sms = new SMS();

            sms = (SMS)Raw.RawDeserialize(DataBuf, typeof(SMS));

            Tag          = sms.Tag;
            ID           = sms.ID;
            ValidMinutes = sms.ValidMinutes;
            Reserved     = sms.Reserved;

            //decode time from uint value type to string value type
            int Time = (int)sms.StartTime;
            int Year, Month, Day, Hour, Minute, Second;

            Second = Time % 60;
            Time  /= 60;
            Minute = Time % 60;
            Time  /= 60;
            Hour   = Time % 24;
            Time  /= 24;
            Day    = Time % 31 + 1;
            Time  /= 31;
            Month  = Time % 12 + 1;
            Time  /= 12;
            Year   = Time + 2000;
            DateTime dt;

            try
            {
                dt = new DateTime((int)Year, (int)Month, (int)Day, (int)Hour, (int)Minute, (int)Second);
            }
            catch (Exception e)
            {
                dt = new DateTime(1970, 1, 1, 1, 1, 1);
                MessageBox.Show(e.ToString(), "Error");
            }
            StartTime = dt.ToString();

            Array.Copy(DataBuf, 11, ContentBuf, 0, UDisk.MAX_SMS_CONTENT_SIZE + 1);

            Content = System.Text.Encoding.Default.GetString(ContentBuf);
        }
Exemplo n.º 4
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
        }
Exemplo n.º 5
0
        /****************************************************************************************************************************
         * FunctionName:SetSSRUserInfoToDat
         * Parameters In:PIN,Privilege,Password,Name,Card,Group,TimeZones(string),PIN2(string)
         * Parameters Out:DataBuf
         * Return Value:void
         * Device Used:user.dat in TFT screen Device
         * Function:To convert the independent parameters to bytes arrays DataBuf according to the class SSR_User
         * Auther:Darcy
         * Date:Oct.23, 2009
         *****************************************************************************************************************************/
        public void SetSSRUserInfoToDat(out byte[] DataBuf, int PIN, int Privilege, string Password,
                                        string Name, int Card, int Group, string TimeZones, string PIN2)
        {
            DataBuf = new byte[72];
            byte[] PasswordBuf  = new byte[8];
            byte[] NameBuf      = new byte[24];
            byte[] CardBuf      = new byte[4];
            byte[] TimeZonesBuf = new byte[8];
            byte[] PIN2Buf      = new byte[24];

            SSR_User ssruser = new SSR_User();

            ssruser.PIN       = (ushort)PIN;
            ssruser.Privilege = (byte)Privilege;

            PasswordBuf = System.Text.Encoding.Default.GetBytes(Password);
            Array.Copy(PasswordBuf, ssruser.Password, 8);

            NameBuf = System.Text.Encoding.Default.GetBytes(Name);
            Array.Copy(NameBuf, ssruser.Name, 24);

            CardBuf = BitConverter.GetBytes(Card);
            Array.Copy(CardBuf, ssruser.Card, 4);

            ssruser.Group = (byte)Group;

            TimeZonesBuf         = System.Text.Encoding.Default.GetBytes(TimeZones);
            ssruser.TimeZones[0] = (ushort)TimeZonesBuf[0]; //whether to use timezones or not (0 stands for yes,1 stands for defining by yourself)
            ssruser.TimeZones[1] = (ushort)TimeZonesBuf[1]; //(if you use the timezones)timezoune1
            ssruser.TimeZones[2] = (ushort)TimeZonesBuf[2]; //timezone2
            ssruser.TimeZones[3] = (ushort)TimeZonesBuf[3]; //timezone3

            PIN2Buf = System.Text.Encoding.Default.GetBytes(PIN2);
            Array.Copy(PIN2Buf, ssruser.PIN2, 24);

            Array.Copy(Raw.RawSerialize(ssruser), DataBuf, 72);
        }
Exemplo n.º 6
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);
        }