Преглед изворни кода

dynamische session list in patientform

RD125632 пре 10 година
родитељ
комит
07b3571ec0

+ 1 - 0
Proftaak Remote Healthcare/FietsClientV2/CurrentData.cs

@@ -10,6 +10,7 @@ namespace FietsClient
     public class CurrentData
     {
         private string userID;
+        public bool isDoctor { set; get; }
         private List<Session> testResult;
 
 

+ 3 - 3
Proftaak Remote Healthcare/FietsClientV2/FietsClient.csproj

@@ -82,10 +82,10 @@
     </Compile>
     <Compile Include="JSONObjecten\Session.cs" />
     <Compile Include="JSONObjecten\Measurement.cs" />
-    <Compile Include="Resources\PatientForm.cs">
+    <Compile Include="Forms\PatientForm.cs">
       <SubType>Form</SubType>
     </Compile>
-    <Compile Include="Resources\PatientForm.Designer.cs">
+    <Compile Include="Forms\PatientForm.Designer.cs">
       <DependentUpon>PatientForm.cs</DependentUpon>
     </Compile>
     <Compile Include="lib\JsonConverter.cs" />
@@ -100,7 +100,7 @@
     <EmbeddedResource Include="Forms\DoctorForm.resx">
       <DependentUpon>DoctorForm.cs</DependentUpon>
     </EmbeddedResource>
-    <EmbeddedResource Include="Resources\PatientForm.resx">
+    <EmbeddedResource Include="Forms\PatientForm.resx">
       <DependentUpon>PatientForm.cs</DependentUpon>
     </EmbeddedResource>
     <EmbeddedResource Include="Properties\Resources.resx">

+ 41 - 51
Proftaak Remote Healthcare/FietsClientV2/Resources/PatientForm.Designer.cs → Proftaak Remote Healthcare/FietsClientV2/Forms/PatientForm.Designer.cs

@@ -30,16 +30,15 @@ namespace FietsClient
         /// </summary>
         private void InitializeComponent()
         {
-            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea4 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
-            System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series();
-            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea5 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
-            System.Windows.Forms.DataVisualization.Charting.Series series5 = new System.Windows.Forms.DataVisualization.Charting.Series();
-            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea6 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
-            System.Windows.Forms.DataVisualization.Charting.Series series6 = new System.Windows.Forms.DataVisualization.Charting.Series();
+            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
+            System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
+            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
+            System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();
+            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea3 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
+            System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series();
             this.menuStrip1 = new System.Windows.Forms.MenuStrip();
             this.archiefToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.selectSessionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
-            this.sESSIONSToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.bicycleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.selectPortToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.toolStripComboBox1 = new System.Windows.Forms.ToolStripComboBox();
@@ -136,18 +135,10 @@ namespace FietsClient
             // 
             // selectSessionToolStripMenuItem
             // 
-            this.selectSessionToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
-            this.sESSIONSToolStripMenuItem});
             this.selectSessionToolStripMenuItem.Name = "selectSessionToolStripMenuItem";
             this.selectSessionToolStripMenuItem.Size = new System.Drawing.Size(181, 26);
             this.selectSessionToolStripMenuItem.Text = "Select Session";
             // 
-            // sESSIONSToolStripMenuItem
-            // 
-            this.sESSIONSToolStripMenuItem.Name = "sESSIONSToolStripMenuItem";
-            this.sESSIONSToolStripMenuItem.Size = new System.Drawing.Size(150, 26);
-            this.sESSIONSToolStripMenuItem.Text = "SESSIONS";
-            // 
             // bicycleToolStripMenuItem
             // 
             this.bicycleToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -164,7 +155,7 @@ namespace FietsClient
             this.requestDataToolStripMenuItem,
             this.closePortToolStripMenuItem});
             this.selectPortToolStripMenuItem.Name = "selectPortToolStripMenuItem";
-            this.selectPortToolStripMenuItem.Size = new System.Drawing.Size(181, 26);
+            this.selectPortToolStripMenuItem.Size = new System.Drawing.Size(156, 26);
             this.selectPortToolStripMenuItem.Text = "Select port";
             // 
             // toolStripComboBox1
@@ -213,7 +204,7 @@ namespace FietsClient
             this.distanceTraining,
             this.setTimeToolStripMenuItem});
             this.distanceToolStripMenuItem.Name = "distanceToolStripMenuItem";
-            this.distanceToolStripMenuItem.Size = new System.Drawing.Size(181, 26);
+            this.distanceToolStripMenuItem.Size = new System.Drawing.Size(179, 26);
             this.distanceToolStripMenuItem.Text = "Select training";
             // 
             // distanceTraining
@@ -269,7 +260,7 @@ namespace FietsClient
             // stopTrainingToolStripMenuItem
             // 
             this.stopTrainingToolStripMenuItem.Name = "stopTrainingToolStripMenuItem";
-            this.stopTrainingToolStripMenuItem.Size = new System.Drawing.Size(181, 26);
+            this.stopTrainingToolStripMenuItem.Size = new System.Drawing.Size(179, 26);
             this.stopTrainingToolStripMenuItem.Text = "Reset training";
             this.stopTrainingToolStripMenuItem.Click += new System.EventHandler(this.stopTrainingToolStripMenuItem_Click);
             // 
@@ -279,7 +270,7 @@ namespace FietsClient
             this.powerBox,
             this.setPower});
             this.setToolStripMenuItem.Name = "setToolStripMenuItem";
-            this.setToolStripMenuItem.Size = new System.Drawing.Size(181, 26);
+            this.setToolStripMenuItem.Size = new System.Drawing.Size(179, 26);
             this.setToolStripMenuItem.Text = "Power";
             // 
             // powerBox
@@ -300,7 +291,7 @@ namespace FietsClient
             this.toolStripTextBox3,
             this.toolStripMenuItem1});
             this.energyBox.Name = "energyBox";
-            this.energyBox.Size = new System.Drawing.Size(181, 26);
+            this.energyBox.Size = new System.Drawing.Size(179, 26);
             this.energyBox.Text = "Energy";
             // 
             // toolStripTextBox3
@@ -328,19 +319,19 @@ namespace FietsClient
             // 
             // speedChart
             // 
-            chartArea4.Name = "ChartArea1";
-            this.speedChart.ChartAreas.Add(chartArea4);
+            chartArea1.Name = "ChartArea1";
+            this.speedChart.ChartAreas.Add(chartArea1);
             this.speedChart.Location = new System.Drawing.Point(8, 23);
             this.speedChart.Margin = new System.Windows.Forms.Padding(4);
             this.speedChart.Name = "speedChart";
-            series4.BorderWidth = 10;
-            series4.ChartArea = "ChartArea1";
-            series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
-            series4.Name = "Speed";
-            series4.XValueMember = "Time";
-            series4.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Time;
-            series4.YValueMembers = "Speed";
-            this.speedChart.Series.Add(series4);
+            series1.BorderWidth = 10;
+            series1.ChartArea = "ChartArea1";
+            series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+            series1.Name = "Speed";
+            series1.XValueMember = "Time";
+            series1.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Time;
+            series1.YValueMembers = "Speed";
+            this.speedChart.Series.Add(series1);
             this.speedChart.Size = new System.Drawing.Size(517, 351);
             this.speedChart.TabIndex = 0;
             this.speedChart.Text = "Speed chart";
@@ -359,19 +350,19 @@ namespace FietsClient
             // 
             // bpmChart
             // 
-            chartArea5.Name = "ChartArea1";
-            this.bpmChart.ChartAreas.Add(chartArea5);
+            chartArea2.Name = "ChartArea1";
+            this.bpmChart.ChartAreas.Add(chartArea2);
             this.bpmChart.Location = new System.Drawing.Point(8, 23);
             this.bpmChart.Margin = new System.Windows.Forms.Padding(4);
             this.bpmChart.Name = "bpmChart";
-            series5.BorderWidth = 10;
-            series5.ChartArea = "ChartArea1";
-            series5.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
-            series5.Name = "Beats per minute";
-            series5.XValueMember = "Time";
-            series5.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Time;
-            series5.YValueMembers = "Beats per minutes";
-            this.bpmChart.Series.Add(series5);
+            series2.BorderWidth = 10;
+            series2.ChartArea = "ChartArea1";
+            series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+            series2.Name = "Beats per minute";
+            series2.XValueMember = "Time";
+            series2.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Time;
+            series2.YValueMembers = "Beats per minutes";
+            this.bpmChart.Series.Add(series2);
             this.bpmChart.Size = new System.Drawing.Size(517, 351);
             this.bpmChart.TabIndex = 1;
             this.bpmChart.Text = "beats per second";
@@ -699,19 +690,19 @@ namespace FietsClient
             // 
             // rpmChart
             // 
-            chartArea6.Name = "ChartArea1";
-            this.rpmChart.ChartAreas.Add(chartArea6);
+            chartArea3.Name = "ChartArea1";
+            this.rpmChart.ChartAreas.Add(chartArea3);
             this.rpmChart.Location = new System.Drawing.Point(8, 23);
             this.rpmChart.Margin = new System.Windows.Forms.Padding(4);
             this.rpmChart.Name = "rpmChart";
-            series6.BorderWidth = 10;
-            series6.ChartArea = "ChartArea1";
-            series6.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
-            series6.Name = "Rounds per minute";
-            series6.XValueMember = "Time";
-            series6.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Time;
-            series6.YValueMembers = "Rounds per minutes";
-            this.rpmChart.Series.Add(series6);
+            series3.BorderWidth = 10;
+            series3.ChartArea = "ChartArea1";
+            series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+            series3.Name = "Rounds per minute";
+            series3.XValueMember = "Time";
+            series3.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Time;
+            series3.YValueMembers = "Rounds per minutes";
+            this.rpmChart.Series.Add(series3);
             this.rpmChart.Size = new System.Drawing.Size(517, 351);
             this.rpmChart.TabIndex = 2;
             this.rpmChart.Text = "rounds per minute";
@@ -799,7 +790,6 @@ namespace FietsClient
         private System.Windows.Forms.MenuStrip menuStrip1;
         private System.Windows.Forms.ToolStripMenuItem archiefToolStripMenuItem;
         private System.Windows.Forms.ToolStripMenuItem selectSessionToolStripMenuItem;
-        private System.Windows.Forms.ToolStripMenuItem sESSIONSToolStripMenuItem;
         private System.Windows.Forms.GroupBox speedBox;
         private System.Windows.Forms.GroupBox bpmBox;
         private System.Windows.Forms.GroupBox sessionInfoBox;

+ 21 - 0
Proftaak Remote Healthcare/FietsClientV2/Resources/PatientForm.cs → Proftaak Remote Healthcare/FietsClientV2/Forms/PatientForm.cs

@@ -6,8 +6,10 @@ using System.Drawing;
 using System.IO.Ports;
 using System.Linq;
 using System.Text;
+using System.Threading;
 using System.Threading.Tasks;
 using System.Windows.Forms;
+using FietsClient.JSONObjecten;
 
 namespace FietsClient
 {
@@ -47,6 +49,9 @@ namespace FietsClient
         {
             string[] ports = SerialPort.GetPortNames();
             toolStripComboBox1.Items.AddRange(ports);
+           
+            
+            MenuSessionItems();
         }
 
         private void requestDataToolStripMenuItem_Click(object sender, EventArgs e)
@@ -123,6 +128,20 @@ namespace FietsClient
             sendButton_Click(sender, e);
         }
 
+
+        private void MenuSessionItems()
+        {
+            foreach (Session s in _connection.currentData.GetSessions())
+            {
+                selectSessionToolStripMenuItem.DropDownItems.Add(
+                    new ToolStripMenuItem(s.id.ToString(), null, delegate
+                    {
+                       // Load Session data
+                    })
+                );
+
+            }
+        }
         private void printMessage(string[] data)
         {
 
@@ -130,6 +149,8 @@ namespace FietsClient
             chatBox.AppendText(finalMessage);
         }
 
+
+
         
     }
 }

+ 0 - 0
Proftaak Remote Healthcare/FietsClientV2/Resources/PatientForm.resx → Proftaak Remote Healthcare/FietsClientV2/Forms/PatientForm.resx


+ 31 - 20
Proftaak Remote Healthcare/FietsClientV2/TCPConnection.cs

@@ -16,7 +16,7 @@ namespace FietsClient
         public bool isConnectedFlag { private set; get; }
         private NetworkStream serverStream;
         public CurrentData currentData { private set; get; }
-        private string userID;
+        public string userID { private set; get; }
         private Thread receiveThread;
 
         public delegate void ChatmassegeDelegate(string[] data);
@@ -78,29 +78,18 @@ namespace FietsClient
                         case "0":   //login and display correct window after login
                             if (response_parts.Length == 4)
                             {
+                                SendGet(1);
+
                                 if (response_parts[1] == "1" && response_parts[2] == "1")
                                 {
-                                    
-                                    Form activeForm = Form.ActiveForm;
-                                    activeForm.Invoke((MethodInvoker)delegate ()
-                                    {
-                                        DoctorForm doctorForm = new DoctorForm(this);
-					activeForm.Hide();
-                                        doctorForm.Show();
-                                    });
                                     currentData = new CurrentData(userID);
+                                    currentData.isDoctor = true;
                                 }
                                 else if (response_parts[2] == "0" && response_parts[1] == "1")
                                 {
-                                    
-                                    Form activeForm = Form.ActiveForm;
-                                    activeForm.Invoke((MethodInvoker)delegate ()
-                                    {
-                                        PatientForm patientForm = new PatientForm(this);
-                                        activeForm.Hide();
-                                        patientForm.Show();
-                                    });
+
                                     currentData = new CurrentData(userID);
+                                    currentData.isDoctor = false;
                                 }
                                 else
                                     new Login("Geen gebruiker gevonden");
@@ -108,6 +97,28 @@ namespace FietsClient
                             break;
                         case "1":
                             currentData.setSessionList(JsonConvert.DeserializeObject<List<Session>>(response_parts[1]));
+
+                            if (currentData.isDoctor == true)
+                            {
+                                Form activeForm = Form.ActiveForm;
+                                activeForm.Invoke((MethodInvoker) delegate()
+                                {
+                                    DoctorForm doctorForm = new DoctorForm(this);
+                                    activeForm.Hide();
+                                    doctorForm.Show();
+                                });
+                            }
+                            else
+                            {
+                                Form activeForm = Form.ActiveForm;
+                                activeForm.Invoke((MethodInvoker)delegate ()
+                                {
+                                    PatientForm patientForm = new PatientForm(this);
+                                    activeForm.Hide();
+                                    patientForm.Show();
+                                });
+                            }
+
                             break;
                         case "2":
                             currentData.GetSessions().Last().AddMeasurement(JsonConvert.DeserializeObject<Measurement>(response_parts[1]));
@@ -130,19 +141,19 @@ namespace FietsClient
         public void SendGet(int GetWhat)
         {
             // send command ( cmdID | username )
-            SendString(GetWhat + "|" + userID);
+            SendString(GetWhat + "|" + userID + "|");
         }
 
         public void SendNewSession()
         {
             // send command ( cmdID | username )
-            SendString("3|" + userID + lib.JsonConverter.SerializeSession(currentData.GetSessions().Last()));
+            SendString("3|" + userID + lib.JsonConverter.SerializeSession(currentData.GetSessions().Last()) + "|");
         }
 
         public void SendNewMeasurement()
         {
             // send command ( cmdID | username )
-            SendString("5|" + userID + lib.JsonConverter.SerializeLastMeasurement(currentData.GetSessions().Last().GetLastMeasurement()));
+            SendString("5|" + userID + lib.JsonConverter.SerializeLastMeasurement(currentData.GetSessions().Last().GetLastMeasurement()) + "|");
         }
 	
 	public void SendChatMessage(string message)

+ 11 - 0
Proftaak Remote Healthcare/Server/AppGlobal.cs

@@ -13,6 +13,8 @@ namespace Server
         private static AppGlobal _instance;
 
         private List<User> users;
+        private List<User> activePatient;
+        private List<User> activeDoctor;
         public List<Client> Clients;
 
         public static AppGlobal Instance
@@ -46,6 +48,15 @@ namespace Server
                 {
                     admin = u.isDoctor ? 1 : 0;
                     id = users.IndexOf(u);
+                    if (u.isDoctor)
+                    {
+                        activeDoctor.Add(u);
+                    }
+                    else
+                    {
+                        activePatient.Add(u);
+                    }
+
                 }
             }
         }

+ 1 - 1
Proftaak Remote Healthcare/Server/FileIO/JsonConverter.cs

@@ -13,7 +13,7 @@ namespace Server.FileIO
     {
         public static void SaveUser(User u)
         {
-            File.WriteAllText(Environment.CurrentDirectory + "\\" + u.id + ".json", GetUser(u));
+            File.WriteAllText(@"../../JSONObjecten/JSON Files/" + u.id + ".json", GetUser(u));
         }
 
         public static string GetUser(User u)