Categories
.NET C#

Creating thumbnail images with C#

Today, I’ve been searching for a .NET solution for resizing images to thumbnail sizes. I’ve found a solution using the System.Drawing classes.

You can use this method for creating thumbnails:

ImageManipulation.SaveThumbnail(srcImageFilePath, thumbnailOutFilePath, maxWidth, maxHeight);

Categories
PowerShell

Alternative for Invoke-SqlCmd

Invoke-SqlCmd ist a great cmdlet for PowerShell for querying SQL databases. But sometimes you don’t want to install the extra requirement SQL Server Management Objects on the server.

Invoke-SqlCmd -ServerInstance $Server -Database $Database -Query "SELECT * FROM Staff"

There’s an simple alternative. Use the .NET classes in the System.Data.SqlClient namespace which are available on every computer which has the .NET framework installed.

function SqlQuery($server, $database, $query)
{
 $connection = New-Object System.Data.SqlClient.SqlConnection
 $connection.ConnectionString = "Server=$server;Database=$database;Integrated Security=True;"
 $connection.Open()
 $command = $connection.CreateCommand()
 $command.CommandText = $query
 $result = $command.ExecuteReader()
 $table = new-object “System.Data.DataTable”
 $table.Load($result)
 $connection.Close()
 return $table
}

SqlQuery $Server $Database "SELECT * FROM Staff"
Categories
Web

Modify the window URL without reloading the page

Today I found an easy solution for the problem that if you’re changing the URL of the current window with JavaScript in the traditonal way, unfortenately the whole page will be reloaded.

window.location = "http://peter-doering.com/mynewurl"

You may want to update the URL after you’ve updated parts of the page with an Ajax call. This would enable the users to share the current page as link or to add an bookmark.

HTML5 introduced a new API for manipulating the browsers history. You can use the pushState()-method to change the current page url without page reload.

history.pushState(null, null, "http://peter-doering.com/mynewurl")
history.pushState(null, null, "http://peter-doering.com?id=1234")
Categories
Visual Studio

Using Visual Studio Code behind a proxy

Microsoft has built a new lightweight IDE Visual Studio Code. Actually VS Code has nothing in common with their traditional full-featured IDE Visual Studio. It’s more like an enhanced Code Editor like the Atom Editor or vim. VS Code is developed with pure JavaScript and it’s based an Electron (UI-Framework) and Node.js.

If you’re using VS Code from within a companies network und you probably may want to install plugins from the Internet, you have to set the proxy settings first. Because VS Code is built for cross-plattform-ability it isn’t aware of the Windows IE proxy settings.

Please open File -> Preferences -> Settings

Add these two lines to the settings.json:

// Place your settings in this file to overwrite the default settings
{
    "http.proxy": "https://proxy.contoso.com",
    "http.proxyStrictSSL": false
}
Categories
ALM Team Foundation Server VSO

TFS got a new homepage

Good News! Some days ago Microsoft published a release candidate of their first update to TFS 2017 (Release Notes).

The very big improvement is the new personal homepage.

If you’re using Visual Studio Online (VSO) in the cloud, you can activate the new homepage by clicking on the preview link.

Have a look at the Work tab. TFS has now an overall report of the open work in all team projects. This is the great new feature we have waited for years. Thank you Microsoft!

Nw you can always keep track of your open work in all projects.