public void addDiagnosis(string username, NewMailDataContract temp) { echelperDBEntities context = new echelperDBEntities(); context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Mail); context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Patient); context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Doctor); DateTime time = DateTime.Now; Mail newMail = new Mail(); newMail.PatientID = temp.PatientId; newMail.DoctorID = temp.DoctorId; newMail.Title = temp.Title; newMail.TextContent = temp.TextContent; newMail.Time = time; newMail.ECG = temp.ECG; newMail.FromOrTo = temp.FromOrTo; newMail.IsRead = 0; context.AddToMail(newMail); context.SaveChanges(); // return ConvertMailToDataContract(newMail); Patient patient = context.Patient.First(p => p.LiveID == temp.PatientId); int count = 0; foreach (Mail i in context.Mail) { if (i.PatientID == temp.PatientId && i.FromOrTo == 0 && i.IsRead == 0) { count++; } } string toastMessage = null; toastMessage = "<EmergencyConfirm>" + "<Type>0</Type>" + "<doctorName>" + count + "</doctorName>" + "<latitude>0</latitude>" + "<longitude>0</longitude>" + "<reply>0</reply>" + "</EmergencyConfirm>"; byte[] strBytes = new UTF8Encoding().GetBytes(toastMessage); if (patient.Channel != null) { sendWinNotificationType(strBytes, patient.Channel); } }
public void addnewMail(string username, NewMailDataContract temp) { echelperDBEntities context = new echelperDBEntities(); context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Mail); context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Patient); DateTime time = DateTime.Now; Mail newMail = new Mail(); newMail.PatientID = temp.PatientId; newMail.DoctorID = temp.DoctorId; newMail.Title = temp.Title; newMail.TextContent = temp.TextContent; newMail.Time = time; newMail.ECG = temp.ECG; newMail.FromOrTo = temp.FromOrTo; newMail.IsRead = 0; context.AddToMail(newMail); context.SaveChanges(); //Patient patient = context.Patient.First(p => p.LiveID == username); Doctor doctor = context.Doctor.First(p => p.LiveID == temp.DoctorId); int count = 0; foreach (Mail i in context.Mail) { if (i.DoctorID == temp.DoctorId && i.FromOrTo == 1 && i.IsRead == 0) { count++; } } string toastMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<wp:Notification xmlns:wp=\"WPNotification\">" + "<wp:Toast>" + "<wp:Text0>0</wp:Text0>" + "<wp:Text1>" + count + "</wp:Text1>" + "<wp:Text2>0</wp:Text2>" + "<wp:Text3>0</wp:Text3>" + "</wp:Toast>" + "</wp:Notification>"; byte[] strBytes = new UTF8Encoding().GetBytes(toastMessage); if (doctor.Channel != null) { sendNotificationType(strBytes, doctor.Channel); } //return ConvertMailToDataContract(newMail); }