GetDeviceData

Definition

Usage

The function is used to read the device data (for example, the punch records, time segment, user information, and holiday information). The data can be one or multiple records.

Parameter

[in]: The handle that is returned when the connection is successful.

[in]: The buffer used to receive the returned data; the returned data is expressed in a text format;

if the returned data is multiple records, the multiple records are separated by \r\n.

[in] The size of the buffer used to receive the returned data.

[in]: Data table name. Attached table 4 lists the available data tables.

[in]: Field name list; the multiple fields are separated by semicolons; * indicates all fields,

and the first line in the returned data field is the field names.

[in]: The conditions of reading the data; the character string in the format of “field name, operator, value” can support multiple conditions,

which are separated by commas; for example: =(no space is allowed at two sides of =)

[in]: Only used to download data of the access control records event effectively at present;

when the parameter value is New Record, new records are downloaded. When the value is null, all records are downloaded.

When download the other table data, this field can set to an empty string.

Return Value

When the returned value is 0 or a positive value, it indicates that the operation is successful

(the returned value indicates the number of records). When the returned value is a negative value,

it indicates that the operation fails. Attached table 5 lists the information about the error codes.

Related Function

DeleteDeviceData

 

Ejemplo

C#

        
[DllImport("plcommpro.dll", EntryPoint = "GetDeviceData")]
public static extern int GetDeviceData(IntPtr h, ref byte buffer, int buffersize, string tablename, string filename, string filter, string options);
public void GetDeviceData_Pull()
{
	Connect_Pull();
        int ret = 0;
        int BUFFERSIZE = 1 * 1024 * 1024;
        byte[] buffer = new byte[BUFFERSIZE];
        string str = "CardNo\tPin\tPassword\tGroup\tStartTime\tEndTime";
        if (IntPtr.Zero != h)
		ret = GetDeviceData(h, ref buffer[0], BUFFERSIZE, "user", str, "", "");
        else
	{
		MessageBox.Show("Connect device failed!");
        return;
	}
	str = Encoding.Default.GetString(buffer);
        if (ret >= 0)
		MessageBox.Show("Get " + ret + " records");
        else
	{
		MessageBox.Show("Get data failed.The error is " + ret);
        return;
	}
	Disconnect_pull();
}

VB

    Public Sub GetDeviceData_Pull()
	    Connect_Pull()
            Dim ret As Integer = 0
            Dim BUFFERSIZE As Integer = 1 * 1024 * 1024
            Dim buffer As Byte() = New Byte(BUFFERSIZE - 1) {}
            Dim str As String = "CardNo" & vbTab & "Pin" & vbTab & "Password" & vbTab & "Group" & vbTab & "StartTime" & vbTab & "EndTime"
            If IntPtr.Zero <> h Then
		    ret = GetDeviceData(h, buffer(0), BUFFERSIZE, "user", str, "",
            "")
            Else
		    MessageBox.Show("Connect device failed!")
            Return
            End If
	    str = Encoding.[Default].GetString(buffer)
            If ret >= 0 Then
		    MessageBox.Show("Get " + ret + " records")
            Else
		    MessageBox.Show("Get data failed.The error is " + ret)
            Return
            End If
	    Disconnect_pull()
    End Sub