Monthly Archives: October 2008

VS.NET needs implicit closing of debugger files like Delphi

One of the features I really miss from Delphi is the option to close files implicitly opened while debugging. You know, those files that are opened by the debugger as your stepping through code. In Delphi, those files are closed automatically at the end of the debug session thus helping keep you focused on the code you’ve been working on. I was just wading through all of the open files in my current solution and trying to close files I no longer wanted open the vast majority of which were opened during a debug session. After closing 6-8 files manually I clicked on the tab dropdown and there was still a huge list of open files so my usual approach is to close all my tabs and start opening files individually again. Here is the option as it appears in Delphi, note the default is checked. I’m sure lots of Delphi developers now take this option for granted.

Delphi Environment Options dialog

I wonder if CodeGear will have this in Prism? Anyone know how/where to make a VS.NET feature requests?

[Update: Oct. 30, 2008] Thanks to a comment I’ve logged a suggestion for this feature and if this is something you would like to see as well please vote for this request. Warning, that link may require login.

Using LINQ on results from SubSonic's generic ExecuteTypedList

Lately, I’ve been working on the Purchase Order portion of the EDI system I’ve blogged about. The system makes use of SubSonic, a .NET DAL framework, which comes in handy when dealing with the DB of an ERP system with 429 tables and approaching 2000 SPROCs.

Recently, I worked on the $g(EDI 856) which is an “Advanced Ship Notice” (ASN) document that includes shipping details for the PO. Included in the line item details, as stored in the DB, are “special services” which have to be separated out from normal line items within the document. The are reason they’re stored together is historic though tangential to my point. Fetching the 856 line item data is done via a stored proc and the result set is an aggregate of fields from a number of tables as well as calculated values. Fortunately, Subsonic can generate wrappers for calling SPROCs though doesn’t provide a wrapper for the result set in cases such as this.

Working with SPROC results using SubSonic

Subsonic generates a generic method called ExecuteTypedList<> that takes a class that will be the type of an IList returned from the call like this:

SPs.SaRptShipConfirmDetails(OrderHeaderID, true).ExecuteTypedList<ShipmentDetail>(); 

SaRptShipConfirmDetails is a wrapper for the like named SPROC and this call returns an IList<ShipmentDetail> where ShipmentDetail declared as follows:

public class ShipmentDetail
{
    public int LineNumber { get; set; }
    public string SKU { get; set; }
    public string ProductDescription { get; set; }
    public int Ordered { get; set; }
    public int Committed { get; set; }
    public int Shipped { get; set; }
    public decimal Price { get; set; }
    public decimal Amount { get; set; }
    public string CountryOfOrigin { get; set; }
    public decimal UnitWeight { get; set; }
    public string SizeName { get; set; }
    public int OrderDetailID { get; set; }
    public int ProductID { get; set; }
    public string BuyerProductCode { get; set; }
    public string UOMCode { get; set; }
    public string EDIUOMCode { get; set; }
    public int ShipmentDetailId { get; set; }
}

The get/set declarations above are required allowing ExecuteTypedList<> to determine where to stuff the returned SPROC column values into the ShipmentDetail structure. In fact, the SubSonic sources for the underlying SqlQuery.BuildTypedResult method read “//coerce the values, using some light reflection”. From there you can easily use LINQ to query the IList results as desired. Below is a very simple example of filtering out these “special services” by ProductID:

var lineitems = from p in Details
                    where !p.ProductID.Equals(52276) &&
                    !p.ProductID.Equals(53257)
                    select p;

Clearly this is a simple example and it would be easy enough to write logic to skip the two ProductIDs indicated though simply playing around with LINQ in this manner has been interesting. For example, it gave me an opportunity to experiment with code completion in such a case which was interesting. I definitely recommend setting up a similar example where it’s easy to test the results and give yourself time to get used to “thinking” LINQ.

Using LINQ to query for specific instances of a class within an array

Another case where LINQ came in handy was in finding data read into an in memory structure of an EDI document. I’ve created a class hierarchy for working with $g(EDI segments) which make up an EDI document and with LINQ can now easily query a loaded document looking for specific segment instances like this:

public EdiRecord[] FindSegments<T>()
{
    var query = from EdiRecord s in this
                where s.GetType() == typeof(T)
                select s;
    return query.ToArray<EdiRecord>();
}

FindSegments is a generic method that takes the class that I’m looking for an returns an array of all the instances of that class type found. I’ll admit that starting to use LINQ has been an interesting if not counter intuitive experience for me as it’s hard not to think of doing this sort of thing the “old fashioned” way and immediate start writing that code.

Lastly, a minor blog note, I’m testing a new syntax highlighter via Windows Live Writer so it will be interesting to see how well it works (or not).

Anyway, what’s been your experience using LINQ?

Running Windows on Amazon's EC2

Now this is really cool! Using $g(ElasticFox), Amazon’s Open Source tool for managing machine instances on their $g(EC2) service you can easily boot a Windows 2003 server instance.

1. Select an AMI (a machine configuration)…
ElasticFox EC2 control panel
2. Select hardware configuration, security options then boot the machine…
 ElasticFox launch AMI dialog

3. Wait a minute or two for the instance to boot then grab the Admin password and login via Remote Desktop:

image image

Now, what to do next hmmm….  🙂

Btw, once you have an instance up and running you might as well keep it around for at least an hour since that’s how it’s billed. In this case a “small” instance without Authentication Services runs $0.125/hour.

[UPDATE Oct. 26 2008] Btw, here is your Getting Started Guide & Setting up an Account to EC2

JungleDisk acquired by Rackspace

Today Rackspace announced that it has acquired JungleDisk which I blogged about the other day regarding cloud storage for photos (among other things). From what I understand JungleDisk will continue to work with Amazon and it looks like Rackspace may try to match Amazon’s hosting costs though the full details are not yet available. JungleDisk will be available for Rackspace’s Cloud Files service which will support API’s for third part development. It’ll be interesting to see if or how JungleDisk’s support for Amazon S3 will change over time.

Online photo storage solution using JungleDisk and Amazon's S3

After my trials and tribulations with Western Digital MyBook external drives, yes that’s plural, I started looking around for alternative storage solutions and decided to go the route of “cloud” storage.

image 

I’m now running JungleDisk which is a Windows Tray application using Amazon’s S3 service for storage. JungleDisk is $20 (one time purchase with free lifetime upgrades) for the Desktop Edition that I’m using, includes Windows/Mac/Linux versions, can easily run from a USB key and can be installed on unlimited machines with one S3 account. JungleDisk is a Windows tray application that, when installed and connected to S3, adds a new drive to Explorer where you can easily copy files like you normally would albeit slower and at a price. It took me a few weeks worth of uploading batches of photos at a time but eventually I got all ~65GB uploaded. I’m now paying roughly $10-$11 USD a month for storage of said of photo’s.

JungleDisk Monitor, the software that runs in your Windows tray, comes with backup features that will automatically synchronize your local files with your S3 account though some of the terminology is a bit terse and the UI isn’t exactly parent friendly but it certainly gets the job done.

[Update: Oct. 21, 2008] Added a few more details about JungleDisk (cost etc.)

Macbook Pro motherboard had to be replaced

I left my MBP at the Apple store in the Domain Shopping Center in Austin, TX and 12 days later it arrived back at my house. It appears that the motherboard may have been replaced though it’s rather hard to tell since the only information I was given on the repair was that it was not covered as I previously had guessed and the part number given was 605-1793 with the remark PCBA,MLB,2.4GHZ,REV2. Now, I’m not exactly sure where that leaves me with regard to the latest round of NVidia problems that were brought to light last week. I will say it’s not at all satisfying that the only two Macs I’ve had experience with have needed motherboard replacements a mere few months after the one year warrantee expired. I’ll also admit I’m not a big fan of Apple’s lack of details regarding repairs. The status site didn’t provide any insight as to the repair time, it only stated parts had to be ordered, nor did it provide any return shipping information for tracking purposes. Apple doesn’t seem to be big on details with anything like iPod updates, OSX security updates, iTunes updates and on and on. It seems the only thing you’ll get updates about are new products.

Anyway, I still like the MBP as a laptop though it’s the only one I’ve ever used full time. One last note, the switching of the motherboard has causes a few unusual tweaks in Vista that were unexpected though not terribly annoying to deal with.

A little economic dialog

Like most people I’ve had a lot on my mind lately with everything that’s going on and I decided to write some of it down if for no other reason to capture the moment for me personally. To that end welcome any/all comments…

image
Chart from bloomberg.com

The economy is sinking, the housing market is a wreck and it seems the last shoe to drop could be employment opportunities. I, like I’m sure most if not all, people with a 401k or other stock based investment vehicle kept an eye on the market much of the day today and was relieved at the outset that it wasn’t another hugely off day. That was until about 12:30pm PST and I saw that we were in free fall once again ending with a DJIA of 8579. Personally, I don’t think we’re at the bottom and in fact, I expect things to get worse for awhile. I remarked to my wife this evening that I don’t think our home value will return to what it was when we bought in 1999 but we’ve lost +$160,000 from the highs of a few years ago and I can’t say I foresaw that happening thought I’m not shocked. I feel somewhat confident we won’t return to our purchase price but take no solace in the fact we’ve lost what amounts to the purchase price of a new home many parts of the country. Currently, we’re still up over 50% however, I have no faith that we won’t drop below that mark in the coming 12-18 months.

Personally, I’ve been struggling with just what to with our investments and haven’t made any moves other than to halt some of my automatic investing. Of course, the trick is to know when to turn it back on. The difficult thing is that there are so many balls in play at present it’s hard to know where to focus. I’ve been spending a lot of time reading opinions from all sides trying to understand how I can best navigate my family’s finances as things worsen. In the mean time, we’ve been closely examining our expenses and looking for ways to reduce even those things that seem essential. Looks like the holiday season will be rather mild.

I started this post mentioning the job market and I think that’s the next thing that’s apt to take a beating. We’ve already see that start with layoffs at HP and eBay and I suspect large RIF’s to continue over the coming months. I’ve been reading that some people expect that the mortgage crisis isn’t really over yet as there are still 2-3 year mortgages that will balloon in Q1 of ’09. I’m infinitely frustrated by the huge numbers of people who accepted completely unrealistic terms and landed themselves in a home that they never could have afforded. I’m a little surprised there haven’t been more articles like this one, critical of Alan Greenspan’s role in perhaps setting up the current economic climate focusing on derivatives. I think combined with what became the addictively low mortgage interest rates spurned on by his historic rate cuts allowed these derivative driven institutions to lure a seemingly uneducated resource, the American home buyer into today’s morass.

As I sit here listening to Bloomberg radio tomorrow is primed to continue the trend and round out Wall Street’s worse week ever as US futures are down as world markets struggle with the day’s toll. Bush is to speak at 7:45am and I can’t imagine there is anything he can say at this point that’s likely to calm the market.

MacBook Pro logic board failure makes me 0-2 with Macs less than 18 months

Last week I was in Austin, TX at a clients site and my MBP was sitting on a table running Windows Vista when it went to into sleep mode which is very normal. What wasn’t normal was the fact that it never made it out of sleep mode. I hard reset it and tried to boot it again but it never made its normal chime sound and I was unable to get it to boot into either OSX or Vista. I tried a PRAM reset and several other incantations including, among other things, a reset with the battery removed and reseating the RAM all to no avail. That left me with out a machine for three days out of a five day contract and now I’m hoping it will show up by tomorrow.

You may recall I recently blogged about our Mac Mini which died within 18 months of purchase. Now, for me this doesn’t bode well for Apple. I’m basically 0-2 when it comes to Macs lasting more than 18 months which I think is terrible. I’m writing this on a Dell which I’ve never had a problem with that’s 6 years old and I have another Dell that’s pushing 12 years old and still running.

In the case of this MBP, it’s a $300 repair job and I had to give permission for the drive to essentially be erased. I know for a fact that it’s not the drive because I sat in the Austin Apple store for 2 hours pulling files off of it onto my iPod Touch using (the most excellent) AirSharing app. Anyway, at this point while I think the MBP is an excellent laptop otherwise I’m seriously not impressed with Apple’s quality control. Granted the MacBook Pro and Mac Mini are certainly different than your standard Desktop machine with ample cooling but less than 18 months of uptime??

Update I should clarify that I had to sign knowing that I might get the machine back without any of my data, not that it would be intentionally wiped clean. One more thing, if you buy a Mac be sure to buy Apple Care unfortuantely it’s not just a gimmick it’s really needed.

Update #2 According to Apple’s service status web site a replacement part has to be ordered so hoping for the machine to show up tomorrow just went out the window. The genius in the store said "5 days but probably sooner" and that was last Wednesday.

Update #3 Apple has released this note that I’d guess most likely accounts for the problem with my laptop. Found on Gizmodo. Sounds like the repair might actually be free.