//Getting Today's Log Data public ICollection <MachineInfo> GetTodayLogData(ZkemClient objZkeeper, int machineNumber) { string dwEnrollNumber1 = ""; int dwVerifyMode = 0; int dwInOutMode = 0; int dwYear = 0; int dwMonth = 0; int dwDay = 0; int dwHour = 0; int dwMinute = 0; int dwSecond = 0; int dwWorkCode = 0; ICollection <MachineInfo> lstEnrollData = new List <MachineInfo>(); objZkeeper.ReadAllGLogData(machineNumber); while (objZkeeper.SSR_GetGeneralLogData(machineNumber, out dwEnrollNumber1, out dwVerifyMode, out dwInOutMode, out dwYear, out dwMonth, out dwDay, out dwHour, out dwMinute, out dwSecond, ref dwWorkCode)) { string inputDate = new DateTime(dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond).ToString(); DateTime dt = DateTime.Now; dt = DateTime.Parse(dt.ToString("yyyy-MM-dd")); MachineInfo objInfo = new MachineInfo(); //objInfo.MachineNumber = machineNumber; objInfo.EmployeeID = int.Parse(dwEnrollNumber1); objInfo.DateTimeRecord = inputDate; objInfo.InOut = dwInOutMode + ""; DateTime dt_compare = DateTime.Parse(DateTime.Parse(inputDate).ToString("yyyy-MM-dd")); if (dt == dt_compare) { lstEnrollData.Add(objInfo); } } return(lstEnrollData); }
// Filtering Data from Synced Table public ICollection <MachineInfo> GetFilteredData(ZkemClient objZkeeper, int machineNumber, DateTime dt) { string dwEnrollNumber1 = ""; int dwVerifyMode = 0; int dwInOutMode = 0; int dwYear = 0; int dwMonth = 0; int dwDay = 0; int dwHour = 0; int dwMinute = 0; int dwSecond = 0; int dwWorkCode = 0; ICollection <MachineInfo> lstEnrollData = new List <MachineInfo>(); objZkeeper.ReadAllGLogData(machineNumber); while (objZkeeper.SSR_GetGeneralLogData(machineNumber, out dwEnrollNumber1, out dwVerifyMode, out dwInOutMode, out dwYear, out dwMonth, out dwDay, out dwHour, out dwMinute, out dwSecond, ref dwWorkCode)) { string inputDate = new DateTime(dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond).ToString(); // String.Format("{0:MM/dd/yyyy}", dt); DateTime date = new DateTime(dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond); DateTime dateCompare = new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second); MachineInfo objInfo = new MachineInfo(); //objInfo.MachineNumber = machineNumber; objInfo.EmployeeID = int.Parse(dwEnrollNumber1); objInfo.DateTimeRecord = inputDate; objInfo.InOut = dwInOutMode + ""; if ((dateCompare <= date)) { lstEnrollData.Add(objInfo); } } return(lstEnrollData); }
//public bool ClearGLog(ZkemClient objZkeeper, int machineNumber) public ICollection <MachineInfo> GetLogData(ZkemClient objZkeeper, int machineNumber) { string dwEnrollNumber1 = ""; int dwVerifyMode = 0; int dwInOutMode = 0; int dwYear = 0; int dwMonth = 0; int dwDay = 0; int dwHour = 0; int dwMinute = 0; int dwSecond = 0; int dwWorkCode = 0; ICollection <MachineInfo> lstEnrollData = new List <MachineInfo>(); objZkeeper.ReadAllGLogData(machineNumber); try { var SL = GetSerialNumber(objZkeeper, machineNumber); while (objZkeeper.SSR_GetGeneralLogData(machineNumber, out dwEnrollNumber1, out dwVerifyMode, out dwInOutMode, out dwYear, out dwMonth, out dwDay, out dwHour, out dwMinute, out dwSecond, ref dwWorkCode)) { string inputDate = new DateTime(dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond).ToString(); MachineInfo objInfo = new MachineInfo(); objInfo.MachineNumber = machineNumber; objInfo.IndRegID = int.Parse(dwEnrollNumber1); objInfo.DateTimeRecord = inputDate; objInfo.SerialNumber = SL; lstEnrollData.Add(objInfo); } } catch (Exception ex) { } return(lstEnrollData); }
public ICollection <MachineInfo> GetLogData(ZkemClient objZkeeper, int machineNumber) { string dwEnrollNumber1 = ""; int dwVerifyMode = 0; int dwInOutMode = 0; int dwYear = 0; int dwMonth = 0; int dwDay = 0; int dwHour = 0; int dwMinute = 0; int dwSecond = 0; int dwWorkCode = 0; ICollection <MachineInfo> lstEnrollData = new List <MachineInfo>(); objZkeeper.ReadAllGLogData(machineNumber); cnx.Open(); SqlCommand cmd2 = new SqlCommand("select * from atdrecord", cnx); SqlDataReader dr = cmd2.ExecuteReader(); DataTable tb = new DataTable(); tb.Load(dr); while (objZkeeper.SSR_GetGeneralLogData(machineNumber, out dwEnrollNumber1, out dwVerifyMode, out dwInOutMode, out dwYear, out dwMonth, out dwDay, out dwHour, out dwMinute, out dwSecond, ref dwWorkCode)) { string inputDate = new DateTime(dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond).ToString(); string recDate = dwYear + "-" + dwMonth + "-" + dwDay, recTime = dwHour + ":" + dwMinute + ":" + dwSecond; string RecDate2 = dwYear + "-" + dwMonth + "-" + dwDay + ' ' + dwHour + ":" + dwMinute + ":" + dwSecond; DateTime dateP = new DateTime(dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond); // DateTime d = new DateTime(0,0,0,dwHour, dwMinute, dwSecond); MachineInfo objInfo = new MachineInfo(); objInfo.MachineNumber = machineNumber; objInfo.IndRegID = int.Parse(dwEnrollNumber1); objInfo.DateTimeRecord = inputDate; // MessageBox.Show(d.ToShortTimeString()); if (cnx.State == ConnectionState.Open) { if (tb.Rows.Count == 0) { DateTime datetime = DateTime.ParseExact(RecDate2, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); cmd = new SqlCommand("insert into AtdRecord values('" + datetime.ToShortDateString() + "','" + datetime.ToShortTimeString() + "','" + datetime + "','" + dwEnrollNumber1 + "')", cnx); cmd.ExecuteNonQuery(); } else { bool b = true; for (int i = 0; i < tb.Rows.Count; i++) { if ((tb.Rows[i][2].ToString() == dwEnrollNumber1.ToString() && tb.Rows[i][5].ToString() == inputDate.ToString())) { b = false; } } if (b) { //cmd = new SqlCommand("insert into AtdRecord values('" + dwVerifyMode + "','" + dwEnrollNumber1 + "','" + recDate + "','" + recTime + "','" + RecDate2 + "')", cnx); cmd = new SqlCommand("insert into AtdRecord values('" + datetime.ToShortDateString() + "','" + datetime.ToShortTimeString() + "','" + datetime + "','" + dwEnrollNumber1 + "')", cnx); cmd.ExecuteNonQuery(); cmd2 = new SqlCommand("select * from AtdRecord", cnx); dr = cmd2.ExecuteReader(); tb = new DataTable(); tb.Load(dr); } } } else { } lstEnrollData.Add(objInfo); } cnx.Close(); return(lstEnrollData); }
private Boolean GetLogsToMySql(Combination combination) { Device device = combination.device; ZkemClient objZkeeper = combination.objZkeeper; Boolean status = false; if (device.status) { try { ShowStatusBar(string.Empty, true); ICollection <MachineInfo> lstMachineInfo = manipulator.GetLogData(objZkeeper, int.Parse(device.DeviceId)); if (lstMachineInfo != null && lstMachineInfo.Count > 0) { Boolean clearedLog = false; ShowStatusBar(device.IP + " -> " + lstMachineInfo.Count + " records found !!", true); Console.WriteLine("---"); Console.WriteLine(lstMachineInfo.Count); IEnumerator enumerator = lstMachineInfo.GetEnumerator(); string theCommand = "INSERT INTO log (MachineNumber, IndRegID, DateTimeRecord ) VALUES "; int count = 0; while (enumerator.MoveNext()) { MachineInfo item = (MachineInfo)enumerator.Current; theCommand += "('" + item.MachineNumber + "', '" + item.IndRegID + "', '" + item.DateTimeRecord + "')"; count++; if (count < lstMachineInfo.Count) { theCommand += ", "; } } Console.WriteLine(theCommand); MySqlCommand command = conn.CreateCommand(); command.CommandText = theCommand; Boolean mysqlInsertSuccess = false; try { int o = command.ExecuteNonQuery(); mysqlInsertSuccess = true; } catch (Exception ex) { Console.WriteLine(ex); mysqlInsertSuccess = false; } if (mysqlInsertSuccess) { clearedLog = manipulator.ClearGLog(objZkeeper, int.Parse(device.DeviceId)); } status = true; } else { DisplayListOutput("No records found"); status = false; } } catch (Exception ex) { DisplayListOutput(ex.Message); } } return(status); }
private Boolean GetLogsToMySql(Combination combination) { Device device = combination.device; ZkemClient objZkeeper = combination.objZkeeper; Boolean status = false; if (device.status) { Console.WriteLine("Getting logs for Device at: " + device.IP); try { ICollection <MachineInfo> lstMachineInfo = manipulator.GetLogData(objZkeeper, int.Parse(device.DeviceId)); if (lstMachineInfo != null && lstMachineInfo.Count > 0) { Boolean clearedLog = false; Console.WriteLine(lstMachineInfo.Count); IEnumerator enumerator = lstMachineInfo.GetEnumerator(); string theCommand = "INSERT INTO logs (machine_number, ind_reg_id, date_time_record ) VALUES "; int count = 0; while (enumerator.MoveNext()) { MachineInfo item = (MachineInfo)enumerator.Current; theCommand += "('" + item.MachineNumber + "', '" + item.IndRegID + "', '" + item.DateTimeRecord + "')"; count++; if (count < lstMachineInfo.Count) { theCommand += ", "; } } // Console.WriteLine(theCommand); MySqlCommand command = conn.CreateCommand(); command.CommandText = theCommand; Boolean mysqlInsertSuccess = false; try { int o = command.ExecuteNonQuery(); mysqlInsertSuccess = true; } catch (Exception ex) { Console.WriteLine(ex); mysqlInsertSuccess = false; } if (mysqlInsertSuccess) { clearedLog = manipulator.ClearGLog(objZkeeper, int.Parse(device.DeviceId)); } status = true; } else { Console.WriteLine("changes 0"); status = false; } } catch (Exception ex) { Console.WriteLine(ex); } } return(status); }
private void btnPullData_Click(object sender, EventArgs e) { try { // string connetionString = null; //MySqlConnection cnn; //connetionString = "server=localhost;port=3306;database=rashmi;uid=root;pwd=;"; //cnn = new MySqlConnection(connetionString); //cnn.Open(); // ICollection<MachineInfo> lstMachineInfo = manipulator.GetLogData(objZkeeper, int.Parse(tbxMachineNumber.Text.Trim())); int dwEnrollNumber = 0; int dwEMachineNumber = 0; int dwTMachineNumber = 0; int dwVerifyMode = 0; int dwInOutMode = 0; int dwYear = 0; int dwMonth = 0; int dwDay = 0; int dwHour = 0; int dwMinute = 0; int dwSecond = 0; // int dwWorkCode = 0; int dwMachineNumber = int.Parse(tbxMachineNumber.Text.Trim()); ICollection <MachineInfo> lstEnrollData = new List <MachineInfo>(); objZkeeper.ReadGeneralLogData(dwMachineNumber); // while (objZkeeper.SSR_GetGeneralLogData(dwMachineNumber, out dwEnrollNumber, out dwVerifyMode, out dwInOutMode, out dwYear, out dwMonth, out dwDay, out dwHour, out dwMinute, out dwSecond, ref dwWorkCode)) while (objZkeeper.GetGeneralLogData(dwMachineNumber, ref dwTMachineNumber, ref dwEnrollNumber, ref dwEMachineNumber, ref dwVerifyMode, ref dwInOutMode, ref dwYear, ref dwMonth, ref dwDay, ref dwHour, ref dwMinute)) { c++; string inputDate = new DateTime(dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond).ToString(); MachineInfo objInfo = new MachineInfo(); objInfo.MachineNumber = dwMachineNumber; objInfo.UserID = dwEnrollNumber; objInfo.Mode = dwInOutMode; objInfo.DateTimeRecord = inputDate; using (var client = new WebClient()) { var responseStr = client.DownloadString("http://www.drbawasakar.com/ras.php?UserId=" + dwEnrollNumber + "&DateTime=" + inputDate + ""); } // string Query = "insert into biometric(machine_num,user_id,inout_mode,date_time)values('" + dwMachineNumber + "','" + dwEnrollNumber + "','" + dwInOutMode + "','" + objInfo.DateTimeRecord + "');"; //MySqlCommand MyCommand = new MySqlCommand(Query, cnn); lstEnrollData.Add(objInfo); } BindToGridView(lstEnrollData); //MessageBox.Show("Save Data"); // cnn.Close(); if (lstEnrollData.Count > 0) { // BindToGridView(lstMachineInfo); ShowStatusBar(lstEnrollData.Count + " records found !!", true); } else { DisplayListOutput("No records found"); } } catch (Exception ex) { DisplayListOutput(ex.Message); } }