//Update data from session #region public void UpdateDataFromSession(string dataSessionId, ErgometerData data) { foreach (DoctorApplication_SessionClient s in doctorApplication_Session.followed_sessions) { if (s.sessionID == dataSessionId) { s.currentData.Add(data); s.updateChart(); } } }
//Processs answer from Server #region public void ProcessAnswer(string information) { dynamic jsonData = JsonConvert.DeserializeObject(information); if (jsonData.id == "doctor/login") { if (jsonData.data.status == "ok") { doctorApplication_Session = new DoctorApplication_Session(this); application.RunSessionForm(doctorApplication_Session); } else { new Thread(() => { MessageBox.Show("Wrong username and password"); }).Start(); } } else if (jsonData.id == "doctor/sessions") { List <String> connected_Sessions = new List <string>(); foreach (dynamic d in jsonData.data.sessions) { connected_Sessions.Add((string)d); } doctorApplication_Session.UpdateComboBox(connected_Sessions); } else if (jsonData.id == "doctor/sessions/users") { List <string> users = new List <string>(); foreach (dynamic e in jsonData.data.users) { if (e != null) { users.Add((string)e); } } doctorApplication_Session.UpdateOlderDataComboBox(users); } else if (jsonData.id == "session/data/historic") { HandleHistoricData(jsonData); } else if (jsonData.id == "data") { string session = (string)jsonData.sessionId; int power = jsonData.data.data.Requested_Power; double speed = jsonData.data.data.Speed; int time = jsonData.data.data.Time; int rpm = jsonData.data.data.RPM; double distance = jsonData.data.data.Distance; int pulse = jsonData.data.data.Pulse; ErgometerData data = new ErgometerData(pulse, rpm, speed, distance, time, 0, 0, power); UpdateDataFromSession(session, data); } else if (jsonData.id == "doctor/UnfollowPatient") { } else if (jsonData.id == "Doctor/StartAstrand") { if (jsonData.data.status == "ok") { new Thread(() => { MessageBox.Show("Ästrand test gestart"); }).Start(); } } else if (jsonData.id == "StopAstrand") { if (jsonData.data.status == "error") { string patientid = (string)jsonData.data.patientId; string error = (string)jsonData.data.data.status; new Thread(() => { MessageBox.Show("Error in de gevolgde astrand test van patient: " + patientid + "\r\nOpgetrede fout: " + error); }).Start(); } } }
public void AddData(ErgometerData ergometerData) { data.Add(ergometerData); }