Пример #1
0
        public EditUserInfo()
        {
            InitializeComponent();
            string selected_UserID = (App.Current as App).LoginUserID;

            ConnectionStringSettings conSettings = ConfigurationManager.ConnectionStrings["connString"];

            connectionString = conSettings.ConnectionString;
            try
            {
                con = new SqlConnection(connectionString);
                con.Open();

                UserModel.UserModel cm = UserModel.UserModel.retrieveUserFromDatabase(selected_UserID);
                cmd    = new SqlCommand("select * from [dbo].[test] where UserID = '" + selected_UserID + "'", con);
                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    Console.WriteLine(" | UserID : " + reader.GetString(0) + " | Password : "******" | Name : " + reader.GetString(2) + " | Email : " + reader.GetString(3) + " | ContactNo : " + reader.GetString(4) + " | DOB : " + reader.GetString(5) + " | SecurityQ1 : " + reader.GetString(6) + " | Q1Ans : " + reader.GetString(7) + " | SecurityQ2 : " + reader.GetString(8) + " | Q2Ans : " + reader.GetString(9));
                    (App.Current as App).UserID       = reader.GetString(0);
                    (App.Current as App).UserPassword = reader.GetString(1);
                    (App.Current as App).UserName     = reader.GetString(2);
                    (App.Current as App).UserEmail    = reader.GetString(3);
                    (App.Current as App).UserContact  = reader.GetString(4);
                    (App.Current as App).UserDOB      = reader.GetString(5);
                    (App.Current as App).SecurityQ1   = reader.GetString(6);
                    (App.Current as App).Q1Ans        = reader.GetString(7);
                    (App.Current as App).SecurityQ2   = reader.GetString(8);
                    (App.Current as App).Q2Ans        = reader.GetString(9);
                    userpassword = reader.GetString(1);
                    Console.WriteLine(cm.profile1);
                    Console.WriteLine(cm.profile2);
                    userID = reader.GetString(0);
                    string preference1 = cm.profile1;
                    string preference2 = cm.profile2;
                    string preference3 = cm.profile3;
                    string preference4 = cm.profile4;
                    setProfile1Preference(preference1);
                    setProfile2Preference(preference2);
                    setProfile3Preference(preference3);
                    setProfile4Preference(preference4);
                    ChangeInfoName.Text  = reader.GetString(2);
                    ChangeInfoQ1.Text    = reader.GetString(6);
                    ChangeInfoQ1Ans.Text = reader.GetString(7);
                    ChangeInfoQ2.Text    = reader.GetString(8);
                    ChangeInfoQ2Ans.Text = reader.GetString(9);
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.Message);
            }
            finally
            {
                con.Close();
            }
        }
        private void NextPageHandler(object sender, MouseButtonEventArgs e)
        {
            Boolean isValidated = CurrentPageModel.secondValidation;
            string  data        = null;

            if (option1.IsChecked == true)
            {
                data = "a";
            }
            if (option2.IsChecked == true)
            {
                data = "b";
            }
            if (option3.IsChecked == true)
            {
                data = "c";
            }
            if (option4.IsChecked == true)
            {
                data = "d";
            }
            CurrentPageModel.secondValidation = true;
            UserModel.UserModel currentUserModel = UserModel.UserModel.currentUserModel;
            currentUserModel.profile2            = data;
            UserModel.UserModel.currentUserModel = currentUserModel;
            if (isValidated == true)
            {
                CurrentPageModel currentClass = CurrentPageModel.getcurrentclass();
                currentClass._currentPage = "2";
                Page page3 = CurrentPageModel.thirdPage;

                if (page3 == null)
                {
                    Page currentPage = new ProfileCreationPage3();
                    this.NavigationService.Navigate(currentPage);
                }
                else
                {
                    this.NavigationService.Navigate(page3);
                    WpfApp1.NavigationControls.NavigationControls thirdControl = (WpfApp1.NavigationControls.NavigationControls)CurrentPageModel.thirdControl;
                    thirdControl.buttonManipulation(currentClass.currentpage);
                    thirdControl.PageNumber.Text = thirdControl.currentPageNumber(currentClass.currentpage);
                }
            }
            else
            {
                MessageBox.Show("No option have been chosen. Please choose your option");
            }
            //Save the Instance of the second page//
            CurrentPageModel.secondPage = this;
            //Save the Instance of the second page controls//
            CurrentPageModel.secondControl = page2Controls;
        }
Пример #3
0
        protected override DocumentModel SetModel(Document entity)
        {
            List <MarginModel>    documentMargins    = ConvertBodysToModels(entity.DocumentMargins);
            List <ParagraphModel> documentParagraphs = ConvertParagraphsToModels(entity.DocumentParagraphs);

            UserModel.UserModel userModel = ConvertUserToModel(entity.CreatorUser);

            Id                 = entity.Id;
            CreatorUser        = userModel;
            Title              = entity.Title;
            CreationDate       = entity.CreationDate;
            LastModifyDate     = entity.LastModifyDate;
            OwnStyleClass      = entity.OwnStyleClass;
            DocumentMargins    = documentMargins;
            DocumentParagraphs = documentParagraphs;
            return(this);
        }
Пример #4
0
        private void ForgotPassword3NextButton_Click(object sender, RoutedEventArgs e)
        {
            string selected_ForgotPasswordCode = UserModel.UserModel.twoFAcode;

            UserModel.UserModel cm = UserModel.UserModel._currentUserModel;
            string userID          = cm.userID;

            Console.WriteLine(userID + "TEICJASMCA");
            if (ForgotPasswordCodeTextBox.Text == selected_ForgotPasswordCode)
            {
                MessageBox.Show("Correct!");
                string date      = AlgorithmLibary.PredictionModel.getCurrentDate();
                string loginTime = DateTime.Now.ToString("HH.mm");
                string publicIP  = PredictionModel.getCurrentPublicIP();
                string publicMAC = PredictionModel.getCurrentMAC();
                Console.WriteLine(publicMAC + "HELLO");

                UserModel.UserModel.saveDateTimeOfUser(userID, connectionString, loginTime, date, publicIP, publicMAC);
                string        exist = UserModel.UserModel.checkFollowUp(userID, connectionString);
                SqlConnection con;
                SqlCommand    cmd;
                string        riskLevelStatement = null;
                riskLevelStatement = "Low";

                con = new SqlConnection(connectionString);
                try
                {
                    string connectionString = conSettings.ConnectionString;

                    con = new SqlConnection(connectionString);
                    con.Open();
                    cmd = new SqlCommand("DELETE FROM [dbo].[FailedAttempt] where UserID = '" + userID + "'", con);
                    cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    System.Windows.MessageBox.Show(ex.Message);
                }
                finally
                {
                    con.Close();
                }
                if (exist != null)
                {
                    UserModel.UserModel.updateFollowUp(userID, connectionString, "False");


                    //Navigate to Chester page
                    //Page cloud = new StartupPage();
                    //this.NavigationService.Navigate(cloud);
                }

                else
                {
                    UserModel.UserModel.saveFollowUp(userID, connectionString, "False");
                    //Navigate To chester page
                    //Page cloud = new StartupPage();
                    //this.NavigationService.Navigate(cloud);
                }
                PredictionModel.SessionRiskValue = riskLevelStatement;
                UserModel.UserModel.twoFASucceed = true;
            }
            else
            {
                MessageBox.Show("Invalid code! Please Try Again");
                counter++;
                if (counter > 3)
                {
                    MessageBox.Show("More than 3  Failed attempts! Account will be locked now!");
                    string exist = UserModel.UserModel.checkFollowUp(userID, connectionString);
                    UserModel.UserModel.deleteDateTimeOfUser(userID, connectionString, loginTime, date);
                    if (exist != null)
                    {
                        UserModel.UserModel.updateFollowUp(userID, connectionString, "True");
                    }
                    else
                    {
                        UserModel.UserModel.saveFollowUp(userID, connectionString, "True");
                    }

                    counter = 0;
                    UserModel.UserModel.twoFASucceed = false;
                }
            }
        }
Пример #5
0
        //private void saveDateTimeOfUser(string userID, string connectionString, string loginTime, string date, string publicIP, string publicMAC)
        //{
        //    SqlConnection con;
        //    SqlCommand cmd;
        //    con = new SqlConnection(connectionString);
        //    string currentHostname = System.Environment.MachineName.ToString();
        //    con.Open();
        //    try
        //    {


        //        cmd = new SqlCommand("INSERT INTO [dbo].[LogAnalysis] (UserID, LoginTime, LoginDate, IpAddress , MacAddress , hostname) VALUES (@UserID, @LoginTime, @LoginDate , @IPAddress , @MACAddress , @HostName)", con);
        //        cmd.Parameters.AddWithValue("@UserID", userID);
        //        cmd.Parameters.AddWithValue("@LoginTime", loginTime);
        //        cmd.Parameters.AddWithValue("@LoginDate", date.ToString());
        //        cmd.Parameters.AddWithValue("@IPAddress", publicIP);
        //        cmd.Parameters.AddWithValue("@MACAddress", publicMAC);
        //        cmd.Parameters.AddWithValue("@HostName", currentHostname);
        //        cmd.ExecuteNonQuery();

        //    }
        //    catch (Exception ex)
        //    {
        //        Console.WriteLine(ex.Message);
        //    }
        //    finally
        //    {
        //        con.Close();
        //    }
        //}

        private void ForgotPassword3NextButton_Click(object sender, RoutedEventArgs e)
        {
            string selected_ForgotPasswordCode = UserModel.UserModel.twoFAcode;

            UserModel.UserModel cm = UserModel.UserModel._currentUserModel;
            string userID          = cm.userID;

            if (ForgotPasswordCodeTextBox.Text == selected_ForgotPasswordCode)
            {
                MessageBox.Show("Correct!");
                string date      = AlgorithmLibary.PredictionModel.getCurrentDate();
                string loginTime = DateTime.Now.ToString("HH.mm");
                string publicIP  = PredictionModel.getCurrentPublicIP();
                string publicMAC = PredictionModel.getCurrentMAC();
                Console.WriteLine(publicMAC + "HELLO");
                string riskLevelStatement = "Low";
                //Use the same class for saveDateTime Method - Justin Changed at 1:20 am on 6/8/2017
                UserModel.UserModel.saveDateTimeOfUser(userID, connectionString, loginTime, date, publicIP, publicMAC);
                string exist = UserModel.UserModel.checkFollowUp(userID, connectionString);

                string selected_UserID = (App.Current as App).LoginUserID;

                try
                {
                    string connectionString = conSettings.ConnectionString;

                    con = new SqlConnection(connectionString);
                    con.Open();
                    cmd = new SqlCommand("DELETE FROM [dbo].[FailedAttempt] where UserID = '" + selected_UserID + "'", con);
                    cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    System.Windows.MessageBox.Show(ex.Message);
                }
                finally
                {
                    con.Close();
                }

                if (exist != null)
                {
                    UserModel.UserModel.updateFollowUp(userID, connectionString, "False");
                }
                else
                {
                    UserModel.UserModel.saveFollowUp(userID, connectionString, "False");
                }

                Page cloud = new StartupPage();
                PredictionModel.SessionRiskValue = riskLevelStatement;
                this.NavigationService.Navigate(cloud);
            }
            else
            {
                MessageBox.Show("Invalid code! Please Try Again");
                //Remove the statement below because it will conflict with my fe
                counter++;
                if (counter > 3)
                {
                    MessageBox.Show("More than 3 attempts! Account will be locked now!");
                    string exist = UserModel.UserModel.checkFollowUp(userID, connectionString);
                    if (exist != null)
                    {
                        UserModel.UserModel.updateFollowUp(userID, connectionString, "True");
                    }
                    else
                    {
                        UserModel.UserModel.saveFollowUp(userID, connectionString, "True");
                    }
                    Page LoginPage = new LoginPage();
                    this.NavigationService.Navigate(LoginPage);
                }
            }
        }
Пример #6
0
 private User ConvertModelToUser(UserModel.UserModel userModel)
 {
     return(userModel.ToEntity());
 }
        private void NextPageHandler(object sender, MouseButtonEventArgs e)
        {
            Boolean isValidated = CurrentPageModel.fourthValidation;
            string  finalString = getFinalString();

            UserModel.UserModel currentUserModel = UserModel.UserModel.currentUserModel;
            currentUserModel.profile4            = finalString;
            UserModel.UserModel.currentUserModel = currentUserModel;



            if (
                CurrentPageModel.firstValidation == true &&
                CurrentPageModel.secondValidation == true &&
                CurrentPageModel.thirdValidation == true &&
                CurrentPageModel.fourthValidation == true
                )
            {
                //MessageBox.Show(currentUserModel.userName);
                //MessageBox.Show(currentUserModel.profile1);
                //MessageBox.Show(currentUserModel.profile2);
                //MessageBox.Show(currentUserModel.profile3);
                //MessageBox.Show(currentUserModel.profile4);
                currentUserModel.saveToDatabase();
                MessageBox.Show("Successfully Completed Profiling Survey");
                this.NavigationService.Navigate(new Uri(@"LoginPage.xaml", UriKind.RelativeOrAbsolute));
            }
            else
            {
                MessageBox.Show("Typing test hasn't been completed");
            }
            //if (isValidated == true)
            //{
            //    //Get the current instance of the navigation class
            //    CurrentPageModel currentClass = CurrentPageModel.getcurrentclass();
            //    currentClass.currentpage = "4";
            //    for(int i = 0; i < _checkBoxValue.Count(); i++)
            //    {
            //        Console.WriteLine(_checkBoxValue[i]);
            //    }
            //    Page page5 = CurrentPageModel.fifthPage;
            //    if (page5 == null)
            //    {
            //        Page currentPage = new ProfileCreationPage5();
            //        this.NavigationService.Navigate(currentPage);
            //    }
            //    else
            //    {
            //        //Load in the instance of the page
            //        this.NavigationService.Navigate(page5);
            //        //Load in the current navigation control
            //        WpfApp1.NavigationControls.NavigationControls fifthControl = (WpfApp1.NavigationControls.NavigationControls)CurrentPageModel.fifthControl;
            //        //Set the button manipulation
            //        fifthControl.buttonManipulation(currentClass.currentpage);
            //        //Set the page number
            //        fifthControl.PageNumber.Text = fifthControl.currentPageNumber(currentClass.currentpage);

            //    }
            //}
            //else
            //{
            //    MessageBox.Show("No option have been chosen. Please choose your option");
            //}
            //Save current instance of the page
            CurrentPageModel.fourthPage = this;
            //Save current instance of the user control
            CurrentPageModel.fourthControl = page4Controls;
        }
Пример #8
0
        private void SignUp2NextButton_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(SecurityQuestion1TextBox.Text) || String.IsNullOrEmpty(SecurityQuestion2TextBox.Text) ||
                String.IsNullOrEmpty(Answer1TextBox.Text) || String.IsNullOrEmpty(Answer2TextBox.Text))
            {
                MessageBox.Show("Please fill in all blanks!");

                if (String.IsNullOrEmpty(SecurityQuestion1TextBox.Text))
                {
                    Q1Image.Visibility = Visibility.Visible;
                }

                else
                {
                    Q1Image.Visibility = Visibility.Hidden;
                }

                if (String.IsNullOrEmpty(SecurityQuestion2TextBox.Text))
                {
                    Q2Image.Visibility = Visibility.Visible;
                }

                else
                {
                    Q2Image.Visibility = Visibility.Hidden;
                }

                if (String.IsNullOrEmpty(Answer1TextBox.Text))
                {
                    A1Image.Visibility = Visibility.Visible;
                }

                else
                {
                    A1Image.Visibility = Visibility.Hidden;
                }

                if (String.IsNullOrEmpty(Answer2TextBox.Text))
                {
                    A2Image.Visibility = Visibility.Visible;
                }

                else
                {
                    A2Image.Visibility = Visibility.Hidden;
                }
            }

            else
            {
                string selected_userID = (App.Current as App).UserID;

                string selected_userPassword = (App.Current as App).UserPassword;

                string selected_userName = (App.Current as App).UserName;

                string selected_userEmail = (App.Current as App).UserEmail;

                string selected_userContact = (App.Current as App).UserContact;

                string selected_userDOB = (App.Current as App).UserDOB;

                string selected_securityQ1 = SecurityQuestion1TextBox.Text;

                string selected_securityQ1Ans = Answer1TextBox.Text;

                string selected_securityQ2 = SecurityQuestion2TextBox.Text;

                string selected_securityQ2Ans = Answer2TextBox.Text;

                //Comment out the method to save to database
                UserModel.UserModel newModel = new UserModel.UserModel(selected_userID, selected_userPassword, selected_userName, selected_userEmail, selected_userContact, selected_userDOB,
                                                                       selected_securityQ1, selected_securityQ1Ans, selected_securityQ2, selected_securityQ2Ans);

                UserModel.UserModel.currentUserModel = newModel;

                //newModel.saveToDatabase();

                //ConnectionStringSettings conSettings = ConfigurationManager.ConnectionStrings["connString"];
                //string connectionString = conSettings.ConnectionString;

                //try
                //{
                //    con = new SqlConnection(connectionString);
                //    con.Open();
                //    cmd = new SqlCommand("INSERT INTO [dbo].[test] (UserID, Password, Name, Email, ContactNo, DOB, SecurityQ1, Q1Ans, SecurityQ2, Q2Ans) VALUES (@UserID, @Password, @Name, @Email, @ContactNo, @DOB, @SecurityQ1, @Q1Ans, @SecurityQ2, @Q2Ans)", con);
                //    cmd.Parameters.AddWithValue("@UserID", selected_userID);
                //    cmd.Parameters.AddWithValue("@Password", selected_userPassword);
                //    cmd.Parameters.AddWithValue("@Name", selected_userName);
                //    cmd.Parameters.AddWithValue("@Email", selected_userEmail);
                //    cmd.Parameters.AddWithValue("@ContactNo", selected_userContact);
                //    cmd.Parameters.AddWithValue("@DOB", selected_userDOB);
                //    cmd.Parameters.AddWithValue("@SecurityQ1", SecurityQuestion1TextBox.Text);
                //    cmd.Parameters.AddWithValue("@Q1Ans", Answer1TextBox.Text);
                //    cmd.Parameters.AddWithValue("@SecurityQ2", SecurityQuestion2TextBox.Text);
                //    cmd.Parameters.AddWithValue("@Q2Ans", Answer2TextBox.Text);

                //    cmd.ExecuteNonQuery();

                //}
                //catch (Exception ex)
                //{
                //    System.Windows.MessageBox.Show(ex.Message);
                //}
                //finally
                //{

                //    con.Close();
                //}

                //MessageBox.Show("You're almost done. An email has been sent to your email address. Please verify your email address, thank you!");
                CurrentPageModel currentModel = new CurrentPageModel();
                Page             currentPage  = new WpfApp1.ProfilePages.Page1();
                this.NavigationService.Navigate(currentPage);
                //rootBox.NavigationService.Navigate(currentPage);
                //this.NavigationService.Navigate(new Uri(@"SignUp3.xaml", UriKind.RelativeOrAbsolute));
            }
        }
Пример #9
0
 public Page1()
 {
     InitializeComponent();
     UserModel.UserModel cm = UserModel.UserModel.currentUserModel;
     nameBox.Text = cm.userID;
 }