Tuesday, October 30, 2007

Using Sharepoint activities in a workflow designer

If you're hosting the Windows Workflow designer control in your own application (this shows you how to host the control) and you want to use the Sharepoint activities, these are the files you'll need (these are for Sharepoint Services, I think there are more activities for MOSS 2007).

Microsoft.SharePoint.dll

Microsoft.SharePoint.Security.dll

microsoft.sharepoint.WorkflowActions.dll

microsoft.sharepoint.WorkflowActions.intl.dll

microsoft.SharePoint.workflowactions.intl.resources.dll

I'm not sure of the rules regarding redistribution of these files since I'm only using it for my own personal use. If you're having trouble getting any of these files out of the GAC then read this post which explains how to get them out.

Monday, October 29, 2007

MSDN forums not very useful

How hard can it be to write some code for a web forum? After all it's a problem that has been solved thousands of times before. Well apparently it's too hard for Microsoft. I've been trying to post to their MSDN forums for the last week and whenever I try to create a new thread or reply to a thread I get the following error message.forums

 

 

 

I've tried clearing out all the crud from IE, with no joy. So I'm forced to kick off a Virtual PC session to post, not very handy.

Not only that, when I get an email alert telling me about a reply to my post, the link starts with 'h ttp://forums.micro' so it doesn't fecking work.

A no-op activity

I'm in the process (no pun intended) of converting one business process XML language to XOML via some XSLT. I'm not really sure how some of the source activities will map to Windows Workflow activities so I'd like a no-op activity for the time being, just so I get the correct layout of the process, without having to nail down all the details. The solution is actually very simple, just use the base Activity class whose Execute method does nothing, simply returning ActivityExecutionStatus.Closed. Although it's not available in the Visual Studio toolbox, Visual Studio copes quite happily with a XOML file that contains an Activity activity.

Sunday, October 28, 2007

Web applications aren't the solution to every problem

I've been working on an ASP.NET website for a while now. For the admin side of things, I've added a few pages for updating the database and such like. There have always been problems with updating the data, which is read in from some text files and then dumped in the database. First there were problems with the size of the data in the files, which was solved initially via the maxRequestLength attribute in web.config. Then the file upload to the web server was still taking a long time so I started to require the data to be uploaded via Remote Desktop or FTP. Then I had problems with the SQL update timing out. This was solved by increasing the value of the executionTimeout attribute in web.config. But after a while even this didn't work and the update failed when the request timed out. I could probably increase the timeout some more or I could use some other technique to get it working, but I eventually came to the conclusion that this just isn't what I should be doing. ASP.NET sets these values quite low for a reason, it's just trying to protect itself from poorly written applications. A request to a web server should take as short a time as possible before getting the hell out of there. That's what the web sever is designed to handle.

So I ripped out the code and dumped it in a WinForms application. WinForms has no problems with threads that hang around for a long time so that solved my initial problem. And, even better, I can give feedback to the user very easily, without fiddling round with AJAX. It's also more secure. Remote desktop connections to this server are only accepted from certain IP addresses, whereas anyone might find the admin pages (even though they are password protected).

So to the moral of the story, remember that not every problem is a nail and there are other tools in your toolbox other than the hammer.

Thursday, October 25, 2007

The problem with LINQ

In principle it sounds like a great idea. Rather than having to learn SQL, XPath and whatever other query language you care to mention, just learn LINQ and use it to access any data source you like. That's great and all, if I'm using .NET 3.5 for every single project I work on. And until I am (which I'm guessing will be, er, never), LINQ is actually yet another thing to learn. So now I need to know SQL, XPath and LINQ. Or perhaps not, perhaps best to just forget LINQ and stick to the old stuff, since it works and is available on most platforms. When LINQ is available everywhere, then I'll start to think about learning it. 

Tuesday, October 23, 2007

MySQL error messages = crap

OK, it's an old version of MySQL (4.0.25 to be precise) but the error messages are completely useless. Almost any kind of SQL syntax error shows this helpful message.

#1064 - You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT PubID FROM Pubs )  LIMIT 0, 30' at line 1

Of course the problem is that MySQL 4 doesn't support subqueries (!), apparently MySQL 5 does and perhaps my ISP will upgrade one day...

Monday, October 22, 2007

SonicWall VPN client for Vista released

My post about the SonicWall Vista client beta is one of the most popular things on here, lord knows why. Anyway, the final version has been released and it is working perfectly for me. I've not had any problems with Vista complaining about two computers with the same IP address being connected to the network. I realise I'm really tempting fate writing that...

Friday, October 19, 2007

Licensing

Somebody emailed me asking what the licensing terms were for some code he'd found. I was surprised somebody would bother asking since I tend to assume any code I find on the web is public domain (although I wouldn't dream of stealing somebody's prose - odd how I think of code differently to the written word). But of course this isn't necessarily the case. In fact I believe if no licensing terms are explicitly stated, the code is by default copyright of the author.

So to clarify the licensing for anything on this site, any code samples are public domain. Do what the hell you want with them. I do however claim the copyright for the English on here, not because I think it's particularly valuable but because I don't want spammers stealing it for their own sites. Not that a little copyright theft is likely to stop them of course, but I don't want to make it perfectly legal for them either.

Whether any of this is legally binding, who knows, but I'm definitely not hiring a lawyer to tell me either way.

Improved Excel-like select all in a DataGrid

My first attempt at this worked mostly but if the user clicked anywhere in the grid that wasn't a cell, the whole grid would be selected, which wasn't what I was after. So here's an improved version which will only select all when the user clicks in the top left cell.

    public void SelectAll()
    {
      BindingManagerBase bm = BindingContext[DataSource];
      for (int i = 0; i < bm.Count; i++)
      {
        Select(i);
      }
    }

    protected override void OnClick (EventArgs e)
    {
      base.OnClick(e);
      Point client = PointToClient(Cursor.Position);
      HitTestInfo hitInfo = HitTest(client);
      if ((hitInfo.Column == -1) && (hitInfo.Row == -1))
      {
        if (client.X < TableStyles[0].GridColumnStyles[0].Width)
          if (client.Y < TableStyles[0].PreferredRowHeight)
            SelectAll();
      }
    }

Friday, October 12, 2007

Radiohead's pay as much you like strategy

I had every intention of buying the new Radiohead album from their website. After all, they've done exactly what I've asked for. It's DRM-free and the price is reasonable (since it's whatever I consider to be reasonable*). But I had some problems. First the site constantly timed out when I tried to connect yesterday (which I guess is a good sign since it suggests they are getting a good number of hits). When I did manage to connect and I registered, I was asked for my mobile number, which was a required field. Er, I don't have a mobile. And if I did, why do I need to give the number to you?

Unsurprisingly, the album is pretty easy to find from illegitimate sources and there are no hoops to jump through to get it from those sources. So if I wasn't fussed about a bit of copyright infringement, that's what I'd probably do.

It's clear the music industry and Radiohead are still missing the point about downloading music. Price isn't the key issue, although it's important (iTunes' pricing is completely screwed, I might as well buy the CD). Downloading has to be as easy, if not easier than the illegal alternatives.

*Since I've been disappointed with every Radiohead album released in the last ten years but have kept buying them in the hope they would repeat the brilliance of 'OK Computer', a reasonable price for me would probably not be very high.

Wednesday, October 10, 2007

Words that annoy me

Spelunking - This word comes from the caving community, the weird guys who like to go down small wet holes at the weekend (fnar, fnar). They may be weird, but their sport is kind of dangerous and possibly exciting. Now the geek community have appropriated the word to describe, er, groping around in new technology or source code. It seems to be a desperate attempt to make IT sound much more interesting than it really is. Look, computing is not cool, get over it.

Grok - What is wrong with 'understand'? It's been in the English language for quite some time and everybody (including normal, non-geek people) knows what it means. Also see above.

Regards - Email and the web have always seemed pretty informal to me. There was a time in about 1990 when I ended emails with some kind of sign off, but now I find my name is plenty to mark the end of a message. So when I see 'regards' (or worse 'kind regards'), I think that the person sending that message has some kind of problem. In fact, I wonder why they are being so formal and wonder if they are implicitly telling me to feck off.

Consumer - Is that all we are good for? Buying more tat to help fuel the economy? I am not a consumer, I am a person. When I think of consumers, I think of Fight Club - "working jobs we hate so we can buy shit we don't need"

Tuesday, October 02, 2007

Excel-like select all in a DataGrid

Clicking on the top-left cell in Excel selects the whole worksheet, which always seemed like a good use of an otherwise useless cell. So I've done the same with the DataGird-derived control I've been using in one of my apps. It's pretty damn simple to implement, but for the lazy amongst you, here's some code.

    public void SelectAll()
    {
      BindingManagerBase bm = BindingContext[DataSource];
      for (int i = 0; i < bm.Count; i++)
      {
        Select(i);
      }
    }

    protected override void OnClick (EventArgs e)
    {
      base.OnClick(e);
      HitTestInfo hitInfo = HitTest(PointToClient(Cursor.Position));
      if ((hitInfo.Column == -1) && (hitInfo.Row == -1))
      {
        SelectAll();
      }
    }