Develop #10
@@ -184,7 +184,7 @@ namespace ClientApp.Utils
|
|||||||
else if (DataParser.isRawDataBikeServer(messageBytes))
|
else if (DataParser.isRawDataBikeServer(messageBytes))
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Received data: {BitConverter.ToString(payloadbytes)}");
|
Console.WriteLine($"Received data: {BitConverter.ToString(payloadbytes)}");
|
||||||
}
|
}
|
||||||
|
|
||||||
totalBufferReceived -= expectedMessageLength;
|
totalBufferReceived -= expectedMessageLength;
|
||||||
expectedMessageLength = BitConverter.ToInt32(totalBuffer, 0);
|
expectedMessageLength = BitConverter.ToInt32(totalBuffer, 0);
|
||||||
|
|||||||
@@ -123,6 +123,9 @@ namespace DoctorApp.Utils
|
|||||||
}
|
}
|
||||||
else if (DataParser.isRawDataBikeDoctor(messageBytes))
|
else if (DataParser.isRawDataBikeDoctor(messageBytes))
|
||||||
{
|
{
|
||||||
|
// read the .bin file that is in the message
|
||||||
|
// update the view
|
||||||
|
|
||||||
MainViewModel.TransferDataToClientBike(payloadbytes);
|
MainViewModel.TransferDataToClientBike(payloadbytes);
|
||||||
}
|
}
|
||||||
else if (DataParser.isRawDataBPMDoctor(messageBytes))
|
else if (DataParser.isRawDataBPMDoctor(messageBytes))
|
||||||
|
|||||||
@@ -83,9 +83,14 @@ namespace DoctorApp.ViewModels
|
|||||||
PatientInfo.Resistance = float.Parse(((TextBox)parameter).Text);
|
PatientInfo.Resistance = float.Parse(((TextBox)parameter).Text);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// request the historic data from the server
|
||||||
this.SaveHistoricData = new RelayCommand<object>((parameter) =>
|
this.SaveHistoricData = new RelayCommand<object>((parameter) =>
|
||||||
{
|
{
|
||||||
this.client.sendMessage(DataParser.GetGetFileMessage(PatientInfo.Username, DateTime.Now));
|
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
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -494,7 +494,7 @@ namespace Util
|
|||||||
|
|
||||||
public static string GetDateFromGetFileBytes(byte[] json)
|
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)
|
public static byte[] GetFileMessage(byte[] file)
|
||||||
|
|||||||
@@ -149,6 +149,8 @@ namespace Server
|
|||||||
break;
|
break;
|
||||||
case DataParser.GET_FILE:
|
case DataParser.GET_FILE:
|
||||||
//ugly
|
//ugly
|
||||||
|
|
||||||
|
//get the raw bike data of the user with the specified username
|
||||||
string username = DataParser.GetUsernameFromGetFileBytes(payloadbytes);
|
string username = DataParser.GetUsernameFromGetFileBytes(payloadbytes);
|
||||||
string path = Directory.GetCurrentDirectory() + "/" + username + "/" + DataParser.GetDateFromGetFileBytes(payloadbytes) + "/rawBike.bin";
|
string path = Directory.GetCurrentDirectory() + "/" + username + "/" + DataParser.GetDateFromGetFileBytes(payloadbytes) + "/rawBike.bin";
|
||||||
int length = Int32.MaxValue;
|
int length = Int32.MaxValue;
|
||||||
@@ -164,7 +166,8 @@ namespace Server
|
|||||||
if (length > 10240)
|
if (length > 10240)
|
||||||
break;
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
Console.WriteLine($"Received json with identifier {identifier}:\n{Encoding.ASCII.GetString(payloadbytes)}");
|
Console.WriteLine($"Received json with identifier {identifier}:\n{Encoding.ASCII.GetString(payloadbytes)}");
|
||||||
|
|||||||
Reference in New Issue
Block a user