Dev Blog - Johan Danforth
I'm Johan Danforth and this is my dev blog - a mix of .NET, ASP.NET, Rest, Azure and some other random coding stuff.
-
[Team System] Getting Rid of Default Document Folders in the Quick Launch Bar
I just recently blogged about how to display document folders in the Quick Launch area of the TFS Sharepoint portal. Here's a follow-up to that one on how to remove the default folders which are created when you set up a new Team System project. It's all about modifying the Sharepoint template. You should only try this if you are creating a custom Team System Process Template.
1) Create a new test-project in Team System, don't bother to add any source control to it.
2) In Team Explorer, remove the Document folders and files you're not interested in. This will be reflected on the project portal. As is explained in detail at the MSDN site, you must also edit the Process Template XML files to reflect these changes to the template content. While at it, you may also delete any reports you don't want (or add for that matter), but again - modify the template XML files to reflect this. I'm pretty sure it will still work well, but you never know, things will probably be messed up if you don't. If you change the portal content, change the XML files (repeat as a mantra).
3) On the project portal, go to "Site Settings", "Go to Site Administration" and click "Save site as template". This will create an .stp file on the portal that you can download and put anywhere on your Team Foundation Server for now. Write down the name of the Sharepoint template because you need it in the following steps.
4) The rest about how to add the template to the server and so on is well described on the TFS site on MSDN. In short - Go to the server, add the template to the TFS by using the stsadm.exe tool and pointing at your .stp file. Then get back you your lovely Process Template files and refer to it (by name) in the <site> section of the WssTasks.xml file.
5) Now, upload the new Process Template to TFS, create a new project and see if it looks alright.
As I wrote earlier, to change the overall look and feel of the Sharepoint portal, you still need to use Frontpage, but that is something I will go into later.
-
[Team System] Displaying Document Folders in the Quick Launch Bar
Some people who are editing their Team System process templates and are new to Sharepoint wonder how to publish their own document folders in the menu of the portal home page. There are at least 2 ways - either use Frontpage (which I haven't tested yet), or in Sharepoint go to "Documents and Lists", click the folder in question, click "Modify settings and columns" in the left hand menu and then "Change general settings" and tell it to "Display this document library on the Quick Launch bar".
To modify the Quick Launch bar when it comes to reports and such, I think Frontpage is the tool. I'll try that as soon as I get Frontpage installed... not even sure which version of Frontpage to use actually.
Last thing to do is to modify the Sharepoint portal template in a way that suits the new process template, then create a new template out of it, make sure it's installed on the Team System server and then point at it from the WssTasks.xml file:
<site template="Your_Sharepoint_template" language="1033" />
Who said creating your own process template for TFS was easy? :) I'll get back to this process in a later post.
-
[Team System] Great Tool for Modifying Process Template
I found a great tool for those of you who wants to modify the process template - Process Template Editor from imagiNET, and it's free. It won't see to all your needs, but it's a great help and the best tool I've seen so far to get you started. You still need to do some manual XML editing if your goal is to create a completely new template, and I still need to find a good way to modify the document folders and the content within there. So far I've been editing the WssTasks.xml file by hand, and it *beeps*... :)
-
Get Padded Aspect Ratio Thumbnail Image
I needed a GetThumbnail method which kept the aspect ratio of the original and also scaled the image with decent quality. There are several ways you can do this, I got a few examples here.
First, there is the Image.GetThumbnailImage() method which is pretty good if you just want to scale down the original image to a specific size, say 64 x 64:
thumbnail = img.GetThumbnailImage(64, 64, Nothing, IntPtr.Zero)
But the problem with this method is the image get scewed and most people I think want to keep the aspect ratio. So if I want to scale down the original image by, say by 50%, and still keep the aspect ratio:
Private Function GetAspectRatioThumbnail(ByVal img As Image, ByVal percent As Integer) As Image
Dim ratio As Double = percent / 100
Return img.GetThumbnailImage(img.Width * ratio, img.Height * ratio, Nothing, IntPtr.Zero)
End Function
Very simple, yes, but if you've not been doing image manipulation before this could get you going I guess.
Now, I needed to fit a big image with unknown size into a fixed size area in a report, and this image area in the report streches the image to fit the bounds by itself. Not good. So I needed to both scale down the image, and "pad" it so it filled out the image area in the report. This little method helped me out here:
Private Function GetPaddedAspectRatioThumbnail(ByVal img As Image, ByVal newSize As Size) As Image
Dim thumb As New Bitmap(newSize.Width, newSize.Height)
Dim ratio As Double
If img.Width > img.Height Then
ratio = newSize.Width / img.Width
Else
ratio = newSize.Height / img.Height
End If
Using g As Graphics = Graphics.FromImage(thumb)
'if you want to tweak the quality of the drawing...
g.InterpolationMode = InterpolationMode.HighQualityBicubic
g.SmoothingMode = SmoothingMode.HighQuality
g.PixelOffsetMode = PixelOffsetMode.HighQuality
g.CompositingQuality = CompositingQuality.HighQuality
g.DrawImage(img, 0, 0, CInt(img.Width * ratio), CInt(img.Height * ratio))
End Using
Return thumb
End Function
You can tweek the quality of the image drawing as you see fit, it all depends on the size of the image, how much you need to scale it down and so on. I'm sure there are many other ways to do this, but it works for me.
-
[Books] Essential ASP.NET 2.0 - off to the presses!
My production editor at Addison Wesley just informed me that Essential ASP.NET 2.0 just went to press last week! I should have copies in my hand before Halloween, just in time to bring with me to TechEd Developers in Barcelona (where they should also be available at the conference bookstore, assuming everything is shipped successfully). If you won't be in Barcelona, you can also pre-order it from Amazon, Barnes and Noble, or Bookpool.com of course ;)
I'll see if I can pre-order it where I usually buy books like this... -
[Ajax] Top 10 Web 2.0 Attack Vectors
This technological transformation is bringing in new security concerns and attack vectors into existence. Yamanner, Samy and Spaceflash type worms are exploiting “client-side” AJAX frameworks, providing new avenues of attack and compromising some of the confidential information.
Worth reading I say. Especially #6, Client side validation in AJAX routines:WEB 2.0 based applications use AJAX routines to do a lot of work on the client-side, such as client-side validations for data type, content-checking, date fields, etc. Normally, these client-side checks must be backed up by server-side checks as well. Most developers fail to do so; their reasoning being the assumption that validation is taken care of in AJAX routines. It is possible to bypass AJAX-based validations and to make POST or GET requests directly to the application – a major source for input validation based attacks such as SQL injection, LDAP injection, etc. that can compromise a Web application’s key resources.
This is just not a common mistake in Ajax code, it relates to all web pages and forms where you leave input validation to be handled by JavaScript on the client side. If you're concerned with what data you get fed by people, always check it on the server side. And not just data from form fields, also check data you get via web services, POX over HTTP or even the product catalog you import from trusted parts.
-
Missing the App Pools Folder in Windows 2003?
Well, that happened to me today, and even though I've been working with Win 2k3 for quite some time now, not seeing the application pools where they were supposed to be quite baffled me :)
Of course the simple answer is that IIS was running in IIS 5.0 Isolation Mode (also called IIS 5.0 compatibility mode). Not sure why though, but I guess there may have been some issues with old COM components or something and therefore the default IIS settings were changed.
If you want to change back to "Worker Process Isolation Mode"? Just (quoted from TechNet):
1. In IIS Manager, expand the local computer, right-click Web Sites, and then click Properties.
2. Click the Service tab, clear the Run WWW service in IIS 5.0 isolation mode check box, and then click OK.
3. To start the WWW service, click Yes when asked if you want to restart IIS now.If the switch to worker process isolation mode is successful, a folder named Application Pools appears in the IIS Manager listing for your local computer. You can quickly determine which isolation mode IIS is running because the Application Pools folder is present in worker process isolation mode and absent in IIS 5.0 isolation mode.
-
Save Image to Byte Array
Saving an Image object to disk is straight forward, just call the Image.Save(filname) method and it's done. But what if you need to save that Image to a Byte() array (or Byte[] in c# speak ;) because you need to store it in a database or stream it somewhere? It turned out to be quite simple if you use the MemoryStream class of .NET and the Image.Save(stream, imagetype) method overload:Dim img As Image = LoadImageSomehow()Dim rawData() AsByteUsing ms AsNew MemoryStream()img.Save(ms, Imaging.ImageFormat.Png)rawData = ms.GetBuffer()EndUsing'do something with the rawData buffer here...Works for me. -
del.icio.us Buttons
-
Windows Presentation Foundation Resources