I've got a new form of code for you, erm, coders!

Code:
switch x
case 1:
do crap that needs to be done to 1;
case 2:
do crap that needs to be done to 1 and 2;
break;

It is very useful when dealing with stuff like commands and other things that tend to be either redundant or easily portable. In C# you might as well use nothing but if statements because case statements are broke.

Good pun at the end there...intended? :)

Quick summary on why...http://msdn2.microsoft.com/en-us/vcsharp/aa336815.aspx

I didn't read it *all* the way so if this point was made, forgive me...but it did touch on maintainability and large switch statements contribute to higher cyclomatic complexity which is typically a sign that something needs to be refactored, and again, points to potential problems in maintenance.

I'd argue that for commands in particular, you'd be better off at the very least utilizing an abstract factory which would drop the whole block down to a few lines of a code to obtain and execute the "command".

It's late...I can't sleep...so I troll.

trying to remember what I posted to one of our internal WoW communities a while ago (guess I didn't archive that email apparently...)

Code:
HAI
   CAN HAS STDIO?
   
   I HAS A IZUAHORDE

   VISIBLE "IZ U A HORDE?"

   GIMMEH IZUAHORDE

   IZ IAZUAHORDE
        YARLY
             IM IN YR LOOP
                   VISIBLE "TAURENZ MAKE GOOD CHEEZEBURGERZ"                                 
             KTHX
        NOWAI
             VISIBLE "U CAN HAZ CHEEZEBURGERZ!"     
    KTHX

KTHXBYE

On that note...I think I may officially be sleepy! w00t! no more trolling and looking to stir up Microsoft trouble late at night! mwuahahahaha

I get the feeling my wife will be giving me this look in the morning...

funny-pictures-therapy-cat.jpg
 
Last edited:
I am debating starting my own CMS using perl, I hate doing the back end stuff though, but the front end is fun to mess with. My idea is to have tags you can place in the text {perleval include="blah.pl"} or {perleval}print "Hello World!";{/perleval} then maybe make {phpeval}, etc. Hmm, might as well throw in HTML tidy for the fun of it. Tempting...
 
please...don't encourage the use of drag and drop database connections within the ASP.NET page :D

kidding aside...the tooling for it is very good...and some of which you can get for free, obviously not fully featured, but unless you're developing enterprise class apps with it...you don't really need them
 
please...don't encourage the use of drag and drop database connections within the ASP.NET page :D

kidding aside...the tooling for it is very good...and some of which you can get for free, obviously not fully featured, but unless you're developing enterprise class apps with it...you don't really need them

Im actually getting all my information from the API,

sucky procedural search example I wrote up, the spacing was all messed up from the copy lol:

Code:
<%@ Page language="c#" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="OSGeo.MapGuide" %>
<!-- #Include File="utilityfunctions.aspx" -->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<%
    string mgSessionId = GetParameters()["SESSION"];
    string mgDataSourceLoc = "Library://OkaloosaGas/Data/Cycles.FeatureSource";
    string mgDataSourceObj = "Cycles";
    string mgDataSourceGeom = "Geom";
    string appTitle = "Search Template Thingy";
    string appZoomScale = "65000";

    HybridDictionary SearchColumns = new HybridDictionary();
    SearchColumns.Add("county", "County Number");
    SearchColumns.Add("cycle", "Cycle Number");
    SearchColumns.Add("PRIMARYINDEX", "Index Number");

    HybridDictionary DisplayColumns = new HybridDictionary();
    DisplayColumns.Add("county", "County Number");
    DisplayColumns.Add("cycle", "Cycle Number");
    DisplayColumns.Add("PRIMARYINDEX", "Index Number");
%>
<html>

<head>
    <title><%= appTitle %></title>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <meta http-equiv="content-script-type" content="text/javascript" />
    <meta http-equiv="content-style-type" content="text/css" />
    <link href="styles/globalstyles.css" rel="stylesheet" type="text/css">
    <link href="styles/alphastyles.css" rel="stylesheet" type="text/css">
    <link href="/mapguide/viewerfiles/viewer.css" rel="stylesheet"type="text/css">
</head>

<body class="AppFrame">
<h1 class="AppHeading"><%= appTitle %></h1>
    <form action="<%= Context.Request.CurrentExecutionFilePath.ToString()%>" method="get" target="_self">
    	<input name="SESSION" type="hidden" value="<%= mgSessionId %>">
    		<%
    			foreach (DictionaryEntry SearchColumn in SearchColumns)
    			{
    				Response.Write("<label>" + SearchColumn.Value + "</label>");
    				Response.Write("<input name=\"" + SearchColumn.Key + "\"type=\"text\" size=\"30\" value=\"" + GetParameters()[SearchColumn.Key.ToString()] + "\"><br/>");
                }
            %>
    	<input type="submit" value="Find">
    </form>
<hr>

<%
    HybridDictionary SearchValues = new HybridDictionary();
    foreach (DictionaryEntry SearchColumn in SearchColumns)
    {
    	string tmpKey = SearchColumn.Key.ToString();
    	string tmpParam = GetParameters()[tmpKey];
    	if(tmpParam != null)
    	        SearchValues.Add(tmpKey, tmpParam);
    }

    if(SearchValues.Count == 0)
    {
        Response.Write("Please enter something to search");
    }
    else
    {
    	try
    	{
    		InitializeWebTier();
    		MgUserInformation userInfo = new MgUserInformation(mgSessionId);
    		MgSiteConnection siteConnection = new MgSiteConnection();
    		siteConnection.Open(userInfo);

    		MgFeatureService featureService = siteConnection.CreateService(MgServiceType.FeatureService) asMgFeatureService;
    		MgResourceIdentifier resId = new MgResourceIdentifier(mgDataSourceLoc);

            string filter = "";

            foreach (DictionaryEntry Search in SearchValues)
            {
                if(Search.Value.ToString().Length != 0)
                {
                    if(filter.Length > 0)
                            filter += " AND ";

                    filter += Search.Key + " LIKE '%" + Search.Value + "%' ";
                }
    		}

    		MgFeatureQueryOptions queryOptions = new MgFeatureQueryOptions();
    		queryOptions.SetFilter(filter);


    		MgFeatureReader featureReader = featureService.SelectFeatures(resId, mgDataSourceObj, queryOptions);
    		MgAgfReaderWriter geometryReaderWriter = new MgAgfReaderWriter();

    		Response.Write("<table width=\"100%\"><tr>");
    		
    		foreach (DictionaryEntry ColName in DisplayColumns)
    			Response.Write("<td>" + ColName.Value + "</td>");

            Response.Write("</tr>");
            int NumResults = 0;

            while (featureReader.ReadNext() && ++NumResults > 0)
            {
    			MgByteReader byteReader = featureReader.GetGeometry(mgDataSourceGeom);
    			MgGeometry geometry = geometryReaderWriter.Read(byteReader);
    			MgPoint point = geometry.GetCentroid();
    			double x = point.GetCoordinate().GetX();
    			double y = point.GetCoordinate().GetY();

    			Response.Write("<tr>");
    			int i = 0;
    			
    			foreach (DictionaryEntry DisplayCol in DisplayColumns)
    			{
    				string ColName = DisplayCol.Key.ToString();
    				int DataType = featureReader.GetPropertyType(ColName);
    				string tmpData = "";

                    if(DataType == MgPropertyType.String)
                            tmpData = featureReader.GetString(ColName);
                    else if(DataType == MgPropertyType.Int32)
                            tmpData = featureReader.GetInt32(ColName).ToString();

                    if(i++ == 0)
                            Response.Write("<td><a href=gotopoint.aspx?X="+x+"&Y="+y+"&Scale=" + appZoomScale + " target=\"scriptFrame\">" + tmpData + "</a></td>");
                    else
                            Response.Write("<td>" + tmpData + "</td>");
                }
                Response.Write("</tr>");
            }
            Response.Write("</table><hr>This query returned " + NumResults + " results");
        }
        catch (MgException mge)
        {
            Response.Write(mge.GetMessage() + "<br>");
            Response.Write(mge.GetDetails());
        }
    }
%>
</body>

</html>

It needs to be optimized a bit (eliminate the hybriddictionary for the get variables by moving them into the select statement generation, etc) then I will split the results and search form systems into 2 classes. I just wanted to make a quick and dirty search form that could be easily made into a template. And if anyone knows ASP/C# feel free to give suggestions.

edit: replaced all the tabs with spaces, sed <3
 
Back
Top