Using WordWriter to merge Word Documents

Several of our consulting projects have had a similar need: programatically merge multiple Word documents into a single Word file. Using SoftArtisans’ WordWriter, this task is fairly easy. In this article, I’ll show you how. If you’re not a current WordWriter user, you can download a free evaluation and follow along!

When you use WordWriter to merge documents, the page setup of the destination document you are merging into is used for all pages. (This follows the same behavior as Word.) If you create a new document to merge into, you’re resulting document will have default formatting.

If you want to preserve the formatting of each document that you are merging, insert a section break in your final output file before merging each document. You will then need to copy the formatting information from each document to the section you just created. Some types of document formatting that you may want to preserve include: margins; paper size or orientation; page borders; vertical alignment; and number of columns. (Text formatting, such as font, font size, text color are preserved, so you don’t need to manually set these.) Continue reading Using WordWriter to merge Word Documents

SSRS: Improve Performance by Automating Report Caching Using Null Delivery Provider

If you’re familiar with subscriptions in SQL Server Reporting Services, you may have wondered what the “Null Delivery Provider” is for. While it may seem odd to deliver the reports to a black hole, it does come in handy from time to time. In this post, I’ll show you how the “Null Delivery Provider” can help you increase performance by automatically creating cached reports. The basic idea is to create a data-driven subscription to run the report with a number of different parameter values to build the cached copies. This is similar to creating Execution Snapshots, but in this case we can specify a number of different sets of parameters, where as Execution Snapshots allow only one set of parameters. The “Null Delivery Provider” allows you to do this without having to save the reports somewhere, taking up valuable disk space, or have them emailed to someone, taking up valuable sanity.

In case you’re not familiar with cached reports, SSRS lets you create copies (or “caches”) of a report after the data has been gathered, but before the report has actually been rendered. When a user runs the report, it’s rendered from the cached copy which already has all the data. This means the queries don’t have to be run every time the report is generated. If you’d like to read more about report caching, there are some good articles on MSDN.

This example uses the Product Line Sales SSRS 2005 sample report. Everything for this example still works the same in SSRS 2008. Continue reading SSRS: Improve Performance by Automating Report Caching Using Null Delivery Provider

MBTA Bus Locator

I wrote an app for my G1 to get information from the real-time MBTA bus location feed and display it in Google Maps as bus icons. It was an interesting experience to develop for.

The Android eclipse environment has its fair share of hiccups unfortunately, simple things like how a down arrow usually behaves, or not being able to scroll all the way to the bottom of a list using your mouse scrollwheel. The emulator and eclipse’s debugging capabilities were really helpful, and robust for the most part. The most difficult thing in developing for it was figuring out how to do what I wanted to do, what functions and classes to use. I guess that’s inherent in developing for a new platform.

The app is pretty simple. It’s one screen, with most of it taken up by Google Maps and a bar at the top containing space for a refresh button and a status update box. It defaults to Watertown square when it starts, although that could easily be changed to use GPS or something else. When the app starts and when the refresh button is pushed, it retrieves a list of bus locations from the feed XML. Those locations are sorted by distance to get the 20 closest buses to where the center of the map is. (The distance is currently computed by sqrt(latitude^2 + longitude^2). This is slightly incorrect since a difference in latitude may be smaller or larger than a difference in longitude. I’ll fix that soon using this. Overlays are then created using a bus picture I got from Wikipedia and inserted into Google Maps. Continue reading MBTA Bus Locator

Manually Patching Backup Exec Remote Agents

After installing a live update on a backup exec media server, you may be tasked with updating all your Backup Exec remote agents (it is usually mentioned in the release nots of the update/patch). Symantec included a remote agent update tool that can be run from a media server, but occasionally it flakes out (like it did today for me with no explanation in the logs when attempting to update to 12.5 SP3). As long as the patch applied successfully on the media server this method below should work.

How To Patch BE Remote Agents Manually

Warning: I only tested this with BE Remote Agents for Windows!
  1. Copy the RAWSx32 (or RAWSx64) folder from the BE Media Server (located @ C:\Program Files\Backup Exec\Agents) to any server that requires the agent update.
  2. Open the Updates directory (in the RAWS32 folder) and find the most recent .msp file (MS patch file).
  3. Run that .msp file
    • You’ll may have to restart after applying.
  4. You can verify that the patch applied successfully a few different ways.
    • Rerun the remote agent update tool against the server. If it was updated then it should pop up a msg indicating so. I guess it is useful for something!
    • Compare the BE remote agent version on the media server against the server you updated by right clicking About the BE remote agent utility on the each box.

Where Did My Server’s Disk Space Go?

Every server administrator, at one time or another, has probably built a server image with a small primary partition housing the operating system/ possibly applications (raises hand)  and in hindsight wishes they hadn’t.

With the prevalence of virtual machines now in many IT environments, it is a lot easier to expand the disk either if you get into trouble, but chances are you still have a few physical servers left in your environment (domain controllers, backup servers, etc). So what do you do when you start to see that low disk warning?

Short term solutions for freeing up space
  • Run a disk cleanup
  • Compress large folders (check the contents before attempting this)
  • Remove $folders under the %systemroot&:\windows dir – typically these folders are uninstallers for updates/patches
  • Remove unneeded logs files – search for text files with a .log extension.
  • Remove everything from the download folder located @ %systemroot%\Windows\SoftwareDistribution\Download – this is the temp location where patches are extracted to.
  • Run Windirstat

Searching for Files with CAML

I was interested in searching for a file in a Document Library. Using a CAML query is much more efficient than iterating through the Document Library and examining each file. There are a couple of scenarios.

Searching at the root level of the Document Library

Searching for files is a little different from searching for other list items. In SharePoint, a file is shown with the same attributes as any other list item. When creating the CAML query, it would seem natural to search a field such as Title for a given file name. However, for a document, the Title field by default doesn’t store the file name. Rather, it contains arbitrary content that can be edited in Word (under the document’s Properties).

Furthermore, when creating the CAML query, you must reference a field using its internal name. So you won’t be able to use a field such as “Name”, as it is not a valid internal name (source: List of internal names for SharePoint fields).

Incorrect internal name error
If you don’t use the correct internal name of a field in a query, you may get the following error when attempting to access the results of the query: One or more field types are not installed properly. Go to the list settings page to delete these fields.

The correct field to use when searching for files is FileLeafRef, which is the appropriate internal name to use for the Name field. The C# snippet to create the query is as follows: Continue reading Searching for Files with CAML

List of Internal Names for SharePoint Fields

In order to reference a column or field using the the SharePoint object model, you often need to know its internal name. For example, when creating a CAML query, you can specify the field on which to search by providing its internal name. As opposed to the display name, which can be changed in the UI, the internal name is immutable. While the default display name and the internal name are often identical or similar, they can also be very different. The difference isn’t always consistent. For example, spaces in the display name can be removed, such as IsCheckedoutToLocal, or replaced with the hexadecimal equivalent, such as HTML_x0020_File_x0020_Type. Furthermore, the display name can be the same for more than one fields, so the internal name is the only way to distinguish between them.

You can quickly determine the internal name of a field using the UI:

  1. Open the List Settings page
  2. Under the Columns section, select a column to view the Edit Column page
  3. The URL of this page includes the internal name in the query string. For example, the URL for the Created By field includes the following query string List=%7BF641CEF1%2DCDE2%2D49E1%2D9800%2D861A408EF890%7D&Field=Author. The value for the Field parameter, Author, is the internal name for Created By. Continue reading List of Internal Names for SharePoint Fields

Adding Web Reference to SSRS 2008 in Visual Studio

To add a reference to SSRS 2005 in Visual Studio, you’d specify the URL to the Web Service definition file, for example
http://server/ReportServer/ReportService2005.asmx or equivalently http://server/ReportServer/ReportService2005.asmx?wsdl. You can use a shorter alternate URL, http://server/ReportServer/ReportService.asmx. If you open these URLs in a Web browser, you’d be able to view the content of the ASMX file.

With SSRS 2008, I’d expect to use the same URLs, replacing 2005 with 2008 where applicable. Alas, it doesn’t work that way. If you browse to http://server/ReportServer/ReportService2008.asmx, you’d get a directory listing rather than the expected Web service definition. A quick check of the MSRS10.MSSQLSERVER\Reporting Services\ReportServer directory reveals that the only relevant Web service definition file is ReportService2005.asmx. Further, the ReportService.asmx file has been inexplicably removed. Continue reading Adding Web Reference to SSRS 2008 in Visual Studio

Scripting Deployment of Reporting Service Reports with Stored Credentials

When developing SSRS reports, it’s convenient to deploy data sources and reports to the Report Server using Visual Studio. However, when it comes to production, using Visual Studio is not practical or even possible.

A common solution is to use a tool such as RSBuild, which lets you specify deployment parameters in, appropriately, an XML file.

Alternatively, you can use the SSRS Web service API directly by writing a console application in your favorite .NET language. You can also create a Visual Basic script that can be run on the command line by the RS utility that comes with SSRS.

The problem

I had to deploy a report with stored credentials. The report is deployed correctly from Visual Studio. For production, I wrote a console application to deploy the report based on the Microsoft Reporting Service samples. However, when the report is viewed, it always prompts the user to enter data source credentials, as seen below. Continue reading Scripting Deployment of Reporting Service Reports with Stored Credentials

Blogged