private void button_Click(object sender, RoutedEventArgs e) { string[] namedob = patientsuggest.Text.Split(','); Debug.WriteLine(namedob[0]); Debug.WriteLine(namedob[1]); PatientSheet Item = patientList.Find(c => (c.patientName == namedob[0]) && (c.patientDOB == namedob[1])); patientToTreat = Item.patientUser; patientDisplayName = patientsuggest.Text; this.Hide(); }
private async void LoginLoad() { // Login screen ContentDialog1 signInDialog = new ContentDialog1(); Debug.WriteLine("login"); await signInDialog.ShowAsync(); Debug.WriteLine("login shows"); // Because it is statically allocated all the instances of content dialog share it, thus it only makes sense to access the property from the type itself var client = ContentDialog1.client; sharedClient = client; // Patient list request //Debug.WriteLine(signInDialog.username); string preQuery = String.Format("MATCH (a:doctor)-[: treat]->(b:patient) WHERE a.username = \"{0}\" RETURN b", signInDialog.username); // Preparing a JSON query queryObject query1 = new queryObject(preQuery); string output = await query1.cypherPOST(client); // Deserialization of data JsonObject value = JsonObject.Parse(output); IJsonValue j, k, m; value.TryGetValue("data", out j); JsonArray value2 = j.GetArray(); // In case the search does not return any results, this array will be empty List <PatientSheet> patientList = new List <PatientSheet> { }; // Meaning it will be empty if zero found if (value2.Count != 0) // If there are patients { for (int i = 0; i < value2.Count; i++) { JsonArray value3 = value2[i].GetArray(); JsonObject object2 = value3[0].GetObject(); object2.TryGetValue("data", out k); JsonObject object3 = k.GetObject(); // Switching it to name object3.TryGetValue("username", out m); string username = m.GetString(); string id = await fetchPatientId(username); // patients user Debug.WriteLine(id); string[] keys = await downloadPrivateKeys(signInDialog.username, id); // doctors user Debug.WriteLine(keys[0]); string decryptedDoctorPrivate = keyGenerator.Decrypt(keys[0], signInDialog.password); Debug.WriteLine(keys[1]); // Patient's private key is decrypted. It can be decrypted by doctor's private key, but only in pieces. // Partition string by _ string[] splitKeys = keys[1].Split('_'); string combinedKey = ""; foreach (string splittedKey in splitKeys) { if (splittedKey.Length > 0) { string decryptedKeyPart; Debug.Write("encrypted:"); Debug.WriteLine(splittedKey); keyGenerator.AsymmetricDecrypt(decryptedDoctorPrivate, splittedKey, out decryptedKeyPart); Debug.Write("decrypted:"); Debug.WriteLine(decryptedKeyPart); combinedKey += decryptedKeyPart; } } Debug.WriteLine(combinedKey); // Combined key is patient's private key, with those we can decrypt the other relevant data string dob; object3.TryGetValue("dob", out m); keyGenerator.AsymmetricDecrypt(combinedKey, m.GetString(), out dob); Debug.WriteLine(dob); string name; object3.TryGetValue("name", out m); keyGenerator.AsymmetricDecrypt(combinedKey, m.GetString(), out name); Debug.WriteLine(name); PatientSheet patientItem = new PatientSheet { patientName = name, patientDOB = dob, patientUser = username }; patientList.Add(patientItem); } } ContentDialog2 patientDialog = new ContentDialog2(signInDialog.username); patientDialog.patientList = patientList; // You could make patientlist private if you do an initaliser for it await patientDialog.ShowAsync(); commandBar.Text = String.Format("Currently treating {0}.", patientDialog.patientDisplayName); this.userBeingTreated = patientDialog.patientToTreat; this.doctor = signInDialog.username; // When everything is done, load the patient measurement data into the plot List <MeasurementPoint> mes = await fetchMeasurements(); Debug.Write("mes:"); Debug.WriteLine(mes.Count); if (mes.Count != 0) { updatePatientPlot(mes); } }