Exemplo n.º 1
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            //Library.WriteErrorLog("********************************start*************************************");
            //for (int i = 0; i < iFaceMachine.Length; i++)
            //    iFaceMachine[i].iFace_ReadLog();
            //for (int i = 0; i < MA500Machine.Length; i++)
            //    MA500Machine[i].MA500_ReadLog();
            //Library.WriteErrorLog("*******************************end***************************************");
            //MessageBox.Show("Done");

            Library.WriteErrorLog("Start Working");
            int r = 0, c = 0;

            for (int i = 0; i < Devices.GetLength(0); i++)
            {
                if (Devices[i][2] == "IFACE")
                {
                    iFaceMachine[r] = new iFace(Devices[i][0], Devices[i][1]);
                    iFaceMachine[r].iFace_Connect();
                    //iFaceMachine[r].iFace_ReadLog();
                    r++;
                }
                if (Devices[i][2] == "MA500")
                {
                    MA500Machine[c] = new MA500(Devices[i][0], Devices[i][1]);
                    MA500Machine[c].MA500_Connect();
                    MA500Machine[c].EnableLogTimer();
                    //MA500Machine[c].MA500_ReadLog();
                    c++;
                }
            }
        }
Exemplo n.º 2
0
        private void btnCards_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            for (int i = 1; i < Devices.Length; i++)
            {
                ip    = Devices[i][0];
                inout = Devices[i][1];
                type  = Devices[i][2];

                bool Selected = this.lsdevices.Items[i - 1].Checked;
                //lsdevices.BeginUpdate();
                if (Selected && Devices[i][2] == "IFACE")
                {
                    iFace ifacedevice = new iFace(ip, Devices[cmbdevices.SelectedIndex + 1][2]);
                    ifacedevice.iFace_Connect();
                    if (ifacedevice.bIsConnected)
                    {
                        lsdevices.Items[i - 1].SubItems[3].Text = "Connected";
                    }
                    else
                    {
                        lsdevices.Items[i - 1].SubItems[3].Text = "disconnect";
                    }
                    lsdevices.EndUpdate();
                    ifacedevice.iFace_Discoonect();
                }
                if (Selected && Devices[i][2] == "MA500")
                {
                    MA500 MA500device = new MA500(ip, Devices[cmbdevices.SelectedIndex + 1][2]);
                    MA500device.MA500_Connect();

                    if (MA500device.bIsConnected)
                    {
                        lsdevices.Items[i - 1].SubItems[3].Text = "Connected";
                    }
                    else
                    {
                        lsdevices.Items[i - 1].SubItems[3].Text = "disconnect";
                    }
                    lsdevices.EndUpdate();
                    MA500device.MA500_Disconnect();
                }
            }
            Cursor = Cursors.Default;
        }
Exemplo n.º 3
0
        private void btnReadLog_Click(object sender, EventArgs e)
        {
            string       IP, InOut = "1", Type;
            ComboboxItem cbitem = (ComboboxItem)cbDevicestb4.SelectedItem;

            ip     = cbitem.Text;
            type   = cbitem.Value.ToString();
            Cursor = Cursors.WaitCursor;
            if (type == "IFACE")
            {
                iFace faceTemp = new iFace(ip, InOut);
                faceTemp.iFace_Connect();
                if (faceTemp.bIsConnected)
                {
                    faceTemp.iFace_ReadLog();
                }
                else
                {
                }
                //faceTemp.iFace_Discoonect();
            }
            if (type == "MA500")
            {
                MA500 ma500Temp = new MA500(ip, InOut);
                ma500Temp.MA500_Connect();
                if (ma500Temp.bIsConnected)
                {
                    ma500Temp.MA500_ReadLog();
                }
                else
                {
                }
                //ma500Temp.MA500_Disconnect();
            }

            MessageBox.Show("Done");
        }
Exemplo n.º 4
0
        private void btnConnecttb4_Click(object sender, EventArgs e)
        {
            if (cbDevicestb4.SelectedIndex < 0)
            {
                return;
            }
            //////////////////////////////////////////////////////DisConnect/////////////////////////////
            ComboboxItem cbitem = (ComboboxItem)cbDevicestb4.SelectedItem;

            ip     = cbitem.Text;
            type   = cbitem.Value.ToString();
            Cursor = Cursors.WaitCursor;
            if (btnConnecttb4.Text == "DisConnect")
            {
                if (iFaceDevice != null)
                {
                    if (iFaceDevice.bIsConnected)
                    {
                        iFaceDevice.iFace_Discoonect();
                        cbDevicestb4.Enabled       = true;
                        cbDevicestb4.SelectedIndex = -1;
                    }
                }
                if (MA500Device != null)
                {
                    if (MA500Device.bIsConnected)
                    {
                        MA500Device.MA500_Disconnect();
                        cbDevicestb4.Enabled       = true;
                        cbDevicestb4.SelectedIndex = -1;
                    }
                }
                btnConnecttb4.Text = "Connect";

                Cursor = Cursors.Default;
                return;
            }
            //////////////////////////////////////////////////////Connect/////////////////////////////

            List <string> Users = new List <string>();

            //lbstatus.Text = cmbdevices.SelectedItem.ToString() + " " + type ;
            if (type == "IFACE")
            {
                iFaceDevice = new iFace(ip, "");
                iFaceDevice.axCZKEM1.OnHIDNum += new zkemkeeper._IZKEMEvents_OnHIDNumEventHandler(axCZKEM1_OnHIDNum);
                Cursor = Cursors.WaitCursor;
                iFaceDevice.iFace_Connect();
                if (iFaceDevice.bIsConnected)
                {
                    btnConnecttb4.Text   = "DisConnect";
                    lblStatustb4.Text    = ip + " Connected ";
                    cbDevicestb4.Enabled = false;
                }
                else
                {
                    cbDevicestb4.Enabled = true;
                    lblStatustb4.Text    = "Connection Faild";
                }
                Cursor = Cursors.Default;
            }
            if (type == "MA500")
            {
                MA500Device          = new MA500(ip, Devices[cbDevicestb4.SelectedIndex + 1][2]);
                cbDevicestb3.Enabled = false;
                Cursor = Cursors.WaitCursor;
                MA500Device.MA500_Connect();
                if (MA500Device.bIsConnected)
                {
                    btnConnecttb4.Text   = "DisConnect";
                    lblStatustb4.Text    = ip + " Connected ";
                    cbDevicestb4.Enabled = false;

                    MA500Device.EnableCradTimer();
                    MA500Device.ReadingCard += MA500Device_ReadingCard;
                }
                else
                {
                    cbDevicestb4.Enabled = true;
                    lblStatustb4.Text    = "Connection Faild";
                }
                //MA500Device.MA500_Disconnect();

                Cursor = Cursors.Default;
            }
        }
Exemplo n.º 5
0
        private void button3_Click(object sender, EventArgs e)
        {
            string IP, InOut, Type;
            string UserID;

            if (cbUserTb3.SelectedIndex == -1)
            {
                MessageBox.Show("Please select user first", "Error");
                return;
            }
            for (int i = 0; i < lvDevicestb3.Items.Count; i++)
            {
                lvDevicestb3.Items[i].SubItems[3].Text = "";
                lvDevicestb3.Refresh();
            }
            UserID = cbUserTb3.SelectedItem.ToString();
            lvDevicestb3.BeginUpdate();
            Cursor = Cursors.WaitCursor;
            for (int i = 0; i < lvDevicestb3.Items.Count; i++)
            {
                if (lvDevicestb3.Items[i].Checked)
                {
                    IP    = lvDevicestb3.Items[i].SubItems[0].Text;
                    InOut = lvDevicestb3.Items[i].SubItems[1].Text;
                    Type  = lvDevicestb3.Items[i].SubItems[2].Text;
                    if (Type == "IFACE")
                    {
                        iFace faceTemp = new iFace(IP, InOut);
                        faceTemp.iFace_Connect();
                        if (faceTemp.bIsConnected)
                        {
                            lvDevicestb3.Items[i].SubItems[3].Text = "Connected ";
                            bool result = faceTemp.RegisterCard(UserID, txtCardNumbertb3.Text);
                            Library.UpdateCard(int.Parse(UserID), txtCardNumber.Text);
                            lvDevicestb3.Items[i].SubItems[3].Text += result.ToString();
                        }
                        else
                        {
                            lvDevicestb3.Items[i].SubItems[3].Text = "DisConnected";
                        }
                        //faceTemp.iFace_Discoonect();
                    }
                    if (Type == "MA500")
                    {
                        MA500 ma500Temp = new MA500(IP, InOut);
                        ma500Temp.MA500_Connect();
                        if (ma500Temp.bIsConnected)
                        {
                            lvDevicestb3.Items[i].SubItems[3].Text = "Connected ";
                            ma500Temp.RegisterCard(UserID, txtCardNumbertb3.Text, "", "", "", "");
                            lvDevicestb3.Items[i].SubItems[3].Text += " - Card Add";
                        }
                        else
                        {
                            lvDevicestb3.Items[i].SubItems[3].Text = "DisConnected";
                        }
                        //ma500Temp.MA500_Disconnect();
                    }
                }
            }
            lvDevicestb3.EndUpdate();
            Cursor = Cursors.Default;
            MessageBox.Show("Done");
        }
Exemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            string IP, InOut, Type;
            string UserID;
            bool   Vaild;

            for (int i = 0; i < lvDevicestb2.Items.Count; i++)
            {
                //lvDevicestb2.BeginUpdate();
                lvDevicestb2.Items[i].SubItems[3].Text = "";
                //lvDevicestb2.EndUpdate();
                lvDevicestb2.Refresh();
            }
            if (cbUserTb2.SelectedIndex == -1)
            {
                MessageBox.Show("Please select user first", "Error");
                return;
            }
            UserID = cbUserTb2.SelectedItem.ToString();
            Vaild  = cbVaildTb2.Checked;
            lvDevicestb2.BeginUpdate();
            Cursor = Cursors.WaitCursor;
            for (int i = 0; i < lvDevicestb2.Items.Count; i++)
            {
                if (lvDevicestb2.Items[i].Checked)
                {
                    IP    = lvDevicestb2.Items[i].SubItems[0].Text;
                    InOut = lvDevicestb2.Items[i].SubItems[1].Text;
                    Type  = lvDevicestb2.Items[i].SubItems[2].Text;
                    if (Type == "IFACE")
                    {
                        iFace faceTemp = new iFace(IP, InOut);
                        faceTemp.iFace_Connect();
                        if (faceTemp.bIsConnected)
                        {
                            lvDevicestb2.Items[i].SubItems[3].Text = "Connected ";
                            bool result = faceTemp.EnableUser(UserID, Vaild);
                            if (Vaild)
                            {
                                Library.EnableUser(int.Parse(UserID), 1);
                            }
                            else
                            {
                                Library.EnableUser(int.Parse(UserID), -1);
                            }
                            lvDevicestb2.Items[i].SubItems[3].Text += result.ToString();
                        }
                        else
                        {
                            lvDevicestb2.Items[i].SubItems[3].Text = "DisConnected";
                        }
                        faceTemp.iFace_Discoonect();
                    }
                    if (Type == "MA500")
                    {
                        MA500 ma500Temp = new MA500(IP, InOut);
                        ma500Temp.MA500_Connect();
                        if (ma500Temp.bIsConnected)
                        {
                            lvDevicestb2.Items[i].SubItems[3].Text = "Connected";
                            bool result = ma500Temp.EnableUser(UserID, Vaild);
                            lvDevicestb2.Items[i].SubItems[3].Text += result.ToString();
                        }
                        else
                        {
                            lvDevicestb2.Items[i].SubItems[3].Text = "DisConnected";
                        }
                        ma500Temp.MA500_Disconnect();
                    }
                }
            }
            lvDevicestb2.EndUpdate();
            Cursor = Cursors.Default;
            MessageBox.Show("Done");
        }
Exemplo n.º 7
0
        private void btUpload_Click(object sender, EventArgs e)
        {
            //if (cmbdevices.SelectedIndex == -1 )
            //{
            //    MessageBox.Show("Select Device First","Error");
            //    return;
            //}
            //if (iFaceDevice== null  || MA500Device == null  )
            //{
            //    MessageBox.Show("Device is not Connected", "Error");
            //    return;
            //}
            //if (iFaceDevice.bIsConnected  || MA500Device.bIsConnected )
            //{
            //    MessageBox.Show("Device is not Connected", "Error");
            //    return;
            //}
            //if (cbUser.SelectedIndex == -1)
            //{
            //    MessageBox.Show("Select User First", "Error");
            //    return;
            //}
            for (int i = 0; i < lsdevices.Items.Count; i++)
            {
                lsdevices.Items[i].SubItems[3].Text = "";
                lsdevices.Refresh();
            }
            string IP, InOut, Type;

            lsdevices.BeginUpdate();
            Cursor = Cursors.WaitCursor;
            for (int i = 0; i < lsdevices.Items.Count; i++)
            {
                if (lsdevices.Items[i].Checked)
                {
                    IP    = lsdevices.Items[i].SubItems[0].Text;
                    InOut = lsdevices.Items[i].SubItems[1].Text;
                    Type  = lsdevices.Items[i].SubItems[2].Text;
                    if (Type == "IFACE")
                    {
                        iFace faceTemp = new iFace(IP, InOut);
                        faceTemp.iFace_Connect();
                        if (faceTemp.bIsConnected)
                        {
                            lsdevices.Items[i].SubItems[3].Text = "Connected";
                            string UserID = cbUser.SelectedItem.ToString();
                            if (cbCard.Checked)
                            {
                                bool result = faceTemp.RegisterCard(UserID, txtCardNumber.Text);
                                lsdevices.Items[i].SubItems[3].Text += " - " + result;
                                Library.UpdateCard(int.Parse(UserID), txtCardNumber.Text);
                            }
                            if (cbFinger.Checked)
                            {
                                faceTemp.DeleteTemp(int.Parse(UserID));
                                for (int FingerIndex = 0; FingerIndex < UserDataTemp.Templates.Count; FingerIndex++)
                                {
                                    faceTemp.RegisterTemplate(UserID, UserDataTemp.Templates[FingerIndex].FingerID, UserDataTemp.Templates[FingerIndex].Template, UserDataTemp.Templates[FingerIndex].TemplateSize);
                                    Library.insertFinger(int.Parse(UserID), UserDataTemp.Templates[FingerIndex].FingerID, UserDataTemp.Templates[FingerIndex].Template, UserDataTemp.Templates[FingerIndex].TemplateSize);
                                }
                                lsdevices.Items[i].SubItems[3].Text += "- " + txtFingerCount.Text + "Finger Add ";
                            }
                            if (cbFace.Checked)
                            {
                                faceTemp.DeleteFace(int.Parse(UserID));
                                for (int FaceIndex = 0; FaceIndex < UserDataTemp.Faces.Count; FaceIndex++)
                                {
                                    faceTemp.RegisterFace(UserID, UserDataTemp.Faces[FaceIndex].FaceID, UserDataTemp.Faces[FaceIndex].Face, UserDataTemp.Faces[FaceIndex].FaceSize);
                                    Library.insertFace(int.Parse(UserID), UserDataTemp.Faces[FaceIndex].FaceID, UserDataTemp.Faces[FaceIndex].Face, UserDataTemp.Faces[FaceIndex].FaceSize);
                                }
                                lsdevices.Items[i].SubItems[3].Text += "- " + txtFingerCount.Text + "Face Add";
                            }
                        }
                        else
                        {
                            lsdevices.Items[i].SubItems[3].Text = "DisConnected";
                        }
                        faceTemp.iFace_Discoonect();
                    }
                    if (Type == "MA500")
                    {
                        MA500 ma500Temp = new MA500(IP, InOut);
                        ma500Temp.MA500_Connect();
                        if (ma500Temp.bIsConnected)
                        {
                            lsdevices.Items[i].SubItems[3].Text = "Connected";
                            string UserID = cbUser.SelectedItem.ToString();
                            if (cbFinger.Checked)
                            {
                                for (int FingerIndex = 0; FingerIndex < UserDataTemp.Templates.Count; FingerIndex++)
                                {
                                    ma500Temp.RegisterFinger(UserID, FingerIndex.ToString(), "1", UserDataTemp.Templates[FingerIndex].Template);
                                    Library.insertFinger(int.Parse(UserID), UserDataTemp.Templates[FingerIndex].FingerID, UserDataTemp.Templates[FingerIndex].Template, UserDataTemp.Templates[FingerIndex].TemplateSize);
                                }
                                lsdevices.Items[i].SubItems[3].Text += "- " + txtFingerCount.Text + "Finger Add ";
                            }
                            if (cbCard.Checked)
                            {
                                ma500Temp.RegisterCard(UserID, txtCardNumber.Text, "", "0", "", "");
                                lsdevices.Items[i].SubItems[3].Text += "- " + txtFingerCount.Text + " Add";
                                Library.UpdateCard(int.Parse(UserID), txtCardNumber.Text);
                            }
                        }
                        else
                        {
                            lsdevices.Items[i].SubItems[3].Text = "DisConnected";
                        }
                        ma500Temp.MA500_Disconnect();
                    }
                }
            }
            lsdevices.EndUpdate();
            Cursor = Cursors.Default;
            MessageBox.Show("Done");
        }
Exemplo n.º 8
0
        private void btConnect_Click(object sender, EventArgs e)
        {
            if (cmbdevices.SelectedIndex < 0)
            {
                return;
            }
            //////////////////////////////////////////////////////DisConnect/////////////////////////////
            ComboboxItem cbitem = (ComboboxItem)cmbdevices.SelectedItem;

            //cbUser.Items.Clear();
            ip     = cbitem.Text;
            type   = cbitem.Value.ToString();
            Cursor = Cursors.WaitCursor;
            if (btConnect.Text == "DisConnect")
            {
                if (iFaceDevice != null)
                {
                    if (iFaceDevice.bIsConnected)
                    {
                        iFaceDevice.iFace_Discoonect();
                        cmbdevices.Enabled = true;
                        lbstatus.Text      = iFaceDevice.IPAdreess + " DisConnected";
                    }
                }
                if (MA500Device != null)
                {
                    if (MA500Device.bIsConnected)
                    {
                        MA500Device.MA500_Disconnect();
                        cmbdevices.Enabled       = true;
                        lbstatus.Text            = MA500Device.IPAdreess + " DisConnected";
                        cmbdevices.SelectedIndex = -1;
                    }
                }
                btConnect.Text = "Connect";
                cbUser.Items.Clear();
                txtCardNumber.Text  = "";
                txtFaceCount.Text   = "";
                txtFingerCount.Text = "";
                Cursor = Cursors.Default;
                return;
            }
            //////////////////////////////////////////////////////Connect/////////////////////////////

            List <string> Users = new List <string>();

            //lbstatus.Text = cmbdevices.SelectedItem.ToString() + " " + type ;
            if (type == "IFACE")
            {
                iFaceDevice = new iFace(ip, "");
                iFaceDevice.axCZKEM1.OnHIDNum += new zkemkeeper._IZKEMEvents_OnHIDNumEventHandler(axCZKEM1_OnHIDNum);
                Cursor = Cursors.WaitCursor;
                cbUser.Items.Clear();
                //cbUser.BeginUpdate();
                iFaceDevice.iFace_Connect();
                if (iFaceDevice.bIsConnected)
                {
                    btConnect.Text     = "DisConnect";
                    lbstatus.Text      = ip + " Connected ";
                    cmbdevices.Enabled = false;
                    Users = iFaceDevice.UserIDs();
                    if (Users.Count <= 0)
                    {
                        lbstatus.Text = "Error Reading Users";
                    }
                    cbUser.Items.Clear();
                    foreach (string user in Users)
                    {
                        cbUser.Items.Add(user);
                    }
                }
                else
                {
                    cmbdevices.Enabled = true;
                    lbstatus.Text      = "Connection Faild";
                }
                cbUser.EndUpdate();
                Cursor = Cursors.Default;
            }
            if (type == "MA500")
            {
                MA500Device        = new MA500(ip, Devices[cmbdevices.SelectedIndex + 1][2]);
                cmbdevices.Enabled = false;
                Cursor             = Cursors.WaitCursor;
                MA500Device.MA500_Connect();
                if (MA500Device.bIsConnected)
                {
                    MA500Device.EnableCradTimer();
                    MA500Device.ReadingCard += MA500Device_ReadingCard;

                    btConnect.Text = "DisConnect";
                    lbstatus.Text  = ip + " Connected ";
                    Users          = MA500Device.MA500_Users();

                    if (Users.Count <= 0)
                    {
                        lbstatus.Text = "Error Reading Users";
                    }
                    cbUser.Items.Clear();
                    cbUser.Items.AddRange(Users.ToArray());
                }
                else
                {
                    cmbdevices.Enabled = true;
                    lbstatus.Text      = "Connection Faild";
                }
                //MA500Device.MA500_Disconnect();
                cbUser.EndUpdate();
                Cursor = Cursors.Default;
            }
        }
Exemplo n.º 9
0
        private void addCon_Click(object sender, EventArgs e)
        {
            //build the proxy for our xmlrpc interface
            iFace proxy = XmlRpcProxyGen.Create <iFace>();


            //Make sure our text boxes are not null.
            if (fName.Text != null && lName.Text != null && eMail.Text != null)
            {
                //Create a struct to hold the contact records data
                XmlRpcStruct conDat = new XmlRpcStruct();
                conDat.Add("FirstName", fName.Text);
                conDat.Add("LastName", lName.Text);
                conDat.Add("Email", eMail.Text);

                //make the call to add the contact.
                try
                {
                    result        = proxy.Add(key, conDat);
                    Results.Text += "Contact added - ID: " + result + System.Environment.NewLine;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }


                //now we will add the contact to any groups or campaigns that were checked.
                //if we wanted to we could check if the calls return true/false to determine output.
                try
                {
                    if (news1.Checked)
                    {
                        //news1 is checked so add it to the correct group ID.
                        proxy.AddGrp(key, result, 91);
                        Results.Text += "Contact " + result + " added to group 91" + System.Environment.NewLine;
                    }
                    if (news2.Checked)
                    {
                        //news2 is checked so add it to the correct group ID.
                        proxy.AddGrp(key, result, 92);
                        Results.Text += "Contact " + result + " added to group 92" + System.Environment.NewLine;
                    }

                    if (camp1.Checked)
                    {
                        //camp1 is checked so add it to the correct campaign ID.
                        proxy.AddCamp(key, result, 21);
                        Results.Text += "Contact " + result + " added to campaign 21" + System.Environment.NewLine;
                    }
                    if (camp2.Checked)
                    {
                        //camp2 is checked so add it to the correct campaign ID.
                        proxy.AddCamp(key, result, 23);
                        Results.Text += "Contact " + result + " added to campaign 23" + System.Environment.NewLine;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                Results.Text += System.Environment.NewLine;
            }
            else
            {
                MessageBox.Show("Error: First Name, Last Name and Email are required!");
            }
        }