Exemple #1
0
        public HttpResponseMessage DownloadForms(int requestHeaderId, string documentType)
        {
            HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);

            var formConfigs = _worklistRepository.GetReqAppByCode(documentType);

            //string reportPath = Settings.Default["RPT_PATH_" + documentType].ToString();
            var segment = formConfigs.ReportPath.Split('/');

            IGenericFormRpt genericForm = new GenericFormRpt();

            byte[] buffer = genericForm.Export(
                new GenericFormParam {
                RequestHeaderId = requestHeaderId,
                Username        = RequestContext.Principal.Identity.Name
            },
                formConfigs.ReportPath, ExportType.Pdf);
            var stream = new MemoryStream(buffer);

            result.Content = new StreamContent(stream);
            result.Content.Headers.ContentType        = new MediaTypeHeaderValue("application/octet-stream");
            result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
            {
                FileName = string.Concat(segment.Last(), "_", DateTime.Now.ToString("yyyyMMddhhmmss"), ".pdf")
            };

            return(result);
        }
Exemple #2
0
        public SmartObjectPdf GetSmartObjectPdfCurrentUser(int requestHeaderId, string currentUser)
        {
            string folio = string.Empty;

            try
            {
                var repository  = new Repository();
                var genericForm = new GenericFormRpt();

                var query = repository.DynamicQuery(@"
                        SELECT A.REPORT_PATH, A.REQUEST_CODE, H.TITLE FROM [BPMDATA].[REQUEST_APPLICATION] A
                        INNER JOIN BPMDATA.REQUEST_HEADER H ON H.REQUEST_CODE = A.REQUEST_CODE
                        WHERE H.ID = " + requestHeaderId);

                var application = query.GetDynamicObject();

                string fileContent = string.Empty;
                folio = application.TITLE;
                string fileName = string.Concat(folio, "_", DateTime.Now.ToString("yyyyMMddhhmmss"), ".pdf");

                byte[] buffer = genericForm.Export(
                    new GenericFormParam
                {
                    RequestHeaderId = requestHeaderId,
                    Username        = currentUser
                },
                    application.REPORT_PATH, ExportType.Pdf);

                using (Stream fs = new MemoryStream(buffer))
                {
                    fileContent = Convert.ToBase64String(DataStream.ReadToEnd(fs));
                }


                return(new SmartObjectPdf()
                {
                    FileName = fileName,
                    PdfContent = string.Format("<file><name>{0}</name><content>{1}</content></file>", fileName, fileContent)
                });
            }
            catch (Exception ex)
            {
                logger.Info("Folio: " + folio + ", cannot export pdf because - " + ex.Message);
                return(new SmartObjectPdf()
                {
                    FileName = "FORM",
                    PdfContent = "<file><name>{0}</name><content>{1}</content></file>"
                });
            }
        }
Exemple #3
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 #4
0
        private void SendNotification()
        {
            var repository = new Repository();
            var emails     = repository.ExecDynamicSqlQuery(@"SELECT RH.* FROM HR.COURSE_REGISTRATION R 
                                                            INNER JOIN BPMDATA.REQUEST_HEADER RH 
                                                            ON R.RequestHeaderId = RH.ID
                                                            WHERE 
                                                            CAST(R.ReminderOn AS DATE) = CAST(GETDATE() AS DATE) AND 
                                                            RH.STATUS IN ('Approved', 'Edit')
                                                            AND CURRENT_ACTIVITY IN ('Email Notification', 'Modification')");

            var repo       = new WMRepository(_DbFactory);
            var RequestApp = repo.GetReqAppByCode("TASCR_REQ");
            IRequestHeaderRepository requestHeaderRepository = new RequestHeaderRepository(_DbFactory);

            if (!IsNullEmpty(emails))
            {
                foreach (var e in emails)
                {
                    List <EmailFileAttachment> attachments = new List <EmailFileAttachment>();
                    var recipients = new List <string>();
                    var originator = requestHeaderRepository.GetRequestorEmail(e.submittedBy);
                    recipients.Add(originator.EMAIL);
                    var           ccs            = repository.ExecDynamicSqlQuery(string.Format(@"[BPMDATA].[DESTINATION_USERS] @RequestHeaderId = {0}, @ActivityName = 'Email Notification', @IsMergeActivity = 1", e.id));
                    List <string> ccParticipants = new List <string>();
                    if (!IsNullEmpty(ccs))
                    {
                        foreach (var cc in ccs)
                        {
                            ccParticipants.Add(cc.email);
                        }
                    }
                    var    genericForm = new GenericFormRpt();
                    byte[] buffer      = genericForm.Export(new GenericFormParam {
                        RequestHeaderId = e.id
                    }, RequestApp.ReportPath, ExportType.Pdf);
                    var FileName        = string.Concat(e.title, "_", DateTime.Now.ToString("yyyyMMddhhmmss"), ".pdf");
                    var fileAttachments = new EmailFileAttachment(FileName, buffer);
                    attachments.Add(fileAttachments);
                    var    emailContent = _EmailContentRepository.Get(p => p.JobId == _Job.Id);
                    string content      = emailContent.MessageBody.Replace("@Originator", originator.DISPLAY_NAME).Replace("@Title", e.title);
                    _EmailService.SendEmail("Reminder Notification", content, recipients, ccParticipants, null, attachments, null);
                }
            }
        }
Exemple #5
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);
        }