Ejemplo n.º 1
0
    public static ReturnObject getEnrollmentData()
    {
        lan_upload   page_object     = new lan_upload();
        DBConnection db_connection   = new DBConnection();
        DataTable    device_data     = new DataTable();
        DataTable    enrollment_data = new DataTable();
        ReturnObject return_object   = new ReturnObject();
        string       device_type     = string.Empty;
        string       query           = string.Empty;

        try {
            query       = "select devicetype from devicetype";
            device_data = db_connection.ReturnDataTable(query);

            device_type = device_data.Rows[0]["devicetype"].ToString();

            if (device_type == "Anviz")
            {
                page_object.prepareEnrollmentData();
                enrollment_data = page_object.getAnvizEnrollmentData();
            }
            else if (device_type == "BioSecurity")
            {
                enrollment_data = page_object.getBioSecurityEnrollmentData();
            }

            return_object.status      = "success";
            return_object.return_data = JsonConvert.SerializeObject(enrollment_data, Formatting.Indented);
        }
        catch (Exception ex) {
            Logger.LogException(ex, page, "GET_ENROLLMENT_DATA");

            return_object.status      = "error";
            return_object.return_data = "An error occurred while loading Enrollment Data. Please try again. If the error persists, please contact Support.";
        }

        return(return_object);
    }
Ejemplo n.º 2
0
    public static ReturnObject uploadTemplates(string employees, string devices)
    {
        lan_upload   page_object        = new lan_upload();
        JArray       device_list        = new JArray();
        DBConnection db_connection      = new DBConnection();
        ReturnObject return_object      = new ReturnObject();
        string       device_ip          = string.Empty;
        string       device_type        = string.Empty;
        string       communication_type = string.Empty;
        string       query        = string.Empty;
        bool         is_connected = false;
        int          device_id    = 0;
        int          status       = 0;
        int          i            = 0;

        try {
            device_list = JArray.Parse(devices);

            for (i = 0; i < device_list.Count; i++)
            {
                device_id          = Convert.ToInt32(device_list[i]["deviceid"]);
                device_ip          = device_list[i]["deviceip"].ToString();
                device_type        = device_list[i]["devicetype"].ToString();
                communication_type = device_list[i]["communation"].ToString();

                switch (device_type)
                {
                case "Anviz":
                    status = page_object.connectanvizdevice(device_id, device_ip, communication_type);
                    if (status != 0)
                    {
                        page_object.uploadFingerPrint(device_id, device_ip, communication_type, employees);

                        return_object.status      = "success";
                        return_object.return_data = "Templates uploaded successfully!";
                    }
                    else
                    {
                        return_object.status      = "error";
                        return_object.return_data = "Unable to communicate with the Device. Please try again.";
                    }
                    break;

                case "BioSecurity":
                    is_connected = axCZKEM1.Connect_Net(device_ip, Convert.ToInt32(4370));
                    if (is_connected == true)
                    {
                        page_object.uploadCard_Face(device_id, device_ip, employees);

                        return_object.status      = "success";
                        return_object.return_data = "Templates uploaded successfully!";
                    }
                    else
                    {
                        return_object.status      = "error";
                        return_object.return_data = "Unable to communicate with the Device. Please try again.";
                    }
                    break;
                }
            }
        }
        catch (Exception ex) {
            Logger.LogException(ex, page, "LAN_UPLOAD_TEMPLATES");

            return_object.status      = "error";
            return_object.return_data = "An error occurred while Uploading Templates to the Devices. Please try again. If the error persists, please contact Support.";
        }

        return(return_object);
    }