private static MailDataContract ConvertMailToDataContract(Mail blog) //----------- { return new MailDataContract() { MailId = blog.ID, Title = blog.Title, Time = (DateTime)blog.Time, TextContent = blog.TextContent, DoctorId = blog.DoctorID, PatientId = blog.PatientID, FromOrTo = (int)blog.FromOrTo, ECG = blog.ECG, IsRead = (int)blog.IsRead }; }
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); } }
/// <summary> /// Create a new Mail object. /// </summary> /// <param name="id">Initial value of the ID property.</param> public static Mail CreateMail(global::System.Int32 id) { Mail mail = new Mail(); mail.ID = id; return mail; }
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); }
/// <summary> /// Deprecated Method for adding a new object to the Mail EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToMail(Mail mail) { base.AddObject("Mail", mail); }