private int ModifyPersonInfoUSB(int enroll_id, int device_id) { AnvizNew.PERSONINFO person = new AnvizNew.PERSONINFO(); byte[] nms = Encoding.ASCII.GetBytes(""); byte[] pss = Encoding.Default.GetBytes(""); int final_status = 0, status = 0, i = 0; int pLongRun = new int(); if (AnvizNew.CKT_ChangeConnectionMode(0) != 1) { } status = AnvizNew.CKT_RegisterUSB(device_id, 0); if (status != 0) { person.CardNo = 5216455; person.Name = new byte[12]; for (i = 0; i < 12; i++) { if (i < pss.Length) { person.Name[i] = pss[i]; continue; } person.Name[i] = 0; } person.Password = new byte[8]; for (i = 0; i < 8; i++) { if (i < nms.Length) { person.Password[i] = nms[i]; continue; } person.Password[i] = 0; } person.PersonID = enroll_id; person.KQOption = 6; person.Group = 1; final_status = AnvizNew.CKT_ModifyPersonInfo(device_id, ref person); // NOTE: Below section has been commented on purpose. Please uncomment after adding the code for LOGGING errors. /*switch (final_status) { * * case 1: * case -1: * default: * //TODO: Add logic for LOGGING here. * break; * }*/ } return(final_status); }
private int ModifyPersonInfoDNS(int enroll_id, int device_id, string device_ip, long card_string, string password, string employee_name) { int final_status = 0; string temp_device_ip = device_ip; if (AnvizNew.CKT_ChangeConnectionMode(0) != 1) { } System.Net.IPAddress[] addresslist = System.Net.Dns.GetHostAddresses(temp_device_ip); device_ip = Convert.ToString(addresslist[0]); final_status = ModifyPersonInfoLAN(enroll_id, device_id, device_ip, card_string, password, employee_name); return(final_status); }
public int connectanvizdevice(int device_id, string device_ip, string communication_type) { int status = 0; switch (communication_type) { case "LAN": if (AnvizNew.CKT_ChangeConnectionMode(0) != 1) { } status = AnvizNew.CKT_RegisterNet(device_id, device_ip); break; case "WAN": int pLongRun = new int(); if (AnvizNew.CKT_ChangeConnectionMode(1) != 1) { } status = AnvizNew.CKT_NetDaemonWithPort(5010); if (status == 1) { Thread.Sleep(5000); status = AnvizNew.CKT_GetClockingRecordEx(device_id, ref pLongRun); } break; case "USB": if (AnvizNew.CKT_ChangeConnectionMode(0) != 1) { } status = AnvizNew.CKT_RegisterUSB(device_id, 0); break; case "DNS": if (AnvizNew.CKT_ChangeConnectionMode(0) != 1) { } IPAddress[] addresslist = Dns.GetHostAddresses(device_ip); device_ip = Convert.ToString(addresslist[0]); status = AnvizNew.CKT_RegisterNet(device_id, device_ip); break; } return(status); }
private void uploadFingerPrint(int device_id, string device_ip, string communication_type, string employees) { JArray employees_list = new JArray(); string[] path = new string[10]; int[] file = new int[10]; int[] device_status = new int[10]; long card_string = 0; string employee_name = string.Empty, password = string.Empty; int enroll_id = 0, status = 0, i, j; try { employees_list = JArray.Parse(employees); for (i = 0; i < employees_list.Count; i++) { password = string.Empty; card_string = 0; enroll_id = Convert.ToInt32(employees_list[i]["Enrollid"]); if (!string.IsNullOrEmpty(employees_list[i]["Cardid"].ToString())) { card_string = Convert.ToInt64(employees_list[i]["Cardid"]); } if (!string.IsNullOrEmpty(employees_list[i]["pin"].ToString())) { password = employees_list[i]["pin"].ToString(); } if (!string.IsNullOrEmpty(employees_list[i]["Name"].ToString())) { employee_name = employees_list[i]["Name"].ToString(); } switch (communication_type) { case "LAN": status = ModifyPersonInfoLAN(enroll_id, device_id, device_ip, card_string, password, employee_name); break; case "DNS": status = ModifyPersonInfoDNS(enroll_id, device_id, device_ip, card_string, password, employee_name); break; case "USB": status = ModifyPersonInfoUSB(enroll_id, device_id); break; } if (status == 1) { string pat = ConfigurationManager.AppSettings["FingerPrintLocation"]; if (!Directory.Exists(pat)) { Directory.CreateDirectory(pat); } path[0] = pat + enroll_id + ".anv"; for (j = 1; j < path.Length; j++) { path[j] = pat + enroll_id + "_" + j + ".anv"; } file[0] = Convert.ToInt32(Directory.GetFiles(pat, enroll_id + ".anv", SearchOption.TopDirectoryOnly).Length); for (j = 1; j < file.Length; j++) { file[j] = Convert.ToInt32(Directory.GetFiles(pat, enroll_id.ToString() + "_" + j + ".anv", SearchOption.TopDirectoryOnly).Length); } for (j = 0; j < file.Length; j++) { if (file[j] == 1) { device_status[j] = AnvizNew.CKT_PutFPTemplateLoadFile(device_id, enroll_id, j, path[j]); // TODO: Add logic for LOGGING the return value of the above statement } else { // TODO: Add logic for LOGGING. } } } } } catch (Exception ex) { // TODO: Add logic for LOGGING. throw; } }
private int ModifyPersonInfoLAN(int enroll_id, int device_id, string device_ip, long card_string, string password, string employee_name) { AnvizNew.PERSONINFO person = new AnvizNew.PERSONINFO(); DBConnection db_connection = new DBConnection(); byte[] nms = Encoding.ASCII.GetBytes(password); byte[] pss = Encoding.Default.GetBytes(employee_name); int status = 1, card_number, final_status = 0, i = 0; long card_long = 0; bool is_admin = false; string query = string.Empty; status = AnvizNew.CKT_RegisterNet(device_id, device_ip); if (status == 1) { if (card_string > 0) { card_long = Convert.ToInt64(card_string); } else { card_long = 0; } if (card_long > 2147483647) { card_long = card_long - 4294967296; card_number = Convert.ToInt32(card_long); } else { card_number = Convert.ToInt32(card_long); } person.CardNo = card_number; person.Name = new byte[12]; for (i = 0; i < 12; i++) { if (i < pss.Length) { person.Name[i] = pss[i]; continue; } person.Name[i] = 0; } person.Password = new byte[8]; for (i = 0; i < 8; i++) { if (i < nms.Length) { person.Password[i] = nms[i]; continue; } person.Password[i] = 0; } person.PersonID = enroll_id; person.KQOption = 6; person.Group = 1; query = "select count(*) from Admin where EnrollId = " + enroll_id + " and Deviceid = " + device_id + " "; if (db_connection.RecordExist(query)) { is_admin = true; } if (is_admin == false) { final_status = AnvizNew.CKT_ModifyPersonInfo(device_id, ref person); } // NOTE: Below section has been commented on purpose. Please uncomment after adding the code for LOGGING errors. /*switch (final_status) { * * case 1: * case -1: * default: * //TODO: Add logic for LOGGING here. * break; * }*/ } return(final_status); }
public static ReturnObject SetDeviceTime(string current) { lan_information page_object = new lan_information(); ReturnObject return_object = new ReturnObject(); string communication_type = string.Empty; string device_ip = string.Empty; string device_type = string.Empty; string device_time = string.Empty; bool is_connected = false; int idwErrorCode = 0; int idwYear = 0; int idwMonth = 0; int idwDay = 0; int idwHour = 0; int idwMinute = 0; int idwSecond = 0; int device_id = 0; int status = 0; try { JObject current_data = JObject.Parse(current); device_ip = current_data["device_ip"].ToString(); device_type = current_data["device_type"].ToString(); communication_type = current_data["communication_type"].ToString(); device_id = Convert.ToInt32(current_data["device_id"]); switch (device_type) { case "Anviz": status = page_object.ConnectAnvizDevice(device_id, device_ip, communication_type); if (status != 0) { //int ReaderNo = Convert.ToInt32(listView1.SelectedItems[0].SubItems[0].Text); AnvizNew.DATETIMEINFO PTime = new AnvizNew.DATETIMEINFO(); PTime.Year = Convert.ToUInt16(DateTime.Now.Year); PTime.Month = Convert.ToByte(DateTime.Now.Month); PTime.Day = Convert.ToByte(DateTime.Now.Day); PTime.Hour = Convert.ToByte(DateTime.Now.Hour); PTime.Minute = Convert.ToByte(DateTime.Now.Minute); PTime.Second = Convert.ToByte(DateTime.Now.Second); if (AnvizNew.CKT_SetDeviceClock(device_id, ref PTime) == 1) { device_time = PTime.Year.ToString() + "-" + (PTime.Month).ToString("00") + "-" + (PTime.Day).ToString("00") + " " + (PTime.Hour).ToString("00") + ":" + (PTime.Minute).ToString("00") + ":" + (PTime.Second).ToString("00"); return_object.status = "success"; return_object.return_data = device_time; } else { return_object.status = "error"; return_object.return_data = "Setting Device Clock failed. Please try again."; } } else { return_object.status = "error"; return_object.return_data = "Unable to communicate with the Device. Please try again."; } break; case "BioSecurity": is_connected = page_object.axCZKEM1.Connect_Net(device_ip, Convert.ToInt32(4370)); if (is_connected == true) { idwErrorCode = 0; idwYear = Convert.ToInt32(DateTime.Now.Year); idwMonth = Convert.ToInt32(DateTime.Now.Month); idwDay = Convert.ToInt32(DateTime.Now.Day); idwHour = Convert.ToInt32(DateTime.Now.Hour); idwMinute = Convert.ToInt32(DateTime.Now.Minute); idwSecond = Convert.ToInt32(DateTime.Now.Second); //Cursor = Cursors.WaitCursor; if (page_object.axCZKEM1.SetDeviceTime2(device_id, idwYear, idwMonth, idwDay, idwHour, idwMinute, idwSecond)) { page_object.axCZKEM1.RefreshData(device_id); //the data in the device should be refreshed return_object.status = "success"; return_object.return_data = device_time; } else { return_object.status = "error"; return_object.return_data = "Setting Device Clock failed. Please try again."; } } else { return_object.status = "error"; return_object.return_data = "Unable to communicate with the Device. Please try again."; } page_object.axCZKEM1.Disconnect(); break; } } catch (Exception ex) { Logger.LogException(ex, page, "SET_DEVICE_TIME"); return_object.status = "error"; return_object.return_data = "An error occurred while Setting Device Clock. Please try again. If the error persists, please contact Support"; throw; } finally { page_object.Dispose(); } return(return_object); }
public static ReturnObject GetDeviceTime(string current) { lan_information page_object = new lan_information(); ReturnObject return_object = new ReturnObject(); string communication_type = string.Empty; string device_type = string.Empty; string device_ip = string.Empty; string device_time = string.Empty; bool is_connected = false; int idwErrorCode = 0; int idwYear = 0; int idwMonth = 0; int idwDay = 0; int idwHour = 0; int idwMinute = 0; int idwSecond = 0; int device_id = 0; int status = 0; try { JObject current_data = JObject.Parse(current); device_id = Convert.ToInt32(current_data["device_id"]); device_ip = current_data["device_ip"].ToString(); device_type = current_data["device_type"].ToString(); communication_type = current_data["communication_type"].ToString(); switch (device_type) { case "Anviz": status = 0; status = page_object.ConnectAnvizDevice(device_id, device_ip, communication_type); if (status != 0) { AnvizNew.DATETIMEINFO PTime = new AnvizNew.DATETIMEINFO(); if (AnvizNew.CKT_GetDeviceClock(device_id, ref PTime) == 1) { device_time = PTime.Year.ToString() + "-" + (PTime.Month).ToString("00") + "-" + (PTime.Day).ToString("00") + " " + (PTime.Hour).ToString("00") + ":" + (PTime.Minute).ToString("00") + ":" + (PTime.Second).ToString("00"); return_object.status = "success"; return_object.return_data = device_time; } else { return_object.status = "error"; return_object.return_data = "Getting Device Time failed. Please try again."; } } else { return_object.status = "error"; return_object.return_data = "Unable to communicate with the Device. Please try again."; } break; case "BioSecurity": is_connected = page_object.axCZKEM1.Connect_Net(device_ip, Convert.ToInt32(4370)); if (is_connected == true) { //Cursor = Cursors.WaitCursor; if (page_object.axCZKEM1.GetDeviceTime(device_id, ref idwYear, ref idwMonth, ref idwDay, ref idwHour, ref idwMinute, ref idwSecond)) { device_time = idwYear.ToString() + "-" + idwMonth.ToString() + "-" + idwDay.ToString() + " " + idwHour.ToString() + ":" + idwMinute.ToString() + ":" + idwSecond.ToString(); return_object.status = "success"; return_object.return_data = device_time; } else { return_object.status = "error"; return_object.return_data = "Set Device Clock failed. Please try again."; } } else { return_object.status = "error"; return_object.return_data = "Unable to communicate with the Device. Please try again."; } page_object.axCZKEM1.Disconnect(); //Cursor = Cursors.Default; break; } } catch (Exception ex) { Logger.LogException(ex, page, "GET_DEVICE_TIME"); return_object.status = "error"; return_object.return_data = "An error occurred when getting Device Time. Please try again. If the error persists, please contact Support"; } finally { page_object.Dispose(); } return(return_object); }
public static ReturnObject deleteEnrollment(string device, string employees) { lan_download page_object = new lan_download(); List <string> employees_list = JsonConvert.DeserializeObject <List <string> >(employees); DBConnection db_connection = new DBConnection(); ReturnObject return_object = new ReturnObject(); ReturnObject zk_status = new ReturnObject(); string communication_type = string.Empty; string device_ip = string.Empty; string device_type = string.Empty; string device_model = string.Empty; bool download_status = false; bool is_connected = false; int enroll_id = 0; int device_id = 0; int status = 0; int i = 0; try { JObject device_data = JObject.Parse(device); communication_type = device_data["communation"].ToString(); device_model = device_data["devicemodel"].ToString(); device_type = device_data["devicetype"].ToString(); device_ip = device_data["deviceip"].ToString(); device_id = Convert.ToInt32(device_data["deviceid"]); if (device_model == "T5") { device_id = 0; } switch (device_type) { case "Anviz": status = page_object.connectanvizdevice(device_id, device_ip, communication_type); if (status != 0) { for (i = 0; i < employees_list.Count; i++) { enroll_id = Convert.ToInt32(employees_list[i].ToString()); AnvizNew.CKT_DeletePersonInfo(device_id, enroll_id, 0xFF); download_status = true; } } else { return_object.status = "error"; return_object.return_data = "Unable to communicate with the Device. Please try again."; } break; case "BioSecurity": is_connected = axCZKEM1.Connect_Net(device_ip, Convert.ToInt32(4370)); if (is_connected == true) { for (i = 0; i < employees_list.Count; i++) { enroll_id = Convert.ToInt32(employees_list[i].ToString()); download_status = axCZKEM1.SSR_DeleteEnrollData(device_id, enroll_id.ToString(), 12); } axCZKEM1.RefreshData(device_id); axCZKEM1.Disconnect(); } else { return_object.status = "error"; return_object.return_data = "Unable to communicate with the Device. Please try again."; } break; case "Zk": zk_status = page_object.deleteZKTemplate(device, employees); if (zk_status.status == "success") { download_status = true; } else { return_object.status = "error"; return_object.return_data = "Unable to communicate with the Device. Please try again."; } break; } if (download_status) { return_object.status = "success"; return_object.return_data = "Templates deleted successfully!"; } } catch (Exception ex) { Logger.LogException(ex, page, "DELETE_ENROLLMENT"); return_object.status = "error"; return_object.return_data = "An error occurred while deleting Enrollments. Please try again. If the error persists, please contact Support."; } finally { page_object.Dispose(); } return(return_object); }
private void saveFingerPrint(int device_id, string employees) { lan_download page_object = new lan_download(); List <string> employees_list = JsonConvert.DeserializeObject <List <string> >(employees); string drive = page_object.getDrives(); string keyname = "FingerPrintLocation"; string pat = ConfigurationManager.AppSettings["FingerPrintLocation"]; string pat1 = pat.Substring(0, 3); string pat2 = pat.Substring(3); int enroll_id = 0; int i = 0; string path = string.Empty, path1 = string.Empty, path2 = string.Empty, path3 = string.Empty, path4 = string.Empty, path5 = string.Empty, path6 = string.Empty, path7 = string.Empty, path8 = string.Empty, path9 = string.Empty; int status = 0, status1 = 0, status2 = 0, status3 = 0, status4 = 0, status5 = 0, status6 = 0, status7 = 0, status8 = 0, status9 = 0; if (drive == pat1) { if (!Directory.Exists(pat)) { Directory.CreateDirectory(pat); } } else { string newdrive = drive + pat2; if (!Directory.Exists(newdrive)) { Directory.CreateDirectory(newdrive); } Configuration webConfigApp = WebConfigurationManager.OpenWebConfiguration("~"); // var section = WebConfigurationManager.GetSection("appSettings"); //webConfigApp = section as Configuration; string Key_c = keyname; string Value_c = newdrive; webConfigApp.AppSettings.Settings[Key_c].Value = Value_c; webConfigApp.Save(); } for (i = 0; i < employees_list.Count; i++) { enroll_id = Convert.ToInt32(employees_list[i]); path = pat + enroll_id + ".anv"; path1 = pat + enroll_id + "_" + 1 + ".anv"; path2 = pat + enroll_id + "_" + 2 + ".anv"; path3 = pat + enroll_id + "_" + 3 + ".anv"; path4 = pat + enroll_id + "_" + 4 + ".anv"; path5 = pat + enroll_id + "_" + 5 + ".anv"; path6 = pat + enroll_id + "_" + 6 + ".anv"; path7 = pat + enroll_id + "_" + 7 + ".anv"; path8 = pat + enroll_id + "_" + 8 + ".anv"; path9 = pat + enroll_id + "_" + 9 + ".anv"; var file = Directory.GetFiles(pat, enroll_id + ".anv", SearchOption.TopDirectoryOnly).Length; var file1 = Directory.GetFiles(pat, enroll_id + "_" + 1 + ".anv", SearchOption.TopDirectoryOnly).Length; var file2 = Directory.GetFiles(pat, enroll_id.ToString() + "_" + 2 + ".anv", SearchOption.TopDirectoryOnly).Length; var file3 = Directory.GetFiles(pat, enroll_id.ToString() + "_" + 3 + ".anv", SearchOption.TopDirectoryOnly).Length; var file4 = Directory.GetFiles(pat, enroll_id.ToString() + "_" + 4 + ".anv", SearchOption.TopDirectoryOnly).Length; var file5 = Directory.GetFiles(pat, enroll_id.ToString() + "_" + 5 + ".anv", SearchOption.TopDirectoryOnly).Length; var file6 = Directory.GetFiles(pat, enroll_id.ToString() + "_" + 6 + ".anv", SearchOption.TopDirectoryOnly).Length; var file7 = Directory.GetFiles(pat, enroll_id.ToString() + "_" + 7 + ".anv", SearchOption.TopDirectoryOnly).Length; var file8 = Directory.GetFiles(pat, enroll_id.ToString() + "_" + 8 + ".anv", SearchOption.TopDirectoryOnly).Length; var file9 = Directory.GetFiles(pat, enroll_id.ToString() + "_" + 9 + ".anv", SearchOption.TopDirectoryOnly).Length; if (file == 0) { status = AnvizNew.CKT_GetFPTemplateSaveFile(device_id, enroll_id, 0, path); if (file1 == 0) { status1 = AnvizNew.CKT_GetFPTemplateSaveFile(device_id, enroll_id, 1, path1); } if (file2 == 0) { status2 = AnvizNew.CKT_GetFPTemplateSaveFile(device_id, enroll_id, 2, path2); } if (file3 == 0) { status3 = AnvizNew.CKT_GetFPTemplateSaveFile(device_id, enroll_id, 3, path3); } if (file4 == 0) { status4 = AnvizNew.CKT_GetFPTemplateSaveFile(device_id, enroll_id, 4, path4); } if (file5 == 0) { status5 = AnvizNew.CKT_GetFPTemplateSaveFile(device_id, enroll_id, 5, path5); } if (file6 == 0) { status6 = AnvizNew.CKT_GetFPTemplateSaveFile(device_id, enroll_id, 6, path6); } if (file7 == 0) { status7 = AnvizNew.CKT_GetFPTemplateSaveFile(device_id, enroll_id, 7, path7); } if (file8 == 0) { status8 = AnvizNew.CKT_GetFPTemplateSaveFile(device_id, enroll_id, 8, path8); } if (file9 == 0) { status9 = AnvizNew.CKT_GetFPTemplateSaveFile(device_id, enroll_id, 9, path9); } } else { status = AnvizNew.CKT_GetFPTemplateSaveFile(device_id, enroll_id, 0, path); status1 = AnvizNew.CKT_GetFPTemplateSaveFile(device_id, enroll_id, 1, path1); status2 = AnvizNew.CKT_GetFPTemplateSaveFile(device_id, enroll_id, 2, path2); status3 = AnvizNew.CKT_GetFPTemplateSaveFile(device_id, enroll_id, 3, path3); status4 = AnvizNew.CKT_GetFPTemplateSaveFile(device_id, enroll_id, 4, path4); status5 = AnvizNew.CKT_GetFPTemplateSaveFile(device_id, enroll_id, 5, path5); status6 = AnvizNew.CKT_GetFPTemplateSaveFile(device_id, enroll_id, 6, path6); status7 = AnvizNew.CKT_GetFPTemplateSaveFile(device_id, enroll_id, 7, path7); status8 = AnvizNew.CKT_GetFPTemplateSaveFile(device_id, enroll_id, 8, path8); status9 = AnvizNew.CKT_GetFPTemplateSaveFile(device_id, enroll_id, 9, path9); } } }
private void downloadCard(int device_id, string device_ip, string employees) { List <string> employees_list = JsonConvert.DeserializeObject <List <string> >(employees); DBConnection db_connection = new DBConnection(); AnvizNew.PERSONINFO person = new AnvizNew.PERSONINFO(); DataTable employee_details = new DataTable(); string enroll_id = string.Empty; string employee_name = string.Empty; string employee_id = string.Empty; string password = string.Empty; string card_id = string.Empty; string query = string.Empty; int RecordCount = new int(); int RetCount = new int(); int pPersons = new int(); int pLongRun = new int(); int cardcount = 0; long Cardlong = 0; int i = 0; int status = 0; int ptemp; if (AnvizNew.CKT_ListPersonInfoEx(device_id, ref pLongRun) == 1) { while (true) { status = AnvizNew.CKT_ListPersonProgress(pLongRun, ref RecordCount, ref RetCount, ref pPersons); if (status != 0) { //if (RecordCount > 0) ProgressBar1.Maximum = RetCount; ptemp = Marshal.SizeOf(person); for (i = 0; i < RetCount; i++) { RtlMoveMemory(ref person, pPersons, ptemp); pPersons = pPersons + ptemp; string[] hu = { i.ToString(), person.PersonID.ToString(), Encoding.Default.GetString(person.Name).ToString(), Encoding.Default.GetString(person.Password).ToString(), person.CardNo.ToString() }; enroll_id = person.PersonID.ToString(); if (employees_list.Exists(element => element == enroll_id)) { employee_name = Encoding.Default.GetString(person.Name).ToString(); password = Encoding.Default.GetString(person.Password).ToString(); password = System.Text.RegularExpressions.Regex.Replace(password, "[^0-9_.]+", "", System.Text.RegularExpressions.RegexOptions.Compiled); password = password.TrimEnd('0'); card_id = person.CardNo.ToString(); Cardlong = Convert.ToInt64(card_id); if (Cardlong < -1) { Cardlong = Cardlong + 4294967296; card_id = Convert.ToString(Cardlong); } if (card_id == "-1") { card_id = ""; } if (employee_name.StartsWith("\0")) { employee_name = ""; } cardcount = cardcount + 1; if (db_connection.RecordExist("select count(emp_card_no) from employeemaster where emp_card_no='" + enroll_id + "' ")) { query = "select emp_code,emp_name as Name from Employeemaster where emp_card_no='" + enroll_id + "'"; employee_details.Rows.Clear(); employee_details = db_connection.ReturnDataTable(query); employee_id = employee_details.Rows[0]["emp_code"].ToString(); employee_name = employee_details.Rows[0]["Name"].ToString(); } if (db_connection.RecordExist("select count(*) from Enrollmaster where enrollid='" + enroll_id + "'")) { query = "update Enrollmaster set cardid='" + card_id + "',pin='" + password + "',empid='" + employee_id + "',name='" + employee_name + "' where enrollid='" + enroll_id + "'"; db_connection.ExecuteQuery_WithOutReturnValue(query); } else { if (password == "\0\0\0\0\0\0\0\0") { password = ""; } query = "Insert into Enrollmaster(enrollid,cardid,pin,empid,name) values('" + enroll_id + "','" + card_id + "','" + password + "','" + employee_id + "','" + employee_name + "')"; db_connection.ExecuteQuery_WithOutReturnValue(query); } } } if (status == 1) { break; } } else { // Add logic for logging error to log file. } } } }
private DataTable getEnrollment(int device_id) { AnvizNew.PERSONINFO person = new AnvizNew.PERSONINFO(); DBConnection db_connection = new DBConnection(); DataTable employee_details = new DataTable(); DataTable enrollments = new DataTable(); string query = string.Empty; string employee_name = string.Empty; int i = 0; int RecordCount = new int(); int RetCount = new int(); int pPersons = new int(); int pLongRun = new int(); int ptemp = 0; int status = AnvizNew.CKT_ListPersonInfoEx(device_id, ref pLongRun); enrollments.Columns.Add("status"); enrollments.Columns.Add("EnrollId"); enrollments.Columns.Add("Employeename"); query = "truncate table exportenrollid"; db_connection.ExecuteQuery_WithReturnValueString(query); if (status == 1) { while (true) { status = AnvizNew.CKT_ListPersonProgress(pLongRun, ref RecordCount, ref RetCount, ref pPersons); if (status != 0) { ptemp = Marshal.SizeOf(person); for (i = 0; i < RetCount; i++) { RtlMoveMemory(ref person, pPersons, ptemp); pPersons = pPersons + ptemp; query = "select emp_name from Employeemaster where emp_card_no = '" + person.PersonID.ToString() + "'"; employee_details = db_connection.ReturnDataTable(query); if (employee_details.Rows.Count > 0) { employee_name = employee_details.Rows[0]["emp_name"].ToString(); } string[] hu = { "", person.PersonID.ToString(), employee_name }; query = "insert into exportenrollid(enrollid, empname)values('" + person.PersonID.ToString() + "','" + employee_name + "')"; db_connection.ExecuteQuery_WithReturnValueString(query); enrollments.Rows.Add(hu); } // end of for loop } // end of if condition if (status == 1) { break; } } // end of while } return(enrollments); }