public void Test2()
        {
            var dc = new DataContext();
            dc.AddTable("data", new[] {
                new Item { Col1="A", Col2 = 2 }
            });

            var flow = new Flow { Orientation = FlowOrientation.Vertical };
            var table = flow.AddTable<Item>("data");
            table.Columns.Single(a => a.DataField == "Col2").ConditionalFormatting = (value) => {
                if (!(value is int))
                    return null;
                var v = (int)value;
                if (v > 0)
                    return new Styling.CellStyle
                    {
                        FontStyle = new Styling.FontStyle
                        {
                            FontColor = Styling.Color.FromHtml("#00FF00")
                        }
                    };
                return null;
            };

            var rep = Report.CreateReport(flow, dc);
            var cells = ReportUtil.GetCellMatrix(rep);

            Assert.IsNull(cells[0][0].CustomStyle);
            Assert.IsNotNull(cells[0][1].CustomStyle);

            var html = HtmlReportWriter.RenderReport(rep, new DefaultHtmlReportTheme());
            Assert.IsTrue(html.Contains("style=\"color:"));
            Assert.IsTrue(html.Contains("#00FF00"));
        }
Example #2
0
        public void TestFooters()
        {
            var dc = new DataContext();

            dc.AddTable("data", new[] {
                new Item2 {
                    Name = "1", Value = 2, G = "1", Weight = 3
                },
                new Item2 {
                    Name = "2", Value = 3, G = "1", Weight = 1
                },
                new Item2 {
                    Name = "3", Value = 4, G = "2", Weight = 4
                }
            });

            var flow = new Flow {
                Orientation = FlowOrientation.Vertical
            };

            flow.AddTable <Item2>("data");

            var rep   = Report.CreateReport(flow, dc);
            var cells = ReportUtil.GetCellMatrix(rep);

            Debug.WriteLine(ReportUtil.RenderTextReport(rep));

            Assert.AreEqual(6, cells.Count);

            //Footers
            Assert.AreEqual(9m / 4, cells[2][2].Value);
            Assert.AreEqual(16m / 4, cells[4][2].Value);
            Assert.AreEqual(25m / 8, cells[5][2].Value);
        }
Example #3
0
        public void Test1()
        {
            var dc = new DataContext();

            dc.AddTable("data", new[] {
                new Item {
                    Name = "1", Value = 2
                },
                new Item {
                    Name = "2", Value = 3
                },
                new Item {
                    Name = "3", Value = 4
                }
            });

            var flow = new Flow {
                Orientation = FlowOrientation.Vertical
            };

            flow.AddTable <Item>("data");

            var rep   = Report.CreateReport(flow, dc);
            var cells = ReportUtil.GetCellMatrix(rep);

            //RowNumber
            Assert.AreEqual(1, cells[0][0].Value);
            Assert.AreEqual(2, cells[1][0].Value);
            Assert.AreEqual(3, cells[2][0].Value);

            //RowNumber
            Assert.AreEqual(2, cells[0][2].Value);
            Assert.AreEqual(5, cells[1][2].Value);
            Assert.AreEqual(9, cells[2][2].Value);
        }
Example #4
0
        public static Report BiggestCountries()
        {
            var dc = new DataContext();
            var data = new Dictionary<string, GdpItem>();
            var src = Pecunia.Services.GdpDataProvider.GetData();
            var lastYear = src.Max(a=>a.Year);
            foreach (var item in src)
            {
                GdpItem i;
                if (!data.TryGetValue(item.Country, out i))
                    data.Add(item.Country, i = new GdpItem { Country = item.Country });
                i.Process(lastYear, item);
            }

            var res = data.Values.ToArray();
            dc.AddTable("data", res);

            var table = TableGenerator.GetTable(typeof(GdpItem), "data");
            table.Columns.Last().SortIndex = 0;
            table.Columns.Last().SortDirection = SortDirection.Descending;
            for (var i = 0; i < 5; i++)
            {
                table.Columns[i + 2].HeaderText = (lastYear - 4 + i).ToString();
            }

            var flow = new Flow { Orientation = FlowOrientation.Vertical };
            flow.Add(table);

            return Report.CreateReport(flow, dc);
        }
        public void Test2()
        {
            var dc = new DataContext();
            dc.AddTable("data", new[] {
                new Item { Name="1", Value = 2, G="1" },
                new Item { Name="2", Value = 3, G="1" },
                new Item { Name="3", Value = 4, G="2" }
            });

            var flow = new Flow { Orientation = FlowOrientation.Vertical };
            flow.AddTable<Item>("data");

            var rep = Report.CreateReport(flow, dc);
            var cells = ReportUtil.GetCellMatrix(rep);

            //RowNumber
            Assert.AreEqual(1, cells[0][0].Value);
            Assert.AreEqual(2, cells[1][0].Value);
            Assert.AreEqual(1, cells[2][0].Value);

            //G2
            Assert.AreEqual(1, cells[2][0].Value);

            //Accumulator
            Assert.AreEqual(2, cells[0][2].Value);
            Assert.AreEqual(5, cells[1][2].Value);
            //G2
            Assert.AreEqual(4, cells[2][2].Value);
        }
Example #6
0
        public void Test1()
        {
            var dc = new DataContext();

            dc.AddTable("data", new[] {
                new Item {
                    Col1 = "A", Col2 = 2
                }
            });

            var flow = new Flow {
                Orientation = FlowOrientation.Vertical
            };

            flow.AddTable <Item>("data");

            var          rep = Report.CreateReport(flow, dc);
            StringWriter sw  = new StringWriter();

            TextReportWriter.WriteTo(rep, sw);

            var lines = sw.ToString().Split('\n').Select(a => a.TrimEnd('\r')).ToArray();

            Assert.AreEqual(lines[1], "=========");
            Assert.AreEqual(lines[2], "Col1 Col2");
            Assert.AreEqual(lines[3], "---- ----");
            Assert.AreEqual(lines[4], "A       2");
            Assert.AreEqual(lines[5], "---------");
        }
Example #7
0
        public void TestFooters()
        {
            var dc = new DataContext();

            dc.AddTable("data", new[] {
                new Item2 {
                    Name = "1", Value = 2, G = "1"
                },
                new Item2 {
                    Name = "2", Value = 3, G = "1"
                },
                new Item2 {
                    Name = "3", Value = 4, G = "2"
                }
            });

            var flow = new Flow {
                Orientation = FlowOrientation.Vertical
            };

            flow.AddTable <Item2>("data");

            var rep   = Report.CreateReport(flow, dc);
            var cells = ReportUtil.GetCellMatrix(rep);

            //Debug.WriteLine(ReportUtil.RenderTextReport(rep));

            Assert.AreEqual(6, cells.Count);

            //RowNumber
            Assert.AreEqual(1, cells[0][0].Value);
            Assert.AreEqual(2, cells[1][0].Value);
            Assert.AreEqual(1, cells[3][0].Value);

            //G2
            Assert.AreEqual(1, cells[3][0].Value);

            //Accumulator
            Assert.AreEqual(2, cells[0][2].Value);
            Assert.AreEqual(5, cells[1][2].Value);
            //G2
            Assert.AreEqual(4, cells[3][2].Value);

            //Footers
            Assert.AreEqual(5, cells[2][2].Value);
            Assert.AreEqual(4, cells[4][2].Value);
            Assert.AreEqual(9, cells[5][2].Value);
        }
Example #8
0
        public void Test2()
        {
            var dc = new DataContext();

            dc.AddTable("data", new[] {
                new Item {
                    Col1 = "A", Col2 = 2
                }
            });

            var flow = new Flow {
                Orientation = FlowOrientation.Vertical
            };
            var table = flow.AddTable <Item>("data");

            table.Columns.Single(a => a.DataField == "Col2").ConditionalFormatting = (value) => {
                if (!(value is int))
                {
                    return(null);
                }
                var v = (int)value;
                if (v > 0)
                {
                    return new Styling.CellStyle
                           {
                               FontStyle = new Styling.FontStyle
                               {
                                   FontColor = Styling.Color.FromHtml("#00FF00")
                               }
                           }
                }
                ;
                return(null);
            };

            var rep   = Report.CreateReport(flow, dc);
            var cells = ReportUtil.GetCellMatrix(rep);

            Assert.IsNull(cells[0][0].CustomStyle);
            Assert.IsNotNull(cells[0][1].CustomStyle);

            var html = HtmlReportWriter.RenderReport(rep, new DefaultHtmlReportTheme());

            Assert.IsTrue(html.Contains("style=\"color:"));
            Assert.IsTrue(html.Contains("#00FF00"));
        }
    }
        public void Test1()
        {
            var dc = new DataContext();
            dc.AddTable("data", new[] {
                new Item { Col1="A", Col2 = 2 }
            });

            var flow = new Flow { Orientation = FlowOrientation.Vertical };
            var table = flow.AddTable<Item>("data");
            table.Columns.Single(a => a.DataField == "Col2").ConditionalFormatting = (value) => { return new Styling.CellStyle(); };

            var rep = Report.CreateReport(flow, dc);
            var cells = ReportUtil.GetCellMatrix(rep);

            Assert.IsNull(cells[0][0].CustomStyle);
            Assert.IsNotNull(cells[0][1].CustomStyle);
        }
Example #10
0
        DataContext GetData()
        {
            var dc = new DataContext();
            List<Item> t = new List<Item>();
            var r = new Random();
            for (var i = 0; i < Filter.Count; i++)
                t.Add(new Item
                {
                    V1 = r.Next(),
                    V2 = r.Next(),
                    V3 = r.Next(),
                    V4 = r.Next(),
                    V5 = r.Next()
                });

            dc.AddTable("table", t);

            return dc;
        }
Example #11
0
        public static Report Generate()
        {
            var dc = new DataContext();
            var data = from item in Pecunia.Services.GdpDataProvider.GetData()
                       select new Item
                       {
                           Country = item.Country,
                           GDP = item.GDP,
                           GdpGrowth = item.GDPGrowth,
                           Year = item.Year,
                           GniPerCapita = item.GniPerCapita
                       };
            dc.AddTable("data", data.ToArray());

            var flow = new Flow { Orientation = FlowOrientation.Vertical };
            var table = flow.AddTable<Item>("data");
            table.Columns.Single(a => a.DataField == "GdpGrowth").ConditionalFormatting = ConditionalFormatters.PercentChange;

            return Report.CreateReport(flow, dc);
        }
Example #12
0
        public static Report FastestGrowingCountries()
        {
            var dc       = new DataContext();
            var data     = new Dictionary <string, GrowthItem>();
            var src      = Pecunia.Services.GdpDataProvider.GetData();
            var lastYear = src.Max(a => a.Year);

            foreach (var item in src)
            {
                GrowthItem i;
                if (!data.TryGetValue(item.Country, out i))
                {
                    data.Add(item.Country, i = new GrowthItem {
                        Country = item.Country
                    });
                }
                i.Process(lastYear, item);
            }

            var res = data.Values.ToArray();

            dc.AddTable("data", res);

            var table = TableGenerator.GetTable(typeof(GrowthItem), "data");

            table.Columns.Last().SortIndex     = 0;
            table.Columns.Last().SortDirection = SortDirection.Descending;
            for (var i = 0; i < 5; i++)
            {
                table.Columns[i + 2].HeaderText            = (lastYear - 4 + i).ToString();
                table.Columns[i + 2].ConditionalFormatting = ConditionalFormatters.PercentChange;
            }

            var flow = new Flow {
                Orientation = FlowOrientation.Vertical
            };

            flow.Add(table);

            return(Report.CreateReport(flow, dc));
        }
Example #13
0
        public void Test1()
        {
            var dc = new DataContext();
            dc.AddTable("data", new[] {
                new Item { Col1="A", Col2 = 2 }
            });

            var flow = new Flow { Orientation = FlowOrientation.Vertical };
            flow.AddTable<Item>("data");

            var rep = Report.CreateReport(flow, dc);
            StringWriter sw = new StringWriter();
            TextReportWriter.WriteTo(rep, sw);

            var lines = sw.ToString().Split('\n').Select(a=>a.TrimEnd('\r')).ToArray();

            Assert.AreEqual(lines[1], "=========");
            Assert.AreEqual(lines[2], "Col1 Col2");
            Assert.AreEqual(lines[3], "---- ----");
            Assert.AreEqual(lines[4], "A       2");
            Assert.AreEqual(lines[5], "---------");
        }
Example #14
0
        public void Test1()
        {
            var dc = new DataContext();

            dc.AddTable("data", new[] {
                new Item {
                    Col1 = "A", Col2 = 2
                }
            });

            var flow = new Flow {
                Orientation = FlowOrientation.Vertical
            };
            var table = flow.AddTable <Item>("data");

            table.Columns.Single(a => a.DataField == "Col2").ConditionalFormatting = (value) => { return(new Styling.CellStyle()); };

            var rep   = Report.CreateReport(flow, dc);
            var cells = ReportUtil.GetCellMatrix(rep);

            Assert.IsNull(cells[0][0].CustomStyle);
            Assert.IsNotNull(cells[0][1].CustomStyle);
        }
Example #15
0
        public static Report Generate()
        {
            var dc   = new DataContext();
            var data = from item in Pecunia.Services.GdpDataProvider.GetData()
                       select new Item
            {
                Country      = item.Country,
                GDP          = item.GDP,
                GdpGrowth    = item.GDPGrowth,
                Year         = item.Year,
                GniPerCapita = item.GniPerCapita
            };

            dc.AddTable("data", data.ToArray());

            var flow = new Flow {
                Orientation = FlowOrientation.Vertical
            };
            var table = flow.AddTable <Item>("data");

            table.Columns.Single(a => a.DataField == "GdpGrowth").ConditionalFormatting = ConditionalFormatters.PercentChange;

            return(Report.CreateReport(flow, dc));
        }
Example #16
0
        public void TestFooters()
        {
            var dc = new DataContext();
            dc.AddTable("data", new[] {
                new Item2 { Name="1", Value = 2, G="1", Weight = 3 },
                new Item2 { Name="2", Value = 3, G="1", Weight = 1 },
                new Item2 { Name="3", Value = 4, G="2", Weight = 4 }
            });

            var flow = new Flow { Orientation = FlowOrientation.Vertical };
            flow.AddTable<Item2>("data");

            var rep = Report.CreateReport(flow, dc);
            var cells = ReportUtil.GetCellMatrix(rep);

            Debug.WriteLine(ReportUtil.RenderTextReport(rep));

            Assert.AreEqual(6, cells.Count);

            //Footers
            Assert.AreEqual(9m/4, cells[2][2].Value);
            Assert.AreEqual(16m/4, cells[4][2].Value);
            Assert.AreEqual(25m/8, cells[5][2].Value);
        }
Example #17
0
        public void TwoLevelGrouping()
        {
            var dc = new DataContext();
            dc.AddTable("data", new[] {
                new Item {  Amount = 10, BrokerageHouseCode = "ADBR", Revoked = false },
                new Item {  Amount = 20, BrokerageHouseCode = "ADBR", Revoked = true},
                new Item {  Amount = 30, BrokerageHouseCode = "MOBR", Revoked = true },
            });

            var flow = new Flow { Orientation = FlowOrientation.Vertical };
            flow.AddTable<Item>("data");

            var rep = Report.CreateReport(flow, dc);
            var cells = ReportUtil.GetCellMatrix(rep);

            //False
            //=================================
            //ADBR
            //=================================
            //BrokerageHouseCode Revoked Amount
            //------------------ ------- ------
            //ADBR               False       10
            //---------------------------------
            //                               10
            //---------------------------------
            //                               10

            //True
            //=================================
            //ADBR
            //=================================
            //BrokerageHouseCode Revoked Amount
            //------------------ ------- ------
            //ADBR               True        20
            //---------------------------------
            //                               20

            //MOBR
            //=================================
            //BrokerageHouseCode Revoked Amount
            //------------------ ------- ------
            //MOBR               True        30
            //---------------------------------
            //                               30
            //---------------------------------
            //                               50

            //Debug.WriteLine(ReportUtil.RenderTextReport(rep));
            Assert.AreEqual(16, cells.Count);

            Assert.AreEqual("False", cells[0][0].Value);
            Assert.AreEqual("ADBR", cells[1][0].Value);
            Assert.AreEqual("BrokerageHouseCode", cells[2][0].Value);
            Assert.AreEqual(10m, cells[3][2].Value);
            Assert.AreEqual(10m, cells[4][2].Value);
            Assert.AreEqual(10m, cells[5][2].Value);
            Assert.AreEqual("True", cells[6][0].Value);
            Assert.AreEqual("ADBR", cells[7][0].Value);
            Assert.AreEqual("BrokerageHouseCode", cells[8][0].Value);
            Assert.AreEqual(20m, cells[9][2].Value);
            Assert.AreEqual(20m, cells[10][2].Value);
            Assert.AreEqual("MOBR", cells[11][0].Value);
            Assert.AreEqual("BrokerageHouseCode", cells[12][0].Value);
            Assert.AreEqual(30m, cells[13][2].Value);
            Assert.AreEqual(30m, cells[14][2].Value);
            Assert.AreEqual(50m, cells[15][2].Value);
        }
        public void TestFooters()
        {
            var dc = new DataContext();
            dc.AddTable("data", new[] {
                new Item2 { Name="1", Value = 2, G="1" },
                new Item2 { Name="2", Value = 3, G="1" },
                new Item2 { Name="3", Value = 4, G="2" }
            });

            var flow = new Flow { Orientation = FlowOrientation.Vertical };
            flow.AddTable<Item2>("data");

            var rep = Report.CreateReport(flow, dc);
            var cells = ReportUtil.GetCellMatrix(rep);

            //Debug.WriteLine(ReportUtil.RenderTextReport(rep));

            Assert.AreEqual(6, cells.Count);

            //RowNumber
            Assert.AreEqual(1, cells[0][0].Value);
            Assert.AreEqual(2, cells[1][0].Value);
            Assert.AreEqual(1, cells[3][0].Value);

            //G2
            Assert.AreEqual(1, cells[3][0].Value);

            //Accumulator
            Assert.AreEqual(2, cells[0][2].Value);
            Assert.AreEqual(5, cells[1][2].Value);
            //G2
            Assert.AreEqual(4, cells[3][2].Value);

            //Footers
            Assert.AreEqual(5, cells[2][2].Value);
            Assert.AreEqual(4, cells[4][2].Value);
            Assert.AreEqual(9, cells[5][2].Value);
        }
Example #19
0
        public void TwoLevelGrouping()
        {
            var dc = new DataContext();

            dc.AddTable("data", new[] {
                new Item {
                    Amount = 10, BrokerageHouseCode = "ADBR", Revoked = false
                },
                new Item {
                    Amount = 20, BrokerageHouseCode = "ADBR", Revoked = true
                },
                new Item {
                    Amount = 30, BrokerageHouseCode = "MOBR", Revoked = true
                },
            });

            var flow = new Flow {
                Orientation = FlowOrientation.Vertical
            };

            flow.AddTable <Item>("data");

            var rep   = Report.CreateReport(flow, dc);
            var cells = ReportUtil.GetCellMatrix(rep);

//False
//=================================
//ADBR
//=================================
//BrokerageHouseCode Revoked Amount
//------------------ ------- ------
//ADBR               False       10
//---------------------------------
//                               10
//---------------------------------
//                               10

//True
//=================================
//ADBR
//=================================
//BrokerageHouseCode Revoked Amount
//------------------ ------- ------
//ADBR               True        20
//---------------------------------
//                               20

//MOBR
//=================================
//BrokerageHouseCode Revoked Amount
//------------------ ------- ------
//MOBR               True        30
//---------------------------------
//                               30
//---------------------------------
//                               50

            //Debug.WriteLine(ReportUtil.RenderTextReport(rep));
            Assert.AreEqual(16, cells.Count);

            Assert.AreEqual("False", cells[0][0].Value);
            Assert.AreEqual("ADBR", cells[1][0].Value);
            Assert.AreEqual("BrokerageHouseCode", cells[2][0].Value);
            Assert.AreEqual(10m, cells[3][2].Value);
            Assert.AreEqual(10m, cells[4][2].Value);
            Assert.AreEqual(10m, cells[5][2].Value);
            Assert.AreEqual("True", cells[6][0].Value);
            Assert.AreEqual("ADBR", cells[7][0].Value);
            Assert.AreEqual("BrokerageHouseCode", cells[8][0].Value);
            Assert.AreEqual(20m, cells[9][2].Value);
            Assert.AreEqual(20m, cells[10][2].Value);
            Assert.AreEqual("MOBR", cells[11][0].Value);
            Assert.AreEqual("BrokerageHouseCode", cells[12][0].Value);
            Assert.AreEqual(30m, cells[13][2].Value);
            Assert.AreEqual(30m, cells[14][2].Value);
            Assert.AreEqual(50m, cells[15][2].Value);
        }