Click here to Skip to main content
15,894,017 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.
<html><head><link rel=stylesheet href=style.css></head><body><div class=SourcePanel style='font-size:12'><pre style='background-color:white'>
&lt%@ Page language="c#" %<font color= "blue">&gt</font>
&lt%@ Import Namespace="System" %<font color= "blue">&gt</font>
&lt%@ Import Namespace="System.Drawing" %<font color= "blue">&gt</font>
&lt%@ Import Namespace="System.Drawing.Imaging" %<font color= "blue">&gt</font>
&lt%@ Import Namespace="System.IO" %<font color= "blue">&gt</font>
&lt%@ Import Namespace="ASPNET.StarterKit.Chart" %<font color= "blue">&gt</font>
<font color= "blue">&lt</font><font color="maroon">script</font> runat="server"<font color= "blue">&gt</font>
<font color= "blue">    private void</font> Page_Load(object sender, System.EventArgs e)
<font color= "blue">    </font>{
<font color= "green">        // set return type to png image format</font>
<font color= "blue">        </font>Response.ContentType = "image/png";
<font color= "blue"></font>
<font color= "blue">        </font>string xValues, yValues, chartType, print;
<font color= "blue">        </font>bool boolPrint;
<font color= "blue"></font>
<font color= "green">        // Get input parameters from query string</font>
<font color= "blue">        </font>chartType = Request.QueryString["chartType"];
<font color= "blue">        </font>xValues = Request.QueryString["xValues"];
<font color= "blue">        </font>yValues = Request.QueryString["yValues"];
<font color= "blue">        </font>print = Request.QueryString["Print"];
<font color= "blue"></font>
<font color= "blue"></font><font color= "blue">        if </font>(chartType == null)<font color= "blue"></font>
<font color= "blue">            </font>chartType = "";
<font color= "blue"></font>
<font color= "green">        // check for printing option </font>
<font color= "blue"></font><font color= "blue">        if </font>(print == null)<font color= "blue"></font>
<font color= "blue">            </font>boolPrint = false;
<font color= "blue"></font><font color= "blue">        else</font><font color= "blue"></font>
<font color= "blue">        </font>{
<font color= "blue">            try</font>
<font color= "blue">            </font>{
<font color= "blue">                </font>boolPrint = Convert.ToBoolean(print);
<font color= "blue">            </font>}
<font color= "blue">            catch</font>
<font color= "blue">            </font>{
<font color= "blue">                </font>boolPrint = false;
<font color= "blue">            </font>}
<font color= "blue">        </font>}
<font color= "blue"></font>
<font color= "blue"></font><font color= "blue">        if </font>(xValues != null && yValues != null)<font color= "blue"></font>
<font color= "blue">        </font>{
<font color= "blue">            </font>Color bgColor;
<font color= "blue"></font>
<font color= "blue"></font><font color= "blue">            if </font>(boolPrint)<font color= "blue"></font>
<font color= "blue">                </font>bgColor = Color.White;
<font color= "blue"></font><font color= "blue">            else</font><font color= "blue"></font>
<font color= "blue">                </font>bgColor = Color.FromArgb(255,253,244);
<font color= "blue"></font>
<font color= "blue">            </font>Bitmap StockBitMap;
<font color= "blue">            </font>MemoryStream memStream = new MemoryStream();
<font color= "blue"></font>
<font color= "blue">            switch</font> (chartType)
<font color= "blue">            </font>{
<font color= "blue">                case</font> "bar":
<font color= "blue">                    </font>BarGraph bar = new BarGraph(bgColor);
<font color= "blue">                    </font>
<font color= "blue">                    </font>bar.VerticalLabel = "$";
<font color= "blue">                    </font>bar.VerticalTickCount = 5;
<font color= "blue">                    </font>bar.ShowLegend = true;
<font color= "blue">                    </font>bar.ShowData = false;
<font color= "blue">                    </font>bar.Height = 400;
<font color= "blue">                    </font>bar.Width = 700;
<font color= "blue"></font>
<font color= "blue">                    </font>bar.CollectDataPoints(xValues.Split("|".ToCharArray()), yValues.Split("|".ToCharArray()));
<font color= "blue">                    </font>StockBitMap = bar.Draw();
<font color= "blue">                    </font>break;
<font color= "blue">                </font>default:
<font color= "blue">                    </font>PieChart pc = new PieChart(bgColor);
<font color= "blue"></font>
<font color= "blue">                    </font>pc.CollectDataPoints(xValues.Split("|".ToCharArray()),yValues.Split("|".ToCharArray()));
<font color= "blue"></font>
<font color= "blue">                    </font>StockBitMap = pc.Draw();
<font color= "blue"></font>
<font color= "blue">                    </font>break;
<font color= "blue">            </font>}
<font color= "blue"></font>
<font color= "green">            // This is a quick check for referrer server name against host server</font>
<font color= "green">            // For best security practice in a deployed application, an authenticating mechanism should be in placed.</font>
<font color= "green">            // Image should only be rendered for authenticated users only.</font>
<font color= "blue"></font><font color= "blue">            if </font>(Request.UrlReferrer != null &&((Request.UrlReferrer.Host.ToLower() == Environment.UserDomainName.ToLower()) <font color= "blue"></font>
<font color= "blue">                </font>|| Request.UrlReferrer.Host.ToLower() == "localhost"))
<font color= "blue">            </font>{
<font color= "green">                // Render BitMap Stream Back To Client</font>
<font color= "blue">                </font>StockBitMap.Save(memStream, ImageFormat.Png);
<font color= "blue">                </font>memStream.WriteTo(Response.OutputStream);
<font color= "blue">            </font>}
<font color= "blue">        </font>}
<font color= "blue">    </font>}
<font color= "blue">&lt/</font><font color="maroon">script</font><font color= "blue">&gt</font>
<font color= "blue">&lt!</font><font color="maroon">doctype</font> html public "-//w3c//dtd html 4.0 transitional//en" <font color= "blue">&gt</font>
<font color= "blue">&lt</font><font color="maroon">html</font><font color= "blue">&gt</font>
    <font color= "blue">&lt</font><font color="maroon">head</font><font color= "blue">&gt</font>
        <font color= "blue">&lt</font><font color="maroon">title</font><font color= "blue">&gt</font>ChartGenerator<font color= "blue">&lt/</font><font color="maroon">title</font><font color= "blue">&gt</font>
        <font color= "blue">&lt</font><font color="maroon">meta</font> name="GENERATOR" content="Microsoft Visual Studio 7.0"<font color= "blue">&gt</font>
        <font color= "blue">&lt</font><font color="maroon">meta</font> name="CODE_LANGUAGE" content="C#"<font color= "blue">&gt</font>
        <font color= "blue">&lt</font><font color="maroon">meta</font> name="vs_defaultClientScript" content="JavaScript"<font color= "blue">&gt</font>
        <font color= "blue">&lt</font><font color="maroon">meta</font> name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"<font color= "blue">&gt</font>
    <font color= "blue">&lt/</font><font color="maroon">head</font><font color= "blue">&gt</font>
    <font color= "blue">&lt</font><font color="maroon">body</font> ms_positioning="GridLayout"<font color= "blue">&gt</font>
        <font color= "blue">&lt</font><font color="maroon">form</font> id="ChartGenerator" method="post" runat="server"<font color= "blue">&gt</font>
        <font color= "blue">&lt/</font><font color="maroon">form</font><font color= "blue">&gt</font>
    <font color= "blue">&lt/</font><font color="maroon">body</font><font color= "blue">&gt</font>
<font color= "blue">&lt/</font><font color="maroon">html</font><font color= "blue">&gt</font>
</pre>

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