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

Conversion of Reporting Starter Kit to use Mono/MySQL

Rate me:
Please Sign up or sign in to vote.
3.69/5 (9 votes)
1 Oct 20053 min read 28.3K   411   32  
A porting of the ASP.NET reporting starter kit to use Mono, MySQL and Apache on a Linux system.
<%@ Page language="c#" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="ASPNET.StarterKit.Chart" %>
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
	// This is a quick check for referrer server name against host server
	// For best security practice in a deployed application, an authenticating mechanism should be in placed.
	// Image should only be rendered for authenticated users only.
	if (Request.UrlReferrer != null &&((Request.UrlReferrer.Host.ToLower() == Environment.UserDomainName.ToLower()) 
		|| Request.UrlReferrer.Host.ToLower() == "localhost"))
	{ 
		// set return type to png image format
		Response.ContentType = "image/png";

		string xValues, yValues, chartType, print;
		bool boolPrint;

		// Get input parameters from query string
		chartType = Request.QueryString["chartType"];
		xValues = Request.QueryString["xValues"];
		yValues = Request.QueryString["yValues"];
		print = Request.QueryString["Print"];

		if (chartType == null)
			chartType = "";

		// check for printing option 
		if (print == null)
			boolPrint = false;
		else
		{
			try
			{
				boolPrint = Convert.ToBoolean(print);
			}
			catch
			{
				boolPrint = false;
			}
		}

		if (xValues != null && yValues != null)
		{
			Color bgColor;

			if (boolPrint)
				bgColor = Color.White;
			else
				bgColor = Color.FromArgb(255,253,244);

			Bitmap StockBitMap;
			MemoryStream memStream = new MemoryStream();

			switch (chartType)
			{
				case "bar":
					BarGraph bar = new BarGraph(bgColor);
				
					bar.VerticalLabel = "$";
					bar.VerticalTickCount = 5;
					bar.ShowLegend = true;
					bar.ShowData = false;
					bar.Height = 400;
					bar.Width = 700;

					bar.CollectDataPoints(xValues.Split("|".ToCharArray()), yValues.Split("|".ToCharArray()));
					StockBitMap = bar.Draw();
					break;
				default:
					PieChart pc = new PieChart(bgColor);

					pc.CollectDataPoints(xValues.Split("|".ToCharArray()),yValues.Split("|".ToCharArray()));

					StockBitMap = pc.Draw();

					break;
			}

			// Render BitMap Stream Back To Client
			StockBitMap.Save(memStream, ImageFormat.Png);
			memStream.WriteTo(Response.OutputStream);
		}
	}
}
</script>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en" >
<html>
	<head>
		<title>ChartGenerator</title>
		<meta name="GENERATOR" content="Microsoft Visual Studio 7.0">
		<meta name="CODE_LANGUAGE" content="C#">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
	</head>
	<body ms_positioning="GridLayout">
		<form id="ChartGenerator" method="post" runat="server">
		</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
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions