internal void sendOrganizationalMessage(DataError ehriError, NtfNotificationevent ne, QmsWorkitemcomment comment) { List<SecUser> users = getReviewersInOrg(ehriError.AssignedToOrgId.Value); string[] emails = new string[users.Count]; NtfNotification notification = new NtfNotification(); notification.CreatedAt = DateTime.Now; notification.Title = string.Format(ne.TitleTemplate,ehriError.Id); notification.Message = formatMessage(ehriError,comment); notification.HasBeenRead = 0; notification.WorkitemId = ehriError.Id; notification.WorkItemTypeCode = WorkItemTypeEnum.CorrectiveActionRequest; notification.SendAsEmail = 0; //Changed from 1 so it doesn't send notification.NotificationEventId = ne.NotificationEventId; int i = 0; foreach(var user in users) { NtfNotification newNotification = notification.Clone(); newNotification.UserId = user.UserId; context.Add(newNotification); emails[i] = user.EmailAddress; i++; } context.SaveChanges(); send(emails,notification.Title,notification.Message); }
public int Update(NtfNotification newNotification) { NtfNotification oldNotification = RetrieveNotificationById(newNotification.NotificationId); context.Entry(oldNotification).State = EntityState.Deleted; context.Entry(newNotification).State = EntityState.Modified; return context.SaveChanges(); }
public WorkItemType MarkAsRead(int NotificationId) { NtfNotification n = notificationRepository.RetrieveNotificationById(NotificationId); //WorkItemType retval = new WorkItemType(n.WorkItemTypeCodeNavigation,NotificationId); WorkItemType retval = new WorkItemType(n.WorkItemTypeCodeNavigation,n.WorkitemId); n.ReadAt = DateTime.Now; n.HasBeenRead = 1; notificationRepository.Update(n); return retval; }
public void MarkAsRead(int[] notificationIds) { foreach(int notificationId in notificationIds) { NtfNotification n = notificationRepository.RetrieveNotificationById(notificationId); n.ReadAt = DateTime.Now; n.HasBeenRead = 1; notificationRepository.Update(n); } }
private void sendIndividualMessage(IListable entity, NtfNotificationevent ne, User submitter, QmsWorkitemcomment comment) { if(submitter.UserId != entity.CreatedByUserId.Value) // if the person doing the action is the originator they don't get a message since they did the action { NtfNotification notification = new NtfNotification(); notification.CreatedAt = DateTime.Now; notification.HasBeenRead = 0; notification.Title = string.Format(ne.TitleTemplate,entity.Id); notification.WorkitemId = entity.Id; notification.WorkItemTypeCode = WorkItemTypeEnum.CorrectiveActionRequest; notification.SendAsEmail = 1; notification.NotificationEventId = ne.NotificationEventId; notification.Message = entity.Message; switch(ne.NotificationEventCode) { case CorrectiveActionNotificationType.CA_Assigned: notification.UserId = entity.AssignedToUserId.Value; // notification.Message = string.Format(ne.MessageTemplate,ca.Id, ca.AssignedAt.Value.ToShortDateString(),ca.EmplId,ca.Employee.FullName); break; case CorrectiveActionNotificationType.CA_Created: notification.UserId = entity.CreatedByUserId.Value; // notification.Message = string.Format(ne.MessageTemplate,ca.Id, ca.CreatedAt.ToShortDateString(),ca.EmplId,ca.Employee.FullName); break; case CorrectiveActionNotificationType.CA_Returned: notification.UserId = entity.CreatedByUserId.Value; // notification.Message = string.Format(ne.MessageTemplate,ca.Id, ca.UpdatedAt.Value.ToShortDateString(),ca.EmplId,ca.Employee.FullName); break; case CorrectiveActionNotificationType.CA_Closed: notification.UserId = entity.CreatedByUserId.Value; // notification.Message = string.Format(ne.MessageTemplate,ca.Id, ca.ResolvedAt.Value.ToShortDateString(),ca.EmplId,ca.Employee.FullName); break; case CorrectiveActionNotificationType.CA_Withdrawn: notification.UserId = entity.AssignedToUserId.Value; // notification.Message = string.Format(ne.MessageTemplate,ca.Id, ca.UpdatedAt.Value.ToShortDateString(), ca.EmplId, ca.Employee.FullName); break; default: //not a indivual message type break; } context.Add(notification); context.SaveChanges(); } }
public NtfNotification NtfNotification() { NtfNotification notification = new NtfNotification(); notification.CreatedAt = this.CreatedAt; notification.DeletedAt = this.DeletedAt; notification.HasBeenRead = this.HasBeenRead; notification.Message = this.Message; notification.NotificationEventId = this.NotificationEventId; notification.NotificationId = this.NotificationId; notification.ReadAt = this.ReadAt; notification.SendAsEmail = this.SendAsEmail; notification.SentAt = this.SentAt; notification.Title = this.Title; notification.UserId = this.UserId; notification.WorkitemId = this.WorkitemId; notification.WorkItemTypeCode = this.WorkItemType; return notification; }
internal void sendIndividualMessage(DataError ehriError, NtfNotificationevent ne, User submitter, QmsWorkitemcomment comment) { if(submitter.UserId != ehriError.CreatedByUserId.Value) // if the person doing the action is the originator they don't get a message since they did the action { SecUser user; NtfNotification notification = new NtfNotification(); notification.CreatedAt = DateTime.Now; notification.HasBeenRead = 0; notification.Title = string.Format(ne.TitleTemplate,ehriError.Id); //HRQMS - EHRI Error Closed ({0}) notification.WorkitemId = ehriError.Id; notification.WorkItemTypeCode = WorkItemTypeEnum.CorrectiveActionRequest; notification.SendAsEmail = 0; //Changed from 1 so it doesn't send notification.NotificationEventId = ne.NotificationEventId; notification.Message = formatMessage(ehriError,comment); switch(ne.NotificationEventCode) { case EhriErrorNotificationType.EHRI_Assigned: notification.UserId = ehriError.AssignedToUserId.Value; break; case EhriErrorNotificationType.EHRI_Returned: notification.UserId = ehriError.CreatedByUserId.Value; break; case EhriErrorNotificationType.EHRI_Closed: notification.UserId = ehriError.CreatedByUserId.Value; break; default: //not a indivual message type break; } if(notification.UserId > 0) //0 = System user - no need to notify. { context.Add(notification); context.SaveChanges(); user = userRepository.RetrieveByUserId(notification.UserId); send(user.EmailAddress,notification.Title,notification.Message); } } }
private void sendOrganizationalMessage(IListable entity, NtfNotificationevent ne, QmsWorkitemcomment comment) { List<SecUser> users = getReviewersInOrg(entity.AssignedToOrgId.Value); NtfNotification notification = new NtfNotification(); notification.CreatedAt = DateTime.Now; notification.Title = string.Format(ne.TitleTemplate,entity.Id); notification.Message = entity.Message; notification.HasBeenRead = 0; notification.WorkitemId = entity.Id; notification.WorkItemTypeCode = WorkItemTypeEnum.CorrectiveActionRequest; notification.SendAsEmail = 1; notification.NotificationEventId = ne.NotificationEventId; /* switch(ne.NotificationEventCode) { case CorrectiveActionNotificationType.CA_Submitted: notification.Message = string.Format(ne.MessageTemplate,ca.Id, dateToUse,ca.EmplId,ca.Employee.FullName); break; case CorrectiveActionNotificationType.CA_PendingReview: notification.Message = string.Format(ne.MessageTemplate,ca.Id, dateToUse,ca.EmplId,ca.Employee.FullName); break; case CorrectiveActionNotificationType.CA_Rerouted: notification.Message = string.Format(ne.MessageTemplate,ca.Id, dateToUse,ca.EmplId,ca.Employee.FullName); break; default: break; } */ foreach(var user in users) { NtfNotification newNotification = notification.Clone(); newNotification.UserId = user.UserId; context.Add(newNotification); } context.SaveChanges(); }
public void Delete(Notification notification) { NtfNotification ntfNotification = notification.NtfNotification(); notificationRepository.Delete(ntfNotification); }
public void MarkAsSent(int NotificationId) { NtfNotification n = notificationRepository.RetrieveNotificationById(NotificationId); n.SentAt = DateTime.Now; notificationRepository.Update(n); }
public void Delete(int notificationId) { NtfNotification ntfNotification = notificationRepository.RetrieveNotificationById(notificationId); notificationRepository.Delete(ntfNotification); }
public int Insert(NtfNotification notification) { context.Add(notification); return context.SaveChanges(); }
public void Delete(NtfNotification notification) { notification.DeletedAt = DateTime.Now; Update(notification); }