Skip to content

Commit

Permalink
successfully able to connect to azure webapp
Browse files Browse the repository at this point in the history
  • Loading branch information
daniyusra committed Jan 23, 2022
1 parent a3c4bb1 commit 4bf49fb
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 18 deletions.
51 changes: 37 additions & 14 deletions UnityAndroidCamera/Assets/Scripts/EmailSurveyPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
using UnityEngine;
using UnityEngine.UI;
using System.Data.SqlClient;
using UnityEngine.Networking;
using System;
using System.Text;

public class EmailSurveyPanel : MonoBehaviour
{
Expand All @@ -30,26 +33,46 @@ void Update()
public void GetAndSendEmail()
{
string email = Field.text;
try {

if (Regex.IsMatch(email, MatchEmailPattern))
{
string connstring = "Server=tcp:unityposedetection.database.windows.net,1433;Initial Catalog=unityposedetection;Persist Security Info=False;User ID=daniyusra;Password=ImagineCup2022;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
SqlConnection conn = new SqlConnection(connstring);
conn.Open();
//SqlCommand cmd = new SqlCommand("Insert Into userData Values ('COK5', 'COK', 'COK', '20120618 10:34:09 AM')", conn);
string s = string.Format("Insert Into userData Values ('{0}','{1}','{2}','{3}'",email,"TEST", "TEST", System.DateTime.Now );
SqlCommand cmd = new SqlCommand(s,conn);
cmd.ExecuteNonQuery();
conn.Close();
gameObject.SetActive(false);


MyClass myrequest = new MyClass();
myrequest.taskName = email;
myrequest.isComplete = true;
//StartCoroutine(SendMail(email));



string json = JsonUtility.ToJson(myrequest);
StartCoroutine(SendMail(json));

//gameObject.SetActive(false);
} else
{
Field.text = "Put proper email!";
}
} catch (System.Exception e)
{
Debug.Log(e.Message);
}

}

[Serializable]
public class MyClass
{
public string taskName;
public bool isComplete;
}

IEnumerator SendMail(string jsonstring)
{
var request = new UnityWebRequest("https://virtuostroke.azurewebsites.net/api/todoitems", "POST");
byte[] bodyRaw = Encoding.UTF8.GetBytes(jsonstring);
request.uploadHandler = (UploadHandler)new UploadHandlerRaw(bodyRaw);
request.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
request.SetRequestHeader("Content-Type", "application/json");
yield return request.SendWebRequest();
Debug.Log("Status Code: " + request.responseCode);
gameObject.SetActive(false);

}

Expand Down
3 changes: 1 addition & 2 deletions UnityAndroidCamera/Assets/Scripts/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ public void GameOver()
Debug.Log("BRUH");
int number = Random.Range(1, 10);

//if(number == 2)
if(true)
if(number == 2)
{
emailSurveyPanel.gameObject.SetActive(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@ void Update()
playerAngle = Mathf.Round(playerAngle);
playerAngle = -playerAngle;

Vector3 horizontalMove = transform.right * (((playerAngle/maxDeg*maxX)- rb.position.x));
//Vector3 horizontalMove = transform.right * (((playerAngle/maxDeg*maxX)- rb.position.x));

rb.MovePosition(rb.position + horizontalMove);

transform.position = new Vector3(playerAngle/maxDeg*maxX, transform.position.y, transform.position.z);

//rb.MovePosition(rb.position + horizontalMove);


if (Input.GetKeyDown(KeyCode.Space))
Expand Down

0 comments on commit 4bf49fb

Please sign in to comment.