private void GenerateData() { ImportFromFile("jthomas.keyring"); ImportFromFile("lmcdonald.keyring"); Patients.Clear(); foreach (var dataRow in SampleDataCsv.Split('\n')) { var record = dataRow.Split(','); var newPatient = new Patient().AsEncrypted(); newPatient.FirstName = record[0]; newPatient.LastName = record[1]; newPatient.ALT = double.Parse(record[2]); newPatient.AST = double.Parse(record[3]); newPatient.BMI = double.Parse(record[4]); newPatient.Weight = double.Parse(record[5]); newPatient.LastBloodPressure = record[6]; newPatient.HDL = double.Parse(record[7]); newPatient.SSN = record[8]; newPatient.DOB = DateTime.Parse(record[9]); newPatient.Collected = DateTime.Parse(record[10]); Patients.Add(newPatient); } using (var fs = new FileStream("data.dat", FileMode.Create)) { Keyring.GlobalKeyring.Lock(); var jsonStr = JsonConvert.SerializeObject(Patients.ToList(), new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.Auto }); using (var sw = new StreamWriter(fs)) { sw.Write(jsonStr); } Keyring.GlobalKeyring.Unlock(); } Keyring.GlobalKeyring.Clear(); }
private static void DataGeneration() { Keyring.GlobalKeyring.Add("Sensitive Information", AesEncryptionKey.Create(TripleDesEncryptionKey.Create())); Keyring.GlobalKeyring.Add("Semi-Sensitive Information", AesEncryptionKey.Create()); Keyring.GlobalKeyring.Add("Non-Sensitive Information", TripleDesEncryptionKey.Create()); using (var db = new DatabaseContext()) { db.Patients.RemoveRange(db.Patients); foreach (var dataRow in SampleDataCsv.Split('\n')) { var record = dataRow.Split(','); var newPatient = new Patient().AsEncrypted(); newPatient.FirstName = record[0]; newPatient.LastName = record[1]; newPatient.ALT = double.Parse(record[2]); newPatient.AST = double.Parse(record[3]); newPatient.BMI = double.Parse(record[4]); newPatient.CPeptide = double.Parse(record[5]); newPatient.Glucose = double.Parse(record[6]); newPatient.HDL = double.Parse(record[7]); newPatient.SSN = record[8]; newPatient.DOB = DateTime.Parse(record[9]); newPatient.Collected = DateTime.Parse(record[10]); db.Patients.Attach(newPatient); db.Patients.Add(newPatient); } db.SaveChanges(); using (var keyringStream = new FileStream("keyring.dat", FileMode.OpenOrCreate)) { Keyring.GlobalKeyring.ExportToStream(keyringStream); } } }
private static List <Patient> GetPatients() { var patients = new List <Patient>(); foreach (var dataRow in SampleDataCsv.Split('\n')) { var record = dataRow.Split(','); var newPatient = new Patient().AsEncrypted(); newPatient.FirstName = record[0]; newPatient.LastName = record[1]; newPatient.ALT = double.Parse(record[2]); newPatient.AST = double.Parse(record[3]); newPatient.BMI = double.Parse(record[4]); newPatient.CPeptide = double.Parse(record[5]); newPatient.Glucose = double.Parse(record[6]); newPatient.HDL = double.Parse(record[7]); newPatient.SSN = record[8]; newPatient.DOB = DateTime.Parse(record[9]); newPatient.Collected = DateTime.Parse(record[10]); patients.Add(newPatient); } return(patients); }