} // constructor public ActionResult Download(decimal amount, string viewName, int loanType, int repaymentPeriod) { var oLog = new SafeILog(LogManager.GetLogger(GetType())); oLog.Info("Download agreement: amount = {0}, view = {1}, loan type = {2}, repayment period = {3}", amount, viewName, loanType, repaymentPeriod); var lastCashRequest = this.customer.LastCashRequest; if (this.customer.IsLoanTypeSelectionAllowed == 1) { var oDBHelper = ObjectFactory.GetInstance <IDatabaseDataHelper>() as DatabaseDataHelper; lastCashRequest.RepaymentPeriod = repaymentPeriod; lastCashRequest.LoanType = oDBHelper.LoanTypeRepository.Get(loanType); } // if var loan = this.loanBuilder.CreateLoan(lastCashRequest, amount, DateTime.UtcNow); var model = this.builder.Build(this.customer, amount, loan); var productSubTypeID = loan.CashRequest.ProductSubTypeID; var originId = loan.CashRequest.Customer.CustomerOrigin.CustomerOriginID; var isRegulated = this.customer.PersonalInfo.TypeOfBusiness.IsRegulated(); LoanAgreementTemplate loanAgreementTemplate = this.serviceClient.Instance.GetLegalDocs(this.customer.Id, this.context.UserId, originId, isRegulated, productSubTypeID ?? 0).LoanAgreementTemplates.FirstOrDefault(x => x.TemplateTypeName == viewName); if (loanAgreementTemplate != null) { var template = loanAgreementTemplate.Template; var pdf = this.agreementRenderer.RenderAgreementToPdf(template, model); return(File(pdf, "application/pdf", viewName + " Summary_" + DateTime.Now + ".pdf")); } return(null); } // Download
public void Execute() { DataTable dt = db.ExecuteReader("GetUnprocessedServiceLogEntries", CommandSpecies.StoredProcedure); log.Info("Fetched {0} entries", dt.Rows.Count); foreach (DataRow row in dt.Rows) { var sr = new SafeReader(row); int serviceLogId = sr["Id"]; int customerId = sr["CustomerId"]; string response = sr["ResponseData"]; try { HandleResponse(response, serviceLogId, customerId); } catch (Exception e) { log.Error("Exception while processing response. ServiceLogId:{0} CustomerId:{1}. The exception:{2}", serviceLogId, customerId, e); } } }