示例#1
0
        public FileMetadata SendDefaultNoticeComm14Borrower(CollectionMailModel model)
        {
            var variables = new Dictionary <string, string> {
                { "CustomerName", model.CustomerName },
                { "CompanyName", model.CompanyName },
                { "GuarantorName", model.GuarantorName },
                { "Date", model.Date.ToLongDateWithDayOfWeek() },
                { "LoanRef", model.LoanRef },
                { "LoanDate", model.LoanDate.ToLongDate() },
                { "LoanAmount", model.LoanAmount.ToNumericNoDecimals() },
                { "SchedDate", model.MissedPayment.DateDue.ToLongDate() },
                { "AmountDue", model.MissedPayment.AmountDue.ToNumeric2Decimals() },
                { "AmountPaid", model.MissedPayment.RepaidAmount.ToNumeric2Decimals() },
                { "AmountTotal", (model.MissedPayment.AmountDue - model.MissedPayment.RepaidAmount).ToNumeric2Decimals() },
                { "OutstandingBalance", model.OutstandingBalance.ToNumeric2Decimals() },
            };

            SetAddress(model.CustomerAddress, ref variables);

            var templateModel = this.templates.FirstOrDefault(x => x.TemplateName == DefaultnoticeComm14BorrowerTemplateName && model.OriginId == x.OriginID && x.IsActive);

            if (templateModel == null)
            {
                Log.Warn("template " + DefaultnoticeComm14BorrowerTemplateName + " was not found for origin" + model.OriginId);
                return(null);
            }
            Stream template = PrepareMail.ByteArrayToStream(templateModel.Template);

            byte[] pdfData = PrepareMail.ReplaceParametersAndConvertToPdf(template, variables);
            return(SendMail(pdfData, model.CustomerId, DefaultnoticeComm14BorrowerTemplateName, templateModel.ID));
        }
示例#2
0
        public FileMetadata SendAnual77ANotification(int customerID, SnailMailTemplate template, Address address, Dictionary <string, string> variables, TableModel schedule, string scheduleNode)
        {
            SetAddress(address, ref variables);
            Stream templateStream          = PrepareMail.ByteArrayToStream(template.Template);
            var    templateDoc             = PrepareMail.GetDocumentFromTemplate(templateStream);
            var    scheduleTableDoc        = PrepareMail.CreateTable(schedule);
            var    templateDocWithSchedule = PrepareMail.ReplaceNodeByAnotherDocument(templateDoc, scheduleNode, scheduleTableDoc);

            byte[] pdfData = PrepareMail.ReplaceParametersAndConvertToPdf(templateDocWithSchedule, variables);
            return(SendMail(pdfData, customerID, template.TemplateName, template.ID));
        }
示例#3
0
        public FileMetadata SendDefaultTemplateConsumer31(CollectionMailModel model)
        {
            var variables = new Dictionary <string, string> {
                { "CustomerName", model.CustomerName },
                { "Date", model.Date.ToLongDateWithDayOfWeek() },
                { "LoanRef", model.LoanRef },
                { "LoanDate", model.LoanDate.ToLongDate() },
                { "TotalBalance", (model.MissedInterest + model.OutstandingPrincipal).ToNumeric2Decimals() },
                { "AmountDue1", (model.PreviousMissedPayment.AmountDue).ToNumeric2Decimals() },
                { "DateDue1", (model.PreviousMissedPayment.DateDue).ToLongDate() },
                { "PartialPaid1", (model.PreviousMissedPayment.RepaidAmount).ToNumeric2Decimals() },
                { "RepaidDate1", (model.PreviousMissedPayment.RepaidDate).ToLongDate() },
                { "Total1", (model.PreviousMissedPayment.AmountDue - model.PreviousMissedPayment.RepaidAmount).ToNumeric2Decimals() },
                { "AmountDue2", (model.MissedPayment.AmountDue).ToNumeric2Decimals() },
                { "DateDue2", (model.MissedPayment.DateDue).ToLongDate() },
                { "PartialPaid2", (model.MissedPayment.RepaidAmount).ToNumeric2Decimals() },
                { "RepaidDate2", (model.MissedPayment.RepaidDate).ToLongDate() },
                { "Total2", (model.MissedPayment.AmountDue - model.MissedPayment.RepaidAmount).ToNumeric2Decimals() },
                { "Total", (model.MissedPayment.AmountDue - model.MissedPayment.RepaidAmount + model.PreviousMissedPayment.AmountDue - model.PreviousMissedPayment.RepaidAmount).ToNumeric2Decimals() },
            };

            SetAddress(model.CustomerAddress, ref variables);

            var templateModel = this.templates.FirstOrDefault(x => x.TemplateName == DefaulttemplateConsumer31TemplateName && model.OriginId == x.OriginID && x.IsActive);

            if (templateModel == null)
            {
                Log.Warn("template " + DefaulttemplateConsumer31TemplateName + " was not found for origin" + model.OriginId);
                return(null);
            }

            Stream template = PrepareMail.ByteArrayToStream(templateModel.Template);

            byte[] pdfData          = PrepareMail.ReplaceParametersAndConvertToPdf(template, variables);
            byte[] concatinatedMail = pdfData;

            var attachmentTemplateModel = this.templates.FirstOrDefault(x => x.TemplateName == DefaulttemplateConsumer31Attachment && model.OriginId == x.OriginID && x.IsActive);

            if (attachmentTemplateModel != null)
            {
                concatinatedMail = PrepareMail.ConcatinatePdfFiles(new List <byte[]> {
                    pdfData,
                    attachmentTemplateModel.Template
                });
            }
            else
            {
                Log.Warn("template " + DefaulttemplateConsumer31Attachment + " was not found for origin" + model.OriginId);
            }

            return(SendMail(concatinatedMail, model.CustomerId, DefaulttemplateConsumer31TemplateName, templateModel.ID));
        }
示例#4
0
        private FileMetadata SendDefaultTemplateComm7Personal(int customerID, Dictionary <string, string> variables, Address customerAddress, int originId)
        {
            SetAddress(customerAddress, ref variables);
            var templateModel = this.templates.FirstOrDefault(x => x.TemplateName == DefaulttemplateComm7PersonalTemplateName && originId == x.OriginID && x.IsActive);

            if (templateModel == null)
            {
                Log.Warn("template " + DefaulttemplateComm7PersonalTemplateName + " was not found for origin" + originId);
                return(null);
            }
            Stream template = PrepareMail.ByteArrayToStream(templateModel.Template);

            byte[] pdfData = PrepareMail.ReplaceParametersAndConvertToPdf(template, variables);
            return(SendMail(pdfData, customerID, DefaulttemplateComm7PersonalTemplateName, templateModel.ID));
        }