private GridDashboardItem CreateGrid(DashboardExcelDataSource dataSource)
        {
            // Creates a grid dashboard item and specifies its data source.
            GridDashboardItem grid = new GridDashboardItem();

            grid.DataSource = dataSource;

            // Creates new grid columns of the specified type and with the specified dimension or
            // measure. Then, adds these columns to the grid's Columns collection.
            grid.Columns.Add(new GridHyperlinkColumn(new Dimension("Product"), "Product")
            {
                UriPattern = "https://www.google.com/search?q={0}"
            });
            grid.Columns.Add(new GridDimensionColumn(new Dimension("Category")));
            grid.Columns.Add(new GridMeasureColumn(new Measure("Count")));
            grid.Columns.Add(new GridDeltaColumn(new Measure("Count"),
                                                 new Measure("TargetCount")));
            grid.Columns.Add(new GridSparklineColumn(new Measure("Count")));
            grid.SparklineArgument = new Dimension("Date", DateTimeGroupInterval.MonthYear);

            grid.GridOptions.EnableBandedRows    = true;
            grid.GridOptions.ShowHorizontalLines = false;

            return(grid);
        }
Beispiel #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Create a dashboard and display it in the dashboard viewer.
            dashboardViewer1.Dashboard = new Dashboard();

            // Create a data source and add it to the dashboard data source collection.
            DashboardExcelDataSource dataSource = CreateExcelDataSource();

            dashboardViewer1.Dashboard.DataSources.Add(dataSource);

            // Create a Range Filter dashboard item with the specified data source
            // and add it to the Items collection to display within the dashboard.
            RangeFilterDashboardItem rangeFilter = CreateRangeFilter(dataSource);

            dashboardViewer1.Dashboard.Items.Add(rangeFilter);

            // Create a pivot and add it to the dashboard.
            PivotDashboardItem pivot = CreatePivot(dataSource);

            dashboardViewer1.Dashboard.Items.Add(pivot);

            // Create the dashboard layout.
            dashboardViewer1.Dashboard.RebuildLayout();
            dashboardViewer1.Dashboard.LayoutRoot.FindRecursive(rangeFilter).Weight = 20;
            dashboardViewer1.Dashboard.LayoutRoot.FindRecursive(pivot).Weight       = 80;
            dashboardViewer1.Dashboard.LayoutRoot.Orientation = DashboardLayoutGroupOrientation.Vertical;

            dashboardViewer1.ReloadData();
        }
Beispiel #3
0
        private Dashboard CreateDashboard()
        {
            DashboardExcelDataSource excelDataSource = CreateExcelDataSource();
            Dashboard dBoard = new Dashboard();

            dBoard.DataSources.Add(excelDataSource);

            dBoard.BeginUpdate();
            // Create dashboard items.
            ChartDashboardItem chart = CreateChart(excelDataSource);

            dBoard.Items.Add(chart);
            DateFilterDashboardItem dateFilterItem = CreateDateFilterItem(excelDataSource);

            dBoard.Items.Add(dateFilterItem);
            DashboardItemGroup group = CreateGroup();

            dBoard.Groups.Add(group);
            group.AddRange(dateFilterItem, chart);
            // Create layout tree.
            DashboardLayoutItem  dateFilterLayoutItem = new DashboardLayoutItem(dateFilterItem, 30);
            DashboardLayoutItem  chartLayoutItem      = new DashboardLayoutItem(chart, 70);
            DashboardLayoutGroup groupLayoutItem      = new DashboardLayoutGroup(group, 100);

            groupLayoutItem.ChildNodes.AddRange(dateFilterLayoutItem, chartLayoutItem);
            DashboardLayoutGroup rootGroup = new DashboardLayoutGroup(null, 100);

            rootGroup.ChildNodes.Add(groupLayoutItem);
            rootGroup.Orientation = DashboardLayoutGroupOrientation.Vertical;
            dBoard.LayoutRoot     = rootGroup;
            dBoard.EndUpdate();
            return(dBoard);
        }
        public Form1()
        {
            InitializeComponent();
            dashboardDesigner1.CreateRibbon();

            Dashboard dashboard = new Dashboard();

            DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource("Excel Data Source");

            excelDataSource.FileName      = @"..\..\Data\GDPByCountry.xlsx";
            excelDataSource.SourceOptions = new ExcelSourceOptions(new ExcelWorksheetSettings("Sheet1"));
            dashboard.DataSources.Add(excelDataSource);

            GridDashboardItem grid = new GridDashboardItem();

            grid.DataSource = excelDataSource;

            // Creates two hyperlink columns: the first column takes hyperlinks from the underlying data source while the second
            // generates links based on the specified URI pattern and country names.
            GridHyperlinkColumn hyperlinkColumn1 = new GridHyperlinkColumn(new Dimension("Name"));

            hyperlinkColumn1.UriDataMember = "Link";
            GridHyperlinkColumn hyperlinkColumn2 = new GridHyperlinkColumn(new Dimension("OfficialName"));

            hyperlinkColumn2.UriDataMember = "Name";
            hyperlinkColumn2.UriPattern    = "https://en.wikipedia.org/wiki/{0}";

            GridMeasureColumn gdpColumn = new GridMeasureColumn(new Measure("GDP"));

            grid.Columns.AddRange(hyperlinkColumn1, hyperlinkColumn2, gdpColumn);
            dashboard.Items.Add(grid);
            dashboardDesigner1.Dashboard = dashboard;
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource()
            {
                FileName      = "SalesPerson.xlsx",
                SourceOptions = new DevExpress.DataAccess.Excel.ExcelSourceOptions(
                    new DevExpress.DataAccess.Excel.ExcelWorksheetSettings()
                {
                    WorksheetName = "Data",
                    CellRange     = "A1:L100"
                }
                    )
            };

            excelDataSource.Fill();

            Dashboard dashBoard = new Dashboard();

            dashBoard.DataSources.Add(excelDataSource);
            PieDashboardItem pies = CreatePies(excelDataSource);

            dashBoard.Items.Add(pies);

            dashboardViewer1.Dashboard = dashBoard;
            dashboardViewer1.ReloadData();
        }
Beispiel #6
0
        public ActionResult AddDataSource(string id, string sheetId, string tableId, string rangeId, string scope)
        {
            string name = new PrefixNameGenerator("Google Sheets Source", " ", 1)
                          .GenerateName(n => ((IDataSourceStorage)DashboardConfig.DataSourceStorage).GetDataSourcesID().Contains(n));
            ExcelSettingsBase excelSettings = null;

            if (!string.IsNullOrEmpty(sheetId))
            {
                excelSettings = new ExcelWorksheetSettings(sheetId);
            }
            else if (!string.IsNullOrEmpty(tableId))
            {
                excelSettings = new ExcelTableSettings(tableId);
            }
            else if (!string.IsNullOrEmpty(rangeId))
            {
                excelSettings = new ExcelDefinedNameSettings(rangeId, scope);
            }
            if (excelSettings != null)
            {
                var excelDataSource = new DashboardExcelDataSource {
                    Name                 = name,
                    SourceOptions        = new ExcelSourceOptions(excelSettings),
                    StreamDocumentFormat = ExcelDocumentFormat.Xlsx,
                    FileName             = id,
                };

                DashboardConfig.DataSourceStorage.RegisterDataSource(name, excelDataSource.SaveToXml());
            }

            return(View("Index"));
        }
Beispiel #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DashboardFileStorage dashboardFileStorage = new DashboardFileStorage("~/App_Data/Dashboards");

            ASPxDashboard1.SetDashboardStorage(dashboardFileStorage);

            DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();

            using (Workbook workbook = new Workbook()) {
                Directory
                .EnumerateFiles(HostingEnvironment.MapPath(@"~/App_Data/ExcelFiles/"), "*.xlsx")
                .SelectMany(file => {
                    workbook.LoadDocument(file);
                    return(workbook.Worksheets.Select(sheet => {
                        var dataSourceId = string.Format("{0} - {1}", Path.GetFileNameWithoutExtension(file), sheet.Name);
                        var excelDataSource = new DashboardExcelDataSource(dataSourceId);
                        excelDataSource.ConnectionName = dataSourceId;
                        excelDataSource.FileName = file;
                        var worksheetSettings = new ExcelWorksheetSettings()
                        {
                            WorksheetName = sheet.Name
                        };
                        excelDataSource.SourceOptions = new ExcelSourceOptions(worksheetSettings);
                        return new {
                            Name = excelDataSource.Name,
                            Xml = excelDataSource.SaveToXml()
                        };
                    }));
                })
                .ToList()
                .ForEach(ds => dataSourceStorage.RegisterDataSource(ds.Name, ds.Xml));
            }
            ASPxDashboard1.SetDataSourceStorage(dataSourceStorage);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            DashboardFileStorage dashboardFileStorage = new DashboardFileStorage("~/App_Data/Dashboards");

            ASPxDashboard1.SetDashboardStorage(dashboardFileStorage);

            // Uncomment this string to allow end users to create new data sources based on predefined connection strings.
            //ASPxDashboard1.SetConnectionStringsProvider(new DevExpress.DataAccess.Web.ConfigFileConnectionStringsProvider());

            DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();

            // Registers an SQL data source.
            DashboardSqlDataSource sqlDataSource = new DashboardSqlDataSource("SQL Data Source", "NWindConnectionString");
            SelectQuery            query         = SelectQueryFluentBuilder
                                                   .AddTable("SalesPerson")
                                                   .SelectAllColumns()
                                                   .Build("Sales Person");

            sqlDataSource.Queries.Add(query);
            dataSourceStorage.RegisterDataSource("sqlDataSource", sqlDataSource.SaveToXml());

            // Registers an Object data source.
            DashboardObjectDataSource objDataSource = new DashboardObjectDataSource("Object Data Source");

            dataSourceStorage.RegisterDataSource("objDataSource", objDataSource.SaveToXml());

            // Registers an Excel data source.
            DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource("Excel Data Source");

            excelDataSource.FileName      = HostingEnvironment.MapPath(@"~/App_Data/Sales.xlsx");
            excelDataSource.SourceOptions = new ExcelSourceOptions(new ExcelWorksheetSettings("Sheet1"));
            dataSourceStorage.RegisterDataSource("excelDataSource", excelDataSource.SaveToXml());

            ASPxDashboard1.SetDataSourceStorage(dataSourceStorage);
        }
Beispiel #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DashboardFileStorage dashboardFileStorage = new DashboardFileStorage("~/App_Data/Dashboards");

            ASPxDashboardExcel.SetDashboardStorage(dashboardFileStorage);

            // Uncomment the next line to allow users to create new data sources based on predefined connection strings.
            //ASPxDashboardExcel.SetConnectionStringsProvider(new DevExpress.DataAccess.Web.ConfigFileConnectionStringsProvider());

            // Create a data source storage.
            DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();

            // Register an Excel data source.
            DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource("Excel Data Source");

            excelDataSource.ConnectionName = "excelDataConnection";
            excelDataSource.SourceOptions  = new ExcelSourceOptions(new ExcelWorksheetSettings("Sheet1"));
            dataSourceStorage.RegisterDataSource("excelDataSource", excelDataSource.SaveToXml());

            // Set the configured data source storage.
            ASPxDashboardExcel.SetDataSourceStorage(dataSourceStorage);

            ASPxDashboardExcel.ConfigureDataConnection += ASPxDashboardExcel_ConfigureDataConnection;

            ASPxDashboardExcel.InitialDashboardId = "dashboardExcel";
        }
Beispiel #10
0
        public static void RegisterService(RouteCollection routes)
        {
            routes.MapDashboardRoute("dashboardControl", "DefaultDashboard");

            DashboardFileStorage dashboardFileStorage = new DashboardFileStorage("~/App_Data/Dashboards");

            DashboardConfigurator.Default.SetDashboardStorage(dashboardFileStorage);

            // Uncomment this string to allow end users to create new data sources based on predefined connection strings.
            //DashboardConfigurator.Default.SetConnectionStringsProvider(new DevExpress.DataAccess.Web.ConfigFileConnectionStringsProvider());

            DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();

            // Registers an SQL data source.
            DashboardSqlDataSource sqlDataSource = new DashboardSqlDataSource("SQL Data Source", "NWindConnectionString");
            SelectQuery            query         = SelectQueryFluentBuilder
                                                   .AddTable("SalesPerson")
                                                   .SelectAllColumns()
                                                   .Build("Sales Person");

            sqlDataSource.Queries.Add(query);
            dataSourceStorage.RegisterDataSource("sqlDataSource", sqlDataSource.SaveToXml());

            // Registers an Excel data source.
            DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource("Excel Data Source");

            excelDataSource.FileName      = HostingEnvironment.MapPath(@"~/App_Data/Sales.xlsx");
            excelDataSource.SourceOptions = new ExcelSourceOptions(new ExcelWorksheetSettings("Sheet1"));
            dataSourceStorage.RegisterDataSource("excelDataSource", excelDataSource.SaveToXml());

            DashboardConfigurator.Default.SetDataSourceStorage(dataSourceStorage);
        }
Beispiel #11
0
        private static DashboardFederationDataSource CreateFederatedDataSource(DashboardSqlDataSource sqlDS,
                                                                               DashboardExcelDataSource excelDS, DashboardObjectDataSource objDS, DashboardJsonDataSource jsonDS)
        {
            DashboardFederationDataSource federationDataSource = new DashboardFederationDataSource("Federated Data Source");

            Source     sqlSource      = new Source("sqlSource", sqlDS, "SQL Orders");
            Source     excelSource    = new Source("excelSource", excelDS, "");
            Source     objectSource   = new Source("objectSource", objDS, "");
            SourceNode jsonSourceNode = new SourceNode(new Source("json", jsonDS, ""));

            // Join
            SelectNode joinQuery =
                sqlSource.From()
                .Select("OrderDate", "ShipCity", "ShipCountry")
                .Join(excelSource, "[excelSource.OrderID] = [sqlSource.OrderID]")
                .Select("CategoryName", "ProductName", "Extended Price")
                .Join(objectSource, "[objectSource.Country] = [excelSource.Country]")
                .Select("Country", "UnitPrice")
                .Build("Join query");

            federationDataSource.Queries.Add(joinQuery);

            // Union and UnionAll
            UnionNode queryUnionAll = sqlSource.From().Select("OrderID", "OrderDate").Build("OrdersSqlite")
                                      .UnionAll(excelSource.From().Select("OrderID", "OrderDate").Build("OrdersExcel"))
                                      .Build("OrdersUnionAll");

            queryUnionAll.Alias = "Union query";

            UnionNode queryUnion = sqlSource.From().Select("OrderID", "OrderDate").Build("OrdersSqlite")
                                   .Union(excelSource.From().Select("OrderID", "OrderDate").Build("OrdersExcel"))
                                   .Build("OrdersUnion");

            queryUnion.Alias = "UnionAll query";

            federationDataSource.Queries.Add(queryUnionAll);
            federationDataSource.Queries.Add(queryUnion);

            // Transformation
            TransformationNode unfoldNode = new TransformationNode(jsonSourceNode)
            {
                Alias = "Unfold",
                Rules = { new TransformationRule {
                              ColumnName = "Products", Alias = "Product", Unfold = true, Flatten = false
                          } }
            };

            TransformationNode unfoldFlattenNode = new TransformationNode(jsonSourceNode)
            {
                Alias = "Unfold and Flatten",
                Rules = { new TransformationRule {
                              ColumnName = "Products", Unfold = true, Flatten = true
                          } }
            };

            federationDataSource.Queries.Add(unfoldNode);
            federationDataSource.Queries.Add(unfoldFlattenNode);

            return(federationDataSource);
        }
        public static void ConfigureDataSource(DashboardConfigurator configurator, DataSourceInMemoryStorage storage)
        {
            // Registers an Excel data source.
            DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource("Excel Data Source");

            excelDataSource.ConnectionName = "excelDataConnection";
            excelDataSource.SourceOptions  = new ExcelSourceOptions(new ExcelWorksheetSettings("Sheet1"));
            storage.RegisterDataSource("excelDataSource", excelDataSource.SaveToXml());

            configurator.ConfigureDataConnection += Configurator_ConfigureDataConnection;
        }
        private DashboardExcelDataSource CreateExcelDataSource()
        {
            DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource();

            excelDataSource.FileName = "SalesPerson.xlsx";
            ExcelWorksheetSettings worksheetSettings = new ExcelWorksheetSettings("Data");

            excelDataSource.SourceOptions = new ExcelSourceOptions(worksheetSettings);
            excelDataSource.Fill();
            return(excelDataSource);
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            services.AddDevExpressControls();
            services.AddMvc()
            .AddDefaultReportingControllers()
            .AddDefaultDashboardController((configurator, serviceProvider) => {
                configurator.SetConnectionStringsProvider(new DashboardConnectionStringsProvider(Configuration));

                DashboardFileStorage dashboardFileStorage = new DashboardFileStorage(FileProvider.GetFileInfo("Data/Dashboards").PhysicalPath);
                configurator.SetDashboardStorage(dashboardFileStorage);

                DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();

                // Registers an SQL data source.
                DashboardSqlDataSource sqlDataSource = new DashboardSqlDataSource("SQL Data Source", "NWindConnectionString");
                sqlDataSource.DataProcessingMode     = DataProcessingMode.Client;
                SelectQuery query = SelectQueryFluentBuilder
                                    .AddTable("Categories")
                                    .Join("Products", "CategoryID")
                                    .SelectAllColumns()
                                    .Build("Products_Categories");
                sqlDataSource.Queries.Add(query);
                dataSourceStorage.RegisterDataSource("sqlDataSource", sqlDataSource.SaveToXml());

                // Registers an Object data source.
                DashboardObjectDataSource objDataSource = new DashboardObjectDataSource("Object Data Source");
                dataSourceStorage.RegisterDataSource("objDataSource", objDataSource.SaveToXml());

                // Registers an Excel data source.
                DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource("Excel Data Source");
                excelDataSource.FileName      = FileProvider.GetFileInfo("Data/Sales.xlsx").PhysicalPath;
                excelDataSource.SourceOptions = new ExcelSourceOptions(new ExcelWorksheetSettings("Sheet1"));
                dataSourceStorage.RegisterDataSource("excelDataSource", excelDataSource.SaveToXml());

                configurator.SetDataSourceStorage(dataSourceStorage);

                configurator.DataLoading += (s, e) => {
                    if (e.DataSourceName == "Object Data Source")
                    {
                        e.Data = Invoices.CreateData();
                    }
                };
            });
            services.ConfigureReportingServices(configurator => {
                configurator.ConfigureReportDesigner(designerConfigurator => {
                    designerConfigurator.RegisterDataSourceWizardConfigFileConnectionStringsProvider();
                });
            });
            services.AddSpaStaticFiles(configuration => {
                configuration.RootPath = "ClientApp/dist";
            });
        }
Beispiel #15
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services
            .AddCors(options => {
                options.AddPolicy("CorsPolicy", builder => {
                    builder.WithOrigins("http://localhost:4200");
                    builder.WithMethods(new String[] { "GET", "POST" });
                    builder.WithHeaders("Content-Type");
                });
            })
            .AddResponseCompression()
            .AddDevExpressControls()
            .AddMvc()
            .AddDefaultDashboardController((configurator, serviceProvider) => {
                configurator.SetConnectionStringsProvider(new DashboardConnectionStringsProvider(Configuration));

                DashboardFileStorage dashboardFileStorage = new DashboardFileStorage(FileProvider.GetFileInfo("Data/Dashboards").PhysicalPath);
                configurator.SetDashboardStorage(dashboardFileStorage);

                DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();

                // Registers an SQL data source.
                DashboardSqlDataSource sqlDataSource = new DashboardSqlDataSource("SQL Data Source", "NWindConnectionString");
                sqlDataSource.DataProcessingMode     = DataProcessingMode.Client;
                SelectQuery query = SelectQueryFluentBuilder
                                    .AddTable("Categories")
                                    .Join("Products", "CategoryID")
                                    .SelectAllColumns()
                                    .Build("Products_Categories");
                sqlDataSource.Queries.Add(query);
                dataSourceStorage.RegisterDataSource("sqlDataSource", sqlDataSource.SaveToXml());

                // Registers an Object data source.
                DashboardObjectDataSource objDataSource = new DashboardObjectDataSource("Object Data Source");
                dataSourceStorage.RegisterDataSource("objDataSource", objDataSource.SaveToXml());

                // Registers an Excel data source.
                DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource("Excel Data Source");
                excelDataSource.FileName      = FileProvider.GetFileInfo("Data/Sales.xlsx").PhysicalPath;
                excelDataSource.SourceOptions = new ExcelSourceOptions(new ExcelWorksheetSettings("Sheet1"));
                dataSourceStorage.RegisterDataSource("excelDataSource", excelDataSource.SaveToXml());

                configurator.SetDataSourceStorage(dataSourceStorage);

                configurator.DataLoading += (s, e) => {
                    if (e.DataSourceName == "Object Data Source")
                    {
                        e.Data = Invoices.CreateData();
                    }
                };
            });
        }
        public DashboardExcelDataSource CreateExcelDataSource()
        {
            // Generates the Excel Data Source.
            DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource();

            excelDataSource.FileName = @"Data\SimpleDataSource.xls";
            ExcelWorksheetSettings worksheetSettings = new ExcelWorksheetSettings("Simple Data", "A1:F12");

            excelDataSource.SourceOptions = new ExcelSourceOptions(worksheetSettings);
            excelDataSource.Fill();

            return(excelDataSource);
        }
        public DashboardExcelDataSource CreateExcelDataSource()
        {
            // Generates the Excel Data Source.
            DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource();

            excelDataSource.FileName = @"Data\Sales.xlsx";
            ExcelWorksheetSettings worksheetSettings = new ExcelWorksheetSettings("Sheet1", "A1:I4166");

            excelDataSource.SourceOptions = new ExcelSourceOptions(worksheetSettings);
            excelDataSource.Fill();

            return(excelDataSource);
        }
Beispiel #18
0
        private static DashboardExcelDataSource CreateExcelDataSource()
        {
            DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource()
            {
                FileName      = @"Data\SalesPerson.xlsx",
                SourceOptions = new ExcelSourceOptions()
                {
                    ImportSettings = new ExcelWorksheetSettings("Data")
                }
            };

            excelDataSource.Fill();
            return(excelDataSource);
        }
Beispiel #19
0
        private ChartDashboardItem CreateChart(DashboardExcelDataSource excelDataSource)
        {
            ChartDashboardItem chart = new ChartDashboardItem();

            chart.Name        = string.Empty;
            chart.ShowCaption = false;
            chart.DataSource  = excelDataSource;
            chart.Arguments.Add(new Dimension("OrderDate", DateTimeGroupInterval.DayMonthYear));
            chart.Panes.Add(new ChartPane());
            SimpleSeries salesAmountSeries = new SimpleSeries(SimpleSeriesType.Line);

            salesAmountSeries.Value = new Measure("Extended Price");
            chart.Panes[0].Series.Add(salesAmountSeries);
            return(chart);
        }
Beispiel #20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DashboardFileStorage dashboardFileStorage = new DashboardFileStorage("~/App_Data/Dashboards");

            ASPxDashboard1.SetDashboardStorage(dashboardFileStorage);

            // Creates an Excel data source and selects the specific cell range from the SalesPerson worksheet.
            DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource("Excel Data Source");

            excelDataSource.ConnectionName = "xlsProducts";
            excelDataSource.FileName       = HostingEnvironment.MapPath(@"~/App_Data/ExcelDataSource.xlsx");
            ExcelWorksheetSettings worksheetSettings = new ExcelWorksheetSettings("SalesPerson", "A1:L2000");

            excelDataSource.SourceOptions = new ExcelSourceOptions(worksheetSettings);

            // Specifies the fields that will be available for the created data source.
            IExcelSchemaProvider schemaProvider = excelDataSource.GetService(typeof(IExcelSchemaProvider))
                                                  as IExcelSchemaProvider;

            FieldInfo[] availableFields = schemaProvider.GetSchema(excelDataSource.FileName, null,
                                                                   ExcelDocumentFormat.Xlsx, excelDataSource.SourceOptions, System.Threading.CancellationToken.None);
            List <string> fieldsToSelect = new List <string>()
            {
                "CategoryName", "ProductName", "Country", "Quantity",
                "Extended Price"
            };

            foreach (FieldInfo field in availableFields)
            {
                if (fieldsToSelect.Contains(field.Name))
                {
                    excelDataSource.Schema.Add(field);
                }
                else
                {
                    field.Selected = false;
                    excelDataSource.Schema.Add(field);
                }
            }

            // Adds the created data source to the data source storage.
            DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();

            dataSourceStorage.RegisterDataSource("excelDataSource", excelDataSource.SaveToXml());
            ASPxDashboard1.SetDataSourceStorage(dataSourceStorage);
        }
Beispiel #21
0
        public static void RegisterService(RouteCollection routes)
        {
            routes.MapDashboardRoute("dashboardControl");

            DashboardFileStorage dashboardFileStorage = new DashboardFileStorage("~/App_Data/Dashboards");

            DashboardConfigurator.Default.SetDashboardStorage(dashboardFileStorage);

            DashboardConfigurator.PassCredentials = true;

            // Uncomment this string to allow end users to create new data sources based on predefined connection strings.
            //DashboardConfigurator.Default.SetConnectionStringsProvider(new DevExpress.DataAccess.Web.ConfigFileConnectionStringsProvider());

            DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();

            // Configures an SQL data source.
            DashboardSqlDataSource sqlDataSource = new DashboardSqlDataSource("SQL Data Source", "NWindConnectionString");
            SelectQuery            query         = SelectQueryFluentBuilder
                                                   .AddTable("Orders")
                                                   .SelectAllColumnsFromTable()
                                                   .Build("SQL Orders");

            sqlDataSource.Queries.Add(query);

            // Configures an Object data source.
            DashboardObjectDataSource objDataSource = new DashboardObjectDataSource("Object Data Source");

            // Configures an Excel data source.
            DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource("Excel Data Source");

            excelDataSource.FileName      = HostingEnvironment.MapPath(@"~/App_Data/SalesPerson.xlsx");
            excelDataSource.SourceOptions = new ExcelSourceOptions(new ExcelWorksheetSettings("Data"));

            // Configures a JSON data source.
            DashboardJsonDataSource jsonDataSource = new DashboardJsonDataSource("JSON Data Source");
            Uri fileUri = new Uri(HostingEnvironment.MapPath(@"~/App_Data/Categories.json"), UriKind.RelativeOrAbsolute);

            jsonDataSource.JsonSource = new UriJsonSource(fileUri);

            // Registers a Federated data source.
            dataSourceStorage.RegisterDataSource("federatedDataSource", CreateFederatedDataSource(sqlDataSource,
                                                                                                  excelDataSource, objDataSource, jsonDataSource).SaveToXml());

            DashboardConfigurator.Default.SetDataSourceStorage(dataSourceStorage);
            DashboardConfigurator.Default.DataLoading += DataLoading;
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            // Creates the Excel data source.
            DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource();

            excelDataSource = CreateExcelDataSource();

            // Creates the Grid dashboard item and adds it to a dashboard.
            dashboardViewer1.Dashboard = new Dashboard();
            dashboardViewer1.Dashboard.DataSources.Add(excelDataSource);
            GridDashboardItem grid = CreateGrid(excelDataSource);

            dashboardViewer1.Dashboard.Items.Add(grid);

            // Reloads data in the data sources.
            dashboardViewer1.ReloadData();
        }
Beispiel #23
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DashboardFileStorage dashboardFileStorage = new DashboardFileStorage("~/App_Data/Dashboards");

            ASPxDashboard1.SetDashboardStorage(dashboardFileStorage);

            // Uncomment this string to allow end users to create new data sources based on predefined connection strings.
            //ASPxDashboard1.SetConnectionStringsProvider(new DevExpress.DataAccess.Web.ConfigFileConnectionStringsProvider());

            DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();

            // Configures an SQL data source.
            DashboardSqlDataSource sqlDataSource = new DashboardSqlDataSource("SQL Data Source", "NWindConnectionString");
            SelectQuery            query         = SelectQueryFluentBuilder
                                                   .AddTable("Orders")
                                                   .SelectAllColumnsFromTable()
                                                   .Build("SQL Orders");

            sqlDataSource.Queries.Add(query);

            // Configures an Object data source.
            DashboardObjectDataSource objDataSource = new DashboardObjectDataSource("Object Data Source");

            objDataSource.DataId = "odsInvoices";

            // Configures an Excel data source.
            DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource("Excel Data Source");

            excelDataSource.ConnectionName = "excelSales";
            excelDataSource.FileName       = HostingEnvironment.MapPath(@"~/App_Data/SalesPerson.xlsx");
            excelDataSource.SourceOptions  = new ExcelSourceOptions(new ExcelWorksheetSettings("Data"));

            // Configures a JSON data source.
            DashboardJsonDataSource jsonDataSource = new DashboardJsonDataSource("JSON Data Source");

            jsonDataSource.ConnectionName = "jsonCategories";
            Uri fileUri = new Uri(HostingEnvironment.MapPath(@"~/App_Data/Categories.json"), UriKind.RelativeOrAbsolute);

            jsonDataSource.JsonSource = new UriJsonSource(fileUri);

            // Registers a Federated data source.
            dataSourceStorage.RegisterDataSource("federatedDataSource", CreateFederatedDataSource(sqlDataSource,
                                                                                                  excelDataSource, objDataSource, jsonDataSource).SaveToXml());

            ASPxDashboard1.SetDataSourceStorage(dataSourceStorage);
        }
Beispiel #24
0
    public CustomDataSourceStorage()
    {
        DashboardSqlDataSource sqlDataSource = new DashboardSqlDataSource(sqlDataSourceId, "sqlCategories");
        SelectQuery            query         = SelectQueryFluentBuilder
                                               .AddTable("Categories")
                                               .SelectAllColumnsFromTable()
                                               .Build("Categories");

        query.Parameters.Add(new QueryParameter("CategoryNameStartsWith", typeof(DevExpress.DataAccess.Expression), new DevExpress.DataAccess.Expression("[Parameters.CategoryPattern]")));
        sqlDataSource.Queries.Add(query);

        DashboardJsonDataSource jsonDataSource = new DashboardJsonDataSource(jsonDataSourceId)
        {
            RootElement    = "Customers",
            ConnectionName = "jsonCustomers"
        };

        DashboardObjectDataSource objDataSource = new DashboardObjectDataSource(odsDataSourceId)
        {
            DataId = "odsSales"
        };

        DashboardOlapDataSource olapDataSource = new DashboardOlapDataSource(olapDataSourceId, "olapAdventureWorks");

        DashboardExtractDataSource extractDataSource = new DashboardExtractDataSource(extractDataSourceId)
        {
            ConnectionName = "extractSalesPerson"
        };

        DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource(excelDataSourceId)
        {
            ConnectionName = "excelSales",
            SourceOptions  = new ExcelSourceOptions(new ExcelWorksheetSettings("Sheet1"))
        };

        DashboardEFDataSource efDataSource = new DashboardEFDataSource(efDataSourceId, new EFConnectionParameters(typeof(NorthwindDbContext)));

        documents[sqlDataSourceId]     = new XDocument(sqlDataSource.SaveToXml());
        documents[jsonDataSourceId]    = new XDocument(jsonDataSource.SaveToXml());
        documents[odsDataSourceId]     = new XDocument(objDataSource.SaveToXml());
        documents[olapDataSourceId]    = new XDocument(olapDataSource.SaveToXml());
        documents[extractDataSourceId] = new XDocument(extractDataSource.SaveToXml());
        documents[excelDataSourceId]   = new XDocument(excelDataSource.SaveToXml());
        documents[efDataSourceId]      = new XDocument(efDataSource.SaveToXml());
    }
Beispiel #25
0
        private DateFilterDashboardItem CreateDateFilterItem(DashboardExcelDataSource excelDataSource)
        {
            DateFilterDashboardItem dateFilter = new DateFilterDashboardItem();

            dateFilter.Name        = string.Empty;
            dateFilter.ShowCaption = false;
            dateFilter.DataSource  = excelDataSource;
            dateFilter.Dimension   = new Dimension("orderDateId", "OrderDate", DateTimeGroupInterval.DayMonthYear);
            dateFilter.Dimension.DateTimeFormat.DateTimeFormat = DateTimeFormat.Short;
            dateFilter.ArrangementMode    = DateFilterArrangementMode.Vertical;
            dateFilter.FilterType         = DateFilterType.Between;
            dateFilter.DatePickerLocation = DatePickerLocation.Hidden;
            dateFilter.DateTimePeriods.AddRange(
                DateTimePeriod.CreateLastYear(),
                DateTimePeriod.CreateNextDays("Next 7 Days", 7),
                new DateTimePeriod
            {
                Name  = "Month-to-date",
                Start = new FlowDateTimePeriodLimit
                {
                    Interval = DateTimeInterval.Month,
                    Offset   = 0
                },
                End = new FlowDateTimePeriodLimit
                {
                    Interval = DateTimeInterval.Day,
                    Offset   = 1
                }
            },
                new DateTimePeriod
            {
                Name  = "Jul-18-2018 - Jan-18-2019",
                Start = new FixedDateTimePeriodLimit
                {
                    Date = new DateTime(2018, 7, 18)
                },
                End = new FixedDateTimePeriodLimit
                {
                    Date = new DateTime(2019, 1, 18)
                }
            }
                );
            return(dateFilter);
        }
        public ViewerForm1()
        {
            InitializeComponent();

            dashboardViewer.Dashboard = new Dashboard();

            // Creates a data source and adds it to the dashboard data source collection.
            DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource();

            excelDataSource = CreateExcelDataSource();
            dashboardViewer.Dashboard.DataSources.Add(excelDataSource);

            // Creates a card dashboard item with the specified data source
            // and adds it to the Items collection to display within the dashboard.
            CardDashboardItem cards = CreateCards(excelDataSource);

            dashboardViewer.Dashboard.Items.Add(cards);

            // Reloads data in the data sources.
            dashboardViewer.ReloadData();
        }
        public Form1()
        {
            InitializeComponent();

            Dashboard dashboard = new Dashboard();

            //Create an Excel data source.
            DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource();

            excelDataSource.FileName = @"..\..\Data\Sales.xlsx";
            ExcelWorksheetSettings worksheetSettings = new ExcelWorksheetSettings("Sheet1", "A1:I4166");

            excelDataSource.SourceOptions = new ExcelSourceOptions(worksheetSettings);
            excelDataSource.Fill();
            dashboard.DataSources.Add(excelDataSource);

            // Create a Choropleth Map dashboard item.
            ChoroplethMapDashboardItem map = new ChoroplethMapDashboardItem();

            map.Name                    = "Choropleth Map";
            map.DataSource              = excelDataSource;
            map.Legend.Visible          = true;
            map.ShapeTitleAttributeName = "NAME";
            map.AttributeName           = "NAME";
            map.AttributeDimension      = new Dimension("State");
            ValueMap revenueYTDMap = new ValueMap(new Measure("RevenueYTD (Sum)"));

            map.Maps.Add(revenueYTDMap);

            // Loads a custom shape file to the map.
            map.Area = ShapefileArea.Custom;
            CustomShapefileData data = new CustomShapefileData();

            data.ShapeData           = File.ReadAllBytes(@"..\..\Map\USA.shp");
            data.AttributeData       = File.ReadAllBytes(@"..\..\Map\USA.dbf");
            map.CustomShapefile.Data = data;

            dashboard.Items.Add(map);
            dashboardViewer.Dashboard = dashboard;
        }
Beispiel #28
0
        public void InitializeDashboard()
        {
            Dashboard dashboard = new Dashboard();
            DashboardSqlDataSource sqliteDataSource = CreateSQLiteDataSource();

            dashboard.DataSources.Add(sqliteDataSource);
            DashboardExcelDataSource exceldataSource = CreateExcelDataSource();

            dashboard.DataSources.Add(exceldataSource);
            DashboardObjectDataSource objectDataSource = CreateObjectDataSource();

            dashboard.DataSources.Add(objectDataSource);
            DashboardFederationDataSource federatedDS = CreateFederatedDataSource(sqliteDataSource, exceldataSource, objectDataSource);

            dashboard.DataSources.Add(federatedDS);

            PivotDashboardItem pivot = new PivotDashboardItem();

            pivot.DataMember = "FDS-Created-by-NodeBulder";
            pivot.DataSource = federatedDS;
            pivot.Rows.AddRange(new Dimension("CategoryName"), new Dimension("ProductName"));
            pivot.Columns.Add(new Dimension("SalesPerson"));
            pivot.Values.Add(new Measure("Extended Price"));

            ChartDashboardItem chart = new ChartDashboardItem();

            chart.DataSource = federatedDS;
            chart.DataMember = "FDS-Created-by-NodeBulder";
            chart.Arguments.Add(new Dimension("SalesPerson"));
            chart.Panes.Add(new ChartPane());
            SimpleSeries theSeries = new SimpleSeries(SimpleSeriesType.Bar);

            theSeries.Value = new Measure("Score");
            chart.Panes[0].Series.Add(theSeries);

            dashboard.Items.AddRange(pivot, chart);
            dashboard.RebuildLayout();
            dashboard.LayoutRoot.Orientation = DashboardLayoutGroupOrientation.Vertical;
            dashboardDesigner1.Dashboard     = dashboard;
        }
        private CardDashboardItem CreateCards(DashboardExcelDataSource dataSource)
        {
            // Creates a card dashboard item and specifies its data source.
            CardDashboardItem cards = new CardDashboardItem();

            cards.DataSource = dataSource;

            // Creates the Card object with measures that provide data for calculating actual and target
            // values, and then adds this object to the Cards collection of the card dashboard item.
            Card card = new Card();

            card.ActualValue = new Measure("RevenueQTD (Sum)");
            card.TargetValue = new Measure("RevenueQTDTarget (Sum)");
            cards.Cards.Add(card);

            // Specifies dimensions that provides data for a card dashboard item series.
            cards.SeriesDimensions.Add(new Dimension("Category"));
            cards.SeriesDimensions.Add(new Dimension("Product"));
            cards.InteractivityOptions.IsDrillDownEnabled = true;

            return(cards);
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            Dashboard dashboard = new Dashboard();

            DashboardExcelDataSource dataSource = CreateExcelDataSource();

            dashboard.DataSources.Add(dataSource);
            RangeFilterDashboardItem rangeFilter = CreateRangeFilter(dataSource);

            dashboard.Items.Add(rangeFilter);
            PivotDashboardItem pivot = CreatePivot(dataSource);

            dashboard.Items.Add(pivot);

            // Create the dashboard layout.
            dashboard.RebuildLayout();
            dashboard.LayoutRoot.FindRecursive(rangeFilter).Weight = 20;
            dashboard.LayoutRoot.FindRecursive(pivot).Weight       = 80;
            dashboard.LayoutRoot.Orientation = DashboardLayoutGroupOrientation.Vertical;

            dashboardViewer1.Dashboard = dashboard;
            dashboardViewer1.ReloadData();
        }