diff --git a/ClientApp/Utils/Client.cs b/ClientApp/Utils/Client.cs index 27d980a..b5f37e1 100644 --- a/ClientApp/Utils/Client.cs +++ b/ClientApp/Utils/Client.cs @@ -184,7 +184,7 @@ namespace ClientApp.Utils else if (DataParser.isRawDataBikeServer(messageBytes)) { Console.WriteLine($"Received data: {BitConverter.ToString(payloadbytes)}"); - } + } totalBufferReceived -= expectedMessageLength; expectedMessageLength = BitConverter.ToInt32(totalBuffer, 0); diff --git a/DoctorApp/Utils/Client.cs b/DoctorApp/Utils/Client.cs index a991343..f6b8e02 100644 --- a/DoctorApp/Utils/Client.cs +++ b/DoctorApp/Utils/Client.cs @@ -123,6 +123,9 @@ namespace DoctorApp.Utils } else if (DataParser.isRawDataBikeDoctor(messageBytes)) { + // read the .bin file that is in the message + // update the view + MainViewModel.TransferDataToClientBike(payloadbytes); } else if (DataParser.isRawDataBPMDoctor(messageBytes)) diff --git a/DoctorApp/ViewModels/ClientInfoViewModel.cs b/DoctorApp/ViewModels/ClientInfoViewModel.cs index b7729bb..6a352e1 100644 --- a/DoctorApp/ViewModels/ClientInfoViewModel.cs +++ b/DoctorApp/ViewModels/ClientInfoViewModel.cs @@ -83,9 +83,14 @@ namespace DoctorApp.ViewModels PatientInfo.Resistance = float.Parse(((TextBox)parameter).Text); }); + // request the historic data from the server this.SaveHistoricData = new RelayCommand((parameter) => { this.client.sendMessage(DataParser.GetGetFileMessage(PatientInfo.Username, DateTime.Now)); + // data is stored on the server + // send request to server that we want to get the current historic data from the patient + // server sends this back + // we parse it }); } diff --git a/Hashing/DataParser.cs b/Hashing/DataParser.cs index 1f9d38d..24cca89 100644 --- a/Hashing/DataParser.cs +++ b/Hashing/DataParser.cs @@ -494,7 +494,7 @@ namespace Util public static string GetDateFromGetFileBytes(byte[] json) { - return ((string)((dynamic)JsonConvert.DeserializeObject(Encoding.ASCII.GetString(json))).data.dateTime)); + return ((string)((dynamic)JsonConvert.DeserializeObject(Encoding.ASCII.GetString(json))).data.dateTime); } public static byte[] GetFileMessage(byte[] file) diff --git a/Server/Client.cs b/Server/Client.cs index 7bf27d9..c11e0bc 100644 --- a/Server/Client.cs +++ b/Server/Client.cs @@ -149,6 +149,8 @@ namespace Server break; case DataParser.GET_FILE: //ugly + + //get the raw bike data of the user with the specified username string username = DataParser.GetUsernameFromGetFileBytes(payloadbytes); string path = Directory.GetCurrentDirectory() + "/" + username + "/" + DataParser.GetDateFromGetFileBytes(payloadbytes) + "/rawBike.bin"; int length = Int32.MaxValue; @@ -164,7 +166,8 @@ namespace Server if (length > 10240) break; - communication.SendMessageToClient(username, DataParser.GetFileMessage(File.ReadAllBytes(path))); + // we need to send it to the doctor and not to the user with the username + communication.SendMessageToClient(this.username, DataParser.GetFileMessage(File.ReadAllBytes(path))); break; default: Console.WriteLine($"Received json with identifier {identifier}:\n{Encoding.ASCII.GetString(payloadbytes)}");