示例#1
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);
        }
示例#2
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));
        }