Exemple #1
0
    public void OnLoginClicked()
    {
        /*m_mainController.SetCurrentPatient(new Patient() { FullName = "MY TEST p" });
         * Therapist therapist = GetUser();
         * therapist.FirstName = "Bar";
         * therapist.LastName = "Attaly";
         * therapist.Email = "*****@*****.**";
         * m_mainController.SetLoggedInTherapist(therapist);
         * m_mainController.ShowScreen(ScreensIndex.TherapistScreen);
         * //return;*/
        int UserName;

        m_statusText.text = "";
        try
        {
            if (m_userNameField.text == string.Empty || m_realPassword == string.Empty)
            {
                m_statusText.text = "Please fill all data";
                return;
            }
            if (!int.TryParse(m_userNameField.text, out UserName))
            {
                m_statusText.text = "Please enter only numbers on username field";
                return;
            }

            Therapist existingUser = QuestFileManager.GetTherapistFromFile(FilePath);

            if (existingUser != null)
            {
                if (existingUser.Password == GetUser().Password)
                {
                    m_mainController.SetLoggedInTherapist(existingUser);
                    m_mainController.ShowScreen(ScreensIndex.TherapistScreen);
                    ClearScreen();
                    return;
                }
                m_statusText.text = "Wrong password";
                return;
            }
            m_statusText.text = "User not found";
        }
        catch (Exception e)
        {
            m_statusText.text = "";
            // This is the first place that if we dont have the permission for some reason
            // an excetion will be thrown so we check that we have the permissions just in case:
            if (!Permission.HasUserAuthorizedPermission(Permission.ExternalStorageWrite) ||
                !Permission.HasUserAuthorizedPermission(Permission.ExternalStorageRead))
            {
                Permission.RequestUserPermission(Permission.ExternalStorageWrite);
                Permission.RequestUserPermission(Permission.ExternalStorageRead);
            }
            else
            {
                m_statusText.text = "Something went wrong. Please restart the application.";
            }
            PrintToLog(e.ToString(), MainController.LogType.Error);
        }
    }
    public void OnLoginClicked()
    {
        /*//m_mainController.SetCurrentPatient(new Patient() { FullName = "MY TEST p" });
         * Therapist therapist = GetUser();
         * therapist.FirstName = "Bar";
         * therapist.LastName = "Attaly";
         * therapist.Email = "*****@*****.**";
         * //therapist.Settings = m_mainController.DefaultSettings;
         * therapist.Settings = new Settings
         * {
         *  SkyBoxColor = m_mainController.DefaultSettings.SkyBoxColor,
         *  ButtonsColorBlock = m_mainController.DefaultSettings.ButtonsColorBlock,
         *  ButtonsTextColor = m_mainController.DefaultSettings.ButtonsTextColor,
         *  SlidersColorBlock = m_mainController.DefaultSettings.SlidersColorBlock
         * };
         * m_mainController.SetLoggedInTherapist(therapist);
         * m_mainController.ShowScreen(ScreensIndex.TherapistScreen);
         * return;*/
        int UserName;

        try
        {
            if (m_userNameField.text == string.Empty || m_realPassword == string.Empty)
            {
                m_statusText.text = "Please fill all data";
                return;
            }
            if (!int.TryParse(m_userNameField.text, out UserName))
            {
                m_statusText.text = "Please enter only numbers on username field";
                return;
            }

            Therapist existingUser = QuestFileManager.GetTherapistFromFile(FilePath);

            if (existingUser != null)
            {
                if (existingUser.Password == GetUser().Password)
                {
                    m_mainController.SetLoggedInTherapist(existingUser);
                    m_mainController.ShowScreen(ScreensIndex.TherapistScreen);
                    ClearScreen();
                    return;
                }
                m_statusText.text = "Wrong password";
                return;
            }
            m_statusText.text = "User not found";
        }
        catch (Exception e)
        {
            PrintToLog(e.ToString(), MainController.LogType.Error);
        }
    }
Exemple #3
0
    public void OnConfirmClicked()
    {
        int UserName;

        try
        {
            m_statusText.text = string.Empty;
            if (m_userNameField.text == string.Empty || m_passwordField.text == string.Empty ||
                m_firstNameField.text == string.Empty || m_lastNameField.text == string.Empty)
            {
                m_statusText.text = "Please fill all data";
                return;
            }
            if (!int.TryParse(m_userNameField.text, out UserName))
            {
                m_statusText.text = "Please enter only numbers on ID field";
                return;
            }
            if (!m_firstNameField.text.All(char.IsLetter) || !m_lastNameField.text.All(char.IsLetter))
            {
                m_statusText.text = "Please enter only letters on Name fields";
                return;
            }
            if (!IsValidEmail(m_emailField.text))
            {
                m_statusText.text = "Please enter a valid email address";
                return;
            }
            if (QuestFileManager.GetTherapistFromFile(FilePath) == null)
            {
                m_statusText.text = "Therapist doesn't exists";
                return;
            }
            Therapist therapist = GetUserFromGui();
            m_mainController.LoggedInTherapist.Password  = therapist.Password;
            m_mainController.LoggedInTherapist.FirstName = therapist.FirstName;
            m_mainController.LoggedInTherapist.LastName  = therapist.LastName;
            m_mainController.LoggedInTherapist.Email     = therapist.Email;
            QuestFileManager.UpdateTherapistOnFile(m_mainController.LoggedInTherapist, FilePath);
            m_mainController.ShowPopup(MessageController.MessageType.Succsess, "Therapist details has been updated!", OnPopupAnswer);
            PrintToLog("Therapist's details update: " + m_mainController.LoggedInTherapist.FirstName + " " + m_mainController.LoggedInTherapist.LastName + ", id: "
                       + m_mainController.LoggedInTherapist.Username + ".", MainController.LogType.Information);
        }
        catch (Exception e)
        {
            PrintToLog(e.ToString(), MainController.LogType.Error);
        }
    }
    public void OnLoginClicked()
    {
        int UserName;

        m_statusText.text = "";
        try
        {
            if (m_userNameField.text == string.Empty || m_realPassword == string.Empty)
            {
                m_statusText.text = "Please fill all data";
                return;
            }
            if (!int.TryParse(m_userNameField.text, out UserName))
            {
                m_statusText.text = "Please enter only numbers on username field";
                return;
            }

            Therapist existingUser = QuestFileManager.GetTherapistFromFile(FilePath);

            if (existingUser != null)
            {
                if (existingUser.Password == GetUser().Password)
                {
                    m_mainController.SetLoggedInTherapist(existingUser);
                    //in case this is an old user, and it doesn't have settings attribute
                    if (m_mainController.LoggedInTherapist.Settings == null)
                    {
                        m_mainController.LoggedInTherapist.Settings = new Settings()
                        {
                            SkyBoxColor       = m_mainController.DefaultSettings.SkyBoxColor,
                            ButtonsColorBlock = m_mainController.DefaultSettings.ButtonsColorBlock,
                            ButtonsTextColor  = m_mainController.DefaultSettings.ButtonsTextColor,
                        };
                    }
                    m_mainController.ShowScreen(ScreensIndex.TherapistScreen);
                    ClearScreen();
                    return;
                }
                m_statusText.text = "Wrong password";
                return;
            }
            m_statusText.text = "User not found";
        }
        catch (Exception e)
        {
            m_statusText.text = "";
            // This is the first place that if we dont have the permission for some reason
            // an excetion will be thrown so we check that we have the permissions just in case:
            if (!Permission.HasUserAuthorizedPermission(Permission.ExternalStorageWrite) ||
                !Permission.HasUserAuthorizedPermission(Permission.ExternalStorageRead))
            {
                Permission.RequestUserPermission(Permission.ExternalStorageWrite);
                Permission.RequestUserPermission(Permission.ExternalStorageRead);
            }
            else
            {
                m_statusText.text = "Something went wrong. Please restart the application.";
            }
            PrintToLog(e.ToString(), MainController.LogType.Error);
        }
    }