/// <summary> /// Initializes a new instance of the <see cref="StiReportConfirmationBuilder" /> class. /// </summary> /// <param name="reportFactory">The report factory.</param> /// <param name="reportModel">The report model.</param> /// <param name="shopContext">The shop context.</param> public StiReportConfirmationBuilder([NotNull] StiReportFactory reportFactory, OrderReportModel reportModel, ShopContext shopContext) { Assert.ArgumentNotNull(reportFactory, "reportFactory"); Assert.ArgumentNotNull(reportModel, "reportModel"); this.reportFactory = reportFactory; this.reportModel = reportModel; this.shopContext = shopContext; }
public virtual StiReport CreateReport([NotNull] OrderReportModel model) { Assert.ArgumentNotNull(model, "model"); StiReport report = new StiReport(); string language = string.IsNullOrEmpty(model.LanguageCode) ? Sitecore.Context.Language.Name : model.LanguageCode; string reportFilePath = FileUtil.MapPath(this.ReportFile); StiConfig.ApplicationDirectory = FileUtil.GetParentPath(reportFilePath); string reportFileName = Path.GetFileNameWithoutExtension(reportFilePath); reportFileName = string.Concat(reportFileName, "-", language, ".dll"); string compiledReportFile = FileUtil.MakePath(StiConfig.ApplicationDirectory, reportFileName); if (!this.reportHelper.CheckIfCompiledReportExists(compiledReportFile)) { report.Load(reportFilePath); report.Dictionary.Variables[UrlKey].Value = this.GetLogoUrl(); report.AutoLocalizeReportOnRun = true; this.reportTranslator.Translate(report, language); StiImage image = (StiImage)report.GetComponentByName(LogoImageKey); string reportLogoFilePath = FileUtil.MapPath(this.LogoFile); image.Image = System.Drawing.Image.FromFile(reportLogoFilePath); this.reportHelper.CompileReport(report, compiledReportFile); } else { report = this.reportHelper.GetCompiledReport(compiledReportFile); } if (model.CompanyMasterData != null) { model.CompanyMasterData.ReadData(); } if (model.Order != null) { report.RegData("Order", model); } return(report); }