public Exercise GetExercise(string type, JSONNode json) { Exercise ex = null; switch (type) { case "Scale": var exercise = json["Scale"]; ScaleExercise scale = createScale(exercise); this.scale = scale; ex = scale; break; case "LongNotesExercise": var exerciseLong = json["LongNotesExercise"]; LongNotesExercise longNotes = createLongNotesExercise(exerciseLong); ex = longNotes; break; case "normalExercise": var exerciseNormal = json["normalExercise"]; break; } ex.getStringNotes(); return(ex); }
private string inserScale(ScaleExercise scale) { string response = ""; try{ response = this.daoScale.insertScaleM(scale); }catch (Exception e) { UnityEngine.Debug.Log("[Manager][InsertScale]:" + e.Message); } return(response); }
private ScaleExercise createScale(JSONNode json) { int beats = json["beats"].AsInt; var tune = json["tune"].Value; var timeSignature = json["timeSignature"].Value; var firstNote = json["firstNote"].Value; var scaleType = json["scaleType"]; var duration = json["duration"]; // List<String> intervalsList = getIntervalScale(intervals); ScaleExercise ExerciseScale = new ScaleExercise(tune, beats, timeSignature, firstNote, scaleType, duration); UnityEngine.Debug.Log(ExerciseScale.ToString()); ExerciseScale.getStringNotes(); return(ExerciseScale); }
/* * public string insertScale(MySqlConnection connection,ScaleExercise scale){ * //this.insertExercise(connection,scale); * MySqlCommand cmd = connection.CreateCommand(); * cmd.CommandText="INSERT INTO ScaleExercise(idExercise,typeScale,firstNote,duration) Values("+scale.idExercise+",'" +scale.scaleTypes+"','"+scale.firstNote+"','"+scale.duration+"');"; * MySqlDataReader reader = cmd.ExecuteReader(); * reader.Close(); * return null; * } * */ public string insertScaleM(ScaleExercise scale) { this.insertExerciseM(scale); var values = new Dictionary <string, string> { { "idExercise", scale.idExercise.ToString() }, { "scaleTypes", scale.scaleTypes }, { "firstNote", scale.firstNote }, { "duration", scale.duration.ToString() } }; var content = new FormUrlEncodedContent(values); var response = client.PostAsync("http://192.168.1.37/UnityBackendTutorial/insertScale.php", content).Result; string resultContent = response.Content.ReadAsStringAsync().Result; return(resultContent); }
/* * public ScaleExercise getScale(MySqlConnection connection, int idScale,Exercise ex){ * ScaleExercise scale = null; * MySqlCommand cmd = connection.CreateCommand(); * cmd.CommandText="Select * from ScaleExercise Where idExercise="+idScale+";"; * MySqlDataReader reader = cmd.ExecuteReader(); * while(reader.Read()){ * string typeScale = reader.GetString(1); * string firstNote = reader.GetString(2); * int duration = reader.GetInt32(3); * scale = new ScaleExercise(ex.tune,ex.beats,ex.timeSignature,firstNote,typeScale,duration); * } * reader.Close(); * return scale; * } */ public ScaleExercise getScaleM(int idScale, Exercise ex) { ScaleExercise scale = null; var values = new Dictionary <string, string> { { "idExercise", idScale.ToString() }, }; var content = new FormUrlEncodedContent(values); var response = client.PostAsync("http://192.168.1.37/UnityBackendTutorial/getScale.php", content).Result; string resultContent = response.Content.ReadAsStringAsync().Result; var json = JSON.Parse(resultContent); string typeScale = json["typeScale"]; string firstNote = json["firstNote"]; int duration = Int16.Parse(json["duration"]); scale = new ScaleExercise(ex.tune, ex.beats, ex.timeSignature, firstNote, typeScale, duration); return(scale); }
public string createScale(string tune, string timeSignature, int beats, string scaleType, string firstNote, int duration, string username, string instrument, int idRoutine) { UnityEngine.Debug.Log("Scale type" + scaleType); ScaleExercise ex = new ScaleExercise(tune, beats, timeSignature, firstNote, scaleType, duration); if (username == this.currentPlayer.username && instrument == this.currentProfile.instrument) { int count = -1; try{ count = this.daoScale.getCountExercisesM(); }catch (Exception e) { UnityEngine.Debug.Log("[Exception] Create scale:" + e.Message); } ex.idExercise = count + 1; this.inserScale(ex); this.createRoutineExercise(idRoutine, ex); } return(null); }
public string setCurrentExercise(int idExercise) { string response = "OK"; Exercise ex = null; ScaleExercise scale = null; try{ ex = this.daoExercise.getExerciseFromIdM(idExercise); }catch (Exception e) { UnityEngine.Debug.Log("[set current Exercise form ID EXCEPTION]" + e.ToString()); response = "ERROR"; } try{ if (this.daoScale.isScaleM(idExercise)) { ex = this.daoScale.getScaleM(idExercise, ex); } }catch (Exception e) { } this.currentExercise = ex; return(response); }