Monday, May 21, 2012 Register  Login

This site uses DNS Made Easy. Use it for reliable and professional DNS services.

RSS Feeds
Categories
  
Blog Archives
  
Blog

Code

    Oct
    16

    I had an interesting time fixing a bug in PainlessSVN when using UNC paths. I had a function in SVNManagerLib that converted the path to the file:/// format. This is what the original looked like: 

    public static string PathToFileUrl( string pathToConvert )
    {
         string parsedDir = "";
         StringBuilder arg = new StringBuilder();
     
         parsedDir = pathToConvert.Replace("\\", "/");
     
         arg.Append("file:///");
         arg.Append((char)34);
         arg.Append(parsedDir);
         arg.Append((char)34);
     
         return arg.ToString();
    }

    That didn't quite work. I did some Googling and found the answer. Let me post the code first then, I'll explain:

     

    public static string PathToFileUrl( string pathToConvert )
    {
        UriBuilder fileURL = new UriBuilder( pathToConvert );
     
        return fileURL.ToString();
    }

    The UriBuilder is a special class that helps build valid URIs. I keep learning this lesson over and over... Don't re-invent the wheel, just use what the .NET framework already has. There's quite a bit in there. I've been using .NET since 2002, and I keep finding these little nuggets.

    posted @ Tuesday, October 16, 2007 8:11 PM by Hector Sosa, Jr

    Posted in: PainlessSVN, Code

    Actions:Tweet This Share on Facebook Share on LinkedIn Emakl Permalink del.icio.us
    Sep
    09

    When debugging MMC snapins, you have to add them to the MMC console manually. I found something quite amusing that I haven't noticed before. I was actually thinking that I needed a nap, when I noticed this:

    I thought that was pretty amusing, but that might be because I'm pretty tired.

    posted @ Sunday, September 09, 2007 4:43 PM by Hector Sosa, Jr

    Actions:Tweet This Share on Facebook Share on LinkedIn Emakl Permalink del.icio.us
    Aug
    29

    I have been using NAnt since around version 0.81. It is more powerful than batch files, but still as annoying. Unfortunately, NAnt has stagnated at version 0.85. It can't compile solutions, so you have to shell out to MSBuild in order to do that.  Anything more complex than copying, zipping, and compiling turns into a morass of back referencing spaghetti. The one thing that could had kept NAnt shinning would have been a nice editor that was NAnt aware.

    The only thing I've found to edit NAnt scripts in a contextual fashion was Nantpad. Unfortunately, this is priced above the sweet spot price for mISV. I've found that this price is around $150 for most developer tools. Anymore than that, has to be justified in doing more than one thing. My personal feeling is that NAnt is going to go the way of NDoc. The reasoning behind that could be a whole post in itself, but I'm not going to that today.

    Enter Finalbuilder. I have been following this tool since the time it was a one man operation. Back then it was listed with AtoZed Software's website. The company has since grown and now host their own website. Back then I was a Delphi and VB6 programmer, doing system-type programming. I built tools for automating business processes, much like what FinalBuilder does now.

    The beauty of FinalBuilder, is that I had only had to look at the help once, in all the years I had used it for work. Not only is it fairly intuitive to use, but it is a joy to work with. It doesn't get in my way. I know that Joel Spolsky uses it to do regular system maintenance activity at FogCreek. You can read what he says here: http://www.joelonsoftware.com/news/20020813.html

    FinalBuilder is out of the sweet pricing spot I mentioned before, but it can justify the price, because it does the automation well for many things, not just doing daily builds. Just as Joel's team, I'm going to be using it to automate several of my system maintenance tasks.

    I already been using it for building Beta 1. It has saved me about 45 minutes for the build time. The other big allure is that I now have a repeatable build process. This has also cut down on the manual typos that can creep in when doing NAnt scripts. I want to absolutely automate anything that I'm doing. I just don't have the time to be monkeying around, especially now that I'm much older (40 in a couple months). Monkey businesses is for younger people.

    I find that FinalBuilder is the most polished build system in this class of software produts. I have tried several others. Here are the competitors:

    I haven't used Automated Build Studio, but to be honest, I don't see how it could beat FinalBuilder. I think that the main reason for this, is that I, as a customer, have access to Vincent, the creator. That personal relationship/touch will trump any other emotional argument every time. I know a couple mISVs that use Automated Build Studio, and they tell me that they don't have that personal touch with that product. I always favor smaller companies, especially because of this personal touch. This touch is what is missing in today's business environment.

    I'm going to cut this short here. I was in the hospital earlier today, and I'm still under the weather. I'm surprised that I was able to be this coherent at all. Maybe I just write better when I'm on drugs, Promethazine at this moment. LOL. Anyways, I hear my bed calling to me.

    posted @ Wednesday, August 29, 2007 10:02 PM by Hector Sosa, Jr

    Posted in: Code, .NET Tools

    Actions:Tweet This Share on Facebook Share on LinkedIn Emakl Permalink del.icio.us
    Aug
    16

    PainlessSVN uses an open sourced library to "objectize" Subversion's command-line utilities. I have it listed on both SourceForge and CodePlex. I just started using SvnBridge to talk to CodePlex. CodePlex is oriented towards .NET projects, so I thought it natural to host the bulk of releases and work items over there.

    The changes in SVNManagerLib bubble up to PainlessSVN. I'm hoping to also power the upcoming XML-RPC server, that will allow me to make PainlessSVN work across WANs. I'm leaning towards XML-RPC, because it is a well known protocol and works very well in non-Windows environments. My goal is to have this running under Mono at some point. This will allow admins to run Subversion on Linux (and any other OS that supports Mono) and the front end on Windows. I have a friend that is creating a front end for the Mac.

    Here's the URL for the CodePlex project:

    http://www.codeplex.com/svnmanagerlib

    posted @ Thursday, August 16, 2007 7:45 PM by Hector Sosa, Jr

    Actions:Tweet This Share on Facebook Share on LinkedIn Emakl Permalink del.icio.us
    Aug
    11

    Here's a list of the tools that I use for both programming and maintaining my website:

    Programming

    .NET Libraries

    Intallation

    Databases

    • SQL Server 2000
    • SQL Server 2005 Express Edition
    • SQL Server 2005 Compact Edition
    • SQLite - http://www.sqlite.org

    Graphics

    Website

    System Administration

    Project Management

    These tools are the ones I want to use, but for lack of funds, time, or knowledge, I haven't been able to incorporate into my practices:

    I'm just amazed at the sheer number of programs that I'm using. I'm pretty sure I left out some, since I did this from memory. A couple of these are just way too expensive at this time. I'm  hoping to purchase them with the proceeds of the sales from the first version of PainlessSVN. This is one of the few disadvantages of growning a company organically.

    I have been making a habit to purchase applications and apps from microISVs. I also check the Business of Software forums and Larkware News for other microISVs for tools that could make my life easier.

    posted @ Saturday, August 11, 2007 7:39 PM by Hector Sosa, Jr

    Actions:Tweet This Share on Facebook Share on LinkedIn Emakl Permalink del.icio.us
    Jun
    10

    I had an interesting time with the output of the "svnadmin dump" command.  My original implementation looks like this:

      189         public static bool ExecuteSvnCommand( string command, string arguments, out string result, out string errors )

      190         {

      191             bool retval = false;

      192             string output = string.Empty;

      193             string errorLines = string.Empty;

      194             Process svnCommand = null;

      195             ProcessStartInfo psi = new ProcessStartInfo( command );

      196 

      197             psi.RedirectStandardOutput = true;

      198             psi.RedirectStandardError = true;

      199             psi.WindowStyle = ProcessWindowStyle.Hidden;

      200             psi.UseShellExecute = false;

      201             psi.CreateNoWindow = true;

      202 

      203             try

      204             {

      205                 Process.Start( psi );

      206                 psi.Arguments = arguments;

      207                 svnCommand = Process.Start( psi );

      208 

      209                 StreamReader myOutput = svnCommand.StandardOutput;

      210                 StreamReader myErrors = svnCommand.StandardError;

      211                 svnCommand.WaitForExit();

      212 

      213                 if ( svnCommand.HasExited )

      214                 {

      215                     output = myOutput.ReadToEnd();

      216                     errorLines = myErrors.ReadToEnd();

      217                 }

      218 

      219                 // Check for errors

      220                 if ( errorLines.Trim().Length == 0 )

      221                 {

      222                     retval = true;

      223                 }

      224             }

      225             catch ( Exception ex )

      226             {

      227                 string msg = ex.Message;

      228                 errorLines += Environment.NewLine + msg;

      229             }

      230             finally

      231             {

      232                 if (svnCommand != null)

      233                 {

      234                     svnCommand.Close();

      235                 }

      236             }

      237 

      238             result = output;

      239             errors = errorLines;

      240 

      241             return retval;

      242         }


    This code works for all the other commands just fine.  The culprit ended up being line 211. I created a new function to handle this. The code is below:

      253         public static bool ExecuteWritesToDiskSvnCommand( string command, string arguments, string destinationFile, out string errors )

      254         {

      255             bool retval = false;

      256             string errorLines = string.Empty;

      257             Process svnCommand = null;

      258             ProcessStartInfo psi = new ProcessStartInfo( command );

      259 

      260             psi.RedirectStandardOutput = true;

      261             psi.RedirectStandardError = true;

      262             psi.WindowStyle = ProcessWindowStyle.Hidden;

      263             psi.UseShellExecute = false;

      264             psi.CreateNoWindow = true;

      265 

      266             try

      267             {

      268                 Process.Start( psi );

      269                 psi.Arguments = arguments;

      270                 svnCommand = Process.Start( psi );

      271 

      272                 StreamReader myOutput = svnCommand.StandardOutput;

      273                 StreamReader myErrors = svnCommand.StandardError;

      274 

      275                 File.AppendAllText( destinationFile, myOutput.ReadToEnd() );

      276                 svnCommand.WaitForExit();

      277                 File.AppendAllText( destinationFile, myOutput.ReadToEnd() );

      278 

      279                 if ( svnCommand.HasExited )

      280                 {

      281                     errorLines = myErrors.ReadToEnd();

      282                 }

      283 

      284                 // Check for errors

      285                 if ( errorLines.Trim().Length == 0 )

      286                 {

      287                     retval = true;

      288                 }

      289             }

      290             catch ( Exception ex )

      291             {

      292                 string msg = ex.Message;

      293                 errorLines += Environment.NewLine + msg;

      294             }

      295             finally

      296             {

      297                 if ( svnCommand != null )

      298                 {

      299                     svnCommand.Close();

      300                 }

      301             }

      302 

      303             errors = errorLines;

      304 

      305             return retval;

      306         }


    The key to solving this was surrounding the call to WaitForExit() with file operations. Also needed to make sure to write the output to disk. Here are the relevant lines:

      275 File.AppendAllText( destinationFile, myOutput.ReadToEnd() );

      276 svnCommand.WaitForExit();

      277 File.AppendAllText( destinationFile, myOutput.ReadToEnd() );


    Notice that I make a call to File.AppendAllText() twice. I have found that the output stream does not write everything during the first call to File.AppendAllText() on some occasions.

    This will be obvious to people that are used to doing this in C and C++ and using stdoutpu and stderror. It's been a LONG time since I had to do anything like this. I had to dig for this information quite deep, as MSDN does not tell you about this, or my Google-Fu was not up to par.

    This code can be found in the open sourced library called SVNMangerLib. You can find it here:

    SVNManagerLib

    I formatted my source code in Visual Studio 2005 using this little gem:

    CopySourceAsHtml for Microsoft Visual Studio 2005

    posted @ Sunday, June 10, 2007 6:36 PM by Hector Sosa, Jr

    Posted in: Code

    Actions:Tweet This Share on Facebook Share on LinkedIn Emakl Permalink del.icio.us
    May
    31
     893 Views ::  1 Comments RSS comment feed

    I came across this little gem earlier this week. I just had a chance to test it tonight. I pointed it to an assembly, and it generated NUnit tests. The test were devoid of code, but there were stubs for everything that can be tested. Sweet!

    I'm one of those that are slowly getting into unit testing, and NStub is a time saver. Here's the URL:

    http://code.google.com/p/nstub/

    posted @ Thursday, May 31, 2007 9:46 PM by Hector Sosa, Jr

    Posted in: Code, .NET Tools

    Actions:Tweet This Share on Facebook Share on LinkedIn Emakl Permalink del.icio.us
    Jan
    07

    I've been experimenting with web services at an open source project I'm part of. It seems to be working well so far. I'm doing this to get a feel of how web services will work for an admin application like PainlessSVN. This will functionality will be added to the team edition of PainlessSVN.

    The open sourced project I'm working on is called WheelMUD and the website is http://www.wheelmud.net

    posted @ Sunday, January 07, 2007 12:17 PM by Hector Sosa, Jr

    Posted in: Code

    Actions:Tweet This Share on Facebook Share on LinkedIn Emakl Permalink del.icio.us
    Page 2 of 2First   Previous   1  [2]  Next   Last   
    Terms Of Use | Privacy Statement | SystemWidgets
    Copyright 2002-2012 by SystemWidgets
    Google Analytics Alternative