Blog Stats
  • Posts - 15
  • Articles - 2
  • Comments - 23
  • Trackbacks - 19

 

Monday, October 20, 2008

Update

Working at TransCanada now so if you are an old friend send me a holler and we can hit up some lunch. I haven't bumped into anyone I know yet - it's quite strange. Well I've bumped into a couple of people I know in Seattle here - in Calgary. Small world.

Wednesday, March 05, 2008

Back to Canada

Well not entirely - I'm still working in Seattle, but yes, I moved back to good old Canada.

Decided to try independent contracting up there - we'll see how it goes as well. Threw together a web site at http://www.onshoresoftware.ca with some personal information about myself and experience.

I'd like to get something going in Calgary but its been a bit of a slow process since I spend half of my time down here and 3/4 of my time STILL working while I'm in Calgary.

Anyhow if you have any solid leads in Calgary for an experienced C# .NET developer / applications lead fire me an email at allen.d.guest (at) gmail.com.

Wednesday, November 15, 2006

Microsoft's XNA

The beta2 version was released a couple of weeks ago and I have to say it's pretty awesome. For keeping up on the lastest developments bookmark http://blogs.msdn.com/xna/. Writing games got me addicted to coding back in the old Vic20 days and continues to be a hobby passion.

The consolidation of DirectX into a more unified managed framework is exciting and I hope to play with it over the next couple of weeks.

Thursday, December 22, 2005

More AJAX

Looks like I am staying on my contract for another 6 months. While I am in the midst of finishing up my real projects, I am tasked with putting together an integration application with http://maps.google.com and City of Seattle address data. What is quite funny is that even though I am utilizing C# on the backend to perform my queries, the application is 80% javascript. Who would have thought we were be reverting back to the client so heavily?

Personally, I find .NET's mechanism of the full page postback to be quite archaic and it has always bothered me. Leveraging AJAX, my .NET server controls are nothing more than javascript renderers that communicate with the server for their data needs. I have to say that AJAX is a cleaner approach to client/server communication that the in the old days when we had to perform cross-frame postbacks to achieve similar effects.

Update: Look to http://web1.seattle.gov/dpd/GoogleDPD in the next few days for an Alpha version of some of the City of Seattle's permit and activity data linked with Google.

Friday, December 02, 2005

AJAX

I recently had the opportunity to dabble in a concept project utilizing AJAX and have been quite impressed with the implementation of a free library found at http://www.schwarz-interactive.de/ for 1.1 or http://dotnet2.schwarz-interactive.de/ for 2.0.

Implementation is as easy as setting a reference to the library, adding an entry to your web.config and decorating the exposed methods. The decorated methods are exposed to your client side javascript. When those methods are called from Javascript, an HTTP get is performed and the parameters are serialized / deserialized and the original marked up method is invoked. Quite elegant.

In addition the library supports direct support for the majority of the .NET base classes, including the DataSet - as well as exposing an IAJAXObjectConverter interface where you can supply support for serialization of your own custom classes. This gives the ability of the client code to directly access the server side object as a client side object.

 

Tuesday, November 01, 2005

HttpHandlers : A Practical Example

I recently had the need to tunnel a protected resource through a firewall and found a great practical use for HttpHandlers.

Click http://geekswithblogs.net/aguest/articles/58795.aspx to read walkthrough and complete code.

Monday, September 26, 2005

The interesting DropDownList ASP.NET control behavior

So if you've decided to use syntax such as this

myDropDownListBox.Items[0].Selected = true;

or

ListItem foo = myDropDownListBox.Items.FindByValue(”foo”);
foo.Selected = true;

you will get the 'A DropDownList cannot have multiple items selected' error.

Seems to me that if the code sets the Selected attribute on an item in a list which by definition can only have one item selected, that the ListItem instance would set the SelectedIndex automatically for me. Seems like a no-brainer. I guess Microsoft found some sort of use for this error being thrown from a DropDownList control - just don't ask me what that could be.

I guess I'd rather see that the DropDownList have DropDownList items if the Selected property was pretty much useless and will only cause errors if used in a DropDownList.

Thursday, September 22, 2005

Time for my yearly blog post

Well its been a great year. I'm thinking of moving on from my current contract - been 4 years slogging on at the same area. Longest contract I've ever had - heck, longest job I've ever had.

Well, on to more interesting things - like code. We have developed a unified Framework here where I am contracting at to centralize (aka reuse) more commonly used areas of functionality, mostly data access. All data access has been abstracted into static method calls such as (note class names have been changed):

DataSet myData = Framework.Data.Enterprise.EmployeeGateway.GetAllEmployees();

or, if a Business Object wrapper was available, can be:

EmployeeCollection myEmployeeCollection = Framework.Data.Enterprise.BusinessObject.EmployeeGateway.GetAllEmployees();

An application that wants employee data simply calls one of the methods above. Simple, huh? Now, we wanted to deploy the application behind a firewall. We no longer had direct access to the database and all data requests had to know be funneled through web services. But who wanted to recode 398 stored procedures? Using a bit of reflection, I was able to potentially open up all of the static method calls so that an application running outside the firewall was able to make the same database call without knowing it was actually been funnelled through one (or more!) web services for its data. Code tidbit below:

public class EmployeeGateway
{
  private EmployeeGateway() { }
  public static DataSet GetAllEmployees()
  {
    return ExecDataSetQuery(“GET_ALL_EMPLOYEES“, null);
  }
  private static DataSet ExecDataSetQuery(string sProc, SqlParameter[] parms)
  {
    // Connection factory returns either a SqlConnection or a WebService instance
    // based on a Framework configuration file. Connection information for a given
    // data source was either an encrypted connection string or an encrypted web
    // service endpoint.
    object connection = ConnectionFactory.CreateConnection(DataSourceEnum.Employee);
    DataSet ds = null;
    if (connection.GetType().Equals(typeof(SqlConnection))
    {
      using (SqlConnection sqlConnection = connection as SqlConnection)
      {
        // standard SqlDataAdapter / Fill code here
      }

    }
    else if (connection.GetType().Equals(typeof(Framework.Web.Services.Enterprise.EmployeeGateway)))
    {
      using (Framework.Web.Services.Enterprise.EmployeeGateway webServiceConnection = connection as Framework.Web.Services.Enterprise.EmployeeGateway)
      {
        try
        {
          MethodInfo method = webServiceConnection.GetType().GetMethod(ExtractWebMethodName(sProc);
          if (null != method)
            ds = (DataSet)method.Invoke(webServiceConnection, Framework.Data.SqlController.ToObjectArray(parms));
          else
            throw new Framework.Data.DataException(String.Format(“Unable to locate Web Service name of {0} on the {1} connection.“, sProc, DataSourceEnum.Employee.ToString()));
        }
        catch (System.Exception ex)
        {
          // publish error to a central event log
          throw new Framework.Data.DataException(String.Format(“Failed to execute Web Service {0}.“, webServiceConnection.ToString()), ex);
        }

      }
    }
    else
      throw new Framework.Data.DataException(String.Format(“Unhandled connection request {0} returned from ConnectionFactory.“, connection.ToString());

  }
}

The caveats of course is that the Web Service proxy names need to match the stored procedure names. Not a bad tradeoff if you don't have to write all the web service proxy instantiations in your code and get them for free. The bolded function names above are included below for completeness.

internal static string ExtractWebMethodName(string sProc)
{
  string webMethodName = sProc;
  int sProcSeperatorIndex = sProc.LastIndexOf(“.“);
  if (sProcSeperatorIndex > -1)
    webMethodName = sProc.SubString(sProcSeperatorIndex+1, sProc.Length - sProcSeperatorIndex);
  return webMethodName;
}

internal static Object[] ToObjectArray(SqlParameter[] parms)
{
  int parmLength = 0;
  if (null != parms)
  {
    // figure out array length
    foreach (SqlParameter parm in parms)
    {
      if (parm.Direction != ParameterDirection.Output)
        parmLength++;
    }
  }
  int index = 0;
  object[] args = new object[parmLength];
  if (null != parms)
  {
    foreach (SqlParameter parm in parms)
    {
      if (parm.Direction != ParameterDirection.Output)
        args[index++] = parm.Value;
    }
  }
  return args;

}

Sunday, May 01, 2005

So it's that time of year again...

So once a year or so I decide to build the latest and greatest computer within my budget and this time (drum roll) I'm going with AMD. I've been an Intel die-hard for so long and after reading and researching price/performance I've decided on the AMD FX-55. It looks sweet.

So I've spec'd out my system and this is what I've come up with:

Purchased

Yet to Purchase

What is so awesome is that the OCZ memory (DDR500) works with the DFI mobo. 2-2-2-8 timings! What could be better than that? I'm building this little PC as we speak so I'll let you know how it goes.

Wow, have I been lazy?

It's been quite a while since my last blog post so let me try and recall some interesting things I've ran into since I've lasted posted. Books that I've read:

Design Patterns in C# published by Addison Wesley ISBN 0-321-12697-1
Programming C# published by O'Reilly ISBN 0-596-00309-9
C# in a Nutshell by O'Reilly ISBN 0-596-00181-9

Monday, July 26, 2004

Back from vacation and back into it

Well, I sure hope that the next version of the IDE has fixed the IIS integration bugs. VS 2003 fixed all of the editor bugs but has introduced some oddities with (my experience so far) asp.net and IIS.

Having to re-execute aspreg_iis.exe -i a couple of times a month because somehow the IIS mappings with ASP.NET get buggered is a pet peeve.

Unable to view page/control in designer error - even though the class IS defined first in the file and a simple IDE quit and restart fixes it. The IDE seems to get confused sometimes when you have a base class like UserControl that you inherit from and add some common code and then you inherit once again to specialize. When viewing the specialized class in the designer you sometimes get the designer error. Sometimes it works. No idea.

IIS gets out of synch with VS sometimes as well. Haven't been able to pinpoint a repeatable pattern, however. Sometimes the IIS meta data gets buggered and you can't create virtual directories and have to go to the command line to remove them manually. This is probably more of a problem with the problematic MMC snap-ins - as well as the refreshing issue with them.

Got any pet peeves? With IIS?

Friday, May 07, 2004

A day in the life of a developer...

Have you ever had one of those days where you sat down at your computer, reviewing the “latest” requirements specification only to find out that something that was supposed to be finished now has major rework?

Well that was my day today.

The original requirement was just to have some contacts added from different departments to an application for the purposes of correspondence via automated email/tasks etc. It now turns out that they need to authenticate on our internal network so they can enter data - but they aren't on our network. So now I have to write an authentication system - which means a new database (roles, accounts, memberships), new webservices for authentication and administration and web front-ends to these tools complete with role enforcement.

Man, I just wanted to add some contacts into a database.

Monday, April 26, 2004

Event problems with controls with no ViewState.

DataGrid, ViewState and SelectedIndex

The ViewState of an ASP.NET page is a hidden field that the ASP.NET framework uses to maintain the state of a web page. When a user posts a page to the server, the server will restore the contents of the controls by parsing out the state and restoring the state in the Base64 encoded field.

If you've worked with the DataGrid you know it has a tendency to increase the contents of the ViewState field by quite a bit - sometimes in excess of 100KB! To combat this, a variety of methods are employed - from overriding the Page.SavePagetoPersistenceMedium and Page.LoadPageFromPersistenceMedium and serializing it to Session state to the most obvious - setting the EnableViewState property to false. Saving the view state to Session can have scalability issues, but for web sites with minimal traffic this may be an option. The better solution IMHO is to remove disable the ViewState for the DataGrid by setting the EnableViewState property to false.

A couple of additional issues rear their heads when you do this however. For starters, you must rebind your data to the Grid on every postback instead of the traditional (!isPostBack) check. You can cache this data yourself in the Page.Cache object to mitigate the database hit issue so that is no problem. As well, you will find out that the SelectedIndex property is now one post behind. This is due to the Page Life Cycle, whereby the SelectedIndexChanged event fires after the Load event. The SelectedIndex property is set correctly but it doesn't get set until after you bind. The solution is to rebind in the OnPreRender event instead.

By setting the EnableViewState to false on my pages, I've reduced the size of the Request and Response by over 60% with no loss of funtionality.

Thursday, April 22, 2004

Javascript function naming from Server Controls

Ever have client side code generated out of your User Controls? You aren't protected by INamingContainer in your Javascript functions - here's a simple approach to handle this issue.

http://geekswithblogs.net/aguest/articles/4213.aspx

First Post

Hidi-Ho!


This is my first post to my Web Blog and I would like to discuss my ongoing experience with .NET development - specifically ASP.NET using C#. I would like to put out topics or coding practices out to the .NET Geeks of the world to comment on or to critique or to flame.

A little about me


My name is Allen Guest and I'm a displaced Canadian living in the Seattle area. I came down here during the .com bubble and have thankfully been busy despite the .com bomb and the economic downturn. Perhaps it has to do with my experience as I've been coding since I was 12 years old - now 23 years ago with my first love - a Commodore Vic20. With a whopping 3584 bytes of memory and a ~1Mhz processor it was my tool to rule the world. I wanted to write computer games back then - and still today have a love of great computer games and their amazing ability to entertain. I have an appreciation of the Art of programming and now marvel and the technical ability and production ability to truly write games. Yes, I said Art.

Due to circumstances, my career deviated from my love of games and in college got my first taste of “work” as a programmer writing data acquisition and analysis systems for oil and gas using C, Pascal and x86 Assembler. The Web started gaining popularity in the early 90's and then I migrated to writing web enabled applications - and finally web applications. In the last year or so, I've settled on my current tool of choice C# for writing applications on Windows platforms.

I want to share my day-to-day experiences with it - including my gripes - in developing applications. I hope that other “Geeks” will read and contribute their thoughts and experiences. I've learned so much from self experimentation and the self experimentation of others that have shared. I hope you do too.

 

 

Copyright © Allen Guest