FAQ/ListReports.md
... ...
@@ -9,88 +9,75 @@ The ListReports method allows you to dynamically alter the list of reports that
9 9
##Sample Method (DatabaseAdHocConfig)
10 10
11 11
```csharp
12
-public override Izenda.AdHoc.ReportInfo[] ListReports()
13
-{
12
+public override Izenda.AdHoc.ReportInfo[] ListReports() {
14 13
/* BEGIN Database Mode Code Sample */
15
-
14
+
16 15
ArrayList reportNames = new ArrayList();
17
- string sql = String.Format("SELECT Name, CreatedDate, ModifiedDate FROM {0} ORDER BY Name",
18
- SavedReportsTable);
16
+ string sql = String.Format("SELECT Name, CreatedDate, ModifiedDate FROM {0} ORDER BY Name",
17
+ AdHocSettings.SavedReportsTable);
19 18
System.Data.IDbCommand command = null;
20
- try
21
- {
22
- command = Izenda.AdHoc.AdHocContext.Driver.CreateCommand(sql);
23
- System.Data.IDataReader reader = command.ExecuteReader();
24
-
25
- while (reader.Read())
26
- {
27
- string reportName = reader["Name"].ToString();
28
- DateTime createdDate = (DateTime)reader["CreatedDate"];
29
- DateTime modifiedDate = (DateTime)reader["ModifiedDate"];
30
- if (reportName != "")
31
- reportNames.Add(new Izenda.AdHoc.ReportInfo(reportName, false, createdDate, modifiedDate));
32
- }
19
+ try {
20
+ command = Izenda.AdHoc.AdHocContext.Driver.CreateCommand(sql);
21
+ System.Data.IDataReader reader = command.ExecuteReader();
22
+
23
+ while (reader.Read()) {
24
+ string reportName = reader["Name"].ToString();
25
+ DateTime createdDate = (DateTime)reader["CreatedDate"];
26
+ DateTime modifiedDate = (DateTime)reader["ModifiedDate"];
27
+ if (reportName != "")
28
+ reportNames.Add(new Izenda.AdHoc.ReportInfo(reportName, false, createdDate, modifiedDate));
33 29
}
34
- catch (Exception) { }
35
-
36
- if (command.Connection.State == System.Data.ConnectionState.Open)
37
- command.Connection.Close();
38
- return (Izenda.AdHoc.ReportInfo[])reportNames.ToArray(typeof(Izenda.AdHoc.ReportInfo));
39
- /* END Database Mode Code Sample */
30
+ }
31
+ catch (Exception) { }
32
+
33
+ if (command.Connection.State == System.Data.ConnectionState.Open)
34
+ command.Connection.Close();
35
+ return (Izenda.AdHoc.ReportInfo[])reportNames.ToArray(typeof(Izenda.AdHoc.ReportInfo));
36
+ /* END Database Mode Code Sample */
37
+}
38
+
40 39
```
41 40
42 41
##Sample Method (FileSystemAdHocConfig)
43 42
44 43
```csharp
45
- /* BEGIN Filesystem Mode Code Sample */
46
- ArrayList reportNames = new ArrayList();
47
-
48
- if (ReportPath != null)
49
- {
50
- DirectoryInfo dir = new DirectoryInfo(ReportPath);
51
- if (dir.Exists)
52
- {
53
- string dirName = Path.GetFullPath(dir.FullName);
54
- ArrayList fileArray = new ArrayList();
55
- GetAllXmlFiles(dir, fileArray);
56
- FileInfo[] files = (FileInfo[])fileArray.ToArray(typeof(FileInfo));
57
- foreach (FileInfo file in files)
58
- {
59
- if (file.Extension == ".xml")
60
- {
61
- try
62
- {
63
- StreamReader reader = file.OpenText();
64
- reader.Close();
65
- }
66
- catch (Exception)
67
- {
68
- continue;
69
- }
70
- bool readOnly = false;
71
- try
72
- {
73
- StreamWriter writer = file.AppendText();
74
- writer.Close();
75
- }
76
- catch (Exception)
77
- {
78
- readOnly = true;
79
- }
80
-
81
- string fileName = Path.GetFullPath(file.FullName);
82
- string reportName = fileName.Substring(dirName.Length + (dirName.EndsWith("\\")?0:1));
83
- reportName = StringHelper.TrimEnd(reportName, ".xml");
84
- reportNames.Add(new ReportInfo(reportName, readOnly, file.CreationTime,
85
- file.LastWriteTime));
86
- }//end if
87
- }//end foreach
88
- }//end if
89
- }//end if
90
- //string[] reportNamesArray = new string[reportNames.Count];
91
- //reportNames.CopyTo(reportNamesArray, 0);
92
- //return (ReportInfo[])reportNames.ToArray(typeof(ReportInfo));
93
-
94
- /* END Filesystem Mode Code Sample */
95
-}
44
+/* BEGIN Filesystem Mode Code Sample */
45
+
46
+public override ReportInfo[] ListReports() {
47
+ ArrayList reportNames = new ArrayList();
48
+
49
+ if (ReportPath != null) {
50
+ DirectoryInfo dir = new DirectoryInfo(ReportPath);
51
+ if (dir.Exists) {
52
+ string dirName = Path.GetFullPath(dir.FullName);
53
+ ArrayList fileArray = new ArrayList();
54
+ GetAllXmlFiles(dir, fileArray);
55
+ FileInfo[] files = (FileInfo[])fileArray.ToArray(typeof(FileInfo));
56
+ foreach (FileInfo file in files) {
57
+ if (file.Extension == ".xml") {
58
+ try {
59
+ StreamReader reader = file.OpenText();
60
+ reader.Close();
61
+ }
62
+ catch (Exception) {
63
+ continue;
64
+ }
65
+ bool readOnly = false;
66
+ try {
67
+ StreamWriter writer = file.AppendText();
68
+ writer.Close();
69
+ }
70
+ catch (Exception) {
71
+ readOnly = true;
72
+ }
73
+ string fileName = Path.GetFullPath(file.FullName);
74
+ string reportName = fileName.Substring(dirName.Length + (dirName.EndsWith("\\") ? 0 : 1));
75
+ reportName = StringHelper.TrimEnd(reportName, ".xml");
76
+ reportNames.Add(new ReportInfo(reportName, readOnly, file.CreationTime,
77
+ file.LastWriteTime));
78
+ }
79
+ }//end foreach
80
+ }//end if
81
+ }//end if
82
+}//end method
96 83
```
... ...
\ No newline at end of file