Example #1
0
        /// <exception cref="InvalidDesignException"></exception>
        public static void ValidateDesignJSON(Stream designFile)
        {
            ReportDesign.ValidateJSON(designFile);

            //TODO: add application-level validation: for example, does the design have
            //references to objects that don't appear in the document template, etc.
        }
Example #2
0
            public void Render(
                RenderingEnv env,
                ReportDesign reportDesign,
                Region region,
                ElementDesign design,
                object data)
            {
                Region r = region.ToPointScale(reportDesign);
                Single x = r.Left + r.GetWidth() / 2;
                Single y = r.Top + r.GetHeight() / 2;
                Single w = 12;

                env.Graphics.DrawRectangle(Pens.Black, x - w / 2, y - w / 2, w, w);
                if ((bool)data)
                {
                    Point[] p =
                    {
                        new Point((int)(x - w / 2), (int)(y - w / 4)),
                        new Point((int)(x - w / 4), (int)(y + w / 2)),
                        new Point((int)(x + w / 2), (int)(y - w / 2)),
                        new Point((int)(x - w / 4), (int)(y))
                    };
                    env.Graphics.FillPolygon(Brushes.SteelBlue, p);
                }
            }
Example #3
0
            public void Render(
                PdfRenderer renderer,
                ReportDesign reportDesign,
                Region region,
                ElementDesign design,
                object data)
            {
                Region         r  = region.ToPointScale(reportDesign);
                PdfContentByte cb = renderer.Writer.DirectContent;
                Single         x  = r.Left + r.GetWidth() / 2;
                Single         y  = r.Top + r.GetHeight() / 2;
                Single         w  = 12;

                cb.SaveState();
                cb.Rectangle(renderer.Trans.X(x - w / 2), renderer.Trans.Y(y - w / 2), w, -w);
                cb.Stroke();
                if ((bool)data)
                {
                    cb.SetColorFill(PdfRenderUtil.GetColor("steelblue"));
                    cb.MoveTo(renderer.Trans.X(x - w / 2), renderer.Trans.Y(y - w / 4));
                    cb.LineTo(renderer.Trans.X(x - w / 4), renderer.Trans.Y(y + w / 2));
                    cb.LineTo(renderer.Trans.X(x + w / 2), renderer.Trans.Y(y - w / 2));
                    cb.LineTo(renderer.Trans.X(x - w / 4), renderer.Trans.Y(y));
                    cb.Fill();
                }
                cb.RestoreState();
            }
Example #4
0
        public static string GetDesignSchemaXML()
        {
            System.Xml.Schema.XmlSchema schema = ReportDesign.GetDesignSchemaXML();
            MemoryStream stream = new MemoryStream();

            schema.Write(stream);
            return(Encoding.UTF8.GetString(stream.GetBuffer()));
        }
        public FileResult StudentWiseReport(int Id, string type)
        {
            var chart = new ReportDesign();

            ReportDesign.ScoresDataTable      card        = chart.Scores;
            ReportDataSourceComponents[]      source      = new ReportDataSourceComponents[] { };
            ReportDesign.SuccessRateDataTable successRate = chart.SuccessRate;

            using (DBEntities dbContext = new DBEntities())
            {
                var log = dbContext.ReportCard.Where(s => s.UserId == Id).ToList();
                foreach (ReportCard score in log)
                {
                    card.AddScoresRow(dbContext.Courses.Where(c => c.CourseId == score.CourseId).Select(c => c.CourseName).FirstOrDefault(),
                                      dbContext.Papers.Where(c => c.PaperId == score.Paperid).Select(c => c.PaperName).FirstOrDefault(),
                                      dbContext.Levels.Where(c => c.Level == score.LevelId).Select(c => c.LevelName).FirstOrDefault(),
                                      score.TotalScore, score.UserId.ToString(),
                                      dbContext.Users.Where(c => c.Id == Id).Select(c => c.UserName).FirstOrDefault());
                }
                var    optionsLog       = dbContext.Scores.Where(s => s.UserId == Id).Select(s => s.Score).ToList();
                double successRateCount = 0;
                double FailRateCount    = 0;
                for (int i = 0; i < optionsLog.Count; i++)
                {
                    if (optionsLog[i] != 0)
                    {
                        successRateCount++;
                    }
                    else
                    {
                        FailRateCount++;
                    }
                }
                successRate.AddSuccessRateRow(successRateCount / (successRateCount + FailRateCount), FailRateCount / (successRateCount + FailRateCount));
                source = new[] { new ReportDataSourceComponents("StudentWiseReportScores", card),
                                 new ReportDataSourceComponents("StudentWiseReportSuccessRate", successRate) };
            }

            string templateName   = "StudentWiseReport.rdlc";
            string path           = GetTemplateFullPath(templateName);
            var    reportOutput   = PublishReportForTemplate(type, path, source);
            string tempReportName = Guid.NewGuid() + "." + type;

            WriteReportToFile(tempReportName, reportOutput);

            byte[] fileBytes = System.IO.File.ReadAllBytes(Path.Combine(GetHomeDirectory(), "TempCharts", tempReportName));
            string fileName  = "StudentWiseReport." + type;

            //Delete temp file
            if (System.IO.File.Exists(Path.Combine(GetHomeDirectory(), "TempCharts", tempReportName)))
            {
                System.IO.File.Delete(Path.Combine(GetHomeDirectory(), "TempCharts", tempReportName));
            }

            return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName));
        }
Example #6
0
        public static void Run()
        {
            // 差込みを行うコンテントを、あらかじめ共有コンテントへ登録しておきます
            ReportDesign sharedReport = new ReportDesign(Json.Read("report/example_shared.rrpt"));

            Report.AddSharedContent("company_info", sharedReport);

            Report report = new Report(Json.Read("report\\example_mergecontent.rrpt"));

            report.GlobalScope.Add("company_name", "株式会社ラピッドレポート");
            report.GlobalScope.Add("tel", "0000-11-2222");
            report.Fill(new ReportDataSource(getDataTable()));
            ReportPages pages = report.GetPages();

            // PDF出力
            using (FileStream fs = new FileStream("output\\example_mergecontent.pdf", FileMode.Create))
            {
                PdfRenderer renderer = new PdfRenderer(fs);
                renderer.Setting.ReplaceBackslashToYen = true;
                pages.Render(renderer);
            }

            // XLS出力
            using (FileStream fs = new FileStream("output\\example_mergecontent.xls", FileMode.Create))
            {
                HSSFWorkbook workbook = new HSSFWorkbook();
                XlsRenderer  renderer = new XlsRenderer(workbook);
                renderer.NewSheet("example_mergecontent");
                pages.Render(renderer);
                workbook.Write(fs);
            }

            // XLSX出力
            using (FileStream fs = new FileStream("output\\example_mergecontent.xlsx", FileMode.Create))
            {
                XSSFWorkbook workbook = new XSSFWorkbook();
                XlsxRenderer renderer = new XlsxRenderer(workbook);
                renderer.NewSheet("example_mergecontent");
                pages.Render(renderer);
                workbook.Write(fs);
            }

            // プレビュー
            {
                FmPrintPreview preview = new FmPrintPreview(new Printer(pages));
                preview.StartUpZoomFit = true;
                preview.ShowDialog();
            }
        }
Example #7
0
            public void Collect(
                XlsxRenderer renderer,
                ReportDesign reportDesign,
                Region region,
                ElementDesign design,
                object data)
            {
                Region r = region.ToPointScale(reportDesign);

                jp.co.systembase.report.renderer.xlsx.component.Shape shape =
                    new jp.co.systembase.report.renderer.xlsx.component.Shape();
                shape.Region   = r;
                shape.Renderer = new CheckBoxShapeRenderer(data);
                renderer.CurrentPage.Shapes.Add(shape);
            }
        public static void Run()
        {
            // 差込みを行うコンテントを、あらかじめ共有コンテントへ登録しておきます
            ReportDesign sharedReport = new ReportDesign(Json.Read("report/example_shared.rrpt"));
            Report.AddSharedContent("company_info", sharedReport);

            Report report = new Report(Json.Read("report\\example_mergecontent.rrpt"));
            report.GlobalScope.Add("company_name", "株式会社ラピッドレポート");
            report.GlobalScope.Add("tel", "0000-11-2222");
            report.Fill(new ReportDataSource(getDataTable()));
            ReportPages pages = report.GetPages();

            // PDF出力
            using (FileStream fs = new FileStream("output\\example_mergecontent.pdf", FileMode.Create))
            {
                PdfRenderer renderer = new PdfRenderer(fs);
                renderer.Setting.ReplaceBackslashToYen = true;
                pages.Render(renderer);
            }

            // XLS出力
            using (FileStream fs = new FileStream("output\\example_mergecontent.xls", FileMode.Create))
            {
                HSSFWorkbook workbook = new HSSFWorkbook();
                XlsRenderer renderer = new XlsRenderer(workbook);
                renderer.NewSheet("example_mergecontent");
                pages.Render(renderer);
                workbook.Write(fs);
            }

            // XLSX出力
            using (FileStream fs = new FileStream("output\\example_mergecontent.xlsx", FileMode.Create))
            {
                XSSFWorkbook workbook = new XSSFWorkbook();
                XlsxRenderer renderer = new XlsxRenderer(workbook);
                renderer.NewSheet("example_mergecontent");
                pages.Render(renderer);
                workbook.Write(fs);
            }

            // プレビュー
            {
                FmPrintPreview preview = new FmPrintPreview(new Printer(pages));
                preview.StartUpZoomFit = true;
                preview.ShowDialog();
            }
        }
        public FileResult ReportGenerator(Guid Id)
        {
            Users usercookie    = Session["usercookie"] as Users;
            int   currentUserId = usercookie.Id;
            var   chart         = new ReportDesign();

            ReportDesign.ScoresDataTable card   = chart.Scores;
            ReportDataSourceComponents[] source = new ReportDataSourceComponents[] { };

            using (DBEntities dbContext = new DBEntities())
            {
                var log = dbContext.ReportCard.Where(s => s.TestId == Id).ToList();
                foreach (ReportCard score in log)
                {
                    card.AddScoresRow(dbContext.Courses.Where(c => c.CourseId == score.CourseId).Select(c => c.CourseName).FirstOrDefault(),
                                      dbContext.Papers.Where(c => c.PaperId == score.Paperid).Select(c => c.PaperName).FirstOrDefault(),
                                      dbContext.Levels.Where(c => c.Level == score.LevelId).Select(c => c.LevelName).FirstOrDefault(),
                                      score.TotalScore, score.UserId.ToString(),
                                      dbContext.Users.Where(c => c.Id == currentUserId).Select(c => c.UserName).FirstOrDefault());
                }
                source = new[] { new ReportDataSourceComponents("ReportCard", card) };
            }

            string templateName   = "ReportCard.rdlc";
            string path           = GetTemplateFullPath(templateName);
            var    reportOutput   = PublishReportForTemplate("pdf", path, source);
            string tempReportName = Guid.NewGuid() + ".pdf";

            WriteReportToFile(tempReportName, reportOutput);

            byte[] fileBytes = System.IO.File.ReadAllBytes(Path.Combine(GetHomeDirectory(), "TempCharts", tempReportName));
            string fileName  = "ReportCard.pdf";

            //Delete temp file
            if (System.IO.File.Exists(Path.Combine(GetHomeDirectory(), "TempCharts", tempReportName)))
            {
                System.IO.File.Delete(Path.Combine(GetHomeDirectory(), "TempCharts", tempReportName));
            }

            return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName));
        }
Example #10
0
        public FileResult AdminExamWiseReport(int CourseId, string type)
        {
            var chart = new ReportDesign();

            ReportDesign.ScoresDataTable card   = chart.Scores;
            ReportDataSourceComponents[] source = new ReportDataSourceComponents[] { };

            using (DBEntities dbContext = new DBEntities())
            {
                var log = dbContext.ReportCard.Where(s => s.CourseId == CourseId).OrderByDescending(s => s.TotalScore).ToList();
                foreach (ReportCard score in log)
                {
                    card.AddScoresRow(dbContext.Courses.Where(c => c.CourseId == score.CourseId).Select(c => c.CourseName).FirstOrDefault(),
                                      dbContext.Papers.Where(c => c.PaperId == score.Paperid).Select(c => c.PaperName).FirstOrDefault(),
                                      dbContext.Levels.Where(c => c.Level == score.LevelId).Select(c => c.LevelName).FirstOrDefault(),
                                      score.TotalScore, score.UserId.ToString(),
                                      dbContext.Users.Where(c => c.Id == score.UserId).Select(c => c.UserName).FirstOrDefault());
                }
                source = new[] { new ReportDataSourceComponents("ExamWiseReport", card) };
            }

            string templateName   = "ExamWiseReport.rdlc";
            string path           = GetTemplateFullPath(templateName);
            var    reportOutput   = PublishReportForTemplate(type, path, source);
            string tempReportName = Guid.NewGuid() + "." + type;

            WriteReportToFile(tempReportName, reportOutput);

            byte[] fileBytes = System.IO.File.ReadAllBytes(Path.Combine(GetHomeDirectory(), "TempCharts", tempReportName));
            string fileName  = "ExamWiseReport." + type;

            //Delete temp file
            if (System.IO.File.Exists(Path.Combine(GetHomeDirectory(), "TempCharts", tempReportName)))
            {
                System.IO.File.Delete(Path.Combine(GetHomeDirectory(), "TempCharts", tempReportName));
            }

            return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName));
        }
Example #11
0
 public void Render(
     RenderingEnv env,
     ReportDesign reportDesign,
     Region region,
     ElementDesign design,
     object data)
 {
     Region r = region.ToPointScale(reportDesign);
     Single x = r.Left + r.GetWidth() / 2;
     Single y = r.Top + r.GetHeight() / 2;
     Single w = 12;
     env.Graphics.DrawRectangle(Pens.Black, x - w / 2, y - w / 2, w, w);
     if ((bool)data)
     {
         Point[] p = {
           new Point((int)(x - w / 2), (int)(y - w / 4)),
           new Point((int)(x - w / 4), (int)(y + w / 2)),
           new Point((int)(x + w / 2), (int)(y - w / 2)),
           new Point((int)(x - w / 4), (int)(y))};
         env.Graphics.FillPolygon(Brushes.SteelBlue, p);
     }
 }
Example #12
0
        public JsonResult GenerateStats()
        {
            Users usercookie = Session["usercookie"] as Users;

            if (Session["usercookie"] == null)
            {
                return(Json(new { success = false, responseText = "Please login.Session expired!!." }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                int currentUserId = usercookie.Id;
                var chart         = new ReportDesign();
                ReportDesign.ScoresDataTable      scores      = chart.Scores;
                ReportDesign.SuccessRateDataTable successRate = chart.SuccessRate;
                ReportDataSourceComponents[]      source      = new ReportDataSourceComponents[] { };
                if (usercookie.RoleId == 2)
                {
                    using (DBEntities dbContext = new DBEntities())
                    {
                        var log = dbContext.ReportCard.ToList();
                        foreach (ReportCard score in log)
                        {
                            scores.AddScoresRow(dbContext.Courses.Where(c => c.CourseId == score.CourseId).Select(c => c.CourseName).FirstOrDefault(),
                                                dbContext.Papers.Where(c => c.PaperId == score.Paperid).Select(c => c.PaperName).FirstOrDefault(),
                                                dbContext.Levels.Where(c => c.Level == score.LevelId).Select(c => c.LevelName).FirstOrDefault(),
                                                score.TotalScore, score.UserId.ToString(),
                                                dbContext.Users.Where(c => c.Id == currentUserId).Select(c => c.UserName).FirstOrDefault());
                        }
                        var    optionsLog       = dbContext.Scores.Select(s => s.Score).ToList();
                        double successRateCount = 0;
                        double FailRateCount    = 0;
                        for (int i = 0; i < optionsLog.Count; i++)
                        {
                            if (optionsLog[i] != 0)
                            {
                                successRateCount++;
                            }
                            else
                            {
                                FailRateCount++;
                            }
                        }
                        successRate.AddSuccessRateRow(successRateCount / (successRateCount + FailRateCount), FailRateCount / (successRateCount + FailRateCount));
                        source = new[] { new ReportDataSourceComponents("Scores", scores), new ReportDataSourceComponents("SuccessRate", successRate) };
                    }
                }
                else
                {
                    using (DBEntities dbContext = new DBEntities())
                    {
                        var log = dbContext.ReportCard.Where(s => s.UserId == currentUserId).ToList();
                        foreach (ReportCard score in log)
                        {
                            scores.AddScoresRow(dbContext.Courses.Where(c => c.CourseId == score.CourseId).Select(c => c.CourseName).FirstOrDefault(),
                                                dbContext.Papers.Where(c => c.PaperId == score.Paperid).Select(c => c.PaperName).FirstOrDefault(),
                                                dbContext.Levels.Where(c => c.Level == score.LevelId).Select(c => c.LevelName).FirstOrDefault(),
                                                score.TotalScore, score.UserId.ToString(),
                                                dbContext.Users.Where(c => c.Id == currentUserId).Select(c => c.UserName).FirstOrDefault());
                        }
                        var    optionsLog       = dbContext.Scores.Where(s => s.UserId == currentUserId).Select(s => s.Score).ToList();
                        double successRateCount = 0;
                        double FailRateCount    = 0;
                        for (int i = 0; i < optionsLog.Count; i++)
                        {
                            if (optionsLog[i] != 0)
                            {
                                successRateCount++;
                            }
                            else
                            {
                                FailRateCount++;
                            }
                        }
                        successRate.AddSuccessRateRow((successRateCount / (successRateCount + FailRateCount)) * 100, (FailRateCount / (successRateCount + FailRateCount)) * 100);
                        source = new[] { new ReportDataSourceComponents("Scores", scores), new ReportDataSourceComponents("SuccessRate", successRate) };
                    }
                }

                string templateName   = "DashBoardChart.rdlc";
                string path           = GetTemplateFullPath(templateName);
                var    reportOutput   = PublishReportForTemplate("Excel", path, source);
                string tempReportName = Guid.NewGuid() + ".xls";
                WriteReportToFile(tempReportName, reportOutput);

                //now export chart to img
                Workbook workbook = new Workbook();
                workbook.LoadFromFile(Path.Combine(GetHomeDirectory(), "TempCharts", tempReportName), ExcelVersion.Version97to2003);
                Worksheet    sheet              = workbook.Worksheets[0];
                ExcelPicture ScoresPicture      = sheet.Pictures[0];
                ExcelPicture SuccessRatePicture = sheet.Pictures[1];

                string scoresPath;
                string successRatePath;
                if (usercookie.RoleId == 2)
                {
                    scoresPath      = Path.Combine(GetHomeDirectory(), "TempCharts", "AdminScoresChart.png");
                    successRatePath = Path.Combine(GetHomeDirectory(), "TempCharts", "AdminSuccessRateChart.png");
                }
                else
                {
                    scoresPath      = Path.Combine(GetHomeDirectory(), "TempCharts", "UserScoresChart.png");
                    successRatePath = Path.Combine(GetHomeDirectory(), "TempCharts", "UserSuccessRateChart.png");
                }

                //Delete old score chart
                if (System.IO.File.Exists(scoresPath))
                {
                    System.IO.File.Delete(scoresPath);
                }

                //Delete old successRate chart
                if (System.IO.File.Exists(successRatePath))
                {
                    System.IO.File.Delete(successRatePath);
                }

                ScoresPicture.Picture.Save(scoresPath, ImageFormat.Png);
                SuccessRatePicture.Picture.Save(successRatePath, ImageFormat.Png);

                //Delete temp file
                if (System.IO.File.Exists(Path.Combine(GetHomeDirectory(), "TempCharts", tempReportName)))
                {
                    System.IO.File.Delete(Path.Combine(GetHomeDirectory(), "TempCharts", tempReportName));
                }

                return(Json(new { success = true, responseText = "" }, JsonRequestBehavior.AllowGet));
            }
        }
Example #13
0
 public Customizer()
 {
     this.reportDesign = new ReportDesign(Json.Read("report\\example_page2.rrpt"));
 }
Example #14
0
 public void Render(
     PdfRenderer renderer, 
     ReportDesign reportDesign, 
     Region region, 
     ElementDesign design, 
     object data)
 {
     Region r = region.ToPointScale(reportDesign);
     PdfContentByte cb = renderer.Writer.DirectContent;
     Single x = r.Left + r.GetWidth() / 2;
     Single y = r.Top + r.GetHeight() / 2;
     Single w = 12;
     cb.SaveState();
     cb.Rectangle(renderer.Trans.X(x - w / 2), renderer.Trans.Y(y - w / 2), w, -w);
     cb.Stroke();
     if ((bool)data)
     {
         cb.SetColorFill(PdfRenderUtil.GetColor("steelblue"));
         cb.MoveTo(renderer.Trans.X(x - w / 2), renderer.Trans.Y(y - w / 4));
         cb.LineTo(renderer.Trans.X(x - w / 4), renderer.Trans.Y(y + w / 2));
         cb.LineTo(renderer.Trans.X(x + w / 2), renderer.Trans.Y(y - w / 2));
         cb.LineTo(renderer.Trans.X(x - w / 4), renderer.Trans.Y(y));
         cb.Fill();
     }
     cb.RestoreState();
 }
Example #15
0
 public void Collect(
     XlsxRenderer renderer,
     ReportDesign reportDesign,
     Region region,
     ElementDesign design,
     object data)
 {
     Region r = region.ToPointScale(reportDesign);
     jp.co.systembase.report.renderer.xlsx.component.Shape shape =
         new jp.co.systembase.report.renderer.xlsx.component.Shape();
     shape.Region = r;
     shape.Renderer = new CheckBoxShapeRenderer(data);
     renderer.CurrentPage.Shapes.Add(shape);
 }
Example #16
0
 public Customizer()
 {
     this.reportDesign = new ReportDesign(Json.Read("report\\example_page2.rrpt"));
 }
Example #17
0
 public static string GetDesignSchemaJSON()
 {
     return(ReportDesign.GetDesignSchemaJSON().ToString());
 }
Example #18
0
        public Stream Generate(
            Stream designFile, int[] chapters, bool drawRules, bool drawPageBoxes,
            string mimeType,
            string photoUri, string resourceUri)             //TODO: return byte[]?
        {
            _reportMimeType = mimeType;
            _fonts.Load();

            //	Set up a reference resolver
            DocumentStructure structure     = new DocumentStructure(_documentId, _unitOfWork);
            DocTaggedObjects  taggedObjects = new DocTaggedObjects(_documentId, _unitOfWork);

            _resolver = new Resolver(structure, taggedObjects, _tracePathDelegate);

            //	Load the report structure as it's designed
            _design = new ReportDesign(designFile, _logger);
            _report = _design.Load(this);
            _report.Validate();

            _report.Subset(chapters);

            //	Load properties from the database and prepare them for matching
            //	against expansion strings in text
            LoadProperties();

            //	Resolve all source references from ref-to-template-object
            //	to ref-to-concrete-object, duplicating layouts as necessary
            TraceLayoutActivity("Resolve references");
            _report.ResolveSublayoutReferences();
            TraceLayoutActivity("Validate conditions");
            _report.ValidateConditions();
            TraceLayoutActivity("Apply static conditions");
            _report.ApplyStaticLayoutConditions();

            //	Load content
            TraceLayoutActivity("Load content");
            _report.LoadContent();
            _report.MergeContent(null);

            //	Remove content based on conditions
            TraceLayoutActivity("Apply dynamic conditions");
            _report.ApplyDynamicConditions();
//			TraceLayoutActivity("Remove empty layouts");
//			layout.RemoveEmptyLayouts();
//			TraceLayoutActivity("Redraft");
//			layout.Redraft();

//			//	Measure and cut content
//			TraceLayoutActivity("Measure and cut content");
//			List<PageLayout> pages = layout.LayOut();

            ReportRenderer renderer = null;

            switch (_reportMimeType)
            {
            case Demon.Core.MimeType.PDF:
                renderer = new PDF();
                break;

            case Demon.Core.MimeType.Word:
                renderer = new Word();
                break;

            case Demon.Core.MimeType.HTML:
                renderer = new HTML();
                break;

            case Demon.Core.MimeType.SVG:
                renderer = new SVG();
                break;

            default:
                throw new ArgumentOutOfRangeException($"Unsupported report content type '{_reportMimeType}'.");
            }

            Stream report = renderer.Render(
                _report, _documentId, _design.Id, _design.Name,
                _documentVersion, _timestamp,
                photoUri, resourceUri, drawRules, drawPageBoxes, this, this);

            return(report);
        }