Exemple #1
0
        private void ComboBoxPort_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                serial.PortName = ComboBoxPort.SelectedItem.ToString();
                RichTextBoxSerial.AppendText(serial.PortName + "\n");
                serial.BaudRate  = Convert.ToInt32("9600");
                serial.Handshake = System.IO.Ports.Handshake.None;
                serial.Parity    = Parity.None;
                serial.DataBits  = 8;
                serial.StopBits  = StopBits.One;

                fingerPrint.RunWorkerAsync();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemple #2
0
        private void fingerPrint_DoWork(object sender, DoWorkEventArgs e)
        {
            string          pattern = @"#\d+";
            Regex           rgx;
            MatchCollection mc;
            Match           match;
            string          rec;

            serial.Open();

            try
            {
                serial.WriteLine("2");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                serial.Close();
            }

            this.Dispatcher.BeginInvoke((Action) delegate() {
                RichTextBoxSerial.AppendText("Place your finger for verification\n");
                RichTextBoxSerial.ScrollToEnd();
            });

            this.Dispatcher.BeginInvoke((Action) delegate() {
                LabelStatus.Content = "Place finger now";
            });

            while (true)
            {
                try
                {
                    serial.WriteLine("2");

                    rec = serial.ReadLine();
                    this.Dispatcher.BeginInvoke((Action) delegate() {
                        RichTextBoxSerial.AppendText(rec);
                        RichTextBoxSerial.ScrollToEnd();
                    });

                    if (rec.Length > 0)
                    {
                        pattern = @"#\d+";
                        rgx     = new Regex(pattern);
                        mc      = rgx.Matches(rec);
                        match   = rgx.Match(rec);

                        if (match.Success)
                        {
                            id = Convert.ToInt32(mc[0].ToString().Replace("#", ""));

                            if (id != 0)
                            {
                                MySqlHelper helper           = new MySqlHelper();
                                string      connectionString = "datasource=localhost; port=3306; username="******"; password="******"db_atm", "t_customers", id);
                                fingerVerified = helper.IDConfirmed(connectionString, "db_atm", "t_customers", acn, id);

                                if (fingerVerified)
                                {
                                    break;
                                }
                            }
                        }

                        pattern = @"not";
                        rgx     = new Regex(pattern);
                        mc      = rgx.Matches(rec);
                        match   = rgx.Match(rec);

                        if (match.Success)
                        {
                            failCount++;

                            if (failCount < 3)
                            {
                                MessageBox.Show("Did not find a match.\nTry again when prompted to");
                            }
                        }

                        if (failCount == 3)
                        {
                            MessageBox.Show("ATM card temporarily disabled");

                            serial.Close();
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    serial.Close();
                }
            }
        }
Exemple #3
0
        private void fingerPrint_DoWork(object sender, DoWorkEventArgs e)
        {
            string rec    = "";
            string recOld = "";
            int    index  = 0;

            if (serial.IsOpen)
            {
                serial.WriteLine("1");
            }
            else
            {
                MessageBox.Show("Couldn't start serial");
            }

            this.Dispatcher.BeginInvoke((Action) delegate() {
                LabelStatus.Content = "Put your " + dict[1];
            });

            while (index < N)
            {
                recOld = rec;
                rec    = serial.ReadLine();

                if (rec.Trim().Equals(recOld.Trim()) || rec.Trim().Length == 0)
                {
                    continue;
                }

                this.Dispatcher.BeginInvoke((Action) delegate() {
                    RichTextBoxSerial.AppendText((line++).ToString() + ". " + rec);
                    RichTextBoxSerial.ScrollToEnd();
                });

                match = rgxGetting.Match(rec);

                if (match.Success)
                {
                    serial.WriteLine(id.ToString());
                }

                match = rgxCommand.Match(rec);

                if (match.Success)
                {
                    serial.WriteLine("1");
                }

                match = rgxStored.Match(rec);

                if (match.Success)
                {
                    customer.GetFingerPrints()[index] = id;
                    id++;
                    index++;

                    if (index < 9)
                    {
                        this.Dispatcher.BeginInvoke((Action) delegate() {
                            LabelStatus.Content = "Put your " + dict[index + 1];
                        });
                    }
                }

                match = rgxRetry.Match(rec);

                if (match.Success)
                {
                    serial.WriteLine(id.ToString());
                    this.Dispatcher.BeginInvoke((Action) delegate() {
                        LabelStatus.Content = "Put your " + dict[index + 1] + " again";
                    });
                }
            }
        }