public static void ConfigureDataSource(DashboardConfigurator configurator, DataSourceInMemoryStorage storage)
        {
            // Registers an Extract data source.
            DashboardExtractDataSource extractDataSource = new DashboardExtractDataSource("Extract Data Source");

            extractDataSource.Name           = "Extract Data Source";
            extractDataSource.ConnectionName = "dataExtract";
            storage.RegisterDataSource("extractDataSource ", extractDataSource.SaveToXml());

            configurator.ConfigureDataConnection += Configurator_ConfigureDataConnection;
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DashboardFileStorage newDashboardStorage = new DashboardFileStorage(HostingEnvironment.MapPath(@"~/App_Data/Dashboards"));

            ASPxDashboard1.SetDashboardStorage(newDashboardStorage);

            ASPxDashboard1.SetConnectionStringsProvider(new ConfigFileConnectionStringsProvider());
            DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();

            DashboardExtractDataSource extractDataSource = new DashboardExtractDataSource("Extract Data Source");

            extractDataSource.ConnectionName = "edsSales";
            dataSourceStorage.RegisterDataSource("extractDataSource", extractDataSource.SaveToXml());
            ASPxDashboard1.SetDataSourceStorage(dataSourceStorage);
        }
Esempio n. 3
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());
    }
        protected void Page_Load(object sender, EventArgs e)
        {
            DashboardFileStorage dashboardFileStorage = new DashboardFileStorage("~/App_Data/Dashboards");

            ASPxDashboardExtract.SetDashboardStorage(dashboardFileStorage);

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

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

            // Register an Extract data source.
            DashboardExtractDataSource extractDataSource = new DashboardExtractDataSource("Extract Data Source");

            extractDataSource.ConnectionName = "extractDataConnection";
            dataSourceStorage.RegisterDataSource("extractDataSource ", extractDataSource.SaveToXml());

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

            ASPxDashboardExtract.ConfigureDataConnection += ASPxDashboardExtract_ConfigureDataConnection;
            ASPxDashboardExtract.InitialDashboardId       = "dashboardExtract";
        }
        static IDashboardDataSource CreateDataSourceCopy(IDashboardDataSource dataSourceToCopy)
        {
            DashboardEFDataSource efDataSource = dataSourceToCopy as DashboardEFDataSource;

            if (efDataSource != null)
            {
                XElement element = efDataSource.SaveToXml();
                DashboardEFDataSource newDataSource = new DashboardEFDataSource();
                newDataSource.LoadFromXml(element);
                newDataSource.Fill();
                return(newDataSource);
            }

            DashboardExcelDataSource excelDataSource = dataSourceToCopy as DashboardExcelDataSource;

            if (excelDataSource != null)
            {
                XElement element = excelDataSource.SaveToXml();
                DashboardExcelDataSource newDataSource = new DashboardExcelDataSource();
                newDataSource.LoadFromXml(element);
                newDataSource.Fill();
                return(newDataSource);
            }

            DashboardExtractDataSource extractDataSource = dataSourceToCopy as DashboardExtractDataSource;

            if (extractDataSource != null)
            {
                XElement element = extractDataSource.SaveToXml();
                DashboardExtractDataSource newDataSource = new DashboardExtractDataSource();
                newDataSource.LoadFromXml(element);
                return(newDataSource);
            }

            DashboardObjectDataSource objectDataSource = dataSourceToCopy as DashboardObjectDataSource;

            if (objectDataSource != null)
            {
                XElement element = objectDataSource.SaveToXml();
                DashboardObjectDataSource newDataSource = new DashboardObjectDataSource();
                newDataSource.LoadFromXml(element);
                newDataSource.Fill();
                return(newDataSource);
            }

            DashboardOlapDataSource olapDataSource = dataSourceToCopy as DashboardOlapDataSource;

            if (olapDataSource != null)
            {
                XElement element = olapDataSource.SaveToXml();
                DashboardOlapDataSource newDataSource = new DashboardOlapDataSource();
                newDataSource.LoadFromXml(element);
                newDataSource.Fill();
                return(newDataSource);
            }

            DashboardSqlDataSource sqlDataSource = dataSourceToCopy as DashboardSqlDataSource;

            if (sqlDataSource != null)
            {
                XElement element = sqlDataSource.SaveToXml();
                DashboardSqlDataSource newDataSource = new DashboardSqlDataSource();
                newDataSource.LoadFromXml(element);
                newDataSource.Fill();
                return(newDataSource);
            }
            return(null);
        }