0% found this document useful (0 votes)
26 views

Bio Auto Time Sync Script

This C# code reads an XML file containing a list of IP addresses. It then connects to each IP address and performs operations on the connected device. For each IP address, it connects to the device, writes out whether the connection was successful, and calls the ConnectHeadOffice method to set the device time and sync it with the PC. The ConnectHeadOffice method connects to the device, sets the device time if possible, refreshes the device data, and gets the current device time.

Uploaded by

itteamdd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Bio Auto Time Sync Script

This C# code reads an XML file containing a list of IP addresses. It then connects to each IP address and performs operations on the connected device. For each IP address, it connects to the device, writes out whether the connection was successful, and calls the ConnectHeadOffice method to set the device time and sync it with the PC. The ConnectHeadOffice method connects to the device, sets the device time if possible, refreshes the device data, and gets the current device time.

Uploaded by

itteamdd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

public static void Main(string[] args)

DataSet ds = new DataSet();


ds.ReadXml("Listofipaddress.xml");

foreach (DataRow dr in ds.Tables[0].Rows)


{
Console.WriteLine(dr[0].ToString());
ConnectHeadOffice(dr[0].ToString());
}

Console.ReadLine();

public static void ConnectIP(string ip)


{
zkemkeeper.CZKEM axCZKEM1 = new zkemkeeper.CZKEM();

bool bIsConnected = axCZKEM1.Connect_Net(ip, 4370); // 4370 is port no of


attendance machine
// try
// {
if (bIsConnected == true)
{

Console.WriteLine("Device connected successfully");


Console.WriteLine(bIsConnected);
// Console.ReadLine();
}
else
{
Console.WriteLine("Device Not Connect");
//Console.ReadLine();
}

public static void ConnectHeadOffice(string ip)


{
zkemkeeper.CZKEM axCZKEM1 = new zkemkeeper.CZKEM();
bool bIsConnected = axCZKEM1.Connect_Net(ip, 4370);
int iMachineNumber = 1;
int idwErrorCode = 0;

if (bIsConnected == false)
{
Console.Write("Please connect the device first");
return;
}

//Cursor = Cursors.WaitCursor;
if (axCZKEM1.SetDeviceTime(iMachineNumber))
{
axCZKEM1.RefreshData(iMachineNumber);//the data in the device should be
refreshed
Console.Write("Successfully set the time of the machine and the
terminal to sync PC!");
int idwYear = 0;
int idwMonth = 0;
int idwDay = 0;
int idwHour = 0;
int idwMinute = 0;
int idwSecond = 0;
if (axCZKEM1.GetDeviceTime(iMachineNumber, ref idwYear, ref idwMonth, ref
idwDay, ref idwHour, ref idwMinute, ref idwSecond))//show the time
{
//txtGetDeviceTime.Text = idwYear.ToString() + "-" +
idwMonth.ToString() + "-" + idwDay.ToString() + " " + idwHour.ToString() + ":" +
idwMinute.ToString() + ":" + idwSecond.ToString();

}
else
{
axCZKEM1.GetLastError(ref idwErrorCode);
Console.Write("Operation failed,ErrorCode=" + idwErrorCode.ToString());
}
// Cursor = Cursors.De
}

You might also like