private IEmailData getEmailData(NotifyMessage notifyMessage)
        {
            IEmailData data = new DefaultEmailData()
            {
                Recipients      = notifyMessage.To,
                Ccs             = notifyMessage.Cc,
                Bccs            = notifyMessage.Bcc,
                Subject         = notifyMessage.Subject,
                Body            = notifyMessage.Body,
                AttachmentFiles = getAttachments(notifyMessage.attachedFiles)
            };

            return(data);
        }
Exemple #2
0
        private IEmailData CreateEmailData()
        {
            IEmailData data = new DefaultEmailData();

            string status = "amended";

            if (RequestHeader.Status == "Cancelled")
            {
                status = "cancelled";
            }

            var body = "<font style='font - family:Verdana; font - size:16px;'>Dear {0},<br/><br/> " +
                       "Complimentary Room Request process has been " + status + " by: {3}.<br/><br/> " +
                       "Summary:<br/><br/> " +
                       "Ref: {1} <br/> " +
                       "Comment: {2} <br/><br/><br/> " +
                       "Thanks & Regards, <br/> " +
                       "Process Automation.<br/> " +
                       "</font > " +
                       "<b><span style = 'font-family:\"ITC Stone Sans Std Medium\";color:navy'> Internet E - mail Confidentiality Footer</span></b><span style = 'font-family:\"ITC Stone Sans Std Medium\";color:navy'> </span><o:p></o:p></p ><p class=MsoNormal style = 'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><i><span style='font-family:\"ITC Stone Sans Std Medium\";color:navy'>This E-mail is confidential and intended only for the use of the individual(s) or entity named above and may contain information that is privileged.&nbsp; If you are not the intended recipient, you are advised that any dissemination, distribution or copying of this E-mail is strictly prohibited. If you have received this E-mail in error, please notify us immediately by return E-mail or telephone and destroy the original message.</span></I> ";

            data.Subject = String.Format("Notification (Ref:{0}) (" + status + " by: {1})", RequestHeader.Title, WorkflowInstance.fullName);
            var recepients = new List <string>();

            RequestHeaderRepository.Originator originator = requestHeaderRepository.GetRequestorEmail(RequestHeader.SubmittedBy);
            recepients.Add(originator.EMAIL);

            data.Body       = String.Format(body, originator.DISPLAY_NAME, RequestHeader.Title, WorkflowInstance.Comment, WorkflowInstance.fullName);
            data.Recipients = recepients;
            //data.Ccs = requestHeaderRepository.GetEmailsByRole(new string[] { "CRR RESERVATION REVIEW"});
            data.Ccs = requestHeaderRepository.GetEmailNotification(RequestHeader.Id, "RSVNCR_REQ", "HOD,CRSR", false);
            //string reportPath = "/K2Report/Reservation/CRoomRequest";
            string reportPath = "/FORMS/FORM_RSVNCR";


            IGenericFormRpt genericForm = new GenericFormRpt();

            byte[] buffer = genericForm.Export(new GenericFormParam {
                RequestHeaderId = RequestHeader.Id
            }, reportPath, ExportType.Pdf);
            var FileName = string.Concat(RequestHeader.Title + "_", DateTime.Now.ToString("yyyyMMddhhmmss"), ".pdf");
            EmailFileAttachment fileAttachments = new EmailFileAttachment(FileName, buffer);

            data.AttachmentFiles.Add(fileAttachments);

            return(data);
        }
Exemple #3
0
        public IEmailData GetEmailData(string codesOf)
        {
            var email = new DefaultEmailData();

            RequestHeader.Status = "Updated";

            var body = @"<font style='font-family:Arial;font-size:11pt;font-weight:Normal;font-style:Normal;font-stretch:Normal;color:#000000;text-align:Left;text-decoration:None;line-height:1'>
                          Dear All,<br/><br/>
                          <p>@@FORM_NAME process has been @@ACTION by: @@DECISION_BY.</p>
                          <p>Items has been return back.</p>
                          <p>Please refer to attachment file.</p>
                          <span>Ref: @@FORM_NO</span><br/>
                          <span>Comment: @@COMMENT</span><br/>
                        </font >
                        @@SIGNATURE";

            string signature = "";

            try
            {
                var contents = new Repository().ExecDynamicSqlQuery(@"SELECT CONTENT [content] FROM [SYSTEM].[SETTINGS] WHERE MODULE = 'EMAIL' AND [KEY] = 'EMAIL_SIGNATURE'");
                signature = contents[0].content;
            }
            catch
            {
                signature = string.Empty;
            }

            var originator = requestHeaderRepository.GetRequestorEmail(RequestHeader.SubmittedBy);

            email.Subject = string.Format(
                "Notification (Ref:{0}) ({1} by: {2})",
                RequestHeader.Title,
                RequestHeader.Status,
                WorkflowInstance.fullName
                );

            email.Body = body
                         .Replace("@@ORIGINATOR", originator.DISPLAY_NAME)
                         .Replace("@@FORM_NAME", REQ_APP.ProcessName)
                         .Replace("@@ACTION", RequestHeader.Status.ToLower())
                         .Replace("@@DECISION_BY", WorkflowInstance.fullName)
                         .Replace("@@FORM_NO", RequestHeader.Title)
                         .Replace("@@COMMENT", WorkflowInstance.Comment)
                         .Replace("@@ORIGINATOR", "ITC Stone Sans Std Medium")
                         .Replace("@@SIGNATURE", signature);

            string[] codes = codesOf.Split(',');

            IEnumerable <string> ccParticipantList = new List <string>();

            foreach (var code in codes)
            {
                if (!string.IsNullOrEmpty(code) && code != ",")
                {
                    ccParticipantList = ccParticipantList.Concat(requestHeaderRepository.GetEmailNotification(-1, REQ_APP.RequestCode, code, false));
                }
            }
            email.Recipients = ccParticipantList.Distinct().ToList();

            var genericForm = new GenericFormRpt();

            byte[] buffer = genericForm.Export(new GenericFormParam {
                RequestHeaderId = RequestHeader.Id
            }, REQ_APP.ReportPath, ExportType.Pdf);
            var FileName        = string.Concat(RequestHeader.Title, "_", DateTime.Now.ToString("yyyyMMddhhmmss"), ".pdf");
            var fileAttachments = new EmailFileAttachment(FileName, buffer);

            email.AttachmentFiles.Add(fileAttachments);
            return(email);
        }
        public IEmailData CreateEmailData(string notifyRole, IEnumerable <string> ccList = null, string subject = "")
        {
            var email = new DefaultEmailData();

            if (RequestHeader.Status != AbstractAction <E> .CANCELED_ACTION)
            {
                RequestHeader.Status = AbstractAction <E> .AMENDED_ACTION;
            }

            var body = @"<font style='font-family:Arial;font-size:11pt;font-weight:Normal;font-style:Normal;font-stretch:Normal;color:#000000;text-align:Left;text-decoration:None;line-height:1'>
                          Dear @@ORIGINATOR,<br/><br/>
                          <p>@@FORM_NAME process has been @@ACTION by: @@DECISION_BY.</p>
                          <span>Summary:</span><br/>
                          <span>Ref: @@FORM_NO</span><br/>
                          <span>Comment: @@COMMENT</span><br/>
                          <p>
                               Thanks &amp; Regards, <br/>Process Automation.
                          </p>
                        </font >
                        @@SIGNATURE";

            string signature = "";

            try
            {
                var contents = new Repository().ExecDynamicSqlQuery(@"SELECT CONTENT [content] FROM [SYSTEM].[SETTINGS] WHERE MODULE = 'EMAIL' AND [KEY] = 'EMAIL_SIGNATURE'");
                signature = contents[0].content;
            } catch
            {
            }

            var originator = requestHeaderRepository.GetRequestorEmail(RequestHeader.SubmittedBy);

            email.Subject = string.Format(
                "Notification (Ref:{0}) ({1} by: {2}){3}",
                RequestHeader.Title,
                RequestHeader.Status,
                WorkflowInstance.fullName,
                subject
                );

            email.Body = body
                         .Replace("@@ORIGINATOR", originator.DISPLAY_NAME)
                         .Replace("@@FORM_NAME", REQ_APP.ProcessName)
                         .Replace("@@ACTION", RequestHeader.Status.ToLower())
                         .Replace("@@DECISION_BY", WorkflowInstance.fullName)
                         .Replace("@@FORM_NO", RequestHeader.Title)
                         .Replace("@@COMMENT", WorkflowInstance.Comment)
                         .Replace("@@ORIGINATOR", "ITC Stone Sans Std Medium")
                         .Replace("@@SIGNATURE", signature);

            var recipients = new List <string>();

            recipients.Add(originator.EMAIL);
            email.Recipients = recipients;
            string[] roleCodes = notifyRole.Split(',');

            IEnumerable <string> ccParticipantList = new List <string>();

            foreach (var roleCode in roleCodes)
            {
                if (!string.IsNullOrEmpty(roleCode) && roleCode != ",")
                {
                    ccParticipantList = ccParticipantList.Concat(requestHeaderRepository.GetEmailNotification(-1, REQ_APP.RequestCode, roleCode, false));
                }
            }

            if (ccList != null)
            {
                ccParticipantList = ccParticipantList.Concat(ccList);
            }

            // Customize modification mailing list
            if (RequestHeader != null)
            {
                var            destinationUsers = requestHeaderRepository.GetEmailModification(RequestHeader.Id);
                IList <string> mailingList      = new List <string>();
                foreach (var destinationUser in destinationUsers)
                {
                    mailingList.Add(destinationUser.Email);
                }
                if (mailingList.Count > 0)
                {
                    ccParticipantList = ccParticipantList.Concat(mailingList);
                }
            }

            // Assign mailing list to CC list of an email.
            email.Ccs = ccParticipantList.Distinct().ToList();

            var genericForm = new GenericFormRpt();

            byte[] buffer = genericForm.Export(new GenericFormParam {
                RequestHeaderId = RequestHeader.Id
            }, REQ_APP.ReportPath, ExportType.Pdf);
            var FileName        = string.Concat(RequestHeader.Title, "_", DateTime.Now.ToString("yyyyMMddhhmmss"), ".pdf");
            var fileAttachments = new EmailFileAttachment(FileName, buffer);

            email.AttachmentFiles.Add(fileAttachments);
            return(email);
        }