Friday, June 17, 2011

Fix for SQL Server users

Today I identified a bug in the SQL Server provider where it does not correctly handle roles that have been assigned to multiple albums. The package downloads have been updated, so if you downloaded 2.5.0 before today, grab the latest GalleryServerPro.Data.SqlServer.dll from the install or upgrade package and replace your version.

Tuesday, June 14, 2011

Gallery Server Pro 2.5 Released

Today I released Gallery Server Pro 2.5.0, featuring new support for Microsoft SQL Server Compact 4.0 (SQL CE), an improved upgrade experience, faster SQL Server performance, and numerous bug fixes. The compiled and source code versions are available for immediate download. The Web Platform Installer version has been submitted to Microsoft and should be approved within a few days. The DotNetNuke Module will be available in a few days as well.

Upgrading the gallery

The upgrade wizard has been revamped to make it even easier to upgrade your gallery. If you are currently using version 2.4 under .NET 4.0, all you have to do is copy the files from the upgrade package over your existing installation and then browse to the gallery. The upgrade wizard automatically appears and guides you through the process. If you are running an earlier version of .NET or are upgrading version 2.0 – 2.3, there are a couple more steps which are described in the Admin Guide.

The upgrade wizard automatically removes the cachingConfiguration section in web.config, which is no longer needed. (Caching is now done with the .NET 4.0 MemoryCache class.) It also deletes these DLLs from the bin directory:

  • AjaxControlToolkit.dll
  • System.Data.SQLite.DLL
  • Microsoft.Practices.EnterpriseLibrary.Caching.dll
  • Microsoft.Practices.EnterpriseLibrary.Common.dll
  • Microsoft.Practices.ObjectBuilder.dll
  • GalleryServerPro.Business.Wpf.dll
  • GalleryServerPro.Data.SQLite.dll
  • TechInfoSystems.TracingTools.dll

If you integrated the gallery into an existing site that requires one or more of these assemblies, be sure to save a copy and then restore them when the upgrade is complete. Similarly, if your site uses the caching functionality from the Microsoft Enterprise library, you will need to restore the cachingConfiguration section in web.config.

New SQL CE data provider

Earlier this year Microsoft released Microsoft SQL Server Compact 4.0. Prior to this release, it could not be used in ASP.NET applications. Microsoft spent a lot of effort making it work in a multi threaded environment like ASP.NET, and it now offers all of the benefits SQLite provided – such as XCOPY deployment and no external dependencies - while offering a few significant bonuses:

  • A single package for 32-bit and 64-bit operating systems – SQLite had a dependence on System.Data.SQLite.dll, which came in 32-bit and 64-bit flavors, necessitating a download package for each type of OS. While SQL CE also must be distributed with 32-bit and 64-bit versions of its engine, Microsoft figured out a way to have both of them deployed in the bin directory so we don’t have to worry about it.
  • Works in medium trust – SQLite only worked in full trust, forcing users in reduced trust environments to use SQL Server, which is more difficult to set up and maintain and not supported by some hosts. And when it is supported, it is often an extra cost option.
  • Increased data integrity – SQLite did not do type checking to verify, for example, that an integer is really being stored in the AlbumId column, nor did it enforce referential integrity. SQL CE does both.
  • Officially supported by Microsoft – SQLite has a robust user community, but the release of SQL CE pretty much eliminates any compelling reason to use SQLite. I expect that interest in maintaining the SQLite ADO.NET provider will shrivel up.

Gallery Server Pro uses Entity Framework 4.1 Code First and LINQ to communicate with the database. This technique allowed me to crank out the provider in a fraction of the time it took me to write all that ADO.NET code used in the SQLite and SQL Server providers.

One of the biggest benefits is that I was able to update the Web Platform installer version of Gallery Server Pro to use SQL CE instead of SQL Server. By switching to SQL CE, the installation process became much simpler because it no longer has to install SQL Server. I know a lot of users tried to install GSP through the gallery but got hung up with a SQL Server issue, usually something to do with logon credentials or not finding the database server. Those problems all disappear.

SQL Server is still fully supported. If you prefer to use it, be sure to download the install package instead of using the WPI.

Where is SQLite?

SQLite is no longer supported in 2.5 as I could not justify the effort in maintaining the provider. During the upgrade process, your SQLite data is imported to a SQL CE database file named GalleryServerPro_Data.sdf in the App_data directory. When the upgrade is complete, the old SQLite file at App_Data\galleryserverpro_data.sqlite is no longer used and can be deleted or archived.

If you were using SQL Server, you will continue to use SQL Server in 2.5.

.NET 4.0 requirement

Moving to SQL CE and EF Code First required changing the system requirements to .NET 4.0. This move brought a lot of side benefits:

  • Ability to use native .NET 4.0 caching instead of the Microsoft Enterprise Library, allowing us to get rid of the cachingConfiguration section in web.config and the three DLLs it required.
  • Use of LINQ. This simplifies certain kinds of coding patterns.
  • Elimination of multiple web.config files. Previous versions of GSP shipped with six – count ‘em – SIX versions of web.config for use in various .NET environments and trust levels.
  • Elimination of separate WPF assembly. I was able to integrate the WPF functionality – used for enhanced metadata extraction – into the business layer.
  • Reduced test matrix. Testing the code base on multiple .NET environments was time consuming.

Faster SQL Server performance

As I was refactoring the code to use the Entity Framework, I noticed opportunities for improving the performance of several areas. These improvements affected both data providers, but are especially noticeable when using SQL Server. The greatest improvements are in galleries having thousands of users or tens of thousands of media objects. This was achieved in three main ways:

  • Re-architecture of the maintenance algorithm that runs during each application restart.
  • Improving the algorithm that maps user roles to albums.
  • Using ordinal positions when retrieving data from a data reader. For example, using dr.GetInt32(0) instead of Int32.Parse(dr["AlbumID"].ToString(), CultureInfo.InvariantCulture).

jQuery 1.6 compatibility

When jQuery 1.6 was released on May 3, it introduced a breaking change that affected a few of the pages in the site admin area. At the time, I blogged about a workaround where you tell GSP to use the older version of jQuery. The new version of GSP fixes those issues, so after the upgrade you can point jQuery back to the original value “//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js”. Do this on the Site Settings – General page.

In fact, you have to do this, since the fix requires jQuery 1.6. Specifically, GSP uses the new prop() function. If you don’t point to the latest version of jQuery, you may discover problems in a few areas, such as the inability to navigate media objects using the Next and Previous buttons.

Code analysis

The code analysis feature of Visual Studio 2010 was used to implement coding best practices. I had run this a couple years ago but much of the code has changed and it was time to do it again. Nothing serious was found but I did make hundreds of changes. Most changes fell into these categories:

  • Perform parameter validation at function entry points and throw an ArgumentException and ArgumentNullException as appropriate.
  • Include an IFormatProvider when processing strings and numbers.
  • Ensure Dispose() is called on all disposable objects. I was already doing that on most but I had missed a few.

Elimination of Ajax Control Toolkit

GSP has used the Ajax Control Toolkit to provide a few impressive UI effects, such as fading when navigating between media objects and creating interactive HTML DOM elements. However, the industry has recognized that jQuery is a better option and has largely abandoned the toolkit. Furthermore, versioning issues have always been a hassle. GSP now uses jQuery for effects previously handled by the toolkit.

Fixed bugs (detailed report)

  • Watermark image is locked by IIS process
  • Watermarked image sometimes fails to be rendered
  • Thumbnail image not generated for PDF files
  • Paging doesn't work on search results page
  • Deleting the root album results in "Album not found" message
  • Incompatibility with jQuery 1.6.0
  • Blank page may appear when error occurs
  • (SQL Server) Delete unnecessary foreign key from gs_Album table
  • (Sql Server) Length of MIME type columns different between gs_BrowserTemplate
    and gs_MimeType
  • (DotNetNuke) Album treeview navigation doesn't work when user-friendly URLs are
    disabled

Upgrading your gallery to .NET 4.0

Gallery Server Pro 2.0 – 2.4 runs on any version of .NET from 2.0 - 4.0. Beginning with version 2.5, Gallery Server Pro requires .NET 4.0 or higher. This change allows GSP to take advantage of new features such as Entity Framework Code First development for SQL Compact CE and LINQ, while also simplifying the packaging and documentation requirements. (You may have noticed that 2.4 ships with six versions of web.config!)

If you are currently running GSP 2.3.* or 2.4.*, I recommend upgrading your gallery to .NET 4.0 *before* upgrading the gallery code to GSP 2.5. Technically, you could perform the .NET 4 upgrade and the GSP 2.5 upgrade at the same time, but why complicate things? By separating it into two steps, if anything goes wrong, it will be easier to troubleshoot.

What if you are using GSP 2.0 – 2.2? Those versions never shipped with a .NET 4.0 version of web.config, and I don’t think it is worth the trouble trying to get them working under .NET 4.0 only to immediately upgrade to GSP 2.5. For these versions, I recommend performing the upgrade to .NET 4.0 and GSP 2.5 at the same time. The Admin Guide has instructions for how to do this.

The rest of this post is intended to help you get your GSP 2.3 – 2.4 gallery running under .NET 4.0. This basically involves two steps:

1. Configure IIS to run the application under .NET 4.
2. Update web.config to conform to .NET 4.

Configure IIS to run the application under .NET 4.

This step is performed with IIS Manager (type inetmgr in a Start-Run box). For IIS 6, right click the gallery web application and choose Properties. Then click the ASP.NET tab and select 4.0 in the ASP.NET version dropdown box.

For IIS 7 and higher, the .NET version is associated with the application pool the application is running under. In IIS Manager, select the Application Pools node in the treeview, then double-click the relevant application pool in the grid. A dialog appears where you can change the .NET Framework version to 4.0. If you don't know which app pool the gallery is running under, right-click the name of the application in the treeview and select Manage Application - Advanced Settings. This brings up a dialog window that shows the app pool.

If you are using a hosting provider, look in your host’s control panel for this setting.

Update web.config to conform to .NET 4.

The web.config file, stored in the root of the web application, contains several references to a specific version of .NET. These must be updated to .NET 4.0 references or, in some cases, removed since they are now present in the machine-wide web.config file. Follow these steps:

  1. Rename your existing web.config to web_old.config.
  2. Grab the relevant web.config from this download and copy to your web application. For example, if you have version 2.3 with SQLite as your database, use web.config from the “Files for upgrading from 2.3\SQLite” directory.
  3. (SQL Server only) Update the connection string to your SQL Server database in web.config with the one from your previous one (now named web_old.config). It should be named SqlServerDbConnection.

Notes

  • If you made any changes to your web.config file, you must manually migrate them to the new web.config file.
  • If your version is 2.3.3421 to 2.3.3512, you should also migrate the <location path="gs/services/Gallery.asmx"> section from your old web.config file. (This section is not required in 2.3.3512 and later, as there is a web.config file in the services directory that performs this task.)
  • You are on your own if you want to get GSP 2.0 – 2.2 working on .NET 4.0. It can be done, but you have to carefully upgrade your web.config to the .NET 4.0 version. As I said before, for these versions I recommend upgrading to .NET 4.0 and GSP 2.5 in a single step. Instructions are provided in the Admin Guide.

Tuesday, May 24, 2011

Bug: Thumbnail image not generated for PDF files

Today I discovered a bug that affects all galleries upgraded from a version earlier than 2.4.3. You are affected if all of the following are true:

  • You have PDF files in your gallery.
  • You originally installed GSP before version 2.4.3 and then upgraded to one of the later versions.
  • Your site is running in Full Trust.
  • You installed the Gallery Server Pro Binary Pack.

In short, this is a bug in the SQL upgrade script that shipped in 2.4.3 and later. Fortunately, there is an easy fix.

First, some background: In a default installation GSP creates a generic thumbnail image for PDF files, like this:

GenericThumbnailImage_PDF

When you install the Gallery Server Pro Binary Pack, GSP uses the ImageMagick and GhostScript utilities to generate a thumbnail image that is an actual preview of the PDF file:

AdminGuide_ss_116x145

Today I discovered a bug, introduced in 2.4.3, where PDF files *always* get the generic thumbnail image, even when the binary pack is installed. The cause of this is a typo in the SQL upgrade script for 2.4.3:

UPDATE [gs_GallerySetting]
SET [SettingValue] = 'pdf,.txt,.eps,.psd,.tif,.tiff'
WHERE [SettingName] = 'ImageMagickFileTypes';

See the typo? I missed the period in front of ‘pdf’. To fix your gallery, update the setting to include the period. You can use this SQL:

UPDATE [gs_GallerySetting]
SET [SettingValue] = '.pdf,.txt,.eps,.psd,.tif,.tiff'
WHERE [SettingName] = 'ImageMagickFileTypes';

Since these settings are cached, recycle the IIS application pool to force the gallery to get a fresh copy from the database.

The next version of GSP will include a fix for this.

Tuesday, May 10, 2011

jQuery 1.6 introduces breaking change

On May 3, jQuery introduced a new version that breaks some of the functionality of Gallery Server Pro 2.4.6 and higher. Earlier versions are not affected. Also not affected is the Gallery Server Pro DotNetNuke Module, *unless* you explicitly changed the default jQuery settings. The good news is there is an easy fix I describe at the end of this post.

Background

Gallery Server Pro uses jQuery to provide a rich user experience. Starting with 2.3.3750, a default installation of GSP uses the Google hosted versions of the jQuery library rather than a locally stored copy of the .js file. This allows the browser to use a previously cached copy of jquery, resulting in a faster loading page.

There are a number of ways one can construct the URL to point to Google’s copy of jQuery. Here are a few examples of how I’ve tinkered with the URL:

2.3.3750: http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js

2.4.0: http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js

2.4.5: http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js

2.4.6 – 2.4.8: //ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js

Notice how the version number is specified. By omitting the minor version from the 2.4.6 and later releases, Google automatically serves the latest 1.X release. You get the benefit of having the latest version of jQuery without having to explicitly upgrade.

But there is some risk with that approach, which brings me to the topic of this post. On May 3, jQuery released version 1.6. It contains a number of improvements and performance enhancements. Unfortunately, it also introduces a breaking change that causes an immediate problem on all 2.4.6 and higher Gallery Server Pro releases. Earlier GSP versions are not affected because the jQuery URL pointed to either a local jQuery file (versions earlier than 2.3.3750) or one of the 1.4 versions. jQuery 1.6 changes how attributes are handled. The details are in this blog post, but what it means to GSP is that the handling of checkboxes and the enabling/disabling of HTML elements in several of the admin pages are broken.

For example, as user happylynlyn pointed out yesterday in the forum, selecting the option ‘Override the following default settings’ on the Gallery Control Settings page no longer enables the child options. This issue also affects the Manage Roles, User Settings, and Metadata pages.

The issue only affects these few pages in the site admin area – browsing the gallery and performing tasks in the gallery (add/editing objects, etc) are not affected.

The Fix

I will have this resolved in the next release. Until then, there is an easy workaround – just tell Gallery Server Pro to use an earlier version of jQuery. On the Site Settings – General page, update the jQuery path to specify version 1.5:

jquery1.6fix

Friday, April 29, 2011

Gallery Server Pro 2.4.8 Released

Version 2.4.8 was released today. It contains fixes for three bugs that won’t seriously affect most people, but I wanted to get it out the door so I can focus on the 2.5 drive. The release includes these fixes:

  • Logging in does not preserve the original requested album or media object
  • Cannot manage users or roles when they contain certain characters
  • (DotNetNuke) Gallery doesn't work when user-friendly URLs are disabled

Get more details about the bugs here. To upgrade from 2.4.7, download the 2.4.8 files to your hard drive. Then replace the GalleryServerPro.*.dll files in the bin directory with those from the download. Finally, replace the following files in your gallery with the matching file in the download:

  • App_GlobalResources/GalleryServerPro.resx
  • gs/pages/admin/usersettings.ascx

If you are upgrading from a version earlier than 2.4.7, follow the instructions in the Admin Guide.

Friday, April 22, 2011

Gallery Server Pro Roadmap

I’ve gotten a lot of good feedback in the poll about the future of Gallery Server Pro – keep on voting! I am particularly pleased that the two lowest vote-getters are “improve performance” and “improve reliability”. That tells me you think Gallery Server Pro is fast and robust. I spent a lot of time getting it there, so it is gratifying to see some objective confirmation.

Based on those results and my internal spidey sense, here is where I see the upcoming versions and features working out. This is rough and can and will change, but at this moment it is my best guess.

2.4.7 (Released April 21, 2011)

  • All known issues in the 2.4.X code base are fixed and the product is stable and performing well.

2.5 (June 2011)

  • Migrate the code base to .NET 4.0.
  • Replace the SQLite data provider with SQL Server CE 4.0. This will allow for simple xcopy deployment that works in medium trust – kind of the holy grail I’ve been wanting for several years.

3.0 (2012)

  • Easier skinning/customizing UI (the top vote-getter in the poll)
  • User comments/ratings (#2 in the poll)
  • New upload experience (#3 in the poll). Allow multiple file selection on client. Possibly include option to create optimized images on client and upload those rather than original images, greatly reducing upload time.
  • Tagging (heirarchical?)
  • Virtual albums: browse by tags, most recent, top rated, most commented, user
  • Editable metadata
  • New sorting options
  • Allow users to password protect individual albums/media objects
  • Namespaced javascript so multiple instances of control can be on same web page

Future (2012-2013)

  • Add viewmode 'Map' that displays map of GPS coordinates
  • Allow gallery-level settings to be overridden at the album level (MO title template, watermark, etc)
  • Allow separate media object title templates for thumbnail and optimized images
  • User quotas
  • Ability to regenerate captions from updated MO title template
  • Mobile app support
  • DeepZoom support
  • Fullscreen slideshow
  • Expand scope of error log to be an event log
  • E-mail notifications of gallery updates
  • Log history (viewing, edits, delete, etc)

Way, way Future (2040-2050)

  • Include teleport feature to take viewer to GPS location embedded in image

Keep your feedback coming. Does this roadmap gel with your needs?

And keep those donations coming! Your financial support allows me to continue working on Gallery Server Pro instead of taking some high-paying consulting work. The pay is poverty-level (average donation for Jan-Mar 2011 was $1300/month), but is highly satisfying, so I expect to keep at it as long as I can keep paying the bills.