Exemplo n.º 1
0
    private int ModifyPersonInfoUSB(int enroll_id, int device_id)
    {
        AnvizNew.PERSONINFO person = new AnvizNew.PERSONINFO();
        byte[] nms = Encoding.ASCII.GetBytes("");
        byte[] pss = Encoding.Default.GetBytes("");
        int    final_status = 0, status = 0, i = 0;
        int    pLongRun = new int();

        if (AnvizNew.CKT_ChangeConnectionMode(0) != 1)
        {
        }

        status = AnvizNew.CKT_RegisterUSB(device_id, 0);
        if (status != 0)
        {
            person.CardNo = 5216455;
            person.Name   = new byte[12];

            for (i = 0; i < 12; i++)
            {
                if (i < pss.Length)
                {
                    person.Name[i] = pss[i];
                    continue;
                }
                person.Name[i] = 0;
            }

            person.Password = new byte[8];

            for (i = 0; i < 8; i++)
            {
                if (i < nms.Length)
                {
                    person.Password[i] = nms[i];
                    continue;
                }
                person.Password[i] = 0;
            }
            person.PersonID = enroll_id;
            person.KQOption = 6;
            person.Group    = 1;

            final_status = AnvizNew.CKT_ModifyPersonInfo(device_id, ref person);

            // NOTE: Below section has been commented on purpose. Please uncomment after adding the code for LOGGING errors.

            /*switch (final_status) {
             *
             * case 1:
             * case -1:
             * default:
             *  //TODO: Add logic for LOGGING here.
             *  break;
             * }*/
        }

        return(final_status);
    }
Exemplo n.º 2
0
    private int ModifyPersonInfoLAN(int enroll_id, int device_id, string device_ip, long card_string, string password, string employee_name)
    {
        AnvizNew.PERSONINFO person        = new AnvizNew.PERSONINFO();
        DBConnection        db_connection = new DBConnection();

        byte[] nms = Encoding.ASCII.GetBytes(password);
        byte[] pss = Encoding.Default.GetBytes(employee_name);
        int    status = 1, card_number, final_status = 0, i = 0;
        long   card_long = 0;
        bool   is_admin  = false;
        string query     = string.Empty;

        status = AnvizNew.CKT_RegisterNet(device_id, device_ip);
        if (status == 1)
        {
            if (card_string > 0)
            {
                card_long = Convert.ToInt64(card_string);
            }
            else
            {
                card_long = 0;
            }
            if (card_long > 2147483647)
            {
                card_long   = card_long - 4294967296;
                card_number = Convert.ToInt32(card_long);
            }
            else
            {
                card_number = Convert.ToInt32(card_long);
            }

            person.CardNo = card_number;
            person.Name   = new byte[12];

            for (i = 0; i < 12; i++)
            {
                if (i < pss.Length)
                {
                    person.Name[i] = pss[i];
                    continue;
                }
                person.Name[i] = 0;
            }

            person.Password = new byte[8];
            for (i = 0; i < 8; i++)
            {
                if (i < nms.Length)
                {
                    person.Password[i] = nms[i];
                    continue;
                }
                person.Password[i] = 0;
            }
            person.PersonID = enroll_id;
            person.KQOption = 6;
            person.Group    = 1;

            query = "select count(*) from Admin where EnrollId = " + enroll_id + " and Deviceid = " + device_id + " ";
            if (db_connection.RecordExist(query))
            {
                is_admin = true;
            }

            if (is_admin == false)
            {
                final_status = AnvizNew.CKT_ModifyPersonInfo(device_id, ref person);
            }

            // NOTE: Below section has been commented on purpose. Please uncomment after adding the code for LOGGING errors.

            /*switch (final_status) {
             *
             * case 1:
             * case -1:
             * default:
             *  //TODO: Add logic for LOGGING here.
             *  break;
             * }*/
        }

        return(final_status);
    }