// ===========================================================================
public void Write(Stream stream) {
// step 1
using (Document document = new Document()) {
// step 2
PdfWriter.GetInstance(document, stream);
// step 3
document.Open();
// step 4
var SQL =
@"SELECT DISTINCT mc.country_id, c.country, count(*) AS c
FROM film_country c, film_movie_country mc
WHERE c.id = mc.country_id
GROUP BY mc.country_id, country ORDER BY c DESC";
// Create a list for the countries
List list = new RomanList();
// loop over the countries
using (var c = AdoDB.Provider.CreateConnection()) {
c.ConnectionString = AdoDB.CS;
using (DbCommand cmd = c.CreateCommand()) {
cmd.CommandText = SQL;
c.Open();
using (var r = cmd.ExecuteReader()) {
while (r.Read()) {
// create a list item for the country
ListItem item = new ListItem(
string.Format("{0}: {1} movies",
r["country"].ToString(), r["c"].ToString()
)
);
// Create a list for the movies
List movielist = new GreekList();
movielist.Lowercase = List.LOWERCASE;
// Loop over the movies
foreach (Movie movie in
PojoFactory.GetMovies(r["country_id"].ToString())
) {
ListItem movieitem = new ListItem(movie.MovieTitle);
// Create a list for the directors
List directorlist = new ZapfDingbatsNumberList(0);
// Loop over the directors
foreach (Director director in movie.Directors) {
directorlist.Add(String.Format("{0}, {1}",
director.Name, director.GivenName
));
}
movieitem.Add(directorlist);
movielist.Add(movieitem);
}
item.Add(movielist);
list.Add(item);
}
document.Add(list);
}
}
}
}
}