Auto-Updater

After the last few releases of applications I’ve been creating for my client it became apparent that we were in need of a more automated process that could guarantee that each employee using the software was aware of, and was made to upgrade to the latest version. This came after a relatively small change to the program to pull more data from a database than trying to dynamically determine the information from disconnected data. The systems around here are a bit on the rustic side of the technology spectrum.

 

Anyway, we’re using Framework 1.1 and desktop deployments are not as user friendly as the ClickOnce of Framework 2.0. There are still the manual processes, and the limitations of not having proper system/network access being a lowly consultant. So, I decided I would write an auto-updating plug-in for the applications, but first I’d check to see what others have done in order to save myself time.

 

That’s when I came across an article by Peter A. Bromber, Ph.D., that addressed building a Framework 1.1 Automatic Application MSI Updater. Pretty swanky, so I decided I’d take a look at his code as obviously he’s run into problems similar to my own. After digesting everything that he had to offer my mouth was left with an unsatisfying flavor of, well, I could do better to say for short.

 

Article for reference: http://www.eggheadcafe.com/articles/20060213.asp

 

Seeing that I could not use a webservice, since I’m not allowed to access the main servers, I was left with a less dynamic alternative. I would just have to use the App.Config file to point my application to an Access database, don’t ask. The access database I’d model similar to Dr. Brombers, but with better column names.

 

I then crafted my own implementation of his code, I noticed early on his recursive lookup for the assembly version was pointless, and also decided to create a typed dataset to return my data values. So I present to you my own implementation, in the works, of the Framework 1.1 Auto-Updater. Of course it’s still in the works as I’m not particularly fond of the fact that while the new installer is running, if you’re installing into the same file directory the running application can not complete until the old application is closed. You are forced to hit the ‘continue’ button twice in order to force the installer to overwrite the running application who spawned the installer via a new process. Anyway, here is my updated code:

using System;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System.Diagnostics;
using System.Reflection;
using System.Windows.Forms;
using ClientName;

namespace ClientName
{

/// <summary>
///
/// </summary>
public class AutoUpdater
{
private static OleDbConnection connUpgrade;

/// <summary>
/// Opens the Upgrade databases OLE DB connection.
/// </summary>
private static void OpenDbConnection()
{
string connString = string.Empty;

try
{
connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ConfigurationSettings.AppSettings.Get("UpgradeDbPath");
connUpgrade =
new OleDbConnection(connString);
connUpgrade.Open();
}
catch(Exception err)
{
CloseDbConnection();
}
}


/// <summary>
/// Closes the Upgrade databases OLE DB connection.
/// </summary>
private static void CloseDbConnection()
{
if(connUpgrade != null)
{
if(connUpgrade.State != ConnectionState.Closed)
{
connUpgrade.Close();
connUpgrade.Dispose();
connUpgrade =
null;
}
}
}

/// <summary>
///
/// </summary>
/// <returns></returns>
public static bool CheckForUpdate()
{
bool result = false;
string appName = string.Empty;
string lastVersion = string.Empty;
string currentVersion = string.Empty;
string appExeName = string.Empty;
UpdateDataset.AppVersionsRow appRow = null;

try
{
// Get the current assemblies Product Name
appName = Assembly.GetEntryAssembly().GetName().Name;
appRow = GetAppVersionInfo(appName);

if(appRow != null)
{
lastVersion = Application.ProductVersion;

if
(appRow.CurrentVersion != lastVersion)
{
UpdateForm frmUpdate =
new UpdateForm();
frmUpdate.BringToFront();
frmUpdate.StartPosition = FormStartPosition.CenterScreen;
DialogResult dlgResult = frmUpdate.ShowDialog();

if (frmUpdate.UserAccept == true)
{
Process proc =
new Process();
proc.StartInfo.FileName = appRow.AppExeName;
proc.StartInfo.WorkingDirectory = appRow.InstallerPath;
proc.Start();
proc.WaitForExit();
Process.Start(Application.ExecutablePath);
Environment.Exit(0);
}
else if (dlgResult == DialogResult.Cancel)
{
result =
false;
}
}
}
}
catch(Exception err)
{
Environment.Exit(0);
}

return result;
}

/// <summary>
/// Gets the Application Version record for the supplied
/// application product name.
/// </summary>
/// <param name="appName"></param>
/// <returns></returns>
private static UpdateDataset.AppVersionsRow GetAppVersionInfo(string appName)
{
string sqlSelect = string.Empty;
UpdateDataset dsUpdate = null;
OleDbDataAdapter adapter = null;
OleDbParameter param = null;
UpdateDataset.AppVersionsRow appRow =
null;

try
{
dsUpdate =
new UpdateDataset();

sqlSelect = @"SELECT AppName, AppExeName, InstallerPath, CurrentVersion FROM AppVersions WHERE AppName = @appName";

OpenDbConnection();

adapter =
new OleDbDataAdapter(sqlSelect, connUpgrade);

param = new OleDbParameter("@appName", OleDbType.VarChar);
param.Value = appName;

adapter.SelectCommand.Parameters.Add(param);
adapter.Fill(dsUpdate.AppVersions);

CloseDbConnection();

appRow = dsUpdate.AppVersions.FindByAppName(appName);
}
catch(Exception err)
{
string message = err.Message;
}
finally
{
CloseDbConnection();
}

return appRow;
}
}
}

26. March 2008 00:48 by Rampidbyter | Comments (0) | Permalink

Whats up?

I’m having a fantastic morning already. I’m not really in that great of a mood but the major upgrade that was performed to the applications I’ve been working on took place last night. There was a lot riding on it. I previously was using a disconnected dataset to perform lookups and matching to load order specific comments into another dataset that held parts dynamically allocated to specific orders. This added an overhead of about four minutes to the load time of the application to individually do this for each application when it first started.

 

I knew right away something had to be done about this. I’ve batched everything else into processes that are fired off during the initial parts pegging application, and this seemed like another need area. SO after identifying all the possible solutions to this problem on paper I went about trying each. Finally I found the solution. Create a new field in the database where the parts were stored to, and then fill in the comments each morning. The programs would run as they normally do with the user totally oblivious to where the comments were stored. At the end of the night the batch processes would run, wipe out the part list, regenerate the part list, and while doing so would do the dynamic lookup of previously issued comments using the new part criterion.

 

Last night it was made apparent this was needed to be pushed out into production. Everything was relying on this program, and thankfully it worked like a charm. However, it wasn’t all roses and chocolates. The program’s normal run time has been steadily increasing, due to the MS Access connection limitations, and due to the networked file share location of the database. The program has to update the database by copying over 15,000 parts, 35,000 build dates, updating the initial 50,000 parts looped through, and maintaining data on about 45,000 PO and WO combinations. Needless to say each one takes a few milliseconds to complete, but the sheer amount of data bogs down Access to where it takes several hours to update all this information.

 

So my task today, while keeping mind on the other applications I’m still working on is to speed up this process even more. It’s kind of hard using the outdated technology that I’m using, the older .Net framework, and the limitation to using MS Access. So we’ll see what I can cook up. Either way the new process worked on its first time in the sandbox. Hopefully we can make it peppy now. Stability and reliability come first right?

24. March 2008 18:39 by Administrator | Comments (1) | Permalink

New blog - company blog - and swag.

I went to the annual all-company meeting yesterday and was greeted with the birthday party for my company. They just turned fifteen years old last week, and in order to celebrate everyone was greeted to a feast. Not only did we get some sweet chow, but we were also given our choice of either a laptop bag that is Ipod accessible, or a backpack with Ipod accessories build in. I think it’s like the one they’re selling on ThinkGeek.com. Anyway, awesome, but we were also exposed to the next big plans of the company. I’ll stay mute on the details other than to say that we’re setting up a company blog.

 

Our new marketing guru is a giant blog fiend; his presentations reek of success and have the distinct feeling of professionalism that makes my skin want to start taking salsa lessons. In short the guy seems to know how to get his marketing on, and I’ll give it to him he’s got the charisma of a class full of Dallas cowboy cheerleaders. Unfortunately there were no Dallas cowboy cheerleaders, but maybe next company meeting? Guess nobody got my memo.

 

Anyway, I suppose that means I’ll be blogging on two fronts. The first of which, will be here where my internal dialog has a home, and the second will be my company blog. We’re trying to reach out to the community and share our group knowledge. Borg anyone? That’s a Star Trek reference in case you’re not in the know. However, I’m not going to be able to really talk about anything other than what I’m working on in the vaguest of sense. Like right now I’m working with JD Edwards Enterprise One. Here I can safely rename it to JD Edwards Enterprise Suck. See, freedom right there. No, at the company blog I’ll probably have to tone it down and mention how I have experience with working around, er, I mean making JD Edwards Enterprise One work better.

 

I suppose at some point I’ll get back to focusing on providing more technical blog posts about some technology I’m working with. Nothing incredibly exciting at the moment, DSN database connections, VB.net windows services, command driven program, management interface software, integrated ASP classic web pages, serviced soft parts pegging application, Kanban quantity calculation processing, and mostly going through the daily grind to work on six applications at once. One thing I can tell you is hard is explaining to a client they have to wait six minutes for an application to refresh its data because you’re having to go through about 40 million database records to get the status, date, and part details for sales orders. Now, that’s the hard one right there sir.

28. February 2008 20:31 by Administrator | Comments (0) | Permalink

Tak(en)ing for granted

Every now and again it occurs to me that things, while seemingly unpleasant in situation, are often made unpleasant by ones attitude on life. I find myself in a daily battle with my client as we’re both entrenched in this dilapidated new system that they’ve implemented worldwide, and are each day at the mercy of the vendors. It’s been over a month now and several requests we’ve put through for procedures to be pushed to production are still in backlog.

 

I’m sitting here after going through the third iteration of releasing this application to my boss, who is very particular about his interfaces, and I just feel a little at peace. I’ve been stressing, stressing, and have become so entrenched in the day to day goings of my client I’ve nearly forgotten I work for another company. I suppose that is not a bad thing since I tend to work more hours than I bill, and am generally pleased to be around these people. I’m a little disappointed that at some point I’ll leave and never really figure out what happens with them, whether what I did mattered, or whether they’re going to curse my name afterwards.

 

At my home company email traffic has dried up, and every once in a while I get news from home base. I don’t expect much more from being a consultant, but it seems the personal contacts I’ve made do not share the same interest to stay in communication. Not that it matters, but it was nice to get to know them on a less work based basis.

 

I like being a consultant, it’s nice to be able to switch companies, switch job duties, and not be pegged to one particular duty. However, I’m not in control of my hours (only am to an extent), I’m not in control of where I work, and I’m not in control of the environment I’m exposed to. Up to this point I’ve been blessed to work with a dedicated group of people in both a financial company, and now in an industrial company. I must say I much prefer the industrial company over any other. It’s a whole unique environment filled with procedure, diverse (in the sense of personality over skin color) group of people, and most of the time people have been in the company on the long term. They’re more vocal about their needs, and that’s what I want to know. I can make them crap and call it dinner, or I can make them steak. It all depends on how they’re willing to work with me, and to this point I can only lump praise on their acceptance of my work. I’ve not yet been called a son of a bitch like many others before me. Trust me, my division manager is quick to point out ones faults, and thus far he’s only been kind. He’s even told me that after I’m done working here I’ll be drinking 40’s, and praying never to see this place again. A lot of the guys ask me if I’ve brought the long necks, or 40’s when I come into the room to install applications. I tell you, appreciation goes a long way, and here I feel it daily.

27. February 2008 20:36 by Administrator | Comments (0) | Permalink

Another day...

Yes indeed I got me one of them PIC boards. I bought a book recently to get myself up to par with a friend whom is deeply engaged in embedded programming. I’m going to work with my friend off and on for the next undetermined period of time on a robotics project. So in order to get my knowledge level up to his I’ve been trying to train myself programming in C, and programming embedded systems. I’ve actually found myself giggling while reading the C programming books because they were written (most of them) well before I was born. The one I was reading last night was published in 83’ and referred to the ANSI standard as the assumed standard that may or may not be adopted in 87’. It’s like a mini trip back in time with these books, but it seems anymore I’ve started very high level then started moving backwards.

 

Anyway, got off topic there, but I bought a PIC programming board, two microprocessors, and the devices required to flash the software to the MCU. Using my UC email address I secured myself a nice little 25% off instant discount, and am expecting the device to arrive sometime in the next three weeks.

 

On a personal note it’s getting closer to Valentines day the corporate day of the year that men (and maybe lesbians) are forced to bestow gifts upon their loved ones. Should we fail in this bestowment of goodies to the womenfolk there is often a swift and unjust punishment. Both that and they cry, and if they cry you don’t want that model because her seals are cracked (not to mention her brain.)

 

So again, this year like all the rest, I’m stuck trying to figure out what to get her. I think last year she got me things, and I got her a strange look on my face. I’m never a good person to ask about when important dates happen. I forget my own birthday most years.

 

Ugh, I’m very stressed out at work. I have one application I’ve been re-writing for the last month. It’s take a long time to get it to work well. Yesterday was the point to which I’ve completely gutted and re-wrote the entire application. I deleted the last comment/code piece written by the previous developer. I’ve had to do that with a lot of his programs. I was originally brought on in order to finish these projects with a final debug. Ha, final debug in that the thing was finally put to rest and a new one born from my code. New programmers have a lot to learn, and unfortunately companies not properly training them just lets them learn on their own through trial and error. Usually the error is what happens when they run these programs, and when the people leave the company is left to suffer through. I’ve had to re-write five applications thus far with more coming. I’m still working on the project I was brought on to finish before January, but due to in-development on the full blown system I’m stuck in the holding line. We’re working hard to get this pushed out. The other four apps build on top of the output generated from the main application, which the business actually runs on. So for the moment I generate output from the main app, hand off the data files, another guy takes them into Excel, and formats the output. From there it goes off for use in production assembly. So we’re trying to get the main app published, and I’m building the four other applications that present the data to users instead of Excel sheets. These other programs facilitate change in the business flow, and allow the user to make on the fly changes to the information instead of submitting a mocked up Excel document. Anyway, still working so I’d better get back because my test case is just about finished.

7. February 2008 00:05 by Administrator | Comments (0) | Permalink

GeekSpeak

I was asked a few months ago to give a presentation at my companies once a month GeekSpeak this January. I was to give a presentation on the new features available to ASP.Net 2.0. Considering there are so many new features, and many of the new features were provided to limit the amount of code required I decided to give a presentation on the code-less functionality of the new features for ASP.Net 2.0. The hope was that by showing how the controls could be simply be dropped onto a form, configurations set through the GUI, and then deployed without many hassles it would show off the neat new abilities provided by ASP.Net 2.0. At least that was my thought anyway.

Well, I got out of my client site about 4pm after working a solid nine without lunch, and started booking it downtown. The client is a little more than an hour away from the downtown office in case you were wondering. I get to the office about 4:40 (may have sped a little), went up to the bullpen (u-shaped cubicle isle way where developers work) to chat with a few associates I hadn’t seen in a while, and started into the presentation room at 5pm. Things were good, everyone had a beer from the company fridge, I was getting setup, and the night before I fixed the lack of SQL Express on the laptop that prevented me from including local databases into the APP_DATA folder. After getting setup I tried to use the projector to display my main display, and that’s when the problems started. First the monitor appeared on the projector (as a second monitor when marked as attached), and regardless of what I nor anyone else tried the projector would not display my main display. Thank you Dell Latitude D610 and your (l)atitude against working properly with external displays.

So in the end we worked out a combination where I displayed the main display on the projector via the Fn-F8 key combo, and I gave the presentation sitting sideways to everyone. It was a bit awkward as I had to violate the don’t speak to the room with your back turned policy, but I did try to focus on returning my focus. Having been up till after 1am studying for finance, troubleshooting the lack of SQL Express/installing SQL Express on the work laptop to display my examples, well it left my brain a little scattered. I gave the presentation and unfortunately deviated from the planned material I had wanted to focus on. I never do prepared speeches as I’m not likely to remember them verbatim so I like to give on the fly presentations as its pretty interesting what new topics get addressed that may otherwise have been scripted over.

In the end I started to recover the presentation about a quarter of the way into giving the talk and trying to demo the material. It went a bit smoother, not totally ripple free, but in the end we got some dialog from the room. Three of the audience members have used ASP.Net, and my luck is that our resident SharePoint expert was in the room, and wanted to contradict that a custom user control plopped into the WebPartZone on the page did not represent an actual WebPart. I’m aware of web parts, and the coding required to make them render correctly, but the way I see it is that a custom user control included into the WebPartZone with attributes set would constitute a WebPart. I’ll have to do more reading to determine who is accurate, but the point stands that it’s still a neat feature to have when developing web applications.

Anyway, the presentation went ok, not fantastic, but I suppose it went well. I’ve yet to hear any feedback (so it could have been horrible) so I’ll have to wait till I hear anything about it before I profess adequate success or major inner office fax-pas. It’s strange being able to talk in front of total strangers without unease, but giving presentations to a group of people I work with and know caught me on edge. I suppose the jitters may have won this round, but the war continues.

23. January 2008 22:58 by Administrator | Comments (0) | Permalink

Movin’ on up, maybe.

Had a meeting earlier with my departmental manager over lunch. During the meeting two things were said that I didn’t realize, first I’m being tapped to take the companies management training program, and second that my contract at my current client is being extended. Cool, and cool. I’ll apparently be out here an additional three months because they’re very pleased with my products and services.

The one about being tapped for management training is neat, and very unexpected. The person whom I’m currently assigned as a trainee too is also being tapped for the same program. I thought it was kind of funny that we’re both being tapped since technically he’s supposed to be overseeing me, and now there may come a time when I’m overseeing others. From what my manager told me I’m being tapped because the company sees me as a valuable asset that it want’s to keep around for the long term, which is pretty neat considering most consultants are only around for about two years.

9. January 2008 01:29 by Administrator | Comments (1) | Permalink

Dumb += Insert Foot In Mouth

Sometimes you can do the dumbest thing without realizing what exactly you’ve done until it’s too late. The other day I ran into a new colleague named Bill who told me about the companies free luncheon they were having. I immediately skipped up and devoured turkey, taters, green beans, pumpkin pie, and assorted dressings. It was fantastic food, but anyway I digress.

I get back to my desk after filling my stomach and my new head boss comes walking by, stops, and goes "Rob, we’re having a lunch today free for employees did anyone tell you?" I waste no time immediately spewing, "Oh, I already hit that." Without blinking an eye my new main boss turns around and heads off, which I reply "thank you though" to him as he leaves. Immediately after I said what I said the guy sitting across from me started to chuckle at my response. That’s when I realized exactly what I had said, and not having meant for it to come off so disrespectful especially when I only said that because my boss was leaving as he mentioned to me about the free lunch. My foot still is dangling solidly embedded in my mouth…

17. December 2007 19:23 by Administrator | Comments (0) | Permalink

Calendar

<<  January 2009  >>
MoTuWeThFrSaSu
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678

View posts in large calendar

RecentPosts