Ejemplo n.º 1
0
        private GeneratedReportPart generateSiteSummary(Rt.Framework.Components.CustomReportComponent reportPart)
        {
            GeneratedReportPart part;

            Rt.Framework.Services.ReportEngine.ReportControls.SiteSummaryTable summary;

            summary = new Rt.Framework.Services.ReportEngine.ReportControls.SiteSummaryTable();
            summary.setDatasource(_db, reportPart.Url.Id);

            part      = new GeneratedReportPart();
            part.Html = getHtmlFromControlRender(summary);

            return(part);
        }
Ejemplo n.º 2
0
        private GeneratedReportPart generateTrendReport(SavedReport savedReport)
        {
            RankChartGenerator  generator;
            RankChartParameters rcp;

            byte[] bytes;
            GeneratedReportPart grp;

            rcp = RankChartParameters.XmlDeserialize(savedReport.XmlData);

            generator = new RankChartGenerator(_db, rcp, savedReport.Name);
            bytes     = generator.GenerateChart();

            grp       = new GeneratedReportPart();
            grp.Bytes = bytes;

            return(grp);
        }
Ejemplo n.º 3
0
        public virtual void SendReport(int id)
        {
            ReportPartGenerator rpg         = new ReportPartGenerator(_db);
            EmailMessage        email       = new EmailMessage(_customReportTemplate);
            StringBuilder       htmlBuilder = new StringBuilder();
            Dictionary <string, MemoryStream> imageStreams = new Dictionary <string, MemoryStream>();
            int imgCounter = 0;

            CustomReport report = _db.ORManager.Get <CustomReport>(id);

            // Prepare the EmailMessage
            email.From = "*****@*****.**";                       // Placeholder - will be replaced by email engine
            email.ReplaceGeneralTokens();
            email.ApplyToUser(Membership.GetUser(report.UserId), _db.ORManager.Get <UserInformation>(report.UserId));
            email.ReplaceInMessage(TOKEN_REPORT_TITLE, report.Name);

            // Fetch the custom report components
            ICriteria componentCriteria = _db.ORManager.Session.CreateCriteria(typeof(CustomReportComponent)).Add(Expression.Eq("CustomReport.Id", id));
            IList <CustomReportComponent> components = componentCriteria.List <CustomReportComponent>();

            htmlBuilder.Append("<table class=\"ReportComponentsTable\">");

            // Add each custom report component to the custom report
            foreach (CustomReportComponent component in components)
            {
                GeneratedReportPart grp = rpg.GenerateReport(component);
                if (grp.Bytes != null)
                {
                    // Create a placeholder for the embedded image
                    string cid = string.Format("{0}{1}", CID_REPORT_IMAGE, imgCounter++);

                    // Create an embedded image tag
                    htmlBuilder.AppendFormat("<tr><td><img src=cid:{0}><br /></td></tr>", cid);

                    // Generate and save the memory stream for this embeded image
                    MemoryStream ms = new MemoryStream(grp.Bytes);
                    imageStreams.Add(cid, ms);
                }
                else
                {
                    // Append the raw HTML
                    htmlBuilder.AppendFormat("<tr><td>{0}</td></tr>", grp.Html);
                }
            }

            htmlBuilder.Append("</table>");

            // Insert report components into email message
            email.ReplaceInMessage(TOKEN_REPORT_CONTENT, htmlBuilder.ToString());
            MailMessage msg = email.GetMailMessage();

            // Create Text-Only AlternateView
            AlternateView plainView = AlternateView.CreateAlternateViewFromString("Your email client does not appear to support viewing HTML emails.  Your email client must support this in order to view this email.", Encoding.Default, "text/plain");

            msg.AlternateViews.Add(plainView);

            // Prepare new AlternateView and clear the message body
            AlternateView htmlView = AlternateView.CreateAlternateViewFromString(msg.Body, Encoding.Default, MediaTypeNames.Text.Html);

            htmlView.TransferEncoding = TransferEncoding.SevenBit;
            msg.AlternateViews.Add(htmlView);
            msg.Body = null;

            // Embed Logo
            EmbedGifImage(htmlView, GetEmbeddedImage("RankTrend-Logo.gif"), "EmbeddedLogo");

            // Embed the images
            foreach (string key in imageStreams.Keys)
            {
                EmbedPngImage(htmlView, imageStreams[key], key);
            }

            // Send the email
            RtEngines.EmailEngine.SendEmail(msg, true);
        }