public bool ConnectMachine() { bool retVal; _AttManager = new zkemkeeper.CZKEM(); retVal = _AttManager.Connect_Net(IPAddress, Port); _AttManager.RegEvent(1, 65535);//Here you can register the realtime events that you want to be triggered(the parameters 65535 means registering all) _AttManager.OnAttTransactionEx += new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(AttManager_OnAttTransactionEx); _Connected = retVal; return(retVal); }
public bool FlushDevice() { string logMsg = ""; zkemkeeper.CZKEM axCZKEM1 = new zkemkeeper.CZKEM(); try { lock (busy) { if (ui.isLoggingUI) { ui.ChangeStatus(devNo, "Flushing...", Color.Blue); } bool bIsConnected = axCZKEM1.Connect_Net(devIP, 4370); // 4370 is port no of attendance machine if (bIsConnected == true) { //log = "Turnstile[" + (device+1) + "]: Device Connected Successfully\n"; axCZKEM1.ClearDataEx(0, "user"); axCZKEM1.ClearDataEx(0, "userauthorize"); axCZKEM1.Disconnect(); logMsg = logMsg + "Turnstile[" + (devNo + 1) + "]: Device Clear Successfully\n"; log.LogText(logMsg); return(true); } else { logMsg = logMsg + "Turnstile[" + (devNo + 1) + "]: Device Not Cleared/Connected\n"; log.LogText(logMsg); return(false); } } } catch (Exception ex) { try { axCZKEM1.Disconnect(); } catch (Exception exx) { log.LogText("Turnstile[" + (devNo + 1) + "]: Exception inside FlushDevice: " + exx.Message.ToString() + System.Environment.NewLine); Disconect(); } logMsg = logMsg + "Turnstile[" + (devNo + 1) + "]: Device Clear/Connect Error: " + ex.Message.ToString(); log.LogText(logMsg); return(false); } }
private void Essl_Connect(string IpAddress, int MachineNo) { try { zkemkeeper.CZKEM axCZKEM1 = new zkemkeeper.CZKEM(); if (axCZKEM1.Connect_Net(IpAddress, 5005)) { XtraMessageBox.Show("Machine Connected"); } else { XtraMessageBox.Show("Machine Not Connected"); } } catch (Exception ex) { } }
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { string marca = this.GridView1.SelectedDataKey["MARCA"].ToString(); string nume = this.GridView1.SelectedRow.Cells[1].Text.ToString(); string card = this.GridView1.SelectedRow.Cells[5].Text.ToString(); zkemkeeper.CZKEM aa = new zkemkeeper.CZKEM(); Literal2.Text = ""; if (aa.Connect_Net("10.10.13.10", 4370)) { Literal2.Text = Literal2.Text + " " + "Conectat..."; //aa.SetStrCardNumber(""); if (aa.SetStrCardNumber(card)) { Literal2.Text = Literal2.Text + " " + "actualizat card :" + card; } else { Literal2.Text = Literal2.Text + " " + "EROARE actualizare card " + card; } if (aa.SSR_SetUserInfo(1, marca, nume, "", 0, true)) { Literal2.Text = Literal2.Text + " " + "actualizat " + marca + " " + nume; } else { Literal2.Text = Literal2.Text + " " + "EROARE actualizare " + marca + " " + nume; } aa.Disconnect(); } else { Literal2.Text = "nu m-am putrut conecta la aparat"; } }
public Device() { ip = string.Empty; MachineNumber = 1; DeviceController = new zkemkeeper.CZKEM(); }
public bool ConnectMachine() { bool retVal; _AttManager = new zkemkeeper.CZKEM(); retVal = _AttManager.Connect_Net(IPAddress, Port); _AttManager.RegEvent(1, 65535);//Here you can register the realtime events that you want to be triggered(the parameters 65535 means registering all) _AttManager.OnAttTransactionEx += new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(AttManager_OnAttTransactionEx); _Connected = retVal; return retVal; }
private void Form1_Load(object sender, EventArgs e) { try { // valida si ya tiene alguna clave guardada para el archivo string cveActual = Properties.Settings.Default.accesoConfig; if (string.IsNullOrEmpty(cveActual)) { string acceso = Modelos.Utilerias.Transform("p4ssw0rd"); Properties.Settings.Default.accesoConfig = acceso; Properties.Settings.Default.Save(); } string fileName = "config.dat"; string pathConfigFile = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\DescChec\"; // si no existe el directorio, lo crea bool exists = System.IO.Directory.Exists(pathConfigFile); if (!exists) { System.IO.Directory.CreateDirectory(pathConfigFile); } // busca en el directorio si exite el archivo con el nombre dado var file = Directory.GetFiles(pathConfigFile, fileName, SearchOption.AllDirectories) .FirstOrDefault(); if (file == null) { // no existe // abrir el formulario para llenar la configuracion de conexion frmConfiguracion form = new frmConfiguracion(); form.ShowDialog(); } else { // si existe // obtener la cadena de conexion del archivo FEncrypt.Respuesta result = FEncrypt.EncryptDncrypt.DecryptFile(file, "milagros"); if (result.status == FEncrypt.Estatus.ERROR) { throw new Exception(result.error); } if (result.status == FEncrypt.Estatus.OK) { string[] list = result.resultado.Split(new string[] { "||" }, StringSplitOptions.None); string ip = list[0].Substring(2); // ip string puerto = list[1].Substring(2); // puerto string servidor = list[2].Substring(2); // servidor string usuario = list[3].Substring(2); // usuario string contra = list[4].Substring(2); // contraseña string baseDatos = list[5].Substring(2); // base de datos string nomChecador = list[6].Substring(2); // nombre checador string tipoChecador = list[7].Substring(2); // tipo de checador string numChecador = list[8].Substring(2); // num de checador // si licencia pasa asigna cadena de conexion Modelos.ConectionString.conn = string.Format( "server={0};User Id={1};password={2};database={3}", servidor, usuario, contra, baseDatos); Modelos.ConectionString.ip = ip; Modelos.ConectionString.puerto = puerto; Modelos.ConectionString.tipoCh = tipoChecador; Modelos.ConectionString.numCh = Convert.ToInt16(numChecador); this.lbChecador.Text = "Checador: " + nomChecador + " - " + tipoChecador; this.lbChecador.Left = (this.ClientSize.Width - this.lbChecador.Width) / 2; } } // inicializa librerias SDK checador axCZKEM1 = new zkemkeeper.CZKEM(); } catch (System.Runtime.InteropServices.COMException cex) { // MessageBox.Show(cex.Message, "Descarga Checadores COMEx", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); MessageBox.Show("Problemas con la conexion al Checador\nRevise si las librerías están correctamente instaladas.", "Descarga Checadores COMEx", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this._comEx = true; } catch (Exception Ex) { MessageBox.Show(Ex.Message, "Descarga Checadores", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }