Develop #10

Merged
SemvdH merged 229 commits from develop into master 2020-10-29 22:50:49 +00:00
8 changed files with 47 additions and 16 deletions
Showing only changes of commit 173dbf2745 - Show all commits

View File

@@ -135,17 +135,17 @@ namespace ClientApp.Utils
Debug.WriteLine($"login failed \"{responseStatus}\""); Debug.WriteLine($"login failed \"{responseStatus}\"");
} }
break; break;
/*case DataParser.START_SESSION: case DataParser.START_SESSION:
Console.WriteLine("Session started!"); Console.WriteLine("Session started!");
this.sessionRunning = true; this.sessionRunning = true;
if (engineConnection.Connected && !engineConnection.FollowingRoute) engineConnection.StartRouteFollow(); if (engineConnection.Connected && !engineConnection.FollowingRoute) engineConnection.StartRouteFollow();
sendMessage(DataParser.getStartSessionJson()); Debug.WriteLine("start");
break; break;
case DataParser.STOP_SESSION: case DataParser.STOP_SESSION:
Console.WriteLine("Stop session identifier"); Console.WriteLine("Stop session identifier");
this.sessionRunning = false; this.sessionRunning = false;
sendMessage(DataParser.getStopSessionJson()); Debug.WriteLine("stop");
break;*/ break;
case DataParser.SET_RESISTANCE: case DataParser.SET_RESISTANCE:
Console.WriteLine("Set resistance identifier"); Console.WriteLine("Set resistance identifier");
if (this.handler == null) if (this.handler == null)
@@ -297,6 +297,7 @@ namespace ClientApp.Utils
public void Dispose() public void Dispose()
{ {
Debug.WriteLine("client dispose called"); Debug.WriteLine("client dispose called");
sendMessage(DataParser.getDisconnectJson(LoginViewModel.Username));
this.stream.Dispose(); this.stream.Dispose();
this.client.Dispose(); this.client.Dispose();
this.handler.stop(); this.handler.stop();

View File

@@ -108,7 +108,7 @@ namespace ClientApp.ViewModels
this.InfoModel = new Info(); this.InfoModel = new Info();
this.client = client; this.client = client;
loginViewModel = new LoginViewModel(this); LoginViewModel loginViewModel = new LoginViewModel(this);
SelectedViewModel = loginViewModel; SelectedViewModel = loginViewModel;
this.client.SetLoginViewModel(loginViewModel); this.client.SetLoginViewModel(loginViewModel);

View File

@@ -240,7 +240,7 @@ namespace DoctorApp.Utils
string hashPassword = Util.Hasher.HashString(password); string hashPassword = Util.Hasher.HashString(password);
byte[] message = DataParser.getJsonMessage(DataParser.GetLoginJson(hashUser, hashPassword)); byte[] message = DataParser.getJsonMessage(DataParser.GetLoginJson(username, hashPassword));
this.stream.BeginWrite(message, 0, message.Length, new AsyncCallback(OnWrite), null); this.stream.BeginWrite(message, 0, message.Length, new AsyncCallback(OnWrite), null);

View File

@@ -69,11 +69,6 @@ namespace DoctorApp.ViewModels
//TODO RelayCommand ChatToAll //TODO RelayCommand ChatToAll
ClientInfo = new RelayCommand(() =>
{
//TODO POPUP
});
SetResistance = new RelayCommand<object>((parameter) => SetResistance = new RelayCommand<object>((parameter) =>
{ {
client.sendMessage(DataParser.getSetResistanceJson(Username, float.Parse(((TextBox)parameter).Text))); client.sendMessage(DataParser.getSetResistanceJson(Username, float.Parse(((TextBox)parameter).Text)));

View File

@@ -63,6 +63,5 @@
<Button Content="Set Resistance" Grid.Column="1" HorizontalAlignment="Left" Margin="187,128,0,0" Grid.Row="3" VerticalAlignment="Top" Width="97" Height="18" Command="{Binding SetResistance}" CommandParameter="{Binding ElementName=textBox_SetResistance}"/> <Button Content="Set Resistance" Grid.Column="1" HorizontalAlignment="Left" Margin="187,128,0,0" Grid.Row="3" VerticalAlignment="Top" Width="97" Height="18" Command="{Binding SetResistance}" CommandParameter="{Binding ElementName=textBox_SetResistance}"/>
<Canvas Grid.Row="3" Background="White" Margin="0,33,0,0"/> <Canvas Grid.Row="3" Background="White" Margin="0,33,0,0"/>
<ComboBox Name="DropBox" HorizontalAlignment="Left" Margin="0,6,0,0" Grid.Row="3" VerticalAlignment="Top" Width="190"/> <ComboBox Name="DropBox" HorizontalAlignment="Left" Margin="0,6,0,0" Grid.Row="3" VerticalAlignment="Top" Width="190"/>
<Button Content="Client Info" Grid.Column="1" HorizontalAlignment="Left" Margin="207,6,0,0" VerticalAlignment="Top" Height="26" Width="82"/>
</Grid> </Grid>
</UserControl> </UserControl>

View File

@@ -5,6 +5,9 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DoctorApp" xmlns:local="clr-namespace:DoctorApp"
mc:Ignorable="d" mc:Ignorable="d"
Background="Transparent"
WindowStyle="None"
AllowsTransparency="True"
Title="MainWindow" Height="450" Width="800"> Title="MainWindow" Height="450" Width="800">
<Window.Resources> <Window.Resources>
<Style TargetType="{x:Type local:MainWindow}"> <Style TargetType="{x:Type local:MainWindow}">

View File

@@ -3,7 +3,6 @@ using System.IO;
using System.Net.Sockets; using System.Net.Sockets;
using System.Text; using System.Text;
using Newtonsoft.Json; using Newtonsoft.Json;
using ClientApp.Utils;
using System.Diagnostics; using System.Diagnostics;
using Util; using Util;
@@ -110,10 +109,10 @@ namespace Server
} }
break; break;
case DataParser.START_SESSION: case DataParser.START_SESSION:
this.saveData = new SaveData(Directory.GetCurrentDirectory() + "/" + this.username + "/" + sessionStart.ToString("yyyy-MM-dd HH-mm-ss")); this.communication.StartSessionUser(DataParser.getUsernameFromJson(payloadbytes));
break; break;
case DataParser.STOP_SESSION: case DataParser.STOP_SESSION:
this.saveData = null; this.communication.StopSessionUser(DataParser.getUsernameFromJson(payloadbytes));
break; break;
case DataParser.SET_RESISTANCE: case DataParser.SET_RESISTANCE:
bool worked = DataParser.getResistanceFromResponseJson(payloadbytes); bool worked = DataParser.getResistanceFromResponseJson(payloadbytes);
@@ -242,5 +241,15 @@ namespace Server
hex.AppendFormat("{0:x2}", b); hex.AppendFormat("{0:x2}", b);
return hex.ToString(); return hex.ToString();
} }
public void StartSession()
{
this.saveData = new SaveData(Directory.GetCurrentDirectory() + "/" + this.username + "/" + sessionStart.ToString("yyyy-MM-dd HH-mm-ss"));
}
public void StopSession()
{
this.saveData = null;
}
} }
} }

View File

@@ -4,7 +4,6 @@ using System.IO.Pipes;
using System.Linq; using System.Linq;
using System.Net.Sockets; using System.Net.Sockets;
using System.Text; using System.Text;
using DoctorApp.Utils;
using Util; using Util;
namespace Server namespace Server
@@ -56,5 +55,30 @@ namespace Server
} }
} }
public void StartSessionUser(string user)
{
foreach(Client client in clients)
{
if(client.username == user)
{
client.sendMessage(DataParser.getStartSessionJson(user));
client.StartSession();
}
}
}
public void StopSessionUser(string user)
{
foreach (Client client in clients)
{
if (client.username == user)
{
client.sendMessage(DataParser.getStopSessionJson(user));
client.StopSession();
}
}
}
} }
} }