Bladeren bron

Merge remote-tracking branch 'origin/inladen-gegevens-naar-docterform'

Bart Reedijk 10 jaren geleden
bovenliggende
commit
8ce8e25c58

+ 12 - 4
Proftaak Remote Healthcare/FietsClientV2/DoctorModel.cs

@@ -25,6 +25,8 @@ namespace FietsClient
         public List<string> onlinePatients { get; set; } = new List<string>();
         public Dictionary<string, Forms.DoctorSessionUC> doctorSessions { get; set; } = new Dictionary<string, Forms.DoctorSessionUC>();
 
+
+
         private DoctorModel()
         {
             startAskingData();
@@ -41,6 +43,12 @@ namespace FietsClient
             receiveDataThread.Abort();
         }
 
+        internal List<User> requestUsers()
+        {
+            tcpConnection.requestUsers();
+            return tcpConnection.users;
+        }
+
         private void receiveDataThreadLoop()
         {
             while (true)
@@ -67,7 +75,7 @@ namespace FietsClient
                         doctorform.Invoke(new Action(() => doctorSessions.Remove(str)));
                     }
                     //onlinePatients.Find(username => username.Equals(str));
-                    
+
                 }
 
                 //voeg een onlinePatient toe aan een doctorSession
@@ -85,7 +93,7 @@ namespace FietsClient
         private List<DataPoint> rpmPoints = new List<DataPoint>();
         private void HandleBikeData(Measurement data)
         {
-            
+
             if (doctorform.InvokeRequired)
             {
                 doctorform.Invoke((new Action(() => HandleBikeData(data))));
@@ -99,7 +107,7 @@ namespace FietsClient
                 doctorform.summaryUserControl.distanceInfoBox.Text = data.distance.ToString();
                 doctorform.summaryUserControl.requestedBox.Text = data.requestedPower.ToString();
                 doctorform.summaryUserControl.energyInfoBox.Text = data.energy.ToString();
-                doctorform.summaryUserControl.timeBox.Text = data.time.ToString() ;
+                doctorform.summaryUserControl.timeBox.Text = data.time.ToString();
                 doctorform.summaryUserControl.actualBox.Text = data.actualPower.ToString();
 
                 //fill graph speed
@@ -129,7 +137,7 @@ namespace FietsClient
                     rpmPoints.RemoveAt(0);
                 doctorform.summaryUserControl.rpmChart.Update();
             }
-            
+
         }
     }
 }

+ 60 - 52
Proftaak Remote Healthcare/FietsClientV2/Forms/DoctorForm.Designer.cs

@@ -31,10 +31,9 @@
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DoctorForm));
             this.menuStrip1 = new System.Windows.Forms.MenuStrip();
             this.archiefToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.PatientBox = new System.Windows.Forms.ToolStripComboBox();
+            this.sessionsBox = new System.Windows.Forms.ToolStripComboBox();
             this.selectSessionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
-            this.sESSIONSToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
-            this.nieuwePatientToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
-            this.selectArchiveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.chatBox = new System.Windows.Forms.TextBox();
             this.messageBox = new System.Windows.Forms.TextBox();
             this.chatArea = new System.Windows.Forms.GroupBox();
@@ -42,6 +41,7 @@
             this.doctorTabControl = new System.Windows.Forms.TabControl();
             this.tabPageSummary = new System.Windows.Forms.TabPage();
             this.doctorSummaryUC1 = new FietsClient.Forms.DoctorSummaryUC();
+            this.loadUsersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.menuStrip1.SuspendLayout();
             this.chatArea.SuspendLayout();
             this.doctorTabControl.SuspendLayout();
@@ -55,61 +55,56 @@
             this.archiefToolStripMenuItem});
             this.menuStrip1.Location = new System.Drawing.Point(0, 0);
             this.menuStrip1.Name = "menuStrip1";
-            this.menuStrip1.Size = new System.Drawing.Size(1084, 24);
+            this.menuStrip1.Padding = new System.Windows.Forms.Padding(8, 2, 0, 2);
+            this.menuStrip1.Size = new System.Drawing.Size(1445, 28);
             this.menuStrip1.TabIndex = 0;
             this.menuStrip1.Text = "menuStrip1";
             // 
             // archiefToolStripMenuItem
             // 
             this.archiefToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
-            this.selectSessionToolStripMenuItem,
-            this.selectArchiveToolStripMenuItem});
+            this.loadUsersToolStripMenuItem,
+            this.PatientBox,
+            this.sessionsBox,
+            this.selectSessionToolStripMenuItem});
             this.archiefToolStripMenuItem.Name = "archiefToolStripMenuItem";
-            this.archiefToolStripMenuItem.Size = new System.Drawing.Size(56, 20);
-            this.archiefToolStripMenuItem.Text = "Patient";
+            this.archiefToolStripMenuItem.Size = new System.Drawing.Size(70, 24);
+            this.archiefToolStripMenuItem.Text = "Archive";
             // 
-            // selectSessionToolStripMenuItem
-            // 
-            this.selectSessionToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
-            this.sESSIONSToolStripMenuItem,
-            this.nieuwePatientToolStripMenuItem});
-            this.selectSessionToolStripMenuItem.Name = "selectSessionToolStripMenuItem";
-            this.selectSessionToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
-            this.selectSessionToolStripMenuItem.Text = "Select patient";
+            // PatientBox
             // 
-            // sESSIONSToolStripMenuItem
+            this.PatientBox.Name = "PatientBox";
+            this.PatientBox.Size = new System.Drawing.Size(121, 28);
+            this.PatientBox.SelectedIndexChanged += new System.EventHandler(this.PatientBox_SelectedIndexChanged);
             // 
-            this.sESSIONSToolStripMenuItem.Name = "sESSIONSToolStripMenuItem";
-            this.sESSIONSToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
-            this.sESSIONSToolStripMenuItem.Text = "Patients";
+            // sessionsBox
             // 
-            // nieuwePatientToolStripMenuItem
+            this.sessionsBox.Name = "sessionsBox";
+            this.sessionsBox.Size = new System.Drawing.Size(121, 28);
             // 
-            this.nieuwePatientToolStripMenuItem.Name = "nieuwePatientToolStripMenuItem";
-            this.nieuwePatientToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
-            this.nieuwePatientToolStripMenuItem.Text = "Nieuwe Patient";
-            this.nieuwePatientToolStripMenuItem.Click += new System.EventHandler(this.nieuwePatientToolStripMenuItem_Click);
-            // 
-            // selectArchiveToolStripMenuItem
+            // selectSessionToolStripMenuItem
             // 
-            this.selectArchiveToolStripMenuItem.Name = "selectArchiveToolStripMenuItem";
-            this.selectArchiveToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
-            this.selectArchiveToolStripMenuItem.Text = "Select archive";
+            this.selectSessionToolStripMenuItem.Name = "selectSessionToolStripMenuItem";
+            this.selectSessionToolStripMenuItem.Size = new System.Drawing.Size(187, 26);
+            this.selectSessionToolStripMenuItem.Text = "Select session";
+            this.selectSessionToolStripMenuItem.Click += new System.EventHandler(this.selectSessionToolStripMenuItem_Click);
             // 
             // chatBox
             // 
-            this.chatBox.Location = new System.Drawing.Point(0, 13);
+            this.chatBox.Location = new System.Drawing.Point(0, 16);
+            this.chatBox.Margin = new System.Windows.Forms.Padding(4);
             this.chatBox.Multiline = true;
             this.chatBox.Name = "chatBox";
             this.chatBox.ReadOnly = true;
-            this.chatBox.Size = new System.Drawing.Size(228, 560);
+            this.chatBox.Size = new System.Drawing.Size(303, 688);
             this.chatBox.TabIndex = 3;
             // 
             // messageBox
             // 
-            this.messageBox.Location = new System.Drawing.Point(0, 579);
+            this.messageBox.Location = new System.Drawing.Point(0, 713);
+            this.messageBox.Margin = new System.Windows.Forms.Padding(4);
             this.messageBox.Name = "messageBox";
-            this.messageBox.Size = new System.Drawing.Size(228, 20);
+            this.messageBox.Size = new System.Drawing.Size(303, 22);
             this.messageBox.TabIndex = 6;
             this.messageBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.messageBox_KeyPress);
             // 
@@ -118,18 +113,21 @@
             this.chatArea.Controls.Add(this.messageButton);
             this.chatArea.Controls.Add(this.chatBox);
             this.chatArea.Controls.Add(this.messageBox);
-            this.chatArea.Location = new System.Drawing.Point(849, 50);
+            this.chatArea.Location = new System.Drawing.Point(1132, 62);
+            this.chatArea.Margin = new System.Windows.Forms.Padding(4);
             this.chatArea.Name = "chatArea";
-            this.chatArea.Size = new System.Drawing.Size(228, 641);
+            this.chatArea.Padding = new System.Windows.Forms.Padding(4);
+            this.chatArea.Size = new System.Drawing.Size(304, 789);
             this.chatArea.TabIndex = 5;
             this.chatArea.TabStop = false;
             this.chatArea.Text = "Chat:";
             // 
             // messageButton
             // 
-            this.messageButton.Location = new System.Drawing.Point(0, 605);
+            this.messageButton.Location = new System.Drawing.Point(0, 745);
+            this.messageButton.Margin = new System.Windows.Forms.Padding(4);
             this.messageButton.Name = "messageButton";
-            this.messageButton.Size = new System.Drawing.Size(228, 30);
+            this.messageButton.Size = new System.Drawing.Size(304, 37);
             this.messageButton.TabIndex = 7;
             this.messageButton.Text = "send";
             this.messageButton.UseVisualStyleBackColor = true;
@@ -138,19 +136,21 @@
             // doctorTabControl
             // 
             this.doctorTabControl.Controls.Add(this.tabPageSummary);
-            this.doctorTabControl.Location = new System.Drawing.Point(13, 28);
+            this.doctorTabControl.Location = new System.Drawing.Point(17, 34);
+            this.doctorTabControl.Margin = new System.Windows.Forms.Padding(4);
             this.doctorTabControl.Name = "doctorTabControl";
             this.doctorTabControl.SelectedIndex = 0;
-            this.doctorTabControl.Size = new System.Drawing.Size(830, 666);
+            this.doctorTabControl.Size = new System.Drawing.Size(1107, 820);
             this.doctorTabControl.TabIndex = 6;
             // 
             // tabPageSummary
             // 
             this.tabPageSummary.BackColor = System.Drawing.Color.Transparent;
             this.tabPageSummary.Controls.Add(this.doctorSummaryUC1);
-            this.tabPageSummary.Location = new System.Drawing.Point(4, 22);
+            this.tabPageSummary.Location = new System.Drawing.Point(4, 25);
+            this.tabPageSummary.Margin = new System.Windows.Forms.Padding(4);
             this.tabPageSummary.Name = "tabPageSummary";
-            this.tabPageSummary.Size = new System.Drawing.Size(822, 640);
+            this.tabPageSummary.Size = new System.Drawing.Size(1099, 791);
             this.tabPageSummary.TabIndex = 0;
             this.tabPageSummary.Text = "Summary";
             // 
@@ -158,23 +158,31 @@
             // 
             this.doctorSummaryUC1.BackColor = System.Drawing.SystemColors.Control;
             this.doctorSummaryUC1.Location = new System.Drawing.Point(0, 0);
-            this.doctorSummaryUC1.Margin = new System.Windows.Forms.Padding(4);
+            this.doctorSummaryUC1.Margin = new System.Windows.Forms.Padding(5);
             this.doctorSummaryUC1.Name = "doctorSummaryUC1";
-            this.doctorSummaryUC1.Size = new System.Drawing.Size(822, 640);
+            this.doctorSummaryUC1.Size = new System.Drawing.Size(1096, 788);
             this.doctorSummaryUC1.TabIndex = 0;
             // 
+            // loadUsersToolStripMenuItem
+            // 
+            this.loadUsersToolStripMenuItem.Name = "loadUsersToolStripMenuItem";
+            this.loadUsersToolStripMenuItem.Size = new System.Drawing.Size(187, 26);
+            this.loadUsersToolStripMenuItem.Text = "Load users";
+            this.loadUsersToolStripMenuItem.Click += new System.EventHandler(this.loadUsersToolStripMenuItem_Click);
+            // 
             // DoctorForm
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.BackColor = System.Drawing.SystemColors.Control;
-            this.ClientSize = new System.Drawing.Size(1084, 711);
+            this.ClientSize = new System.Drawing.Size(1445, 875);
             this.Controls.Add(this.doctorTabControl);
             this.Controls.Add(this.chatArea);
             this.Controls.Add(this.menuStrip1);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
             this.MainMenuStrip = this.menuStrip1;
+            this.Margin = new System.Windows.Forms.Padding(4);
             this.MaximizeBox = false;
             this.Name = "DoctorForm";
             this.Text = "Doctor";
@@ -194,18 +202,18 @@
         #endregion
 
         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.TextBox chatBox;
         private System.Windows.Forms.TextBox messageBox;
         private System.Windows.Forms.GroupBox chatArea;
-        private System.Windows.Forms.ToolStripMenuItem selectArchiveToolStripMenuItem;
         private System.Windows.Forms.Button messageButton;
         private System.Windows.Forms.TabControl doctorTabControl;
-        private System.Windows.Forms.TabPage tabPageSummary;
         private Forms.DoctorSummaryUC doctorSummaryUC1;
-        private System.Windows.Forms.ToolStripMenuItem nieuwePatientToolStripMenuItem;
+        public System.Windows.Forms.ToolStripMenuItem archiefToolStripMenuItem;
+        private System.Windows.Forms.ToolStripComboBox PatientBox;
+        public System.Windows.Forms.TabPage tabPageSummary;
+        public System.Windows.Forms.ToolStripComboBox sessionsBox;
+        private System.Windows.Forms.ToolStripMenuItem selectSessionToolStripMenuItem;
+        private System.Windows.Forms.ToolStripMenuItem loadUsersToolStripMenuItem;
     }
 }
 

+ 103 - 8
Proftaak Remote Healthcare/FietsClientV2/Forms/DoctorForm.cs

@@ -8,6 +8,9 @@ using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Forms;
 using FietsClient.Forms;
+using FietsLibrary.JSONObjecten;
+using System.Windows.Forms.DataVisualization.Charting;
+using System.Threading;
 
 namespace FietsClient
 {
@@ -37,9 +40,10 @@ namespace FietsClient
             }
         }
 
+        private List<User> users = new List<User>();
         private void Form1_Load(object sender, EventArgs e)
         {
-
+            users = doctorModel.requestUsers();
         }
 
         private void messageBox_KeyPress(object sender, KeyPressEventArgs e)
@@ -62,13 +66,13 @@ namespace FietsClient
 
                 doctorModel.tcpConnection.SendChatMessage(data);
             }
-            
+
             else if (messageBox.Text != null && doctorTabControl.SelectedTab.Name == "tabPageSummary")
             {
                 String[] data = new String[2];
                 data[0] = "This is a broadcast: " + messageBox.Text;
                 //all patients:
-                for (int tabs = 1; tabs <= doctorTabControl.TabCount -1; tabs++)
+                for (int tabs = 1; tabs <= doctorTabControl.TabCount - 1; tabs++)
                 {
                     doctorTabControl.SelectTab(tabs);
                     data[1] = doctorTabControl.SelectedTab.Name;
@@ -76,16 +80,16 @@ namespace FietsClient
                 }
                 messageBox.Clear();
 
-            }  
+            }
         }
 
         private void printMessage(string[] data)
         {
             string finalMessage = data[0] + ":\t" + data[2] + "\r\n";
-            chatBox.Invoke((MethodInvoker) delegate ()
-            {
-                chatBox.AppendText(finalMessage);
-            });
+            chatBox.Invoke((MethodInvoker)delegate ()
+           {
+               chatBox.AppendText(finalMessage);
+           });
         }
 
         public void AddSessionToTabcontrol(string patientID)
@@ -118,5 +122,96 @@ namespace FietsClient
             var newPatient = new NewPatientForm(doctorModel.tcpConnection);
             newPatient.Show();
         }
+
+        private List<DataPoint> speedPoints = new List<DataPoint>();
+        private List<DataPoint> bpmPoints = new List<DataPoint>();
+        private List<DataPoint> rpmPoints = new List<DataPoint>();
+        private void selectSessionToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            //get measurments
+            List<Measurement> measurments = new List<Measurement>();
+            User user = null;
+            foreach (User userx in users)
+            {
+                user = userx;
+                if (PatientBox.Text == user.id)
+                {
+                    List<Session> sessions = user.GetSessions();
+                    foreach (Session session in sessions)
+                    {
+                        if (sessionsBox.Text == session.date.ToString())
+                        {
+                            measurments = session.session;
+                        }
+                    }
+                }
+            }
+            //fill boxes
+
+            summaryUserControl.sessionBox.Text = user.id;
+            summaryUserControl.nameBox.Text = user.id;
+            summaryUserControl.pulseBox.Text = measurments[measurments.Count - 1].bpm.ToString();
+            summaryUserControl.rpmInfoBox.Text = measurments[measurments.Count - 1].rpm.ToString();
+            summaryUserControl.speedInfoBox.Text = measurments[measurments.Count - 1].speed.ToString();
+            summaryUserControl.distanceInfoBox.Text = measurments[measurments.Count - 1].distance.ToString();
+            summaryUserControl.requestedBox.Text = measurments[measurments.Count - 1].requestedPower.ToString();
+            summaryUserControl.energyInfoBox.Text = measurments[measurments.Count - 1].energy.ToString();
+            summaryUserControl.timeBox.Text = measurments[measurments.Count - 1].time.ToString();
+            summaryUserControl.actualBox.Text = measurments[measurments.Count - 1].actualPower.ToString();
+
+            //fill speedpoints
+            for (int i = 0; i < measurments.Count; i++)
+            {
+                speedPoints.Add(new DataPoint(measurments[i].time, measurments[i].speed));
+            }
+            //fill speedgraph
+            summaryUserControl.speedChart.Series[0].Points.Clear();
+            for (int i = 0; i < speedPoints.Count; i++)
+                summaryUserControl.speedChart.Series[0].Points.Add(speedPoints[i]);
+            summaryUserControl.speedChart.Update();
+
+            //fill bpm
+            for (int i = 0; i < measurments.Count; i++)
+            {
+                bpmPoints.Add(new DataPoint(measurments[i].time, measurments[i].bpm));
+            }
+            //fill bpmgraph
+            summaryUserControl.bpmChart.Series[0].Points.Clear();
+            for (int i = 0; i < bpmPoints.Count; i++)
+                summaryUserControl.bpmChart.Series[0].Points.Add(bpmPoints[i]);
+            summaryUserControl.bpmChart.Update();
+
+            //fill rpm
+            for (int i = 0; i < measurments.Count; i++)
+            {
+                rpmPoints.Add(new DataPoint(measurments[i].time, measurments[i].rpm));
+            }
+            //fill rpmgraph
+            summaryUserControl.rpmChart.Series[0].Points.Clear();
+            for (int i = 0; i < rpmPoints.Count; i++)
+                summaryUserControl.rpmChart.Series[0].Points.Add(rpmPoints[i]);
+            summaryUserControl.rpmChart.Update();
+        }
+
+        private void PatientBox_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            foreach (User user in users)
+            {
+                if (user.id == PatientBox.Text)
+                    foreach (Session session in user.GetSessions())
+                    {
+                        sessionsBox.Items.Add(session.date.ToString());
+                    }
+            }
+        }
+
+        private void loadUsersToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            users = doctorModel.tcpConnection.users;
+            foreach (User user in users)
+            {
+                PatientBox.Items.Add(user.id);
+            }
+        }
     }
 }

+ 34 - 3
Proftaak Remote Healthcare/FietsClientV2/TcpConnection.cs

@@ -27,6 +27,7 @@ namespace FietsClient
 
         public delegate void ChatmassegeDelegate(string[] data);
         public event ChatmassegeDelegate IncomingChatmessageEvent;
+        public List<User> users = new List<User>();
 
         public TcpConnection()
         {
@@ -119,7 +120,7 @@ namespace FietsClient
 
         public void disconnect()
         {
-           
+
             sslStream.Close();
             client.Close();
             receiveThread.Abort();
@@ -151,7 +152,7 @@ namespace FietsClient
                         case "0":   //login and display correct window after login
                             if (response_parts.Length == 4)
                             {
-                                
+
 
                                 if (response_parts[1] == "1" && response_parts[2] == "1")
                                 {
@@ -217,7 +218,32 @@ namespace FietsClient
                             }
                             break;
                         case "9":
-                            JsonConvert.DeserializeObject<List<User>>(response_parts[1]);
+                            dynamic results = JsonConvert.DeserializeObject<dynamic>(response_parts[1]);
+
+                            foreach (dynamic r in results)
+                            {
+                                User user = r as User;
+                                users.Add(new User(r.id.ToString(), r.password.ToString(), Int32.Parse(r.age.ToString()),
+                                    Boolean.Parse(r.gender.ToString()), Int32.Parse(r.weight.ToString()),
+                                    Boolean.Parse(r.isDoctor.ToString())));
+
+                                int i = 1;
+
+                                foreach (dynamic ses in r.tests)
+                                {
+                                    Session tempSession = new Session(i, Int32.Parse(ses.bikeMode.ToString()), ses.modevalue.ToString());
+                                    i++;
+
+                                    foreach (dynamic m in ses.session)
+                                    {
+                                        Measurement measurement = new Measurement(Int32.Parse(m.pulse.ToString()), Int32.Parse(m.rpm.ToString()), Int32.Parse(m.speed.ToString()), Int32.Parse(m.wattage.ToString()), Int32.Parse(m.distance.ToString()), Int32.Parse(m.requestedPower.ToString()), Int32.Parse(m.energy.ToString()), Int32.Parse(m.actualPower.ToString()), Int32.Parse(m.time.ToString()), Int32.Parse(m.bpm.ToString()));
+                                        tempSession.AddMeasurement(measurement);
+                                    }
+
+                                    users.Last().AddSession(tempSession);
+                                }
+                                Console.WriteLine(users);
+                            }
                             break;
                     }
                 }
@@ -273,6 +299,10 @@ namespace FietsClient
             SendString("8|" + userID + "|");
         }
 
+        public void requestUsers()
+        {
+            SendString("9|");
+        }
         public void SendDistance(int distance)
         {
             SendString("10|" + userID + "|" + distance + "|");
@@ -288,6 +318,7 @@ namespace FietsClient
             SendString("12|" + userID + "|" + power + "|");
         }
 
+
         public void SendString(string s)
         {
             try

+ 1 - 1
Proftaak Remote Healthcare/FietsLibrary/JSONObjecten/Session.cs

@@ -21,7 +21,7 @@ namespace FietsLibrary.JSONObjecten
         public string note { get; private set; }
         public string modevalue { get; private set; }
 
-        public Session(int bikeMode, string modevalue)
+        public Session(int id ,int bikeMode, string modevalue)
         {
             if (!(Directory.Exists(@"JSON Files"))) 
             {

+ 6 - 4
Proftaak Remote Healthcare/ServerV2/AppGlobal.cs

@@ -45,12 +45,12 @@ namespace ServerV2
             users.Add(new User("admin", "admin", 80, false, 77, true));
 
             Random r = new Random();
-            Session session = new Session(1, "100");
+            Session session = new Session(1,1, "100");
             for (int i = 0; i < 20; i++)
                 session.AddMeasurement(new Measurement(r.Next(100, 200), r.Next(60, 100), r.Next(100, 150), r.Next(0, 100), i, r.Next(100), r.Next(100), r.Next(100), i, r.Next(100)));
             users.ElementAt(1).tests.Add(session);
 
-            Session session2 = new Session(2, "100");
+            Session session2 = new Session(2,2, "100");
             for (int i = 0; i < 50; i++)
                 session2.AddMeasurement(new Measurement(r.Next(100, 200), r.Next(60, 100), r.Next(100, 150), r.Next(0, 100), i, r.Next(100), r.Next(100), r.Next(100), i, r.Next(100)));
             users.ElementAt(1).tests.Add(session2);
@@ -156,7 +156,7 @@ namespace ServerV2
                             foreach (User u in users)
                             {
                                 if (u.id == response[1])
-                                    u.AddSession(new Session(int.Parse(response[2]), response[3]));
+                                    u.AddSession(new Session(u.GetSessions().Last().id+1, int.Parse(response[2]), response[3]));
                             }
                         }
                         break;
@@ -212,7 +212,9 @@ namespace ServerV2
                         }
                         break;
                     case "9": //alles doorsturen voor de dokter
-                        Communication.Send(FietsLibrary.JsonConverter.GetUsers(users), sslStream);
+                        Console.WriteLine("send users");
+                        string file = "9|" + FietsLibrary.JsonConverter.GetUsers(users);
+                        Communication.Send(file, sslStream);
                         break;
                     default:
                         break;