/// <summary> /// Notifies the users by sending alarms in the system highlighted by red and blue badges at the the top. /// </summary> /// <param name="notificationReceivers"></param> /// <param name="notificationObjectType"></param> /// <param name="senderUserId"></param> /// <param name="notificationURL"></param> /// <param name="actionType"></param> public static void System <T>(List <UserAccountModel> notificationReceivers, NotificationObjectType notificationObjectType, int senderUserId, string notificationURL, T additionalData, ActionType actionType = ActionType.NotSpecified) { var notificationsRepository = new UsersNotificationsRepository(new DB.PmcsDbContext()); foreach (var user in notificationReceivers) { var email = SystemNotificationsComposer.WriteNotification(notificationObjectType, actionType, user, additionalData); notificationsRepository.Insert(new DB.UsersNotification() { CreatedDate = DateTime.Now, IsActive = true, IsRead = false, NotificationBody = email.Value, NotificationDate = DateTime.Now, NotificationSubject = email.Key, ReceiverUserId = user.UserId, SenderUserId = senderUserId, URL = notificationURL }); } }
public NotificationJobData(XmlElement node) : base(node) { foreach (XmlElement propertyNode in node.ChildNodes) { switch (propertyNode.Name) { case "userId": this._UserId = propertyNode.InnerText; continue; case "type": this._Type = (NotificationType)ParseEnum(typeof(NotificationType), propertyNode.InnerText); continue; case "typeAsString": this._TypeAsString = propertyNode.InnerText; continue; case "objectId": this._ObjectId = propertyNode.InnerText; continue; case "status": this._Status = (NotificationStatus)ParseEnum(typeof(NotificationStatus), propertyNode.InnerText); continue; case "data": this._Data = propertyNode.InnerText; continue; case "numberOfAttempts": this._NumberOfAttempts = ParseInt(propertyNode.InnerText); continue; case "notificationResult": this._NotificationResult = propertyNode.InnerText; continue; case "objType": this._ObjType = (NotificationObjectType)ParseEnum(typeof(NotificationObjectType), propertyNode.InnerText); continue; } } }
public static KeyValuePair <string, string> ComposeEmail <T>(NotificationObjectType objectType, ActionType actionType, UserAccountModel user, T additionalData) { var template = emailTemplatesRepository .SearchData(t => t.NotificationTypeId == (int)objectType) .FirstOrDefault(); if (template == null) { return(new KeyValuePair <string, string>("Simple Email from Pmcs v1.2 email subject", "<p>Sample Email</p>")); } var replacer = new TemplateReplacer <T>(objectType, user, additionalData); var filteredBody = replacer.FilterEmailPlaceHolders(template.TemplateEmailBody); return(new KeyValuePair <string, string>(template.TempalteEmailSubject, filteredBody)); }
public NotificationJobData(JToken node) : base(node) { if (node["userId"] != null) { this._UserId = node["userId"].Value <string>(); } if (node["type"] != null) { this._Type = (NotificationType)ParseEnum(typeof(NotificationType), node["type"].Value <string>()); } if (node["typeAsString"] != null) { this._TypeAsString = node["typeAsString"].Value <string>(); } if (node["objectId"] != null) { this._ObjectId = node["objectId"].Value <string>(); } if (node["status"] != null) { this._Status = (NotificationStatus)ParseEnum(typeof(NotificationStatus), node["status"].Value <string>()); } if (node["data"] != null) { this._Data = node["data"].Value <string>(); } if (node["numberOfAttempts"] != null) { this._NumberOfAttempts = ParseInt(node["numberOfAttempts"].Value <string>()); } if (node["notificationResult"] != null) { this._NotificationResult = node["notificationResult"].Value <string>(); } if (node["objType"] != null) { this._ObjType = (NotificationObjectType)ParseEnum(typeof(NotificationObjectType), node["objType"].Value <string>()); } }
// public static event Func<List<UserAccountModel>, NotificationObjectType, IEmailStatus> OnEmailNotification; /// <summary> /// Sends notifications by emial to a collection of UserAccount objects, the emails tempaltes will be created based on the object type. /// </summary> /// <param name="notificationReceivers"></param> /// <param name="notificationObjectType"></param> /// <param name="actionType"></param> /// <returns></returns> public static MailMessageStatus Email <T>(List <UserAccountModel> notificationReceivers, NotificationObjectType notificationObjectType, T additionalData, ActionType actionType = ActionType.NotSpecified) { MailMessageStatus status = null; foreach (var user in notificationReceivers) { var emailComposer = EmailsComposor.ComposeEmail(notificationObjectType, actionType, user, additionalData); var mailConfig = new MailMessageConfig() { EmailBody = emailComposer.Value, EmailSubject = emailComposer.Key, To = new string[] { user.Email } }; var smtp = new SmtpSender(mailConfig); status = smtp.SendMail(); } return(status); }
public TemplateReplacer(NotificationObjectType notificationObjectType, UserAccountModel user, T additionalData) { this.notificationObjectType = notificationObjectType; this.user = user; this.additionalData = additionalData; }
internal ObjectNotification(StoreObjectId notifyingItemId, StoreObjectId parentFolderId, StoreObjectId previousId, StoreObjectId previousParentFolderId, NotificationObjectType objectType, UnresolvedPropertyDefinition[] propertyDefinitions, NotificationType type) : base(type) { this.notifyingItemId = notifyingItemId; this.parentFolderId = parentFolderId; this.previousId = previousId; this.previousParentFolderId = previousParentFolderId; this.objectType = objectType; this.propertyDefinitions = propertyDefinitions; }
public static KeyValuePair <string, string> WriteNotification <T>(NotificationObjectType objectType, ActionType actionType, UserAccountModel user, T additionalData) { var templateBody = string.Empty; var templateSubject = string.Empty; switch (objectType) { case NotificationObjectType.PAT: templateBody = NotificationTemplates.PAT.Value; templateSubject = NotificationTemplates.PAT.Key; break; case NotificationObjectType.AsBuilt: break; case NotificationObjectType.BeginLeaseWorkflow: templateSubject = NotificationTemplates.BeginLeasePaymentProcess.Key; templateBody = NotificationTemplates.BeginLeasePaymentProcess.Value; break; case NotificationObjectType.LeaseContractWorkflowAction: templateSubject = NotificationTemplates.LeasePaymentWorkflowAction.Key; templateBody = NotificationTemplates.LeasePaymentWorkflowAction.Value; break; case NotificationObjectType.BeginInvoiceWorkflow: templateSubject = NotificationTemplates.BeginInvoiceApprovalProcess.Key; templateBody = NotificationTemplates.BeginInvoiceApprovalProcess.Value; break; case NotificationObjectType.InvoiceWorkflowAction: templateSubject = NotificationTemplates.InvoiceWorkflowAction.Key; templateBody = NotificationTemplates.InvoiceWorkflowAction.Value; break; // break; //case NotificationObjectType.ProjectTask: // break; //case NotificationObjectType.Project: // break; //case NotificationObjectType.MileStone: // break; //case NotificationObjectType.Ticket: // break; //case NotificationObjectType.ChangeRequest: // break; default: break; } if (string.IsNullOrEmpty(templateBody)) { return(new KeyValuePair <string, string>("Simple Email from Pmcs v1.2 email subject", "<p>Sample Email</p>")); } var replacer = new TemplateReplacer <T>(objectType, user, additionalData); var filteredBody = replacer.FilterEmailPlaceHolders(templateBody); return(new KeyValuePair <string, string>(templateSubject, filteredBody)); }