public ICollection <MachineInfo> ReadMachineData(string machineId, string status, string ipAddress, int port, DateTime fromDate, DateTime toDate) { IList <MachineInfo> listAttandance = new List <MachineInfo>(); { try { List <TimeConfigSettings> timeConfigSettings = new List <TimeConfigSettings>(); TimeConfigSettings _timeConfigSettings = new TimeConfigSettings(); timeConfigSettings = GetDynamic(" where IP = " + "'" + ipAddress + "'"); _timeConfigSettings = timeConfigSettings[0]; DateTime fromDate2 = _timeConfigSettings.LastUpdateTime; if (status.Trim() == "Device Is Online") { objZkeeper = new ZkemClient(); bool IsDeviceConnected = objZkeeper.Connect_Net(ipAddress, port); if (IsDeviceConnected) { ICollection <MachineInfo> lstMachineInfo = manipulator.GetLogData(objZkeeper, int.Parse(machineId.Trim())); if (lstMachineInfo != null && lstMachineInfo.Count > 0) { DateTime fromDate1 = DateTime.Parse(fromDate.ToString("yyyy-MM-dd")); DateTime fromDate3 = DateTime.Parse(fromDate2.ToString("yyyy-MM-dd")); DateTime toDate1 = Convert.ToDateTime(toDate.ToString("yyyy-MM-dd")); var myQuery = from p in lstMachineInfo where p.PunchDate > fromDate2 //&& p.PunchDate <= toDate1 orderby p.EmployeeID select p; if (myQuery.ToList <MachineInfo>().Count > 0) { listAttandance = myQuery.ToList <MachineInfo>(); } else { listAttandance = null; } } else { listAttandance = null; } } else { listAttandance = null; } } } catch (Exception ex) { // MessageBox.Show(ex.Message); } } return(listAttandance); }
static ICollection <MachineInfo> GetMachineLog(DeviceManipulator manipulator, ZkemClient objZkeeper) { var machineLogs = new List <MachineInfo>(); try { machineLogs = manipulator.GetLogData(objZkeeper, 1).ToList(); machineLogs = machineLogs.Where(i => i.DateOnlyRecord.Date >= DateTime.Now.Date && i.DateOnlyRecord.Date <= DateTime.Now.Date).ToList(); } catch (Exception ex) { WriteToErrorLog("Something wrong with GetMachineLog()", ex.ToString()); } return(machineLogs); }