Exemple #1
0
        private void btnSync_Click(object sender, EventArgs e)
        {
            string connectionName = cmbConnection.Text;

            if (connectionName.Trim() == "")
            {
                MessageBox.Show("Please select connection.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            Util.DriverHelper driver = new Util.DriverHelper();

            Entity.Connection cn = new Entity.Connection();

            cn = formMain.config.Connections.FirstOrDefault(c => c.ConnectionName == connectionName);
            if (cn == null)
            {
                MessageBox.Show("Connection not exists.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            driver.connection = cn;
            if (driver.Connect())
            {
                driver.GetUsers();
            }
            else
            {
                MessageBox.Show("Connect failed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Exemple #2
0
 private void tvwConnection_AfterSelect(object sender, TreeViewEventArgs e)
 {
     Entity.Connection cn = new Entity.Connection();
     cn = config.Connections.First <Entity.Connection>(c => c.ConnectionName == e.Node.Text);
     if (cn != null)
     {
         ppgConnection.SelectedObject = cn;
     }
 }
        private bool SaveConfig()
        {
            bool saveSuccess = false;

            if (txtConnectionName.Text.Trim() == "")
            {
                MessageBox.Show("Please input connection name.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(saveSuccess);
            }

            if (formMain.config.Connections.FirstOrDefault(c => c.ConnectionName == txtConnectionName.Text.Trim()) != null)
            {
                MessageBox.Show("Connection with same connection name already exists.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(saveSuccess);
            }

            Cursor        = Cursors.WaitCursor;
            btnOK.Enabled = false;

            Entity.Connection cn = new Entity.Connection
            {
                ConnectionName = txtConnectionName.Text.Trim(),
                Provider       = "ZKTeco",
                IP             = txtIP.Text.Trim(),
                Port           = txtPort.Text.Trim(),
                MachineNumber  = Convert.ToInt32(numMachineNumber.Value)
            };
            Util.DriverHelper driver = new Util.DriverHelper();
            driver.connection = cn;
            driver.Connect();
            if (driver.connected)
            {
                formMain.config.Connections.Add(cn);
                Util.JsonHelper.SerializeFile(formMain.config);
                saveSuccess = true;
            }
            else
            {
                saveSuccess = false;
            }

            Cursor        = Cursors.Default;
            btnOK.Enabled = true;

            return(saveSuccess);
        }
Exemple #4
0
        private void btnSetCard_Click(object sender, EventArgs e)
        {
            bool blnSetSuccess = false;

            if (cmbConnection.Text == "")
            {
                return;
            }

            Entity.Connection cn = formMain.config.Connections.FirstOrDefault(c => c.ConnectionName == cmbConnection.Text);
            if (cn == null)
            {
                return;
            }

            Util.DriverHelper device = new Util.DriverHelper
            {
                connection = cn
            };

            Entity.User user = new Entity.User {
                EnrollNumber = txtEnrollNumber.Text,
                Name         = txtName.Text,
                Card         = txtCardNumber.Text,
                Privilege    = 0,
                Password     = "******",
                Enabled      = true,
                FingerIndex  = 1,
                Flag         = 1,
                TmpData      = ""
            };


            device.Connect();

            blnSetSuccess = device.SetUser(user);
            if (blnSetSuccess)
            {
                device.Disconnect();
            }
        }
        private bool TestConnect()
        {
            Entity.Connection cn = new Entity.Connection
            {
                ConnectionName = txtConnectionName.Text.Trim(),
                IP             = txtIP.Text.Trim(),
                Port           = txtPort.Text.Trim(),
                Provider       = "ZKTeco",
                MachineNumber  = Convert.ToInt32(numMachineNumber.Value)
            };

            Cursor = Cursors.WaitCursor;

            Util.DriverHelper driverHelper = new Util.DriverHelper {
                connection = cn
            };
            driverHelper.Connect();

            Cursor = Cursors.Default;

            return(driverHelper.connected);
        }