Friday 26 September 2014

Making Conference / Group call Using Rebtel

If you are a Rebtel user and want to make a conference / group call, then this post is the right place for you. Rebtel is a great, cheap way to make international calls to your loved ones with crystal clear voice quality. I love it and I'm sure that you do too. So when you get what you need without much effort you want more, that’s human nature and in Rebtel's case more is possible in the form of Conference / Group calls.

Wednesday 24 September 2014

Delete Language Branch from all pages and site in EPiServer

Suppose you have large content (e.g. 3000 pages) in your EPiServer CMS project, supporting multiple languages e.g. English (en), French (fr) and Italian (it). Pages might be created using different page types.
You want to delete a language branch e.g. French (fr) from all pages where it’s used and from the website. You don’t know exactly how many pages use French (fr) language.

Thursday 11 September 2014

Get Usage report of EPiServer Page Types & Block Types

Are you are working with a large project build in Episerver? Over the years developers create new page & block types in the system. Editors then create content using new content types and stopped using the old ones. That resulted in piling up a long list of page types, and some of them were not in use.

Tuesday 9 September 2014

DNN: TreeView File Manager nodes and Module "Action" menu not working

I upgraded a client's DotNetNuke version to DotNetNuke 5.1 to 5.6.3. The DNN Portal which was running DotNetNuke Version 5.6.3, while I was working on it, all of a sudden the filemanager stopped working properly "Spinner in the Root TreeView". Same problem was with the modules "Action" menu. It was a mess to do anything on the website in edit mode.

DNN: Change DotNetNuke Username from SQL Server

Sometime users request to change their usernames, the reason could be they don't want to lose their activities in the system. There can be many other reasons but the fact is I have deal with these request time to time.So here is a solutions.

If you are going to change the username from SQL Server, make it repeatable, you might want to wrap the syntax in a transaction. You don't want want the two tables to be out of sync. 

Here is sample series of T-Sql statements. Should be easy to convert to a stored procedure

declare @oldName nvarchar(128)
declare @newName nvarchar(128)
declare @error_var int, @rowcount_var int
declare @newNameCount int

select @oldName = 'someUsername'
select @newName = 'newUsername'

begin transaction

select @newNameCount = count(*)
  from Users
  where Username = @newName
if @newNameCount > 0
  RAISERROR('Username already exists. @newName=%s', 10, 1, @newName)

update Users
set Username = @newName
where Username = @oldName

SELECT @error_var = @@ERROR, @rowcount_var = @@ROWCOUNT
IF @rowcount_var <> 1 OR @error_var <> 0
  RAISERROR('Could not Update User.Username. @oldName=%s', 10, 1, @oldName)

update aspnet_Users
  Username = @newName,
  LoweredUserName = LOWER(@newName)
where LoweredUserName = LOWER(@oldName)

SELECT @error_var = @@ERROR, @rowcount_var = @@ROWCOUNT
IF @rowcount_var <> 1 OR @error_var <> 0
  RAISERROR('Could not Update aspnet_Users.Username. @oldName=%s', 10, 1, @oldName)

Commit transaction


This post is from my old blog posted on May 2012, that unfortunately no longer exist.

DNN: Programmatically Assign Role to User In Dotnetnuke

Assigning role to user programmatically can easily be done using DotNetNuke's RoleController in your code. It means without storing role info in database, and programmatically assign a role rights to the user. You can call AddUserRole function in RoleController to perform this action the below code might help you in achieving this

Remove Skin and Container from .ascx control in DotNetNuke

I was stuck in an annoying problem while working of one of my modules in DNN. The Ideas was to load a usercontrol while click on button, But instead of clean skinless form, DNN automatically add the container and skin into it. That bugged me a lot. So how can you open a .ascx user control in a popup/ new window in DotNetNuke without a Skin and Container. 

Upgrade SQL Server: Security updates for all supported versions of SQL Server

Microsoft released a security bulletin covering several issues that could potentially affect SQL Server; these exploits include remote code execution, denial of service, information disclosure and elevation of privilege. You should test these patches on all machines running SQL Server, including those running only client tools (e.g. Management Studio or Management Studio Express). The updates affect the following versions of SQL Server:
  • SQL Server 2005 SP3
  • SQL Server 2005 SP4
  • SQL Server 2008 SP1
  • SQL Server 2008 SP2
  • SQL Server 2008 R2
So, depending on your SQL Server version (run SELECT @@VERSION;), here is what you should do:

If you are running... And your build number is... Your best course of action is probably to...
SQL Server 2005 Less than 9.0.4035
Upgrade to Service Pack 3 (9.0.4035) or Service Pack 4 (9.0.5000), then come back for the GDR
Exactly 9.0.4035 (SP3) Install the SP3 GDR (9.0.4060) from KB #2494113
Between 9.0.4036 and 9.0.4339 (a) Upgrade to Service Pack 4 (9.0.5000), then come back for the GDR
(b) Install the SP3 QFE (9.0.4340) from KB #2494112
Exactly 9.0.5000 (SP4) Install the SP4 GDR (9.0.5057) from KB #2494120
Greater than 9.0.5000
Install the SP4 QFE (9.0.5292) from KB #2494123
SQL Server 2008 Less than 10.0.2531
Upgrade to Service Pack 1 (10.0.2531) or Service Pack 2 (10.0.4000), then come back for the GDR
Exactly 10.0.2531 (SP1) Install the SP1 GDR (10.0.2573) from KB #2494096
Between 10.0.2532 and 10.0.2840 (a) Upgrade to Service Pack 2 (10.0.4000), then come back for the GDR
(b) Install the SP1 QFE (10.0.2841) from KB #2494100
Exactly 10.0.4000 (SP2) Install the SP2 GDR (10.0.4064) from KB #2494089
Greater than 10.0.4000 Install the SP2 QFE (10.0.4311) from KB #2494094
SQL Server 2008 R2 Exactly 10.50.1600 (RTM) Install the GDR (10.50.1617) from KB #2494088
Between 10.50.1601 and 10.50.1789 Install the QFE (10.50.1790) from KB #2494086
Greater than 10.50.1790
(e.g. 10.50.2418 or 10.50.2425)
Wait for the final release of Service Pack 1
Watch for cumulative update or updates to MS11-049
At this time there is no fix for the CTP of SQL Server 2008 R2 SP1

What is the difference between a GDR and a QFE? 

A GDR (general distribution release) is one that Microsoft support deems is necessary for all systems running SQL Server. A QFE (quick fix engineering) is one that does not affect everyone. Why are there two releases for this important fix? Well, one reason is that after a QFE is installed, it is no longer possible to install a GDR. So, if you have a system that has had previous cumulative updates or QFEs applied, the GDR might not work for you. If you have a system that is exactly at one of the levels described above, then the GDR is probably the better choice, because it will allow you to install either a GDR or a QFE in the future, whereas installing a QFE on such a system kind of paints you into a corner.
There is also a GDR available if you are running Management Studio Express 2005 (but none seem to be listed at this time for the 2008 or 2008 R2 versions):

KB #2546869


This post is from my old blog dated Thursday, October 2011, that unfortunately no longer exist. 

SQL Server: Clean Database Records & reset Identity Columns

I had a problem while back to clean up my database and reset identity columns in all tables. But as we all know the chaos of the database, trace relations and delete records from child tables before parent tables because of foreign key constrains. By manually doing it could take so much time even the database is not that huge. Through some research on Google and books I was able to come up with a solution to achieve my target in few steps. The solution was to use built in stored procedure sp_MSforeachtable (which I already discussed in my previous blog post). So here is the following code bellow  for how I re-zeroed my Database:

/*Disable Constraints & Triggers*/
exec sp_MSforeachtable 'ALTER TABLE ? DISABLE TRIGGER ALL'

 /*Perform delete operation on all table for cleanup*/
exec sp_MSforeachtable 'DELETE ?'

/*Enable Constraints & Triggers again*/
exec sp_MSforeachtable 'ALTER TABLE ? ENABLE TRIGGER ALL'

/*Reset Identity on tables with identity column*/
exec sp_MSforeachtable 'IF OBJECTPROPERTY(OBJECT_ID(''?''), ''TableHasIdentity'') = 1 BEGIN DBCC CHECKIDENT (''?'',RESEED,0) END' 


This post is from my old blog posted on February 2011, that unfortunately no longer exist.  

SQL Server: List of tables and their rows counts in a database

I was trying to identify which tables were affected by an update though an application (3rd party). There were more than 300+ tables in the Database. I was hoping to avoid checking each of them for changes. To get the list of tables and their rows counts in a database you can use the following SQL query before and after the update.
[TableName] =,
[RowCount] = MAX(si.rows)
sysobjects so,
sysindexes si
so.xtype = 'U'

The sysindexes table is usually a little bit inaccurate, because it is not updated constantly. It will also include the 'dtproperties' table, which is one of those hybrid tables that falls neither under the 'system' nor 'user' category. It does not appear in Enterprise Manager's "Tables" view if you choose to hide system objects, but it shows up above.

In any case, it is generally not recommended to query against the system objects directly, so please only use the above for rough, ad-hoc guesstimates.


This post is from my old blog posted on February, 2011, that unfortunately no longer exist.

Deleting a Team Project from Team Foundation Server 2005/2008/2010

Deleting a team project from team foundation server is bit tricky. As there is no user interface available to do it in TFS, you have to use command line with a TfsDeleteProject.exe utility that ships with TFS 2005/2008/2010 to active this. Look complicated but very easy to do :)

You can do this from any computer in the network that has a access to team foundation server .

open Visual studio command prompt or windows command processor (cmd.exe)
and cd to the following path

In 32 Bit windows operating system

%program files%\Microsoft Visual Studio 9.0\Common7\IDE (2008/2010)
%program files%\Microsoft Visual Studio 8\Common7\IDE (2005)

In 64 Bit windows operating system

%Program Files (x86)%\Microsoft Visual Studio 9.0\Common7\IDE (2008/2010)
%Program Files (x86)%\Microsoft Visual Studio 8\Common7\IDE (2005)

then execute the following command

tfsdeleteproject /q /force /server: " "

Keep in mind: Your team foundation server User must have an Administrator rights to execute the above command successfully.  


Note: This post is from my old blog posted on May, 2011, that unfortunately no longer exist  

Monday 8 September 2014

C#: Resize An Image While Maintaining Aspect Ratio and Maximum Height

This function allows to resize the image. It prevents skewed images and  also vertically long images caused by trying to maintain the aspect ratio on images who's height is larger than their width

public void ResizeImage(string OriginalFile, string NewFile, int NewWidth, int MaxHeight, bool OnlyResizeIfWider)
 System.Drawing.Image FullsizeImage = System.Drawing.Image.FromFile(OriginalFile);

 // Prevent using images internal thumbnail

 if (OnlyResizeIfWider)
  if (FullsizeImage.Width <= NewWidth)
   NewWidth = FullsizeImage.Width;

 int NewHeight = FullsizeImage.Height * NewWidth / FullsizeImage.Width;
 if (NewHeight > MaxHeight)
  // Resize with height instead
  NewWidth = FullsizeImage.Width * MaxHeight / FullsizeImage.Height;
  NewHeight = MaxHeight;

 System.Drawing.Image NewImage = FullsizeImage.GetThumbnailImage(NewWidth, NewHeight, null, IntPtr.Zero);

 // Clear handle to original file so that we can overwrite it if necessary

 // Save resized picture


Note: This post is from my old blog dated Thursday, February 17, 2011, that unfortunately no longer exist