Пример #1
0
    IEnumerator check(string lrn, string username)
    {
        string CheckingUrl = "https://scivre.herokuapp.com/api/webapichecklrn";

        canvasLoad.SetActive(true);
        lblLoader.text = "Checking Credentials";

        errorfield.text = "";
        if (Validation1.checkConnectionfail() == true)
        {
            errorfield.text = "Error: Internet Connection";
            canvasLoad.SetActive(false);
        }
        else
        {
            WWWForm form = new WWWForm();

            form.AddField("name", username);
            form.AddField("student_id", lrn);

            using (UnityWebRequest www = UnityWebRequest.Post(CheckingUrl, form))
            {
                www.chunkedTransfer = false;
                //loading for accessing web kung existing ba accoutn    VALIDATING

                yield return(www.SendWebRequest());

                if (www.error != null)
                {
                    errorfield.text = "Error webserver request error: " + www.error;
                    canvasLoad.SetActive(false);
                }
                else
                {
                    Debug.Log("Response" + www.downloadHandler.text);
                    Validation1.UserDetail userDetail = JsonUtility.FromJson <Validation1.UserDetail> (www.downloadHandler.text);
                    Debug.Log(userDetail.status.ToString());


                    //reponse details
                    if (userDetail.status == 1)
                    {
                        StartCoroutine(fetch(lrn));
                    }
                    else
                    {
                        errorfield.text = "Account does not exist!";
                        canvasLoad.SetActive(false);
                    }
                }
            }
        }
    }
Пример #2
0
    IEnumerator  Changepass(string password, string name)
    {
        string ChangepassUrl = "https://scivre.herokuapp.com/api/webapichangepass";

        canvasLoad.SetActive(true);
        lblLoader.text = "Sending Request to webserver";

        //	first if checking internet connection ang web serve response pare
        if (Validation1.checkConnectionfail() == true)
        {
            errorfieldchange.text = "Error: Internet Connection";
            canvasLoad.SetActive(false);
        }
        else

        {
            //Checking web server response
            WWWForm form = new WWWForm();
            Debug.Log(password);
            form.AddField("password", password);
            form.AddField("name", name);



            using (UnityWebRequest www = UnityWebRequest.Post(ChangepassUrl, form))
            {
                www.chunkedTransfer = false;
                yield return(www.SendWebRequest());

                Debug.Log(www.error + " ");
                if (www.error != null)
                {
                    errorfieldchange.text = "Error webserver request error: " + www.error;
                }
                else
                {
                    Debug.Log("Response" + www.downloadHandler.text);

                    Validation1.UserDetail userDetail = JsonUtility.FromJson <Validation1.UserDetail> (www.downloadHandler.text);
                    //reponse details
                    if (userDetail.status == 1)
                    {
                        lblLoader.text = "Password Successfully Updated";
                        yield return(new WaitForSeconds(3f));

                        errorfieldchange.text = userDetail.message;
                        canvasLoad.SetActive(false);



                        changePanel.SetActive(false);

                        loginPanel.SetActive(true);
                    }
                    else
                    {
                        errorfieldchange.text = www.downloadHandler.text;
                        changePanel.SetActive(false);
                    }
                }
            }
        }
    }
Пример #3
0
    IEnumerator LoginDB(string username, string passwordkoto)
    {
        canvasLoad.SetActive(true);
        lblLoader.text = "LOGGING IN...";

        errorfield.text = "";
        if (Validation1.checkConnectionfail() == true)
        {
            errorfield.text = "Error: Internet Connection";
            canvasLoad.SetActive(false);
        }
        else
        {
            WWWForm form = new WWWForm();
            //Debug.Log ("the username is" r username + password);
            form.AddField("name", username);
            form.AddField("password", passwordkoto);

            using (UnityWebRequest www = UnityWebRequest.Post(LoginUrl, form))
            {
                www.chunkedTransfer = false;
                //loading for accessing web kung existing ba accoutn    VALIDATING
                yield return(www.SendWebRequest());

                if (www.error != null)
                {
                    errorfield.text = "Error webserver request error: " + www.error;
                    canvasLoad.SetActive(false);
                }
                else
                {
                    Debug.Log("Response" + www.downloadHandler.text);
                    Validation1.UserDetail userDetail = JsonUtility.FromJson <Validation1.UserDetail> (www.downloadHandler.text);
                    Debug.Log(userDetail.status.ToString());


                    //reponse details
                    if (userDetail.status == 1)
                    {
                        errorfield.text = userDetail.message;
                        loginPanel.SetActive(false);
                        registerPanel.SetActive(false);
                        mainMenuPanel.SetActive(true);
                        StartCoroutine(fetch(username));
                        // animate loading for fetching
                        lblLoader.text = "SYNCING DATA...";
                        yield return(fetch(username));

                        //setting data
                        loadfetch();
                        canvasLoad.SetActive(false);
                    }
                    else
                    {
                        errorfield.text = userDetail.message;
                        canvasLoad.SetActive(false);
                    }
                }
            }
        }
    }
Пример #4
0
    IEnumerator  CreateUser(string student_id, string password, string fname, string mname, string lname, string username)
    {
        errorfield.text = "";

        canvasLoad.SetActive(true);
        lblLoader.text = "Creating account..... wait for response";


        //	first if checking internet connection ang web serve response pare
        if (Validation1.checkConnectionfail() == true)
        {
            errorfield.text = "Error: Internet Connection";
            canvasLoad.SetActive(false);
        }
        else

        {
            //Checking web server response
            WWWForm form = new WWWForm();


            form.AddField("student_id", student_id);
            form.AddField("password", password);
            form.AddField("fname", fname);
            form.AddField("mname", mname);
            form.AddField("lname", lname);
            form.AddField("name", username);



            using (UnityWebRequest www = UnityWebRequest.Post(CreateUserUrl, form))
            {
                www.chunkedTransfer = false;
                yield return(www.SendWebRequest());

                Debug.Log(www.error + " ");
                if (www.error != null)
                {
                    errorfield.text = "Error webserver request error: " + www.error;
                    canvasLoad.SetActive(false);
                }
                else
                {
                    Debug.Log("Response" + www.downloadHandler.text);

                    Validation1.UserDetail userDetail = JsonUtility.FromJson <Validation1.UserDetail> (www.downloadHandler.text);
                    //reponse details
                    if (userDetail.status == 1)
                    {
                        canvasLoad.SetActive(false);
                        errorfield.text = userDetail.message;
                        StartCoroutine(loadaftercreate());
                    }
                    else
                    {
                        errorfield.text = www.downloadHandler.text;
                        canvasLoad.SetActive(false);
                    }
                }
            }
        }
    }
Пример #5
0
    IEnumerator  Changepass(string section_id, string username)
    {
        string SectionCodeUrl = "https://scivre.herokuapp.com/api/webscivreapisectioncode";

        canvasLoad.SetActive(true);
        lblLoader.text = "Sending Request to webserver";

        //	first if checking internet connection ang web serve response pare
        if (Validation1.checkConnectionfail() == true)
        {
            errorfield.text = "Error: Internet Connection";
            canvasLoad.SetActive(false);
        }
        else

        {
            //Checking web server response
            WWWForm form = new WWWForm();

            form.AddField("section_id", section_id);
            form.AddField("name", username);



            using (UnityWebRequest www = UnityWebRequest.Post(SectionCodeUrl, form))
            {
                www.chunkedTransfer = false;
                yield return(www.SendWebRequest());

                Debug.Log(www.error + " ");
                if (www.error != null)
                {
                    errorfield.text = "Error webserver request error: " + www.error;
                    canvasLoad.SetActive(false);
                }
                else
                {
                    Debug.Log("Response" + www.downloadHandler.text);

                    Validation1.UserDetail userDetail = JsonUtility.FromJson <Validation1.UserDetail> (www.downloadHandler.text);
                    //reponse details
                    if (userDetail.status == 1)
                    {
                        errorfield.text = "";
                        lblLoader.text  = "Sucessfully Added Section";
                        yield return(new WaitForSeconds(2f));

                        canvasLoad.SetActive(false);

                        txtcode.text = "";
                    }

                    else if (userDetail.status == 2)
                    {
                        errorfield.text = "";
                        lblLoader.text  = "SECTION CODE IS NOT EXISTED!";
                        yield return(new WaitForSeconds(2f));

                        canvasLoad.SetActive(false);

                        txtcode.text = "";
                    }
                    else if (userDetail.status == 3)
                    {
                        errorfield.text = "";
                        lblLoader.text  = "Account already existed in section";
                        yield return(new WaitForSeconds(2f));

                        canvasLoad.SetActive(false);

                        txtcode.text = "";
                    }

                    else
                    {
                        errorfield.text = www.downloadHandler.text;
                        canvasLoad.SetActive(false);
                    }
                }
            }
        }
    }