public void SaveComment(string message ,int entityId ,int authorId) { DataErrorComment comment = new DataErrorComment(message,entityId,authorId); QmsWorkitemcomment workItemComment = comment.WorkItemComment(); this.repository.context.Add(workItemComment); this.repository.Save(); }
public DataErrorComment(QmsWorkitemcomment comment, bool enableUserSecurityLoading) { this.Id = comment.Id; this.CorrectiveActionId = comment.WorkItemId.Value; this.Message = comment.Message; this.CreatedAt = comment.CreatedAt; this.AuthorId = comment.AuthorId.Value; this.Author = new User(comment.Author,enableUserSecurityLoading); }
public QmsWorkitemcomment WorkItemComment() { QmsWorkitemcomment workItemComment = new QmsWorkitemcomment(); workItemComment.Id = this.Id; workItemComment.WorkItemId = this.CorrectiveActionId; workItemComment.AuthorId = this.AuthorId; workItemComment.CreatedAt = this.CreatedAt; workItemComment.Message = this.Message; workItemComment.WorkItemTypeCode = this.WorkItemType; return workItemComment; }
public void AddComment(IAssignable item, User author, string message) { QmsWorkitemcomment comment = new QmsWorkitemcomment(); comment.Message = message; comment.WorkItemId = item.Id; comment.WorkItemTypeCode = item.WorkItemType; comment.AuthorId = author.UserId; comment.CreatedAt = DateTime.Now; context.Add(comment); context.SaveChanges(); }
private string formatMessage(IListable ca, QmsWorkitemcomment comment) { string retval = ca.Message; string commentTemplate = "Latest Comment:{0}<br/> by {1} on {2}"; if(comment != null) { string commentText = string.Format(commentTemplate,comment.Message,comment.Author.DisplayName,comment.CreatedAt.ToShortDateString()); retval += commentText; } else { retval += "No comments have been made."; } return retval; }
// internal string formatMessage(CorrectiveAction ca, QmsWorkitemcomment comment) internal string formatMessage(CorrectiveAction ca, QmsWorkitemcomment comment) { template = "Corrective Acton ID: {0}<br/>Employee: {1}-{2}<br/>Request Type: {3}<br/>NOA: {4}<br/>Effective Date: {5}<br/>Updated on: {6}<br/>Correction Requested:{7}<br/>"; string dateToUse = ca.UpdatedAt.HasValue ? ca.UpdatedAt.Value.ToShortDateString() : ca.CreatedAt.ToShortDateString(); message = string.Format(template,ca.Id,ca.EmplId, ca.Employee.FullName, getActionRequestType(ca.ActionRequestTypeId.Value) ,ca.NOACode,ca.EffectiveDateOfPar,dateToUse,ca.Details); string commentTemplate = "Latest Comment:{0}<br/> by {1} on {2}"; if(comment != null) { string commentText = string.Format(commentTemplate,comment.Message,comment.Author.DisplayName,comment.CreatedAt.ToShortDateString()); message += commentText; } else { message += "No comments have been made."; } message += "<br/><br/>" + string.Format(footerTemplate,ca.Id); return message; }
internal string formatMessage(DataError ehriError, QmsWorkitemcomment comment) { template = "EHRI Error ID: {0}<br/>Employee: {1}-{2}<br/>Error Details: {3}<br/>{4}<br/<br/>Updated on: {5}<br/><br/>"; string dateToUse = ehriError.UpdatedAt.HasValue ? ehriError.UpdatedAt.Value.ToShortDateString() : ehriError.CreatedAt.ToShortDateString(); message = string.Format(template,ehriError.Id,ehriError.EmplId, ehriError.Employee.FullName,ehriError.QmsErrorCode,ehriError.QmsErrorMessageText,dateToUse); string commentTemplate = "Latest Comment:{0}<br/> by {1} on {2}"; if(comment != null) { string commentText = string.Format(commentTemplate,comment.Message,comment.Author.DisplayName,comment.CreatedAt.ToShortDateString()); message += commentText; } else { message += "No comments have been made."; } return message; }
public void Send(DataError ehriError,string notificationEventCode, User submitter) { EmployeeService employeeService = new EmployeeService(); ehriError.Employee = employeeService.RetrieveById(ehriError.EmplId); notificationEvent = notificationRepository.RetrieveNotificationEventByCode(notificationEventCode); originator = userRepository.RetrieveByUserId(ehriError.CreatedByUserId.Value); bool willSendtoSubmitter = ((originator.UserId == submitter.UserId) && (notificationEvent.NotificationEventType.NotificationEventTypeCode == NotificationEventType.INDIV)); if(!willSendtoSubmitter) { notificationEventType = notificationEvent.NotificationEventType; QmsWorkitemcomment comment = ehriErrorRepository.RetrieveLatestComment(ehriError.Id); switch(notificationEventType.NotificationEventTypeCode) { case NotificationEventType.INDIV: sendIndividualMessage(ehriError,notificationEvent, submitter,comment); break; case NotificationEventType.ORG: sendOrganizationalMessage(ehriError,notificationEvent,comment); break; default: break; } } }
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); } } }
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); }
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(); } }
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(); }