The Engine Room
The engine room is a place for people to contribute ideas on the development of Sharepoint, Visual Studio and information technology.

Even more cool new features in VSTS2010

On top of what I've mentioned here and here, there are even more cool features on VSTS2010:

  • Rich text editor when editing work items
  • Test case runner which allows a tester to pull the test case from TFS, follow the steps and flag them as pass/fail. But even better, this is all being recorded as video, so when the bug is sent back to the developer, he can replay the exact steps to reproduce it.
  • Creating bugs will also log the exact system information of the machine the tester was running on
  • TFS will even log a call stack to allow developers to analyze and reproduce the bug
  • Test Impact View: once you do a code change, it will identify which unit tests
  • Gated check-ins: no changes are committed into the repository until the change is verified. TFS will queue a build in the build server, will get latest version and it will verify that it is valid before commiting the change.
  • UML: VS can now generation sequence for the application's methods, to help analyze the impact of a change

If you haven't upgraded from TFS 2005 to 2008 yet, I'd recommend you do it now. The transition to 2010 will be much easier from 2008 according to the guys in the VSTS team. Also keep in mind that VSTS2010 will only support SQL 2008.

Microsoft Silverlight Futures: Building Business Focused Applications

I listed this session in my pre-pdc rant, and Jamie Cool definitively delivered an interesting presentation. The first part of the session was dedicated to Silverlight 2 (recently gone RTM) and the toolkit announced this week.

The Futures section of the presentation was around topics like navigation, data pagination, authentication and business logic.

I'd recommend you see these features in action. Check out the session video on this link

Silverlight toolkit

On day 2 of PDC2008, the Silverlight toolkit was announced. This release features a series of controls that were only available on WPF and adds charting controls (both static and dynamic). These charts are part of Microsoft's open source program, so the source code will be shipped with the controls as well. Another announcement was the tighter integration between Silverlight and Visual Studio. VS2010 will ship with a fully integrated Silverlight designer and WYSIWYG editor.

ASP.NET 4.0 Roadmap

This session fell into the "too much information too little time" category, which seemed to be the common denominator among the sessions at PDC. There are lots of things coming on the ASP.NET world and MVC, which has recently been released as Beta, is only one of them.

MVC has been very well received by the community and definitively shows promise. Microsoft has made it very clear that one of the main objectives with MVC is to appeal to the Ruby crowd. The other main aspects that will be the focus of ASP.NET 4.0 will be Dynamic Data (which will feature improvement to what has already been shipped in SP1), Core, AJAX and Forms.

In this last area, the main features are around more control over what it is rendered, cleaner HTML and improved JQuery integration (you can get a glimpse of the integration here)

There were 2 other interesting things mentioned: The new buzz word is "hybrid applications", where a web app does not have to be 100% MVC, Web Forms or Dynamic data but a mix of them using the right technology when appropiate. The second one was a brief mention of "Silverlight server controls". I wonder if more info about this will be available of day 2's keynote

Team Build and BVTs: The Gotchas

There are a couple of things that people forget or miss when setting up Team Build to run a series of Build Verification Tests.

·         Test tools need to be installed on the Build Server: Get you Visual Studio installation media. The only option that needs to be installed is “Team Developer and Tester tools”.

·         Once you have setup a series of tests and they are added to your “Test Manager”, you still need to create the BVTs in a new “Test List” or the build you configure won’t pick them up.

And just in case, you can run tests without an .vsmdi file. Check out this blog

Data Mining 101: Fact Tables

The information in these posts is a summation from the book Professional SQL Server Analysis Services 2005 with MDX (Harinath, S., and S.R. Quinn) - credit where credit is due.

The biggest confusion I had when reading about Data Mining was about Facts and Dimensions. When jumping in head first with some of the SQL Server Analysis Services (SSAS) examples, the tables in the example databases are nicely suffixed with _Dim and _Fact where appropriate, allowing you to select Dimensions Facts easily when prompted. But that doesn't necessarily translate to understanding what they are.

A key part of this comes from the last post about how the data sources used for data mining are actually re-architected (i.e. do not have the same schema as the original transactional system). The data is structured “in such a way as to facilitate later numeric manipulation" (Harinath & Quinn).

Fact tables are at the core of data analysis because they contain the values which will actually be 'crunched' - literally such as how many bikes were sold or records of outgoing expenses in the flat. Usually, as one would expect, these values are 'numeric' in order to do number crunching, but this depends on the type of data you are analysing.

I'll touch on how Fact tables differ from Dimension tables next week, but for the moment, the key idea is that Fact tables contain indisputable 'facts'. Even if you added more information to a row in the Fact table (e.g. qualifying that the $10 withdrawn from the Flat account on 23/7/07 was in fact to pay a bill), it only provides more information, but does not alter the unique 'fact' expressed by the data in the row (e.g. $10 Debit on 23/7/07)

Fact tables are often 'summarised' by pre-aggregating the data in some form (e.g. aggregating the total debits and credits per month would result in rows of $25.35 Debit in August for example). This allows improved query performance as the data has already been aggregated and the analysis engine does not have to perform that action. The Microsoft MSDN article linked below discusses some of the options about aggregating data and where it should be stored in the database.

Some useful links that have some more information and good examples:

Microsoft MSDN: Designing a Data Warehouse - Fact Tables: http://msdn2.microsoft.com/en-us/library/aa905984(SQL.80).aspx

DatumResources.com: Data Warehousing Objects - Fact Table, Dimension Table, Heirarchy Table: http://datumresources.com/moodle/mod/forum/discuss.php?d=36

Wikipedia: Fact table: http://en.wikipedia.org/wiki/Fact_table

Active Reports - .Value vs .Text Properties

It seems that some of the basics in constructing a good ActiveReport are often misunderstood, resulting in frustration on behalf of the developer in the form of 'Why won't this work?'. One of the most common mistakes I come across in ActiveReports is the misuse of the .Text property when dynamically assigning numerical values to textboxes with an OutputFormat property assigned.

 

About the OutputFormat Property

When constructing an ActiveReport, use the OutputFormat property of the textbox to specify any formatting for percentages, dates, currency or general numbers.

e.g.

Percentage     :    0.0%        formats as     78.5%

Currency    :    $#,##0.00    formats as    $52,187.23

Number    :    #,##0        formats as     2,548

         

This will apply the formatting string to the value which has been placed in the textbox AFTER the value is assigned, guaranteeing a consistent formatting result regardless of the value in the textbox. In the example above, I have specified a two decimal place currency format, complete with commas.

 

The Problem

Having already declared an OutputFormat property of a textbox specifying formatting, the calculated value is assigned to the textbox in the behind-code using a txtMyTextBox.Text statement.

 

int iResult = Employee.GetEmployeeTotals();

txtMyTextBox.Text = iResult.ToString();

 

This code shows a typical example of retrieving the value we want, and placing it in the text box. However, because the property .Text was used, this will literally remove all text in the box and replace it with the string. Any formatting strings, such as that specified in the OutputFormat, will be overridden and therefore not applied.

In this example, our result would be displayed without any decimal places, a currency sign or any commas.

To the frustration of the developer, it would appear as if the specified OutputFormat string has not been applied. Even adding a line in the code re-declaring the OutputFormat will not achieve anything.

The next inevitable step is modifying the code as follows.

 

int iResult = Employee.GetEmployeeTotals();

txtMyTextBox.Text = ((double)iResult).ToString("c");

 

This converts the integer result to a double to give us our two decimal places, and then uses the C# number formatting specifier of "c" which gives us currently complete with dollar sign and commas. We have now duplicated our ActiveReport OutputFormat property in the C#.

 

The Solution

So instead of using the .Text property, use the .Value property, yes, even with working with strings.

The difference is that the OutputFormat formatting string will be applied post value-assigning, ensuring a consistent format, and removing the need to place redundant string formatting in the C#.

In addition, it ensures that the formatting style you have declared in the ActiveReport is the one in use. Otherwise you could declare a formatting style with two decimal places in the OutputFormat, but format the string to a non-decimal format in the C#. In the end you would wonder why the textbox keeps displaying a 0 decimal answer, when you have specified two decimals.

Storing files in SQL Server 2008

There are many occasions where you need to store files along with metadata inside a database. An example of this would be a document repository where metadata and documents are all stored and managed by a system backed with a database.

Before SQL 2008 there were two methods to store the actual binary data for a file that you want to be managed by your system. Storing the file in the database as a binary object, or storing a URL to the file in the database which points to the file.

There are pros and cons for both which I will quickly touch on.

Storing binary objects in the database: 

Pros:     

·         Database backups will backup files stored in the database.

·         Transactional consistency for your stored files.

Cons:

·         Can potentially take up a large amount of room on the database server.

·         Large amount of disk IO to access file data can slow performance over the rest of the database.

·         Higher cost as database disk storage is usually more expensive than fileserver storage.

·         Harder to access the stored files.

 

Storing a pointer in the database to a file on a file system:

Pros:

·         Database can be kept small.

·         Separate file server for serving files will speed performance.

·         Lower load on the database server.

·         Can access the files through explorer.

Cons:

·         Need to manage two servers.

·         Separate backup.

·         Can lead to more data inconsistencies if files are ever moved/renamed.

 

A general rule for deciding between the two options is to store files inside the database for small systems, and move files out to a separate file system for medium to large systems. Here small systems are database server with medium to low load, and storing less than 10 gigabytes in files.

With the new VARBINARY(MAX) FILESTREAM data type in SQL Server 2008 we should be able to get the best of both worlds.

With the File stream data type, SQL Server will store files on an external file system, but these files will be managed by SQL Server. Your application can access these files as you would a SQL BLOB, with INSERT, UPDATE, and DELETE statements all working as expected. At the same time you get benefits of cheaper storage, the ability to access the data on the file system, and database backups will catch the file data.

Attachments in a WSS List

Sharepoint list attachments

 

Using out of the box sharepoint functionality, it is easy to add and view attachments to list items.

 

However, a common issue in WSS 3.0 is that customised list views do not support attachments ... or, "attachement".  The error "This form was customized not working with attachement" is displayed.

 

The only supported way of storing attachments to a list item, is to use the default newform.aspx page, associated with the given list.

This works, but has a number of restrictions:

Branding

It is difficult to brand or customise the upload form. Even though an upload.aspx file is associated with the list, it is not used (by default). The actual upload form which is used, is located in the 'Layouts' directory, on the webserver; any customisation of this would change the uploading form for all sites in the site collection. This is not desirable.

Views

The default newform.aspx used a listview to display the fields associated with the list. Unfortunately, there is no easy way to change the fields that are displayed to the user; all fields associated with the list are shown by default.

Customisation

With respect to general customisation of the newform.aspx, it is also possible to view the data using dataview webparts, and custom list forms. Unfortunately, both of these approaches appear to strip support for attachments; dataview webparts do not support an upload control, and custom list forms throw the error in the screenshot above.

 

Solution

 

In order to overcome the above issues, it is fairly simple to implement a custom webpart using the Visual Studio extensions for WSS.

The general process is as follows:

 

Setup the project

Firstly, create a new webpart project, using the VSeWSS. Then, change the class declaration to inherit from

 

Microsoft.SharePoint.WebPartPages.WebPart

 

The existing class definition inherits from the standard ASP.NET 2.0 WebPart class – this ensures interoperability with existing .NET webparts, but does not provide access to all of the sharepoint WebPart features.

 

Create the code structure

The default WebPart project contains a single overridable method "Render". The render method outputs straight html, via the use of a HtmlTextWriter. This method is not useful for our purposes: delete it. Create two new methods: CreateChildControls(), and RenderWebPart() – both should be defined as "protected override void".

 

The CreateChildControls() method instantiates the ASP.net controls that you want to use – in this case, a HtmlInputFile (for the attachment). Make sure you declare the controls globally. The RenderWebPart() method adds the controls to the Html, using the format

 

myControl.RenderControl(output)

 

Add your submission eventhandler

 

In your CreateChildControls() method, add a button with an event handler – this will be used to submit the entire form. Make sure you also render this button in the RenderWebPart() method.

In the eventhandler, create a SPList object pointing to the list you want to add an item to, and add an SPListItem to the list, using:

 

    SPListItem myItem = myList.items.add()

 

Now, add any properties to the listitem using:

 

    myItem["Title"] = "{title here}";

 

And, add the attachment, using:

 

    Stream fstream = myHtmlInputFile.PostedFile.InputStream;

    byte[] contents = new byte[fstream.length];

    fstream.Read(contents, 0, (int)fstream.length);

    fstream.Close();

    fstream.Dispose();

 

    myItem.Attachments.Add(Path.GetFileName(myHtmlInputFile.PostedFile.FileName), contents);

 

Finally, make sure you commit these changes to the listitem, using

 

    myItem.Update();

 

Summary

 

Hopefully, a future sharepoint release will solve the current implementation issues with list attachments. In the meantime, you may need to either use the default sharepoint behaviour (without customisation), or create a custom webpart. If you choose to follow the latter route, the preceding instructions should provide you with all of the tools you need to get started.

 

TF30162: Task "SharePointPortal" from Group "Portal" failed

This is one of the things that has been keeping me awake at night. Out of the blue (and yes, I know there will be a reason, but right know... I’m still investigating) I lost the ability to create Team Projects. Not only it fails but it locks my account.

I know it is permissions related, I know it is WSS related but I don’t seem to find exactly where the root of the problem is. At the MSDN forums, I got the following response from:

A Team Foundation Server administrator must be a member of the following groups:

1)      Team Foundation Administrators.

2)      SharePoint Administration group in SharePoint Central Administration.

3)      SQL Server Reporting Services Content Manager

4)      SQL Server Reporting Services System Administrator.

I am a member of the Administrators group of the machine, so that shouldn’t be a problem.

1)      Checked.

2)      I made myself secondary owner of the site collection

3)      I made myself a content manager in SQL Reporting

4)      I made myself a Reporting Services Sys Admin.

And the result was: FAIL! I still have the same problem. Will keep posting until I figure out the issue.

 Next >>