Пример #1
0
        public const int MAX_SSR_SMS_CONTENT_SIZE = 160;//the max length of short message in the TFT screen devices

        /****************************************************************************************************************************
         * FunctionName:GetSSRUserInfoFromDat
         * Parameters In:PDataBuf
         * Parameters Out:PIN,Privilege,Password,Name,Card,Group,TimeZones(string),PIN2(string)
         * Return Value:void
         * Device Used:user.dat in TFT screen Device
         * Function:To parse the bytes arrays from user.dat according to the class SSR_User and get out the independent parameters
         * Auther:Darcy
         * Date:Oct.23, 2009
         *****************************************************************************************************************************/
        public void GetSSRUserInfoFromDat(byte[] DataBuf, out int PIN, out int Privilege, out string Password,
                                          out string Name, out int Card, out int Group, out string TimeZone, out string PIN2)
        {
            byte[]   PasswordBuf = new byte[8];
            byte[]   NameBuf     = new byte[24];
            byte[]   TimeZoneBuf = new byte[8];
            byte[]   PIN2Buf     = new byte[24];
            SSR_User ssruser     = new SSR_User();

            ssruser   = (SSR_User)Raw.RawDeserialize(DataBuf, typeof(SSR_User));
            PIN       = ssruser.PIN;
            Privilege = ssruser.Privilege;
            Array.Copy(DataBuf, 3, PasswordBuf, 0, 8);
            Password = System.Text.Encoding.Default.GetString(PasswordBuf);//"default" is to read the system's current ANSI code page encoding

            Array.Copy(DataBuf, 11, NameBuf, 0, 24);
            Name = System.Text.Encoding.Default.GetString(NameBuf);

            Card = 0;
            for (int i = 35; i <= 38; i++)
            {
                Card += Convert.ToInt32(DataBuf[i] * System.Math.Pow(16, 2 * (i - 35)));
            }
            Group = ssruser.Group;

            Array.Copy(DataBuf, 40, TimeZoneBuf, 0, 8);
            TimeZone = System.Text.Encoding.Default.GetString(TimeZoneBuf);

            Array.Copy(DataBuf, 48, PIN2Buf, 0, 24);
            PIN2 = System.Text.Encoding.Default.GetString(PIN2Buf);
        }
Пример #2
0
        public const int MAX_SMS_CONTENT_SIZE = 60;//the max length of short message in the Black&White screen devices

        /****************************************************************************************************************************
         * FunctionName:GetUserInfoFromDat
         * Parameters In:PDataBuf
         * Parameters Out:PIN,Privilege,Password,Name,Card,Group,TimeZones,PIN2
         * Return Value:void
         * Device Used:user.dat in Black&White screen Device
         * Function:To parse the bytes arrays from user.dat according to the class User and get out the independent parameters
         * Auther:Darcy
         * Date:Oct.23, 2009
         *****************************************************************************************************************************/
        public void GetUserInfoFromDat(byte[] DataBuf, out int PIN, out int Privilege, out string Password,
                                       out string Name, out int Card, out int Group, out int TimeZones, out int PIN2)
        {
            byte[] PasswordBuf = new byte[5];
            byte[] NameBuf     = new byte[8];

            User user = new User();

            user = (User)Raw.RawDeserialize(DataBuf, typeof(User));

            PIN       = user.PIN;
            Privilege = user.Privilege;

            Array.Copy(DataBuf, 3, PasswordBuf, 0, 5);
            Password = System.Text.Encoding.Default.GetString(PasswordBuf);//"default" is to read the system's current ANSI code page encoding

            Array.Copy(DataBuf, 8, NameBuf, 0, 8);
            Name = System.Text.Encoding.Default.GetString(NameBuf);

            Card = 0;
            for (int i = 16; i <= 20; i++)
            {
                Card += Convert.ToInt32(DataBuf[i] * System.Math.Pow(16, 2 * (i - 16)));
            }

            Group     = user.Group;
            TimeZones = user.TimeZones;
            PIN2      = Convert.ToInt32(user.PIN2);
        }
Пример #3
0
        /****************************************************************************************************************************
         * FunctionName:GetUDataFromDat
         * Parameters In:DataBuf
         * Parameters Out:PIN,SmsID
         * Return Value:void
         * Device Used:For Black&White screen devices.udata.dat
         * Function:To parse the attendence logs byte arrays to independent parameters
         * Auther:Darcy
         * Date:Oct.23, 2009
         *****************************************************************************************************************************/
        public void GetUDataFromDat(byte[] DataBuf, out int PIN, out int SmsID)
        {
            UData udata = new UData();

            udata = (UData)Raw.RawDeserialize(DataBuf, typeof(UData));

            PIN   = udata.PIN;
            SmsID = udata.SmsID;
        }
Пример #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
        }
Пример #5
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);
        }
Пример #6
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
        }