public bool SyncTime() { bool result = false; MyLogger.GetInstance.Info("ZKDevice.SyncTime() Device IP: " + this.Device.IP); MyLogger.GetInstance.Info("ZKDevice.SyncTime() - The process for Sync devices is currently running"); ConnectDevice(); if (bIsConnected) { int idwErrorCode = 0; //this line get the local time and update the biometric device if (axCZKEM1.SetDeviceTime(iMachineNumber)) { MyLogger.GetInstance.Debug("ZKDevice.SyncTime() - Syncing ZK devices at " + DateTime.Now); if (axCZKEM1.RefreshData(iMachineNumber)) //the data in the device should be refreshed { MyLogger.GetInstance.Debug("ZKDevice.SyncTime() - 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; result = true; try { if (axCZKEM1.GetDeviceTime(iMachineNumber, ref idwYear, ref idwMonth, ref idwDay, ref idwHour, ref idwMinute, ref idwSecond))//show the time { var device = context.Devices.Find(Device.DeviceId); device.SyncDate = DateTime.Parse(idwYear.ToString() + "-" + idwMonth.ToString() + "-" + idwDay.ToString() + " " + idwHour.ToString() + ":" + idwMinute.ToString() + ":" + idwSecond.ToString()); //var device = context.Devices.Find(de) context.Entry(device).State = EntityState.Modified; context.SaveChanges(); } } catch (Exception e) { MyLogger.GetInstance.Error("ZKDevice.SyncTime() - Sync operation failed ", e); } } else { axCZKEM1.GetLastError(ref idwErrorCode); MyLogger.GetInstance.Error("ZKDevice.SyncTime() - Sync operation failed, ErrorCode=" + idwErrorCode.ToString()); } } DisconnectDevice(); return(result); }