/// <summary> /// 删除用户 /// </summary> /// <param name="device_ip"></param> /// <param name="device_port"></param> /// <param name="userInfos"></param> /// <returns></returns> public ResultSet DeleteUser(string device_ip, int device_port, UserInfo[] userInfos) { try { log.Info(string.Format("Function : DeleteUser Start, Array Size: {0}", userInfos.Length)); int successCount = 0; int failCount = 0; int deviceCount = 0; int backupnumber = 12; int idwErrorCode = 0; deviceCount++; if (Connect(device_ip)) { //log.Info(string.Format(" Looping ---- Device {0}, user count: {1}", deviceCount, u.user.Count)); int userCount = 0; foreach (UserInfo user in userInfos) { if (user != null) { userCount++; log.Info(string.Format(" Looping -------User {0}", userCount, user.ToLogString())); if (getDeviceType(device_ip) == "accesscontrol") { object oEmpNo = Common.GetRefnoByUser(user.Id); if (oEmpNo != null) { log.Info(string.Format("ZKSoftware API : axCZKEM1.DeleteEnrollData, Id{0}", user.Id)); if (axCZKEM1.DeleteEnrollData(iMachineNumber, int.Parse(oEmpNo.ToString()), iMachineNumber, backupnumber)) { Common.DelDevice(device_ip, user.Id.ToString()); successCount++; } else { failCount++; axCZKEM1.GetLastError(ref idwErrorCode); if (idwErrorCode == 0) { Common.DelDevice(device_ip, user.Id.ToString()); } } } } else { object oEmpNo = Common.GetRefnoByUser(user.Id); if (oEmpNo != null) { log.Info(string.Format("ZKSoftware API : axCZKEM1.SSR_DeleteEnrollData, Id{0}", user.Id)); if (axCZKEM1.SSR_DeleteEnrollData(iMachineNumber, oEmpNo.ToString(), backupnumber)) { Common.DelDevice(device_ip, user.Id.ToString()); successCount++; } else { failCount++; axCZKEM1.GetLastError(ref idwErrorCode); if (idwErrorCode == 0) { Common.DelDevice(device_ip, user.Id.ToString()); } } } } } } Close(); _resultset = new ResultSet { SeccessFlag = true, Result = string.Format("Success : {0} Fail : {1}", successCount, failCount) }; } else { _resultset = new ResultSet { SeccessFlag = false, Result = device_ip, Description = string.Format("can not connect to the device. please check it.") }; } } catch (Exception ex) { log.Fatal(ex); _resultset = new ResultSet { SeccessFlag = false, Result = ErrorCode.ToString(), Description = string.Format("Try Catched Error {0}", ex.Message) }; throw ex; } finally { Close(); log.Info(string.Format("Function : DeleteUser finish")); } return(_resultset); }