Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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();
            }


            
        }
Esempio n. 3
0
        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);
                }

            }
        }
Esempio n. 4
0
        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();            
        }
Esempio n. 5
0
 public void Send(IListable entity,string notificationEventCode, User submitter)
 {
     EmployeeService employeeService = new EmployeeService();
     Employee employee = employeeService.RetrieveById(entity.EmplId);
     notificationEvent = notificationRepository.RetrieveNotificationEventByCode(notificationEventCode);
     originator = userRepository.RetrieveByUserId(entity.CreatedByUserId.Value);
     bool willSendtoSubmitter = ((originator.UserId == submitter.UserId) && (notificationEvent.NotificationEventType.NotificationEventTypeCode == NotificationEventType.INDIV));
     if(!willSendtoSubmitter)
     {
         notificationEventType = notificationEvent.NotificationEventType;
         QmsWorkitemcomment comment = correctiveActionRepository.RetrieveLatestComment(entity.Id);
         switch(notificationEventType.NotificationEventTypeCode)
         {
             case NotificationEventType.INDIV:
                 sendIndividualMessage(entity,notificationEvent, submitter,comment);
                 break;
             case NotificationEventType.ORG:
                 sendOrganizationalMessage(entity,notificationEvent,comment);
                 break;
             default:
                 break;
         }
     }
 }