Friday, September 25, 2015

Resize the VHDX file

The following process changes the VHD file size using the power shell (run as administrator).
  1. mount-vhd <vhdname> –passthru | get-disk | get-partition | get-volume
    • This will mount the virtual hard disk in the management operating system, and let you know the drive letter that was assigned to it.
    • Ex: mount-vhd F:\MYVHD.vhdx –passthru | get-disk | get-partition | get-volume
  2. resize-partition –driveletter <driveletter> –size <newsize>
    • This will resize the partition inside the virtual hard disk.
    • Ex: resize-partition –driveletter I –size 60GB
  3. dismount-vhd <vhdname>
    • Dismount the virtual hard disk after shrinking the partition.
    • EX: dismount-vhd F:\MYVHD.vhdx
  4. resize-vhd <vhdname> –ToMinimumSize
    • Now shrink the virtual hard disk to match the new size
    • EX: resize-vhd F:\MYVHD.vhdx –ToMinimumSize

Sunday, August 2, 2015

How to remove windows default apps in Windows 8, 8.1 and 10

Step 1
Open power shell as an Administrator


Step 2
Type the command Get-AppxPackage. It  will show the list of windows apps.
Step 3Now choose the application which you want to remove. Select the Package full name and type the following command. 


remove-appxpackage "package full name" -confirm


For example, to remove the xbox application use following  
remove-appxpackage Microsoft.XboxApp_5.6.17000.0_x64__8wekyb3d8bbwe - Confirm

Xbox app will be removed..

Sunday, March 8, 2015

SQL server Multiple rows to one comma separated value

This is the select statement in Sql server which will select the multiple rows of a column into a single column and single row as a comma separated values.

SELECT  ID ,STUFF((SELECT ', ' + CAST(Name AS VARCHAR(10)) [text()] FROM Customer WHERE GroupId = t.ID FOR XML PATH(''), TYPE).value('.','NVARCHAR(MAX)'),1,2,' ') List_Output
FROM CustomerGroup t
GROUP BY ID

You can test the functionality here http://sqlfiddle.com/#!6/1cda0e/4

Sql Sever Split String function with special character support

The following the is the SQL server table valued function which will return the result as table. The input to the function is string delimited with the comma (for that matter any character which is is not part of the string it self) and the delimited character. This will also work even if the special characters present in the given input string.

1. Function

Create FUNCTION UdfSplitString
(
   @String       NVARCHAR(MAX),
   @SplitChar  NVARCHAR(255)
)
RETURNS TABLE
WITH SCHEMABINDING
AS
   RETURN 
   (  
      SELECT Item = y.i.value('(./text())[1]', 'nvarchar(4000)')
      FROM 
      ( 
        SELECT x = CONVERT(XML, '<i><![CDATA[' 
          + REPLACE(@String, @SplitChar, ']]></i><i><![CDATA[') 
          + ']]></i>').query('.')
      ) AS a CROSS APPLY x.nodes('i') AS y(i)
   );
GO


2. Select Statement

Select * from UdfSplitString('1,2,3,*@#$~!%^&*()-+=_{}|',',')

You can also test the functionality from the following link. http://sqlfiddle.com/#!6/e667f/3/0


Chain of Responsibility design pattern with Dynamic handlers

This is the Chain of responsibility pattern with dynamic handler which can handler. With this we can assign dynamic handler for the request without touching the main handler.
The following is the image shows the list of projects I have used in the demo project.
1. PatternTest --> is the actual client which will use the design pattern
2. Core --> is the Main project which will have default implementation
3. AddOn --> this is the first add on which will extend the core functionality like that we have AddOnTwo and AddOnThree project. 
1. PatternTest
In this Project we have two important files ManageHandlers.cs and Handler.xml. These two files provide the dynamic behaviour.
 
  • ManageHandler.cs: This file contains the code that will load the handlers for the main request. This will take the handler details from Handler.xml file
  • Handler.xml: This file contains the details about dynamic handlers. Assembly path name and class name (Including the namespace).
2. Core
In this Project we have the main business logic. It will deals with the required logic for default implementation for all the possible scenario.
3. AddOn One, Two and Three
These projects deals with specific scenario. These will extend the core functionality and provide the additional functionality. The execution of these add ons will be controlled from the Core module it self using the Handler.xml file.

Link to the Sample Project is here Download