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); } }
// old methods public void CreateNot(string creator, string fileDir, NotType type) { using (boxEntities box = new boxEntities()) { int user; int file; getUser(creator, box, out user); //getFile(fileDir, box, out file); // creat noti header NotificationHeader notHeader = new NotificationHeader(); notHeader.NotType = type.ToString(); box.NotificationHeaders.AddObject(notHeader); // creat notifications // first get the followers for the file //var followers = new Follow().getFollowers(fileDir); // for each follower creat a notitfication //foreach (var f in followers) //{ // NotInfo not = new NotInfo(); // not.Ack = false; // not.Seen = false; // not.FollowerID = f.FollowerID; // not.NotID = notHeader.NotID; // notHeader.NotInfoes.Add(not); //} box.SaveChanges(); } }
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 Notification getNotification(bool generateHaveToAct) { int sourceIndex = random.Next(0, sourcesNumber); bool isSilent = random.Next(0, 2) == 0; if (generateHaveToAct) { sourceIndex = mapNameToIndex(); isSilent = false; } string id = Guid.NewGuid().ToString(); NotificationSource notificationSource = (NotificationSource)Enum.GetValues(typeof(NotificationSource)).GetValue(sourceIndex); string sourceName = EnumDescription.getDescription(notificationSource); NotificationImage notificationImage = (NotificationImage)Enum.GetValues(typeof(NotificationImage)).GetValue(sourceIndex); string sourceImage = EnumDescription.getDescription(notificationImage); NotificationColor notificationColor = (NotificationColor)Enum.GetValues(typeof(NotificationColor)).GetValue(sourceIndex); Color sourceColor = EnumDescription.getColor(EnumDescription.getDescription(notificationColor)); Array values = Enum.GetValues(typeof(NotificationAuthor)); int authorIndex = random.Next(values.Length); if (generateHaveToAct) { authorIndex = mapAuthorToIndex(); } NotificationAuthor notificationAuthor = (NotificationAuthor)values.GetValue(authorIndex); string author = EnumDescription.getDescription(notificationAuthor); values = Enum.GetValues(typeof(NotificationIcon)); NotificationIcon notificationIcon = (NotificationIcon)values.GetValue(authorIndex); string icon = EnumDescription.getDescription(notificationIcon); string text; if (sourceIndex == 2 || sourceIndex == 3) // post or youtube { values = Enum.GetValues(typeof(NotificationHeader)); NotificationHeader notificationHeader = (NotificationHeader)values.GetValue(random.Next(values.Length)); text = EnumDescription.getDescription(notificationHeader); } else // messengers { values = Enum.GetValues(typeof(NotificationText)); NotificationText notificationText = (NotificationText)values.GetValue(random.Next(values.Length)); text = EnumDescription.getDescription(notificationText); } if (isSilent) { sourceColor = EnumDescription.getColor(EnumDescription.getDescription(NotificationColor.Silent)); sourceImage = "_silent_"; } long timestamp = DateTime.Now.Ticks; Notification notification = new Notification(id, sourceImage, sourceName, author, icon, text, timestamp, isSilent, sourceColor, generateHaveToAct); Debug.Log(string.Format("Notification which is {0} and has the following data: {1} was created", generateHaveToAct ? "correct" : "incorrect", notification)); return(notification); }
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); } }