Skip to main content


Creating Organization Hierarchy in ASP.NET using Google Organizational Chart

In this post I will show you how to integrate google org chart in your application. First create a new empty website in visual studioAdd jquery and google visualization api reference to the default page Let's first create dummy data.Create following table schema and insert some dummy data into this. Table Schema CREATETABLE [dbo].[EMPLOYEES] ( [EmpID] CHAR (4) NOTNULL, [Ename] VARCHAR (10) NULL, [MGR] CHAR (4) NULL, PRIMARYKEYCLUSTERED ([EmpID] ASC), UNIQUENONCLUSTERED ([EmpID] ASC) ); Insert Data INSERTINTO [dbo].[EMPLOYEES] ([EmpID], [Ename], [MGR]) VALUES (N'7369', N'Smith', N'7902') INSERTINTO [dbo].[EMPLOYEES] ([EmpID], [Ename], [MGR]) VALUES (N'7499', N'Allen', N'7698') INSERTINTO [dbo].[EMPLOYEES] ([EmpID], [Ename], [MGR]) VALUES (N'7521', N'Ward', N'7698') INSERTINTO [dbo].[EMPLOYEES] ([EmpID], [Ename], [MGR]) VALUES (N'7566', N'Jones', N'7839'…

How to read mp3 tag info using c#

Mp3 tag  consists of attaching a fixed block size of 128 bytes at the end of the file in question. This block contains the following tags: A header that identifies the presence of block ID3 and version. Specifically, said header comprises TAG characters.

Title: 30 characters.
Artist: 30 characters.
Album: 30 characters.
Year: 4 characters.
Comment: 30 characters.
Genre (music): a character.

How to encrypt Bitmap image in c#

In this post I will show you how to encrypt bitmap image in c#.The technique is very simple.First we extract header from the image and then encrypt the rest byte data and then combined the header with this encrypted data.

using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; namespace Enc { class Program { staticstring FILENAME = @"D:\ub.bmp"; staticstring ENCFILENAME = @"D:\enc.bmp"; staticvoid Main(string[] args) { //Create instance of DES TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider(); //Generate IV and Key des.GenerateIV(); des.GenerateKey(); //Set Encryption mode des.Mode = CipherMode.ECB; //Read FileStream fileStream = new FileStream(FILENAME, FileMode.Open, FileAccess.Read…

How to post array of hashes in wcf

In this post I will show you how to post json array hashes in wcf rest service.Before going to code snippet let's discuss some basic terminology.

What is Array of Hashes
Array of hashes is a data structure in which each record itself contains key/value pairs. Arrays of hashes are used less frequently than the other structures.Below is example of array of hashes
AoH = ( { husband => "barney", wife => "betty", son => "bamm bamm", }, { husband => "george", wife => "jane", son => "elroy", }, { husband => "homer", wife => "marge", son => "bart", }, ); JSON String

When we enclosed the json data into quote then we called this string is JSON string
var jsonString='[{ "x": 10, "y": 20, "z": 30 }, { "x": 12, "y"…

Low level bit hacks

I came across a very interesting article on Peteris Krumin’s blog on how to use boolean operators to perform really useful low level bit hacks. Most people are used to just using AND and OR operators on integers, but this article goes into much more detail, explaining good – and fast – ways to manipulate integers at a bit level. It is well worth it to go and check it out.

How to stream video in using WCF rest service

In this post I will show you how to stream video in using WCF rest service.The techniques used here is as we don't know the exact content lenght of the data so we used Content-Encoding transfer encoding allows a server to maintain an HTTP persistent connection for dynamically generated content. In this case the HTTP Content-Length header cannot be used to delimit the content and the next HTTP request/response, as the content size is as yet unknown. Chunked encoding has the benefit that it is not necessary to generate the full content before writing the header, as it allows streaming of content as chunks and explicitly signaling the end of the content, making the connection available for the next HTTP request/response..Open visual studio and create a simple wcf service.Add a new class and add following code into it

How to create custom config section in

You can extend ASP.NET configuration settings with XML configuration elements of
your own. To do this, you create a custom configuration section handler.
The handler must be a .NET Framework class that inherits from 
the System.Configuration.ConfigurationSection class. The section handler 
interprets and processes the settings that are defined in XML configuration 
elements in a specific section of a Web.config file. You can read and write 
these settings through the handler's properties.
using System; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Web; namespace CustomConfigSection { publicclass LoginRedirectByRoleSection : ConfigurationSection { [ConfigurationProperty("roleRedirects")] public RoleRedirectCollection RoleRedirects { get { return (RoleRedirectCollection)this["roleRedirects"]; } set { this["roleRedirects"] = valu…