Exemplo n.º 1
0
    public int connectanvizdevice(int device_id, string device_ip, string communication_type)
    {
        int status = 0;

        switch (communication_type)
        {
        case "LAN":
            if (AnvizNew.CKT_ChangeConnectionMode(0) != 1)
            {
            }
            status = AnvizNew.CKT_RegisterNet(device_id, device_ip);
            break;

        case "WAN":
            int pLongRun = new int();
            if (AnvizNew.CKT_ChangeConnectionMode(1) != 1)
            {
            }
            status = AnvizNew.CKT_NetDaemonWithPort(5010);
            if (status == 1)
            {
                Thread.Sleep(5000);
                status = AnvizNew.CKT_GetClockingRecordEx(device_id, ref pLongRun);
            }
            break;

        case "USB":
            if (AnvizNew.CKT_ChangeConnectionMode(0) != 1)
            {
            }
            status = AnvizNew.CKT_RegisterUSB(device_id, 0);
            break;

        case "DNS":
            if (AnvizNew.CKT_ChangeConnectionMode(0) != 1)
            {
            }
            IPAddress[] addresslist = Dns.GetHostAddresses(device_ip);
            device_ip = Convert.ToString(addresslist[0]);
            status    = AnvizNew.CKT_RegisterNet(device_id, device_ip);
            break;
        }

        return(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);
    }