Develop #10

Merged
SemvdH merged 229 commits from develop into master 2020-10-29 22:50:49 +00:00
5 changed files with 14 additions and 3 deletions
Showing only changes of commit b98ac77261 - Show all commits

View File

@@ -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);

View File

@@ -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))

View File

@@ -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<object>((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
});
}

View File

@@ -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)

View File

@@ -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)}");