public void Login() { Debug.Log("{ \"username\" : \"" + username + "\", \"password\" : \"" + password + "\" }"); //APICALL StartCoroutine(requestService.Post("/user/login", "{ \"username\" : \"" + username + "\", \"password\" : \"" + password + "\" }", success => { Debug.Log(success); JObject response = JObject.Parse(success); HomeRevalSession hrs = HomeRevalSession.Instance; hrs.Token = response.GetValue("accessToken").ToString(); hrs.RefreshToken = response.GetValue("refreshToken").ToString(); StartCoroutine(requestService.Get("/user", successUser => { Debug.Log(successUser); JObject responseUser = JObject.Parse(successUser); hrs.UserID = (int)responseUser.GetValue("id"); // Go to menu mm.HideLogin(); mm.ShowMainMenu(); }, errorUser => { Debug.Log(errorUser); } )); }, error => { Debug.Log(error); } )); }
void Start() { TimerText.text = ""; TimerCountdownText.text = ""; _sensor = KinectSensor.GetDefault(); if (_sensor != null) { _reader = _sensor.BodyFrameSource.OpenReader(); if (!_sensor.IsOpen) { _sensor.Open(); } } // Create bodyDrawer and body from prefab GameObject body = (GameObject)Instantiate(Resources.Load("Prefabs/Body")); bodyDrawer = new BodyDrawer(body); // Get singleton session instance homeRevalSession = HomeRevalSession.Instance; // Temp for creating recording if (homeRevalSession.CurrentRecording == null) { homeRevalSession.CurrentRecording = new Exercise { StartDate = DateTime.Today, EndDate = DateTime.Today.AddDays(20), Amount = 5, Name = "test", Description = "test desc" }; } StartCoroutine(HandGesture()); }
void Start() { TimerText.text = ""; TimerCountdownText.text = ""; _sensor = KinectSensor.GetDefault(); if (_sensor != null) { _reader = _sensor.BodyFrameSource.OpenReader(); if (!_sensor.IsOpen) { _sensor.Open(); } } StartCoroutine(HandGesture()); state = PractiseState.KinectPaused; // Create bodyDrawer and body from prefab GameObject body = (GameObject)Instantiate(Resources.Load("Prefabs/Body")); bodyDrawer = new BodyDrawer(body); // Create bodyDrawer for exercise example GameObject bodyRed = (GameObject)Instantiate(Resources.Load("Prefabs/BodyRed")); exampleBodyDrawer = new BodyDrawer(bodyRed); // Get singleton session instance hrs = HomeRevalSession.Instance; StartCoroutine(requestService.Get("/exercise/" + hrs.Exercises[hrs.currentExerciseIdx].Id, success => { // Decompress response and create ExerciseRecording Debug.Log(success); JObject response = JObject.Parse(success); Debug.Log("Recording: " + response.GetValue("recording").ToString()); string exerciseRecordingJson = Gzip.DeCompress(Convert.FromBase64String(response.GetValue("recording").ToString())); ExerciseRecording exerciseRecording = JsonConvert.DeserializeObject <ExerciseRecording>(exerciseRecordingJson); jsonExercise = new Exercise { Id = Int32.Parse(response.GetValue("id").ToString()), Amount = hrs.Exercises[hrs.currentExerciseIdx].Amount, ExerciseRecording = exerciseRecording, Description = response.GetValue("description").ToString(), Name = response.GetValue("name").ToString() }; exerciseService.StartNewExercise(jsonExercise, exampleBodyDrawer); exerciseResultRecording = new List <ConvertedBody>(); exerciseResultScores = new List <ExerciseScore>(); }, error => { Debug.Log(error); } )); Debug.Log(hrs.Exercises[hrs.currentExerciseIdx].PlanningId); hrs.currentPlanningId = hrs.Exercises[hrs.currentExerciseIdx].PlanningId; // Maak exercise object met recording opgehaald vanuit database // Set exercise for service temp //string json = File.ReadAllText(@"C:\Users\Stefan\Documents\exercise.json"); //Exercise jsonExercise = JsonConvert.DeserializeObject<Exercise>(json); }
// Use this for initialization void Start() { DateTime today = DateTime.Today; hrs = HomeRevalSession.Instance; Debug.Log("TODAY: " + today.ToString("yyyy-MM-dd")); // Get exercises StartCoroutine(requestService.Get("/exerciseplanning/date/" + today.ToString("yyyy-MM-dd"), success => { Debug.Log(success); //JArray response = JArray.Parse(success); List <JObject> response = JArray.Parse(success).ToObject <List <JObject> >(); foreach (JObject exercisePlanning in response.OrderByDescending(o => o.SelectToken("exercise.id")).ToList()) { hrs.Exercises.Add(new Exercise { Id = Convert.ToInt32(exercisePlanning.SelectToken("exercise.id").ToString()), StartDate = DateTime.Parse(exercisePlanning.SelectToken("startDate").ToString()), EndDate = DateTime.Parse(exercisePlanning.SelectToken("endDate").ToString()), Name = exercisePlanning.SelectToken("exercise.name").ToString(), Description = exercisePlanning.SelectToken("exercise.description").ToString(), Amount = Convert.ToInt32(exercisePlanning.SelectToken("amount").ToString()), PlanningId = Convert.ToInt32(exercisePlanning.SelectToken("id").ToString()) }); } // Switch exercise after receiving exercises SwitchExercise(hrs.currentExerciseIdx); maxExerciseIndex = hrs.Exercises.Count - 1; }, error => { Debug.Log(error); })); /*Exercise ex1 = new Exercise { * Id = 0, * StartDate = today.AddDays(5), * EndDate = today.AddDays(10), * Name = "Steps 1 (1234567890123456789012345678901234567890)", * Description = "12345678901234657890123465789012346578901234657890", * ExerciseRecording = null, * Amount = 10 * }; * Exercise ex2 = new Exercise * { * Id = 0, * StartDate = today.AddDays(10), * EndDate = today.AddDays(15), * Name = "Steps 2 (1234567890123456789012345678901234567890)", * Description = "12345678901234657890123465789012346578901234657890", * ExerciseRecording = null, * Amount = 900 * }; * Exercise ex3 = new Exercise * { * Id = 0, * StartDate = today.AddDays(15), * EndDate = today.AddDays(20), * Name = "Steps 3 (1234567890123456789012345678901234567890)", * Description = "(234567890123465789012346578901234657890123465789)", * ExerciseRecording = null, * Amount = 1000 * };*/ /*exList.Add(ex1); * exList.Add(ex2); * exList.Add(ex3);*/ }
public void Awake() { hrs = HomeRevalSession.Instance; }
//private const string API = "http://localhost:58580/api"; public RequestService() { homeRevalSession = HomeRevalSession.Instance; }