public void Post_PatientMirror(Mirror m, string pStr, DateTime pUp) { try { string ipAddress = new WebClient().DownloadString("http://icanhazip.com").Trim(); WebRequest req = WebRequest.Create(FormatForPHP(String.Format( "http://server.infirmary-integrated.com/mirror_post.php" + "?accession={0}&key_access={1}&key_edit={2}&patient={3}&updated={4}&client_ip={5}&client_user={6}", m.Accession, Encryption.HashSHA256(m.PasswordAccess), Encryption.HashSHA256(m.PasswordEdit), Encryption.EncryptAES(pStr), Utility.DateTime_ToString(pUp), Encryption.HashSHA256(ipAddress), Encryption.HashSHA256(Environment.UserName)))); req.GetResponse(); } catch { } }
public Patient Get_PatientMirror(Mirror m) { try { WebRequest req = WebRequest.Create(FormatForPHP(String.Format( "http://server.infirmary-integrated.com/mirror_get.php?accession={0}&accesshash={1}", m.Accession, Encryption.HashSHA256(m.PasswordAccess)))); WebResponse resp = req.GetResponse(); Stream str = resp.GetResponseStream(); string updated = String.Empty; string patient = String.Empty; using (StreamReader sr = new StreamReader(str)) { updated = sr.ReadLine().Trim(); patient = sr.ReadLine().Trim(); } resp.Close(); str.Close(); resp.Dispose(); str.Dispose(); DateTime serverUpdated = Utility.DateTime_FromString(updated); if (DateTime.Compare(serverUpdated, m.PatientUpdated) <= 0) { return(null); } m.ServerQueried = DateTime.UtcNow; m.PatientUpdated = serverUpdated; Patient p = new Patient(); p.Load_Process(Encryption.DecryptAES(patient)); return(p); } catch { return(null); } }