Posts

Showing posts with the label C#

My Adventures in Codeplex

In October 2009 I created 2 codeplex projects which I would to tell you about: SQL Server Reporting Services MSBuild Tasks (ssrsmsbuildtasks) A few years ago I created some tasks for MSBuild to help deploy reports for my project, details can be found here ,  since then my tasks have been re-used in a few other projects within my company.  However lately we have been doing a few projects which have made use of Reporting Services integrated mode with SharePoint, which meant that my tasks were unusable as they only work with a native mode report server. So I have been updating them to include support for an integrated mode report server.  Also before I added the integrated mode support I took some time to rewrite my original native mode tasks as well.  The re-writing of the tasks includes some improved understanding of MSBuild by making more use of Item Groups and metadata for setting of report server properties of the report items being deployed.  I plac...

Some practical SQL Spatial tips.

I have just finished a project were I made a lot of use of the SQL Spatial to do some processing and loading into the database. Here are some of lesson I learnt: The first method that needs to call after instantiating a SQLGeographybuilder object is: SetSrid() then the BeginGeography(), BeginPoint(). Before using sending a SQLGeometry object to the SQL Server use the IsVaild() function to ensure that Geometry object is valid. I create a console application which loaded line, which was using OS coordinates system, data from a flat file. Some of the line data within the file wasn’t as correct as I was led to believe. The application create the SQLGeometry object .NET but the Sql Server then rasied the error when it received and try to save it into the table. The STPointN() function is 1 base which is stated in the Books On-Line If your query needs to select some of the derive data from the functions you can help performance by using persisted compute columns on t...

How to load spatial data into SQL Server 2008 from .Net

I have been working on a project which made use of the spatial data type geography within SQL Server 2008. An issue that I had was how to load the geography data from a KML file into SQL Server 2008. Currently there is no out of the box tools to do this. There is a 3 rd party tool, Safe FME, which offer either their own tool or components which extend integration services. This was overkill for my issues as I only had to do it once. So I wrote a console application which parses the KML file to extract the point data convert it to a SqlGeography type and store it in the database. To use the SqlGeography C# type you need to add reference to the following name space: Microsoft.SqlServer.Types. This can be found in the following dll: Microsoft.SqlServer.Types.dll Then use the following code to create the c# sqlgeography type: 1: // use SqlGeographyBuilder to help create the SqlGeography type 2: SqlGeographyBuilder geographyBuilder = new SqlGeographyBuilder(); 3: s...

The Scrum for Team System report slide show tool

As I have mention in another blog posts; I’ve been heavily involved in the Scrum for Team System process template since the start of version 2 and to coincide with the release of version 2.2; I would like bring your attention to a new tool, which I help to developed, that has been added to this release. I started creating this tool due to some feedback we got from our beta users for “ TaskBoard for Team system ” tool. The request was to add a demonstration mode into the application which would show things like swimming lane-view and the following reports: Sprint burndown chart; Sprint cumulative flow as these can be view within the application. The reason for the request was create the sense of: "Look guys, this is what we are working on, and this is how we are doing", throughout the day, not only during the scrum meetings. This also happen a lot within our projects which they do something similar as well. Another reason for the tool to separate from the Task Board applic...

Using NDepend to help guide Refactoring

Image
In my other blogs entries I mention that I have been looking into building a Team Foundation Server Data Warehouse Adapter.   After I got my initial proof of concept version working, I started to extend it to get a list of available builds from TFS and then import the output of Source Monitor – a popular free code metrics tool. Now I must state that I am not a natural .NET coder. My normal day-to-day work is based around the SQL Server technology stack. I do have some .NET coding skills but generally just enough for what is need in and around SQL Server. So I asked my colleague, Howard van Rooijen who is one of our top .NET coders, to have a look at my code and give me some hints. This provide me with a great opportunity to learn from Howard about some more advance Design Patterns,  Visual Studio tips and tricks , and how to effectively use some tools I’ve not used before to help me write better code. The first thing Howard did was install the following on my machine: ...

How I built a Team Foundation Server custom data warehouse adapter

As mentioned in a previous blog I would like to explain some of the steps I took to get my custom data warehouse adapter to work.  I am going to start from the beginning just so that I have an easy starting point.  The code I show here was based upon my POC and written in C#. 1. Create a new C# Class Library project in Visual Studio. Then add references at least to the following assemblies: Microsoft.TeamFoundation.dll, Microsoft.TeamFoundation.Client.dll, Microsoft.TeamFoundation.Common.dll, Microsoft.TeamFoundation.Warehouse.dll and System.Web. As I need to connect to the build server I added Microsoft.TeamFoundation.Build.Common.dll and Microsoft.TeamFoundation.Build.Client.dll 2. Then specify the use of the IWarehouseAdapter interface. 3. Implement IWarehouseAdapter.RequestStop which only sets a stop flag to true which can then be tested by the other methods periodically. 4. Implement the IWarehouseAdapter.Initialize. This method this where I need to store objects tha...

Delpoying Reporting Services Reports With MSBuild

I am currently responsible for deploying our project into the test and production environments.   The project has a few reports which need to be installed on a few report servers.   The deployment tool that I am using for the rest of my project is MSBuild so I tried to see if there was a way of getting MSBuild to deploy the reports.   The only method that I found was to write an RS script file which deployed the reports and calls the Exec task to run the RS script.   So I started outright with RS script as I was not over joyed about writing VB.Net code as I am a C# coder. Then I remembered that MSBuild is customizable as it allows custom tasks to be written.   So I stopped writing my VB.Net code went back C# and created a few tasks that are commonly needed to deploy: AddReportUser, CreateReportFolder, CreateConnectionSoruces, DeployReports and SetReportsDataSource.   The task code was easy to write. I did have to change some of the auto generated code...

Report Viewer Customizing Printing for Local Report

We had a requirement to allow a front page, which was another local report, to be printed before the report within the report viewer was printed.  As both reports were local reports it was easy to create a print button which allowed us to meet the requirements, here is the code that we used: 1: if ( this .printFrontingSheetCheckbox.Checked) 2: { 3: LocalReport frontsheet = front.reportViewer1.LocalReport; 4: Export(frontsheet, 8.27f, 11.69f, 0f, 0f, 0f, 0f); 5: m_currentPageIndex = 0; 6: Print( false ); 7: 8: foreach (Stream s in m_streams) 9: { 10: s.Close(); 11: } 12: front = null ; 13: } 14:   15: LocalReport report = reportViewer.LocalReport; 16: Export(report, 11.69f, 8.27f, 0f, 0f, 0f, 0f); 17: m_currentPageIndex = 0; 18:   19: Print( true ); foreach (Stream s in m_streams) 20: { 21: s.Close(); 22: } 23:   24: private void Print( bool landscape) 25: { 26:...

Reporting Services Report Viewer using SQL Authentication

I have written some code, which will create a report and deploys it to a report server. However the connection string for the report has to use SQL Authentication. My code which builds the reports uses the same approach that Microsoft does to SQL Authentication within report, which is to not store the UserID and Password, so what would happen now when the report is displayed in the report viewer is that a prompt would appear asking for a username and password. This behavior had to be suppressed, because I did not wish the users to know or need to type in a userid or a password, so I tried to resolved this by looking for a way to get the connection string stored on the server when deploying the report, like you can when you use SQL Server Business Intelligence Development Studio, with no joy. I did find a solution with the Report Viewer control, there is method to send the data source credentials to the server without the user having to type them in. Below is an example: 1: rvRepor...

Createing threads for a windows form

I am wrining a program that has lenghtly process which si casing my UI to freeze. I now how to the solve the probelm which is create thread and let it do the processing. Now this new ground for me so I went looking for some explames on how to this and I found this link CodeGuru: Maintaining a Responsive UI , which I found easy to follow, that explains about UI thread and some of the probelms that can happen.

DTS Custom Tasks written .Net

After writing some custom task in VB6 for a client thought it would be better if they were in .Net. So after some research finding that it can be done I start re-writing them for .Net. I started running into some issues: Could not register custom task within the DTS client. This because Regasm does not expose the DLL entry point for DllRegisterServer, to solve this I had to write some extra code that will register the task in DTS. The task then could not be use within DTS. This was because the default create interface was incorrect by the fact there was read-only function which dts does not like, I had disable the creation of default interface and write my own version. The global variables not working after the .Net custom component set the values. This was some quirk between .Net and DTS as soon as try setting the value through the objects properties The activex script task and other tasks could not access the global variable. I mange to solve this deleting the Global variable and...

Multithreading .Net C#

Here is a list of articles that makes threading sound easy to do: Multithreading Part I: Multithreading and Multitasking Multithreading Part 2: Understanding the System.Threading.Thread Class Multithreading Part 3: Thread Synchronization Multithreading Part 4: The ThreadPool, Timer Classes and Asynchronous Programming Discussed