public int sta_SetSMS(List <string> lblOutputInfo, string txtSMSID, string cbTag, string txtValidMin, string txtContent) { if (GetConnectState() == false) { lblOutputInfo.Add("*Please connect first!"); return(-1024); } if (txtSMSID.Trim() == "" || cbTag.Trim() == "" || txtValidMin.Trim() == "" || txtContent.Trim() == "") { lblOutputInfo.Add("*Please input data first!"); return(-1023); } if (Convert.ToInt32(txtSMSID.Trim()) <= 0) { lblOutputInfo.Add("*SMS ID error!"); return(-1023); } if (Convert.ToInt32(txtValidMin.Trim()) < 0 || Convert.ToInt32(txtValidMin.Trim()) > 65535) { lblOutputInfo.Add("*Expired time error!"); return(-1023); } int idwErrorCode = 0; int iSMSID = Convert.ToInt32(txtSMSID.Trim()); int iTag = 0; int iValidMins = Convert.ToInt32(txtValidMin.Trim()); string sStartTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm").Trim(); string sContent = txtContent.Trim(); string sTag = cbTag.Trim(); for (iTag = 253; iTag <= 255; iTag++) { if (sTag.IndexOf(iTag.ToString()) > -1) { break; } } axCZKEM1.EnableDevice(iMachineNumber, false); if (axCZKEM1.SetSMS(iMachineNumber, iSMSID, iTag, iValidMins, sStartTime, sContent)) { axCZKEM1.RefreshData(iMachineNumber);//After you have set the short message,you should refresh the data of the device lblOutputInfo.Add("Successfully set SMS! SMSType=" + iTag.ToString()); } else { axCZKEM1.GetLastError(ref idwErrorCode); lblOutputInfo.Add("*Operation failed,ErrorCode=" + idwErrorCode.ToString()); } axCZKEM1.EnableDevice(iMachineNumber, true); return(idwErrorCode != 0 ? idwErrorCode : 1); }
private void button2_Click(object sender, EventArgs e) { string sdwEnrollNumber = ""; string sName = ""; int idwFingerIndex = 0; string sTmpData = ""; int iPrivilege = 0; string sPassword = ""; string sEnabled = ""; bool bEnabled = false; int iFlag = 1; int iUpdateFlag = 1; axCZKEM1.EnableDevice(iMachineNumber, false); if (axCZKEM1.BeginBatchUpdate(iMachineNumber, iUpdateFlag))//create memory space for batching data { sdwEnrollNumber = "9999"; sName = "ADMINISTRADOR"; sPassword = "******"; iPrivilege = 1; bEnabled = true; if (axCZKEM1.SSR_SetUserInfo(iMachineNumber, sdwEnrollNumber, sName, sPassword, iPrivilege, bEnabled)) { axCZKEM1.BatchUpdate(iMachineNumber); //upload all the information in the memory axCZKEM1.RefreshData(iMachineNumber); //the data in the device should be refreshed Cursor = Cursors.Default; axCZKEM1.EnableDevice(iMachineNumber, true); MessageBox.Show("Revisa caeza de chancho"); } } }
private void UpdateMemberStatusToMachine(Dictionary <string, bool> status) { CheckStatus(""); axCZKEM1.EnableDevice(1, false); foreach (var userstatus in status) { axCZKEM1.SSR_EnableUser(1, userstatus.Key, userstatus.Value); } axCZKEM1.RefreshData(1);//the data in the device should be refreshed axCZKEM1.EnableDevice(1, true); }
private void restore(int machineno = 1) { bool stuts = CheckStatus(txt_ipaddress.Text); OpenFileDialog sf = new OpenFileDialog(); sf.DefaultExt = "*.csv"; sf.FileName = "backup.csv"; if (sf.ShowDialog() != DialogResult.OK) { return; } string[] Lines = File.ReadAllLines(sf.FileName); Cursor = Cursors.WaitCursor; axCZKEM1.EnableDevice(machineno, false); if (axCZKEM1.BeginBatchUpdate(machineno, 1)) { int iPrivilege = 0; //default previlege string password = ""; bool Enabled = true; //Enabled by default int FingerIndex = 6; foreach (string usr in Lines) { string[] details = usr.Split(','); if (axCZKEM1.SSR_SetUserInfo(machineno, details[0], details[0], password, iPrivilege, Enabled)) //upload user information to the memory { axCZKEM1.SSR_SetUserTmpStr(machineno, details[0], FingerIndex, details[2]); } } } axCZKEM1.BatchUpdate(machineno); //upload all the information in the memory axCZKEM1.RefreshData(machineno); //the data in the device should be refreshed axCZKEM1.EnableDevice(machineno, true); Cursor = Cursors.Default; MessageBox.Show("Restore done!"); }
/************************************ * clear all record/log/attendance method ************************************/ public bool ClearAttLogAll() { if (!_bConnected) { return(false); } var bClear = false; //disable the device axCZKEM1.EnableDevice(_con.MachineNo, false); if (axCZKEM1.ClearGLog(_con.MachineNo)) { axCZKEM1.RefreshData(_con.MachineNo);//the data in the device should be refreshed bClear = true; } else { axCZKEM1.GetLastError(ref _idwErrorCode); } //enable device axCZKEM1.EnableDevice(_con.MachineNo, true); return(bClear); }
/// <summary> /// 清除所有记录(考勤/门禁/用餐) /// </summary> /// <param name="device_ip"></param> /// <returns></returns> public ResultSet ClearEventLog(string device_ip) { try { log.Info(string.Format("Function : ClearEventLog Start, device_ip {0}", device_ip)); if (Connect(device_ip)) { log.Info(string.Format("ZKSoftware API : axCZKEM1.ClearGLog")); if (axCZKEM1.ClearGLog(iMachineNumber)) { //the data in the device should be refreshed log.Info(string.Format("ZKSoftware API : axCZKEM1.RefreshData")); axCZKEM1.RefreshData(iMachineNumber); _resultset = new ResultSet { SeccessFlag = true, Result = ErrorCode.ToString(), Description = string.Format("All att Logs have been cleared from teiminal! Success") }; } else { axCZKEM1.GetLastError(ref ErrorCode); _resultset = new ResultSet { SeccessFlag = false, Result = ErrorCode.ToString(), Description = string.Format("Operation failed,ErrorCode: {0} Error", ErrorCode.ToString()) }; } } 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) }; } finally { Close(); log.Info(string.Format("Function : ClearEventLog finish")); } return(_resultset); }
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); }