public CustomDataSourceStorage() { DashboardSqlDataSource sqlDataSource1 = new DashboardSqlDataSource(sqlDataSourceId1, "NorthwindConnectionString"); SelectQuery query1 = SelectQueryFluentBuilder .AddTable("Categories") .SelectAllColumnsFromTable() .Build("Categories"); sqlDataSource1.Queries.Add(query1); SelectQuery query2 = SelectQueryFluentBuilder .AddTable("Products") .SelectAllColumnsFromTable() .Build("Products"); sqlDataSource1.Queries.Add(query2); DashboardSqlDataSource sqlDataSource2 = new DashboardSqlDataSource(sqlDataSourceId2, "CarsXtraSchedulingConnectionString"); SelectQuery query = SelectQueryFluentBuilder .AddTable("Cars") .SelectAllColumnsFromTable() .Build("Cars"); sqlDataSource2.Queries.Add(query); DashboardJsonDataSource jsonDataSource = new DashboardJsonDataSource(jsonDataSourceId); jsonDataSource.JsonSource = new UriJsonSource(new Uri("https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/customers.json")); jsonDataSource.RootElement = "Customers"; documents[sqlDataSourceId1] = new XDocument(sqlDataSource1.SaveToXml()); documents[sqlDataSourceId2] = new XDocument(sqlDataSource2.SaveToXml()); documents[jsonDataSourceId] = new XDocument(jsonDataSource.SaveToXml()); }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddMvc() .AddDefaultDashboardController(configurator => { // Register Dashboard Storage configurator.SetDashboardStorage(new DashboardFileStorage(_physicalProvider.GetFileInfo("App_Data/Dashboards").PhysicalPath)); // Create a sample JSON data source DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage(); DashboardJsonDataSource jsonDataSourceUrl = new DashboardJsonDataSource("JSON Data Source (URL)"); jsonDataSourceUrl.JsonSource = new UriJsonSource(new Uri("https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/customers.json")); jsonDataSourceUrl.RootElement = "Customers"; jsonDataSourceUrl.Fill(); dataSourceStorage.RegisterDataSource("jsonDataSourceUrl", jsonDataSourceUrl.SaveToXml()); configurator.SetDataSourceStorage(dataSourceStorage); configurator.SetConnectionStringsProvider(new DashboardConnectionStringsProvider(Configuration)); configurator.AllowExecutingCustomSql = true; }); services.AddRazorPages(); services.AddServerSideBlazor(); services.AddHttpContextAccessor(); services.AddSingleton <XpoDataStoreProviderAccessor>(); services.AddScoped <CircuitHandler, CircuitHandlerProxy>(); services.AddXaf <XAFBlazorDashboardsBlazorApplication>(Configuration); }
public static void ConfigureDataSource(DashboardConfigurator configurator, DataSourceInMemoryStorage storage, IFileProvider fileProvider) { // Registers a JSON data source from URL. DashboardJsonDataSource jsonDataSourceUrl = new DashboardJsonDataSource("JSON Data Source (URL)"); jsonDataSourceUrl.JsonSource = new UriJsonSource(new Uri("https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/customers.json")); jsonDataSourceUrl.RootElement = "Customers"; jsonDataSourceUrl.Fill(); storage.RegisterDataSource("jsonDataSourceUrl", jsonDataSourceUrl.SaveToXml()); // Registers a JSON data source from a JSON file. DashboardJsonDataSource jsonDataSourceFile = new DashboardJsonDataSource("JSON Data Source (File)"); jsonDataSourceFile.ConnectionName = "jsonConnection"; jsonDataSourceFile.RootElement = "Customers"; storage.RegisterDataSource("jsonDataSourceFile", jsonDataSourceFile.SaveToXml()); // Registers a JSON data source from JSON string. DashboardJsonDataSource jsonDataSourceString = new DashboardJsonDataSource("JSON Data Source (String)"); string json = "{\"Customers\":[{\"Id\":\"ALFKI\",\"CompanyName\":\"Alfreds Futterkiste\",\"ContactName\":\"Maria Anders\",\"ContactTitle\":\"Sales Representative\",\"Address\":\"Obere Str. 57\",\"City\":\"Berlin\",\"PostalCode\":\"12209\",\"Country\":\"Germany\",\"Phone\":\"030-0074321\",\"Fax\":\"030-0076545\"}],\"ResponseStatus\":{}}"; jsonDataSourceString.JsonSource = new CustomJsonSource(json); jsonDataSourceString.RootElement = "Customers"; storage.RegisterDataSource("jsonDataSourceString", jsonDataSourceString.SaveToXml()); JsonDataSourceConfigurator.fileProvider = fileProvider; configurator.ConfigureDataConnection += Configurator_ConfigureDataConnection; }
public void InitializeDashboard() { Dashboard dashboard = new Dashboard(); DashboardJsonDataSource jsonDataSource = CreateJsonDataSourceFromWeb(); //DashboardJsonDataSource jsonDataSource = CreateJsonDataSourceFromFile(); //DashboardJsonDataSource jsonDataSource = CreateJsonDataSourceFromString(); dashboard.DataSources.Add(jsonDataSource); PivotDashboardItem pivot = new PivotDashboardItem(); pivot.DataSource = jsonDataSource; pivot.Rows.Add(new Dimension("ContactTitle")); pivot.Columns.Add(new Dimension("Country")); pivot.Values.Add(new Measure("Id", SummaryType.Count)); ChartDashboardItem chart = new ChartDashboardItem(); chart.DataSource = jsonDataSource; chart.Arguments.Add(new Dimension("Country")); chart.Panes.Add(new ChartPane()); SimpleSeries theSeries = new SimpleSeries(SimpleSeriesType.Bar); theSeries.Value = new Measure("Id", SummaryType.Count); chart.Panes[0].Series.Add(theSeries); dashboard.Items.AddRange(pivot, chart); dashboard.RebuildLayout(); dashboard.LayoutRoot.Orientation = DashboardLayoutGroupOrientation.Vertical; dashboardDesigner1.Dashboard = dashboard; }
public void ConfigureServices(IServiceCollection services) { services.AddResponseCompression(opts => { opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat( new[] { "application/octet-stream" }); }); services.AddDevExpressControls(); services.AddMvc() .AddDefaultDashboardController(configurator => { // Register Dashboard Storage configurator.SetDashboardStorage(new DashboardFileStorage(_physicalProvider.GetFileInfo("App_Data/Dashboards").PhysicalPath)); // Create a sample JSON data source DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage(); DashboardJsonDataSource jsonDataSourceUrl = new DashboardJsonDataSource("JSON Data Source (URL)"); jsonDataSourceUrl.JsonSource = new UriJsonSource(new Uri("https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/customers.json")); jsonDataSourceUrl.RootElement = "Customers"; jsonDataSourceUrl.Fill(); dataSourceStorage.RegisterDataSource("jsonDataSourceUrl", jsonDataSourceUrl.SaveToXml()); configurator.SetDataSourceStorage(dataSourceStorage); configurator.SetConnectionStringsProvider(new DashboardConnectionStringsProvider(Configuration)); configurator.AllowExecutingCustomSql = true; }); services.AddRazorPages(); services.AddServerSideBlazor(); services.AddSingleton <WeatherForecastService>(); }
public DataSourceInMemoryStorage CreateDataSourceStorage() { DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage(); DashboardJsonDataSource jsonDataSource = new DashboardJsonDataSource("Customers"); jsonDataSource.RootElement = "Customers"; dataSourceStorage.RegisterDataSource("jsonDataSourceSupport", jsonDataSource.SaveToXml()); return(dataSourceStorage); }
public static DashboardJsonDataSource CreateJsonDataSourceFromWeb() { var jsonDataSource = new DashboardJsonDataSource(); jsonDataSource.JsonSource = new UriJsonSource(new Uri("https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/customers.json")); jsonDataSource.RootElement = "Customers"; jsonDataSource.Fill(); return(jsonDataSource); }
public static DashboardJsonDataSource CreateJsonDataSourceFromString() { var jsonDataSource = new DashboardJsonDataSource(); string json = "{\"Customers\":[{\"Id\":\"ALFKI\",\"CompanyName\":\"Alfreds Futterkiste\",\"ContactName\":\"Maria Anders\",\"ContactTitle\":\"Sales Representative\",\"Address\":\"Obere Str. 57\",\"City\":\"Berlin\",\"PostalCode\":\"12209\",\"Country\":\"Germany\",\"Phone\":\"030-0074321\",\"Fax\":\"030-0076545\"}],\"ResponseStatus\":{}}"; jsonDataSource.JsonSource = new CustomJsonSource(json); jsonDataSource.RootElement = "Customers"; jsonDataSource.Fill(); return(jsonDataSource); }
public static DashboardJsonDataSource CreateJsonDataSourceFromFile() { var jsonDataSource = new DashboardJsonDataSource(); Uri fileUri = new Uri("customers.json", UriKind.RelativeOrAbsolute); jsonDataSource.JsonSource = new UriJsonSource(fileUri); jsonDataSource.RootElement = "Customers"; jsonDataSource.Fill(); return(jsonDataSource); }
public DataSourceInMemoryStorage CreateDataSourceStorage() { DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage(); DashboardJsonDataSource jsonDataSourceSupport = new DashboardJsonDataSource("Support"); jsonDataSourceSupport.RootElement = "Employee"; dataSourceStorage.RegisterDataSource("jsonDataSourceSupport", jsonDataSourceSupport.SaveToXml()); DashboardJsonDataSource jsonDataSourceCategories = new DashboardJsonDataSource("Categories"); //jsonDataSourceCategories.RootElement = ""; dataSourceStorage.RegisterDataSource("jsonDataSourceCategories", jsonDataSourceCategories.SaveToXml()); return(dataSourceStorage); }
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; }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddResponseCompression(opts => { opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat( new[] { "application/octet-stream" }); }); services.AddDevExpressControls(); services.AddMvc().AddJsonOptions(options => options.JsonSerializerOptions.PropertyNamingPolicy = null) .AddDefaultDashboardController(configurator => { // Register Dashboard Storage configurator.SetDashboardStorage(new DashboardFileStorage(_physicalProvider.GetFileInfo("AppData/Dashboards").PhysicalPath)); // Create a sample JSON data source DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage(); DashboardJsonDataSource jsonDataSourceUrl = new DashboardJsonDataSource("JSON Data Source (URL)"); jsonDataSourceUrl.JsonSource = new UriJsonSource(new Uri("https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/customers.json")); jsonDataSourceUrl.RootElement = "Customers"; jsonDataSourceUrl.Fill(); dataSourceStorage.RegisterDataSource("jsonDataSourceUrl", jsonDataSourceUrl.SaveToXml()); configurator.SetDataSourceStorage(dataSourceStorage); configurator.SetConnectionStringsProvider(new DashboardConnectionStringsProvider(Configuration)); configurator.AllowExecutingCustomSql = true; }); services.AddRazorPages(); services.AddServerSideBlazor(); services.AddHttpContextAccessor(); services.AddSingleton <XpoDataStoreProviderAccessor>(); services.AddScoped <CircuitHandler, CircuitHandlerProxy>(); services.AddXaf <SonTungERPBlazorApplication>(Configuration); services.AddXafReporting(); services.AddXafSecurity(options => { options.RoleType = typeof(DevExpress.Persistent.BaseImpl.PermissionPolicy.PermissionPolicyRole); options.UserType = typeof(DevExpress.Persistent.BaseImpl.PermissionPolicy.PermissionPolicyUser); options.Events.OnSecurityStrategyCreated = securityStrategy => ((SecurityStrategy)securityStrategy).RegisterXPOAdapterProviders(); options.SupportNavigationPermissionsForTypes = false; }).AddExternalAuthentication <HttpContextPrincipalProvider>() .AddAuthenticationStandard(options => { options.IsSupportChangePassword = true; }); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(options => { options.LoginPath = "/LoginPage"; }); }
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); }
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()); }
protected void Page_Load(object sender, EventArgs e) { DashboardFileStorage dashboardFileStorage = new DashboardFileStorage("~/App_Data/Dashboards"); ASPxDashboardJson.SetDashboardStorage(dashboardFileStorage); // Uncomment the next line to allow users to create new data sources based on predefined connection strings. //ASPxDashboardJson.SetConnectionStringsProvider(new DevExpress.DataAccess.Web.ConfigFileConnectionStringsProvider()); // Create a data source storage. DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage(); // Register a JSON data source from a URL. DashboardJsonDataSource jsonDataSourceUrl = new DashboardJsonDataSource("JSON Data Source (URL)"); jsonDataSourceUrl.ConnectionName = "jsonUrlConnection"; jsonDataSourceUrl.RootElement = "Employee"; dataSourceStorage.RegisterDataSource("jsonDataSourceUrl", jsonDataSourceUrl.SaveToXml()); // Register a JSON data source from a JSON file. DashboardJsonDataSource jsonDataSourceFile = new DashboardJsonDataSource("JSON Data Source (File)"); jsonDataSourceFile.ConnectionName = "jsonFileConnection"; jsonDataSourceFile.RootElement = "Customers"; dataSourceStorage.RegisterDataSource("jsonDataSourceFile", jsonDataSourceFile.SaveToXml()); // Register a JSON data source from a JSON string. DashboardJsonDataSource jsonDataSourceString = new DashboardJsonDataSource("JSON Data Source (String)"); jsonDataSourceString.ConnectionName = "jsonStringConnection"; jsonDataSourceString.RootElement = "Customers"; dataSourceStorage.RegisterDataSource("jsonDataSourceString", jsonDataSourceString.SaveToXml()); // Set the configured data source storage. ASPxDashboardJson.SetDataSourceStorage(dataSourceStorage); ASPxDashboardJson.ConfigureDataConnection += ASPxDashboardJson_ConfigureDataConnection; ASPxDashboardJson.InitialDashboardId = "dashboardJson"; }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddRazorPages(); services.AddServerSideBlazor(); services.AddMvc(); services.AddScoped <DashboardConfigurator>((IServiceProvider serviceProvider) => { DashboardConfigurator configurator = new DashboardConfigurator(); // Register Dashboard Storage configurator.SetDashboardStorage(new DashboardFileStorage(FileProvider.GetFileInfo("App_Data/Dashboards").PhysicalPath)); // Create a sample JSON data source DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage(); DashboardJsonDataSource jsonDataSourceUrl = new DashboardJsonDataSource("JSON Data Source (URL)"); jsonDataSourceUrl.JsonSource = new UriJsonSource( new Uri("https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/customers.json")); jsonDataSourceUrl.RootElement = "Customers"; dataSourceStorage.RegisterDataSource("jsonDataSourceUrl", jsonDataSourceUrl.SaveToXml()); configurator.SetDataSourceStorage(dataSourceStorage); return(configurator); }); }
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); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services .AddResponseCompression() .AddDevExpressControls() .AddMvc(); services.AddScoped <DashboardConfigurator>((IServiceProvider serviceProvider) => { DashboardConfigurator configurator = new DashboardConfigurator(); configurator.SetConnectionStringsProvider(new DashboardConnectionStringsProvider(Configuration)); DashboardFileStorage dashboardFileStorage = new DashboardFileStorage(FileProvider.GetFileInfo("Data/Dashboards").PhysicalPath); configurator.SetDashboardStorage(dashboardFileStorage); DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage(); // Configures an SQL data source. DashboardSqlDataSource sqlDataSource = new DashboardSqlDataSource("SQL Data Source", "NWindConnectionString"); sqlDataSource.DataProcessingMode = DataProcessingMode.Client; 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 = FileProvider.GetFileInfo("Data/SalesPerson.xlsx").PhysicalPath; 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(FileProvider.GetFileInfo("Data/Categories.json").PhysicalPath, UriKind.RelativeOrAbsolute); jsonDataSource.JsonSource = new UriJsonSource(fileUri); // Registers a Federated data source. dataSourceStorage.RegisterDataSource("federatedDataSource", CreateFederatedDataSource(sqlDataSource, excelDataSource, objDataSource, jsonDataSource).SaveToXml()); configurator.SetDataSourceStorage(dataSourceStorage); configurator.DataLoading += (s, e) => { if (e.DataId == "odsInvoices") { e.Data = Invoices.CreateData(); } }; configurator.ConfigureDataConnection += (s, e) => { if (e.ConnectionName == "excelSales") { (e.ConnectionParameters as ExcelDataSourceConnectionParameters).FileName = FileProvider.GetFileInfo("Data/SalesPerson.xlsx").PhysicalPath; } else if (e.ConnectionName == "jsonCategories") { UriJsonSource source = new UriJsonSource(new Uri(FileProvider.GetFileInfo("Data/Categories.json").PhysicalPath, UriKind.RelativeOrAbsolute)); (e.ConnectionParameters as JsonSourceConnectionParameters).JsonSource = source; } }; return(configurator); }); }