public NotificationMessage GetInitialMediaRequestMessage(MSI_MediaRequestResponse submittedRequest) { string thisMethod = string.Format("{0}.{1}", thisClass, System.Reflection.MethodBase.GetCurrentMethod().Name); NotificationMessage message = null; StringBuilder bodyBuilder; try { message = new NotificationMessage(); message.Subject = "New media request-" + DateTime.Now.ToShortDateString(); bodyBuilder = new StringBuilder(); bodyBuilder.Append("<table>"); bodyBuilder.Append("<tr><td>Portfolio Number</td><td>:</td><td>" + submittedRequest.Portfolio + "</td></tr>"); bodyBuilder.Append("<tr><td>Account Holder's Name</td><td>:</td><td>" + submittedRequest.NAME + "</td></tr>"); bodyBuilder.Append("<tr><td>Requested Date</td><td>:</td><td>" + submittedRequest.RequestedDate + "</td></tr>"); string mediaTypesRequested = ""; IEnumerable<MSI_MediaTypes> availableMediaTypes = Query.GetMediaTypes(); foreach (MSI_MediaRequestTypes mediaReqType in submittedRequest.MSI_MediaRequestTypes) { mediaTypesRequested = mediaTypesRequested + availableMediaTypes.Where(record => record.ID == mediaReqType.TypeId).SingleOrDefault().Name + ", "; } bodyBuilder.Append("<tr><td>Requested Media Types</td><td>:</td><td>" + mediaTypesRequested.Substring(0,mediaTypesRequested.Length-2) + "</td></tr>"); message.BodyText = bodyBuilder.ToString(); } catch (Exception ex) { ErrorLogHelper.Error("Error while constructing InitialMediaRequestMessage", ex); } return message; }
public void SaveMessageNotification(NotificationMessage message, List<string> recipientsUserIds) { string thisMethod = string.Format("{0}.{1}", thisClass, System.Reflection.MethodBase.GetCurrentMethod().Name); string logMessage = string.Format("{0}|Method incoming parameters Notification Subject={1}", thisMethod, message.Subject); LogHelper.Info(logMessage); MSI_MessageNotification notification = null; try { foreach (string recipentUserId in recipientsUserIds) { notification = new MSI_MessageNotification(); notification.Id = Guid.NewGuid(); notification.RecipientUserId = Guid.Parse(recipentUserId); notification.Subject = message.Subject; notification.Body = message.BodyText; notification.SentOn = DateTime.Now; notification.IsActive = true; Query.AddMessageNotification(notification); notification = null; } } catch (Exception ex) { ErrorLogHelper.Error(logMessage, ex); } }
public NotificationMessage GetUpdateRequestedToOriginatorMessage(IEnumerable<MSI_MediaRequestTypes> mediaRequestTypes) { string thisMethod = string.Format("{0}.{1}", thisClass, System.Reflection.MethodBase.GetCurrentMethod().Name); NotificationMessage message = null; StringBuilder bodyBuilder; try { message = new NotificationMessage(); message.Subject = "Update requested-" + DateTime.Now.ToShortDateString(); bodyBuilder = new StringBuilder(); bodyBuilder.Append("Update requested for following media:"); string mediaTypesRequested = ""; IEnumerable<MSI_MediaTypes> availableMediaTypes = Query.GetMediaTypes(); foreach (MSI_MediaRequestTypes mediaReqType in mediaRequestTypes) { mediaTypesRequested = mediaTypesRequested + availableMediaTypes.Where(record => record.ID == mediaReqType.TypeId).SingleOrDefault().Name + ", "; } bodyBuilder.Append(mediaTypesRequested.Substring(0, mediaTypesRequested.Length - 2)); message.BodyText = bodyBuilder.ToString(); } catch (Exception ex) { ErrorLogHelper.Error("Error while constructing GetUpdateRequestedToOriginatorMessage", ex); } return message; }