public static void Not_AgendaTaskAssign(AgendaClass.AgendaTaskClass task) { using (boxEntities box = new boxEntities()) { int uid = Profile.getUserID(task.Creator); NotificationHeader notH = new NotificationHeader(); notH.NotType = NotificationType.Agenda_Update.ToString(); notH.NotDate = DateTime.Now; notH.AgendaID = task.AgendaID; notH.NotCreator = uid; box.NotificationHeaders.AddObject(notH); box.SaveChanges(); var parti = Profile.GetUserIDs(task.Usernames).ToList(); foreach (var i in parti) { NotInfo notI = new NotInfo(); notI.UserID = i; notI.NotHeaderID = notH.NotID; notI.Ack = false; notI.Seen = false; box.NotInfoes.AddObject(notI); } box.SaveChanges(); // get data var emails = getEmails(parti); var mtitle = box.Agenda.Where(a => a.AgendaID == task.AgendaID).Select(a => a.Meeting.MeetingTitle).FirstOrDefault(); var msg = FormatTaskMsg(task, NotificationType.Task_Assignment, mtitle); SendEmail(emails, msg, NotificationType.Task_Assignment); } }
public static void Not_NewReply(int disID, string user, string dTitle) { using (boxEntities box = new boxEntities()) { int uid = Profile.getUserID(user); NotificationHeader notH = new NotificationHeader(); notH.NotType = NotificationType.New_Reply.ToString(); notH.NotDate = DateTime.Now; notH.DiscussionID = disID; notH.NotCreator = uid; box.NotificationHeaders.AddObject(notH); box.SaveChanges(); // get ids var ids = (from o in box.Replies where o.DiscussionID == disID select o.UserID).Union((from o in box.Discussions where o.ID == disID select o.UserID)).ToList(); ids.Remove(uid); foreach (var i in ids) { NotInfo notI = new NotInfo(); notI.UserID = i; notI.NotHeaderID = notH.NotID; notI.Ack = false; notI.Seen = false; box.NotInfoes.AddObject(notI); } box.SaveChanges(); // get data var parti = getEmails(ids); var msg = FormatDiscussiongMsg(dTitle, user, NotificationType.New_Reply); SendEmail(parti, msg, NotificationType.New_Reply); } }
public static void InsertMeetingParticipant(List <int> parties, int meetingid, int user) { using (boxEntities box = new boxEntities()) { NotificationHeader notH = new NotificationHeader(); notH.NotType = NotificationType.Meeting_Parti_Insert.ToString(); notH.MeetingID = meetingid; notH.NotDate = DateTime.Now; notH.NotCreator = user; box.NotificationHeaders.AddObject(notH); box.SaveChanges(); var m = (from o in box.Meetings.Include("MeetingType") where o.MeetingID == meetingid select o).FirstOrDefault(); if (m == null) { throw new Exception("Wrong Meeting ID."); } // loop to add info and follower foreach (var i in parties) { NotInfo notI = new NotInfo(); notI.UserID = i; notI.NotHeaderID = notH.NotID; notI.Ack = false; notI.Seen = false; box.NotInfoes.AddObject(notI); //notH.NotInfoes.Add(notI); } var emails = getEmails(parties, meetingid); SendEmail(emails, m, NotificationType.Meeting_Parti_Insert); box.SaveChanges(); } }
public static void Not_DisinviteParti(int meetingid, string username, int user) { using (boxEntities box = new boxEntities()) { // create notification NotificationHeader notH = new NotificationHeader(); notH.NotType = NotificationType.Meeting_Parti_Disinvite.ToString(); notH.MeetingID = meetingid; notH.NotDate = DateTime.Now; notH.NotCreator = user; box.NotificationHeaders.AddObject(notH); box.SaveChanges(); NotInfo notI = new NotInfo(); notI.UserID = Profile.getUserID(username); notI.NotHeaderID = notH.NotID; notI.Ack = false; notI.Seen = false; box.NotInfoes.AddObject(notI); box.SaveChanges(); // send email // get user email string email = Profile.getUserEmail(username); string from; SmtpClient client; CreateSmtpClient(out from, out client); string msg = FormatMeetingMsg(box.Meetings.Where(a => a.MeetingID == meetingid).FirstOrDefault(), "", NotificationType.Meeting_Parti_Disinvite); SendEmail(from, email, username, GetSubject(NotificationType.Meeting_Parti_Disinvite), msg, client); } }
public static void Not_NewMeetingDiscussion(int meetingid, int user, string dTitle) { using (boxEntities box = new boxEntities()) { NotificationHeader notH = new NotificationHeader(); notH.NotType = NotificationType.Meeting_New_Discussion.ToString(); notH.MeetingID = meetingid; notH.NotDate = DateTime.Now; notH.NotCreator = user; box.NotificationHeaders.AddObject(notH); box.SaveChanges(); // get meeting parties var parties = (from o in box.MeetingParticipants where o.MeetingID == meetingid select o.UserID).ToList(); // loop to add info and follower foreach (var i in parties) { NotInfo notI = new NotInfo(); notI.UserID = i; notI.NotHeaderID = notH.NotID; notI.Ack = false; notI.Seen = false; box.NotInfoes.AddObject(notI); //notH.NotInfoes.Add(notI); } box.SaveChanges(); // get meeting title var meetingTitle = (from o in box.Meetings where o.MeetingID == meetingid select o.MeetingTitle).FirstOrDefault(); var r = getEmails(parties); var msg = FormatDiscussiongMsg(dTitle, meetingTitle, NotificationType.Meeting_New_Discussion); SendEmail(r, msg, NotificationType.Meeting_New_Discussion); } }
public static void Not_NewAgendaDiscussion(string dTitle, int AgendaID, int user) { using (boxEntities box = new boxEntities()) { NotificationHeader notH = new NotificationHeader(); notH.NotType = NotificationType.Agenda_New_Discussion.ToString(); notH.AgendaID = AgendaID; notH.NotDate = DateTime.Now; notH.NotCreator = user; box.NotificationHeaders.AddObject(notH); box.SaveChanges(); // get recipients email var re = (from o in box.AgendaPrivacies where o.AgendaID == AgendaID && o.Agendum.Published == true && o.CanSee == true select o.MeetingParticipant.UserID).ToList(); foreach (var i in re) { NotInfo notI = new NotInfo(); notI.UserID = i; notI.NotHeaderID = notH.NotID; notI.Ack = false; notI.Seen = false; box.NotInfoes.AddObject(notI); } box.SaveChanges(); // get agenda title var agendaT = (from o in box.Agenda where o.AgendaID == AgendaID select o.AgendaTitle).FirstOrDefault(); // get information for the email var parti = getEmails(re); var msg = FormatDiscussiongMsg(dTitle, agendaT, NotificationType.Agenda_New_Discussion); SendEmail(parti, msg, NotificationType.Agenda_New_Discussion); } }
public static void Not_UpdateAgenda(Agendum agenda, string user) { using (boxEntities box = new boxEntities()) { int uid = Profile.getUserID(user); NotificationHeader notH = new NotificationHeader(); notH.NotType = NotificationType.Agenda_Update.ToString(); notH.NotDate = DateTime.Now; notH.AgendaID = agenda.AgendaID; notH.NotCreator = uid; box.NotificationHeaders.AddObject(notH); box.SaveChanges(); // get parti // get recipients email var re = (from o in box.AgendaPrivacies where o.AgendaID == agenda.AgendaID && o.Agendum.Published == true && o.CanSee == true select o.MeetingParticipant.UserID).ToList(); re.Remove(uid); foreach (var i in re) { NotInfo notI = new NotInfo(); notI.UserID = i; notI.NotHeaderID = notH.NotID; notI.Ack = false; notI.Seen = false; box.NotInfoes.AddObject(notI); } box.SaveChanges(); // get data var mTitle = agenda.Meeting.MeetingTitle; var emails = getEmails(re); var msg = FormatAgendaMsg(agenda, NotificationType.Agenda_Update, mTitle); SendEmail(emails, msg, NotificationType.Agenda_Update); } }
public static void UpdateMeetingInfo(int meetingid, int user) { using (boxEntities box = new boxEntities()) { NotificationHeader notH = new NotificationHeader(); notH.NotType = NotificationType.Meeting_Info_Update.ToString(); notH.MeetingID = meetingid; notH.NotCreator = user; notH.NotDate = DateTime.Now; box.NotificationHeaders.AddObject(notH); box.SaveChanges(); // get the list of UserIDs of participants var parties = (from o in box.MeetingParticipants where o.MeetingID == meetingid select o.UserID).ToList(); // loop to add info and follower foreach (var i in parties) { NotInfo notI = new NotInfo(); notI.UserID = i; notI.NotHeaderID = notH.NotID; notI.Ack = false; notI.Seen = false; box.NotInfoes.AddObject(notI); //notH.NotInfoes.Add(notI); } box.SaveChanges(); // get meeting var m = (from o in box.Meetings where o.MeetingID == meetingid select o).FirstOrDefault(); SendEmail(getEmails(parties), m, NotificationType.Meeting_Info_Update); } }