/
ReportStorageWebExtension.cs
57 lines (47 loc) · 1.5 KB
/
ReportStorageWebExtension.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
using System.Collections.Generic;
using System.IO;
using DevExpress.XtraReports.Web.Extensions;
using DevExpress.XtraReports.UI;
namespace DXWebApplication1 {
public class ReportStorageWebExtension1 : ReportStorageWebExtension {
private string brokenReportLayoutPath;
public ReportStorageWebExtension1(string brokenReportLayoutPath) {
this.brokenReportLayoutPath = brokenReportLayoutPath;
}
public override bool CanSetData(string url) {
return base.CanSetData(url);
}
public override bool IsValidUrl(string url) {
return url != "invalidUrl";
}
public override byte[] GetData(string url) {
XtraReport report;
if (url == "brokenReportLayout") {
report = XtraReport.FromFile(brokenReportLayoutPath);
} else if (url == "fileNotFound") {
report = XtraReport.FromFile(url);
} else if (url == "reportWithCustomException") {
report = new XtraReport1();
} else if (url == "reportWithException") {
report = new XtraReport2();
} else if (url == "ValidReport") {
report = new XtraReport3();
}
else
throw new KeyNotFoundException();
using (var ms = new MemoryStream()) {
report.SaveLayoutToXml(ms);
return ms.ToArray();
}
}
public override Dictionary<string, string> GetUrls() {
return base.GetUrls();
}
public override void SetData(XtraReport report, string url) {
base.SetData(report, url);
}
public override string SetNewData(XtraReport report, string defaultUrl) {
return base.SetNewData(report, defaultUrl);
}
}
}