Assembly 2011 Summer

By Petteri Lehtonen
Saturday, August 13, 2011
Posted in Blog
Tags:

The Assembly demo party is a demoscene and gaming event in Finland. The most recent Assembly was held from the 4th to 7th August 2011 at Hartwall Areena in Helsinki.

The first Assembly was held from July 24th to July 26th 1992, in Kauniainen. It was organized by the Amiga demo groups Complex and Rebels, and the PC demo group Future Crew. The staff grew into a large non-profit group of individuals known as Assembly Organizing. Through the 1990s, Assembly grew so large that even exposition halls no longer sufficed, and only the largest of sports arenas met the partygoers’ needs. In 1999 they rented the largest sports arena in the country, Hartwall Areena in Helsinki, with over 5000 visitors and 3500 computers on the ice rink and it has been held there ever since. As of 2011 the party has been held for 20 consecutive years.

Read More

Creating an Epic Wedding Reception with Silverlight 4

By Petteri Lehtonen
Sunday, July 31, 2011
Posted in Code
Tags:

This might no be very useful information when creating line of business applications, but I thought that it is cool enough that it’s worth sharing.

It all started when my brother decided to get married and organize a party after the ceremony… you know the usual wedding stuff… As a best man i wanted to do something to make this wedding stand out from the rest. Since i pretty much suck at everything not computer related so that’s what I had to go for. :)

Read More

How to create Waterfall charts in QlikView

By Niklas Lindman
Wednesday, March 16, 2011
Posted in Code

Every now and then customers want waterfall charts in our QlikView applications. As this is not a standard chart type in QlikView, it is not completely straightforward. This is how we have done it.

Read More

More SharePoint Event Handler Gotchas

By Andreas Finne
Monday, December 20, 2010
Posted in Articles

In a previous post, I wrote about a few gotchas that you may come across when doing event handlers in SharePoint. After writing that one, I’ve come across a few more. These are related to number fields.

Gotcha number one, which is not that weird actually, but is good to know about, is that number columns are always stored as doubles. I had a column defined to include numbers from 0 and up, with zero decimals. The error occurred in my event handler, when I tried to do int.Parse(properties.AfterProperties[<field name>].ToString()). This failed miserably. When inspecting the actual result of the .ToString(), it turned out to be “1.000000000000”, and not “1”, as expected.

Gotcha number two, which is a bit stranger, turned up after I had found out about gotcha number one. Both properties.AfterProperties[<field name>] and properties.ListItem[<field name>] return objects, BUT the underlying type for the AfterProperties is string, while the ListItem properties are the real type, in this case double. So, the properties.ListItem[<field name>] could be cast directly to a double, while the properties.AfterProperties[<field name>] had to go through a double.Parse(properties.AfterProperties[<field name>] .ToString()).

Well, that’s it for now. I have a few more “gotcha”-posts, and a couple of “did you know that”-posts waiting to be written, so stay tuned.

IPv4 address conversion for log reporting in TMG 2010

By
Tuesday, November 9, 2010
Posted in Code
Tags: , ,

Both ISA Server 2004/2006 and TMG 2010 can store logs in SQL Server (MSDE/Express Edition) which is recommended configuration.

Unlike ISA Server which stores IP address as bigint type TMG 2010 stores them as GUIDs for IPv4 and IPv6 compatibility.

So, a function is needed to see IPv4 addresses in easily readable way.

CREATE FUNCTION [dbo].[GuidToIPv4]
(
@guid VARCHAR(36)
)
RETURNS VARCHAR(15)
AS
BEGIN
 DECLARE @hex VARCHAR(8)
 SET @hex = LEFT(@guid, 8 )
 RETURN CONVERT(VARCHAR(3), sys.fn_replvarbintoint(sys.fn_cdc_hexstrtobin(LEFT(@hex, 2))), 0) + '.' +
  CONVERT(VARCHAR(3), sys.fn_replvarbintoint(sys.fn_cdc_hexstrtobin(SUBSTRING(@hex, 3, 2))), 0) + '.' +
  CONVERT(VARCHAR(3), sys.fn_replvarbintoint(sys.fn_cdc_hexstrtobin(SUBSTRING(@hex, 5, 2))), 0) + '.' +
  CONVERT(VARCHAR(3), sys.fn_replvarbintoint(sys.fn_cdc_hexstrtobin(RIGHT(@hex, 2))), 0)
END
GO

Actually, IPv4 address forms a GUID where first 8 characters naturally make 4 bytes in hex – 1.1.1.1 makes 01010101-FFFF-0000-0000-000000000000 and 255.255.255.255 makes FFFFFFFF-FFFF-0000-0000-000000000000, so if you read hex fluently – here you go. :-)

SharePoint Dispose Checker Tool

By Andreas Finne
Thursday, September 9, 2010
Posted in Apps
Tags: ,

When using the SharePoint object model, it is important to properly dispose of instantiated objects of certain classes to avoid memory leaks. The most common objects that need to be disposed are SPSite and SPWeb. However, there are certain situations where it is not obvious that an instance is even created.

The SharePoint Dispose Checker Tool checks your assemblies against the dispose patterns listed in Roger Lamb’s SharePoint Developer Blog to check whether any of the patterns are in your code without being disposed.

The tool is run from the command prompt with your assembly as argument, or alternatively, a path to a folder containing several assemblies. If the PDB-files are in the same folder, the output will include additional source information about the problems detected.

Check it out at http://code.msdn.microsoft.com/SPDisposeCheck

SharePoint: Run with elevated privileges

By Andreas Finne
Tuesday, June 22, 2010
Posted in Code
Tags: ,

When developing using the SharePoint object model, certain operations has to be run with elevated privileges. For instance, setting information into the property bag of a site needs to be done with elevated privileges. This post shows how this is done, and also includes a helper method for making it easier and shorter to do this.

There is a method called SPSecurity.RunWithElevatedPrivileges in the object model that takes a delegate as argument. The delegate is then run with more permissions. An important note regarding this: You must not use old references to SPWeb or SPSite instances inside your delegate, since they are “contaminated” with lower permissions. What you have to do is to create new SPSite and SPWeb instances using the Ids of the sites and webs you already have a reference to, like this:

SPSecurity.RunWithElevatedPrivileges(delegate()
{
    using (SPSite site = new SPSite(SPContext.Current.Site.ID))
    {
        using (SPWeb elevatedWeb = site.OpenWeb(webId))
        {
            //Your code here
        }
    }
});

If you need to do these kind of operations in several locations, this is a lot of repeating code to include. A colleague of mine made a small helper method that does the setup for elevated privileges for you. Here’s the short code snippet:

private delegate void CodeToRunElevated(SPWeb elevatedWeb);
private static void RunElevated(Guid webId, CodeToRunElevated secureCode)
{
    SPSecurity.RunWithElevatedPrivileges(delegate()
    {
        using (SPSite site = new SPSite(SPContext.Current.Site.ID))
        {
            using (SPWeb elevatedWeb = site.OpenWeb(webId))
            {
               secureCode(elevatedWeb);
            }
        }
    });
}

To invoke this, you call on the method with the Id of your web as one argument, and a delegate taking an SPWeb as the other. When the method is invoked, the SPWeb argument will be “uncontaminated” and pushed to elevated privileges. This example sets the name, title, and description of a site.

RunElevated(web.ID, delegate(SPWeb elevatedWeb)
{
    elevatedWeb.Name = siteTitle;
    elevatedWeb.Title = siteTitle;
    elevatedWeb.Description = siteDescription;
    elevatedWeb.Update();
});

We’re hiring in Vaasa

By Jörgen Westerling
Thursday, June 17, 2010
Posted in Blog

We have been on the quiet side on the blog lately, but fortunately that’s because we’ve been super busy with customer work. This means we need more dev muscle.

Sorry for spamming the blog with a recruitment plug, but if you are a guru dev looking for a change of scenery in the Vaasa region, have a look at our job posting on our main web site here. Thanks!

SharePoint Event Handler Gotchas

By Andreas Finne
Wednesday, April 21, 2010
Posted in Blog

In a previous SharePoint project, I implemented a few event handlers that get called whenever an item in a list gets changed (or added/deleted). There were a few problems along the way that took a bit of searching before I found solutions. This post documents a few of the things that are good to know.

Read More

SQL access with integrated security from SharePoint

By Andreas Finne
Thursday, April 15, 2010
Posted in Code

When creating custom webparts or other custom features in SharePoint that retrieves data from a SQL server, there are a few gotchas and pitfalls that you should be aware of. I spent a few hours battling a couple of problems, so I thought I’d document the things I found out here to spread the knowledge.

Read More