Ejemplo n.º 1
0
        private async void allowAccessButtonClicked(object sender, RoutedEventArgs e)
        {
            if (usersNotAllowedDropdown.SelectedItem == null)
            {
                Synthesizer.Speak("Please select the user you want to allow in the room.");
            }
            else
            {
                String[]      userInfo         = usersNotAllowedDropdown.SelectedItem.ToString().Split(',');
                ContentDialog deleteUserDialog = new ContentDialog
                {
                    Title               = "Are you sure you want to allow " + userInfo[1] + " in the room?",
                    PrimaryButtonText   = "Yes",
                    SecondaryButtonText = "Cancel",
                };

                ContentDialogResult result = await deleteUserDialog.ShowAsync();

                if (result == ContentDialogResult.Primary)
                {
                    SqliteTransactions.ModifyAccessByUserId(userInfo[0], true);
                    LoadUsers();
                }
                else
                {
                    deleteUserDialog.Hide();
                }
            }
        }
Ejemplo n.º 2
0
 public static void ShowUsersDB()
 {
     Debug.WriteLine("These are the actual users in the system.");
     foreach (User user in SqliteTransactions.GetAllUsers())
     {
         Debug.WriteLine("UserID: " + user.userId + " First Name: " + user.firstName + " Last Name: " + user.lastName + " Phrase: " + user.phrase + " Speaker Id: " + user.speakerId);
     }
 }
        private async void verificationButtonClicked(object sender, RoutedEventArgs e)
        {
            if (!newUser)
            {
                progressRing.IsActive = true;
                Verification verificationResult = await verificationController.VerifySpeaker(speakerID);

                progressRing.IsActive = false;
                if (verificationResult != null)
                {
                    if (verificationResult.Result.ToString().Equals("Accept") &&
                        (verificationResult.Confidence.ToString().Equals("High") || verificationResult.Confidence.ToString().Equals("Normal")))
                    {
                        if (!isAdmin)
                        {
                            if (user.access)
                            {
                                Synthesizer.Speak("Please come on in.");
                                //OPEN DOOR
                                MainPage.DLPin.Write(Windows.Devices.Gpio.GpioPinValue.High);
                                await Task.Delay(10000);

                                MainPage.DLPin.Write(Windows.Devices.Gpio.GpioPinValue.Low);
                                this.Frame.GoBack();
                            }
                            else
                            {
                                Synthesizer.Speak("I am sorry " + user.firstName + ", you are not allowed in this room. You should contact the Administrator.");
                                this.Frame.GoBack();
                            }
                        }
                        else
                        {
                            Synthesizer.Speak("Opening Administrator page.");
                            this.Frame.Navigate(typeof(AdminPage));
                        }
                    }
                    else
                    {
                        failedVerifications++;
                        if (failedVerifications < 3)
                        {
                            Synthesizer.Speak("I am sorry Dave, I'm afraid I cannot do that.");
                        }
                        else
                        {
                            SqliteTransactions.ModifyAccessByUserId(user.userId, false);
                            Synthesizer.Speak("For security purposes, I have to deny your access to the room. You should contact the Administrator.");
                            this.Frame.GoBack();
                        }
                    }
                }
            }
            else
            {
                Synthesizer.Speak("I need you to record your voice first.");
            }
        }
        private async void Timer_Tick(object sender, object e)
        {
            //This part of the code will be reached if a time equal to timer.Interval is exceded after reading a bit
            Debug.WriteLine(bitCount);
            Debug.WriteLine(ones);
            timer.Stop();
            //We are working wih 35 bit Cards
            if (bitCount == 35 && ones % 2 != 0)
            {
                bitCount = 0;
                progressRing.IsActive = true;
                //Get user information through the SOAP service using 6 bits Card Number
                String[] userData = await soapService.GetUserInfo(FormatCard());

                progressRing.IsActive = false;

                //If there is a user in IIT's database with that 6 digit card number
                if (userData != null)
                {
                    String lastName  = userData[0];
                    String firstName = userData[1];
                    String userId    = userData[3];
                    Debug.WriteLine(userId + ": " + firstName + " " + lastName);

                    //Check if user is already registered in the Speaker Recognition Database
                    User user = SqliteTransactions.GetUserByUserId(userId);

                    //if not
                    if (user == null)
                    {
                        //Create new user with user info and open Enrollment Page
                        user           = new User();
                        user.firstName = firstName;
                        user.lastName  = lastName;
                        user.userId    = userId;
                        user.access    = false;
                        OpenEnrollment(user);
                    }
                    else
                    {
                        OpenVerification(user);
                    }
                }
                else
                {
                    Debug.WriteLine("Card reading was wrong, or user not found.");
                    Synthesizer.Speak("Scan your card again.");
                }
            }
            else
            {
                //If the number of bits is different from 35 or odd number of ones, we will take it as a wrong read
                Synthesizer.Speak("Scan your card again.");
                bitCount = 0;
                FormatCard();
            }
        }
        private async void enrollmentButtonClicked(object sender, RoutedEventArgs e)
        {
            if (!newUser)
            {
                if (recorded)
                {
                    progressRing.IsActive = true;
                    //Enroll speaker
                    Enrollment enrollmentResult = await enrollmentController.EnrollSpeaker();

                    progressRing.IsActive = false;
                    if (enrollmentResult != null)
                    {
                        enrollmentController.firstEnrollment = false;
                        int    remainingEnrollments = enrollmentResult.RemainingEnrollments;
                        string enrollmentStatus     = enrollmentResult.EnrollmentStatus.ToString();

                        if (!enrollmentStatus.Equals("Enrolled"))
                        {
                            if (remainingEnrollments == 1)
                            {
                                Synthesizer.Speak("The system needs " + remainingEnrollments + " last enrollment, please repeat the previous step.");
                            }
                            else
                            {
                                Synthesizer.Speak("The system needs " + remainingEnrollments + " more enrollments, please repeat the previous step.");
                            }
                            recorded = false;
                        }
                        else
                        {
                            //Add user to database
                            SqliteTransactions.AddUser(user);
                            Synthesizer.Speak("You have been succesfully enrolled. Contact the Administrator to get access to the room.");
                            this.Frame.GoBack();
                        }
                    }
                }
                else
                {
                    Synthesizer.Speak("I need a different audio sample. Please repeat the previous step.");
                }
            }
            else
            {
                Synthesizer.Speak("I need you to record your voice first.");
            }
        }
Ejemplo n.º 6
0
        private void LoadUsers()
        {
            usersAllowedDropdown.Items.Clear();
            usersNotAllowedDropdown.Items.Clear();
            List <User> users = SqliteTransactions.GetAllUsers();

            foreach (User user in users)
            {
                if (!user.userId.Equals("A20387795"))
                {
                    if (user.access)
                    {
                        usersAllowedDropdown.Items.Add(user.userId + ", " + user.firstName + " " + user.lastName);
                    }
                    else
                    {
                        usersNotAllowedDropdown.Items.Add(user.userId + ", " + user.firstName + " " + user.lastName);
                    }
                }
            }
        }