-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomDataSourceStorage.cs
66 lines (54 loc) · 2.93 KB
/
CustomDataSourceStorage.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using DevExpress.DashboardCommon;
using DevExpress.DashboardWeb;
using DevExpress.DataAccess.EntityFramework;
using DevExpress.DataAccess.Excel;
using DevExpress.DataAccess.Sql;
using System.Collections.Generic;
using System.Xml.Linq;
public class CustomDataSourceStorage : IDataSourceStorage {
private Dictionary<string, XDocument> documents = new Dictionary<string, XDocument>();
private const string sqlDataSourceId = "SQL Data Source";
private const string jsonDataSourceId = "JSON Data Source";
private const string odsDataSourceId = "Object Data Source";
private const string olapDataSourceId = "OLAP Data Source";
private const string excelDataSourceId = "Excel Data Source";
private const string extractDataSourceId = "Extract Data Source";
private const string efDataSourceId = "Entity Framework Data Source";
public CustomDataSourceStorage() {
DashboardSqlDataSource sqlDataSource = new DashboardSqlDataSource(sqlDataSourceId, "sqlCategories");
SelectQuery query = SelectQueryFluentBuilder
.AddTable("Categories")
.SelectAllColumnsFromTable()
.Build("Categories");
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());
}
public XDocument GetDataSource(string dataSourceID) {
return documents[dataSourceID];
}
public IEnumerable<string> GetDataSourcesID() {
return documents.Keys;
}
}