Click here to Skip to main content
15,885,366 members
Articles / Web Development / ASP.NET

Race to Linux - Race 3: Reports Starter Kit using Mono SqlServer/Firebird

Rate me:
Please Sign up or sign in to vote.
2.33/5 (2 votes)
30 Sep 20052 min read 52.7K   328   15  
Reports Starter Kit port to Linux using Mono
<%@ Page EnableSessionState="False" EnableViewState="False" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.IO" %>
<html>
	<head>
		<script language="C#" runat="server">

    String width = "100%";
    String path;
    String font;

    void Page_Load(Object sender, EventArgs e) {

        // Handle .src Path
        
        path = Request.QueryString["path"];
        PopulateNavigationList(path);
        
        string file = Request.QueryString["file"];
        lblTitle.Text = file;
        
        Image1.ImageUrl = "../images/" + file.ToLower() + ".gif";
    }

    void PopulateNavigationList(String path) {

        FileStream fs = new FileStream(Server.MapPath(path), FileMode.Open, FileAccess.Read);
        StreamReader sr = new StreamReader(fs);
        String fileName;

        char [] c1 = { ':' };
        char [] c2 = { ',' };
        String line;

        while ( (line = sr.ReadLine()) != null ) {

            String [] list = line.Split(c1);

            if (list.Length > 1) {

                TableRow row = new TableRow();

                // Construct Group Label for Items

                String sourcegroup = list[0];

                TableCell groupCell = new TableCell();
                groupCell.Text = "<nobr>" + sourcegroup + ": </nobr>";
                groupCell.CssClass ="red";
                row.Cells.Add(groupCell);


                // Construct List of Items

                String [] sourcelist = list[1].Split(c2);

                if ((sourcelist.Length>0)) {
                    fileName = Server.MapPath("~/docs/" + ParseItem(sourcelist[0]).HRef).ToLower();
                }

                StringBuilder sb = new StringBuilder();

                for (int i=0; i< sourcelist.Length; i++) {

                    ItemDetails item = ParseItem(sourcelist[i]);
                    sb.Append("<a class='red' target=docFrame href='" + (Request.ApplicationPath=="/"?"":Request.ApplicationPath) + "/docs/" + item.HRef.ToLower() + "'>");
                    sb.Append(item.Description);
                    sb.Append("</a>&nbsp;&nbsp; ");
                }

                TableCell itemCell = new TableCell();
                itemCell.Text = sb.ToString();
                itemCell.CssClass ="SourceList";
                row.Cells.Add(itemCell);

                SourceTable.Rows.Add(row);
            }
        }

        fs.Close();
    }

    public ItemDetails ParseItem(String item) {

        char [] c3 = { '|' };

        String [] itemParts = item.Split(c3);

        if (itemParts == null) {
            return null;
        }

        ItemDetails itemDetails = new ItemDetails();

        if (itemParts.Length > 1) {
            itemDetails.Description = itemParts[0];
            itemDetails.HRef = itemParts[1];
        }
        else {
            itemDetails.Description = itemParts[0];
            itemDetails.HRef = itemParts[0];
        }

        return itemDetails;
    }

    public class ItemDetails {
        public String Description;
        public String HRef;
    }

		</script>
		<link rel="stylesheet" href="../styles.css">
	</head>
	<body leftmargin="0" bottommargin="0" rightmargin="0" topmargin="0" marginheight="0" marginwidth="0">
		<form runat="server" ID="Form1">
			<table width="100%" border="0" cellpadding="0" cellspacing="0" background="../images/report-table-bg.gif">
				<tr>
					<td width="170" rowspan="5" align="right" valign="top">
						<img src="../images/spacer.gif" width="20" height="5"><br>
						<asp:image id="Image1" runat="server" width="140" height="97"></asp:image>
					</td>
					<td><img src="../images/spacer.gif" width="20" height="50"></td>
					<td width="200">&nbsp;</td>
					<td width="90">&nbsp;</td>
					<td width="200">&nbsp;</td>
					<td align="right"><img src="../images/asp.net-reports.gif"><img src="../images/spacer.gif" width="10" height="2"></td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td class="Title" nowrap>
						<asp:label id="lblTitle" runat="server" CssClass="Title"></asp:label>
						Report
					</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td align="right" nowrap><a class="link" href=".." target="_parent">^ &nbsp;Reports 
							Overview</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td valign="top" colspan="4"><asp:table id="SourceTable" cellpadding="2" cellspacing="2" EnableViewState="true" runat="server" /></td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
				</tr>
				<tr>
					<td bgcolor="#990000"><img src="images/spacer.gif" width="1" height="2"></td>
					<td bgcolor="#990000"><img src="images/spacer.gif" width="1" height="2"></td>
					<td bgcolor="#990000"><img src="images/spacer.gif" width="1" height="2"></td>
					<td bgcolor="#990000"><img src="images/spacer.gif" width="1" height="2"></td>
					<td bgcolor="#990000"><img src="images/spacer.gif" width="1" height="2"></td>
					<td bgcolor="#990000"><img src="images/spacer.gif" width="1" height="2"></td>
					<td bgcolor="#990000"><img src="images/spacer.gif" width="1" height="2"></td>
				</tr>
			</table>
		</form>
	</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Uruguay Uruguay
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions