Pages

Friday, April 8, 2011

Free Windows Azure Camp

Hello Friends,
The Microsoft MVP community is organizing the camp on Windows Azure, Entry is free so you can make this opportunity as a Big one and Enroll for the same.





For any query mail-to: i-abhib@microsoft.com






Thanks

Anil Kumar Pandey

Friday, April 1, 2011

New MVP's Announcement for Apr- 2011

Hello Friends,
Here are the list of new MVP(Most Valuable Professional) announce for this quarter. I like to welcome all the new MVP's in this elite group of community leader.

Sunil Kumar Singh

Project

Ahsan Murshed

ASP.NET

Gouri Subodh Sohoni

Visual Studio ALM

Sameer Desai

Xbox

Kartik Mudgal

Xbox

Hoping to see some more name in the Field if Visual C# and ASP.NET for the next quarter.


Thanks,

Anil Kumar Pandey
MVP (Visual C# 2009-2010)



Monday, March 21, 2011

Google Search API & Bing Search API in C#

Hi all,
Making use of the Google search or Bing search in our business application is a very common and general task, with the help of these search API's we can make our application very effective and user friendly. The 2 top search engine that are Google and Bing has provided API that can be easily used in our application. What is required is a class that can handle the response from these search engine. here I am going to explain the general search result class that can be used to accommodate both the search engines. here is the sample code for the same.

public class result
{
public string url;
public string title;
public string content;
public Engine engine;

public enum Engine { bing,google };

public Result(string url, string title, string content, Engine engine)
{
this.url = url;
this.title = title;
this.content = content;
this.engine = engine;
}
}



this is a sample Wrapper for the result handling. Class having a constructor that can initialize all its member, having normal member variables like URL, Content, Engine and the Title. Both the search engines result contains all these field values so I have simply created a warper using the above fields..

Now Lets c the main API accommodation of the Google search API

public class result
{
public string url;
public string title;
public string content;
public FindingEngine engine;

public enum Engine { bing,google };

public Result(string url, string title, string content, Engine engine)
{
this.url = url;
this.title = title;
this.content = content;
this.engine = engine;
}public static List<Result> GoogleSearch(string expression,
Dictionary<string, object> stats_dict)
{
var template = "http://mannpandey.blogspot.com";

Uri search_url;
var results_list = new List<SearchResult>();

int[] offsets = { 0, 8, 16, 24, 32, 40, 48 };

foreach (var offset in offsets)
{
searchuri = new Uri(string.Format(template, expression, offset));

var page = new WebClient().DownloadString(searchuri);

JObject obj = (JObject) JsonConvert.DeserializeObject(page);

var results =
from result in obj["responseData"]["results"].Children()
select new SearchResult(
url: result.Value<string>("url").ToString(),
title: result.Value<string>("title").ToString(),
content: result.Value<string>("content").ToString(),
engine: SearchResult.FindingEngine.google
);

foreach (var result in results)
results_list.Add(result);
}

return results_list;
}
}


In this class we are simply passing the search expression and the dictionary object. Where the URL is passed and the response coming from the API is deserialize using the JSON deserialization.

What ever member variable we have used in the above class are coming from the APi result. like TITLE, CONTENT etc. The de serilizer can be found in the JSOn library that is Json.NET .

Here is the API accommodation for the Bing search

public static List<SearchResult> BingSearch(string expression, Dictionary<string, object> stats_dict)
{
var template = "http://mannpandey.blogspot.com";

var offset_template = "&Web.Offset={1}";
var listresult= new List<Result>();
Uri search_url;
int[] offsets = { 0, 50, 100, 150 };

foreach (var offset in offsets)
{
if (offset == 0)
searchurl = new Uri(string.Format(template, search_expression));
else
searchurl = new Uri(string.Format(template + offset_template, expression, offset));

var page = new WebClient().DownloadString(searchurl);

JObject obj = (JObject)JsonConvert.DeserializeObject(page);

var results_query =
from result in obj["SearchResponse"]["Web"]["Results"].Children()
select new SearchResult
(
url: result.Value<string>("Url").ToString(),
title: result.Value<string>("Title").ToString(),
content: result.Value<string>("Description").ToString(),
engine: SearchResult.FindingEngine.bing
);

foreach (var result in results_query)
listresults.Add(result);
}

return listresult;
}


Bing search API is also similar to the Google API except some difference in there Offset, here also I am making use of the JSON serializer because its very easy to use and can be found in our .net library..


Now you can easily create the object of these classes or put them under separate project that can be used as a DLL. The idea for the same article was taken from one of the popular publishing site "Oreilly", that publishes so many books in the C# and ASP. You can found the details here. URL

I Hope you like this article, if you have any Query please feel free to contact me.. Thanks.

Anil Kumar Pandey
MVP (Visual C# 2009-2010)

Friday, February 18, 2011

Tracking and Loging using Google Analytics

Hello Every one,
This is very important to check the popularity the site frequently, and for maintaining the same we can make use of the Tracking and Loging facility. What we do is simply get the Information that,

1 How many Members are coming to our site?
2. What is the geographical position of them?
3 What was the channel for them to visit our site?
4. And having the statistics in our hand for the performance measurement.

All this activity can be simply manage by using the Google Analytic. It is an enterprise class that let us know that what is the traffic in our site, How many new and old user are visiting our site, and many more, in a very easy way.


The Google Analytic handle all the headache of maintaining the traffic records and we can also view the report based in the Daily, Weekly and Monthly basic. What we have to do is , we just need to Registered into the site, to have an account where we can watch the activity, and a small piece of JavaScript code we need to put in our application that can track the page.


Now, Here the most important things is that if you just want to maintain the list of user that visited the site only, you can post the code in the Default or the Home page only, but if you wish to maintain the list of all the pages then place the code in all the pages.

If you are making use of the Master Pages, simply put them inside the master page so that they can appear on all the pages.

I will provide you the information that how can you set up the Google Analytic in your .NET application.


Step 1. Registration

You first have to Create an account with the Google Analytic for that make use of the URL.

SignUp

Provide the details there like Your UserId and password and other details and create an account.


Step 2. Confirmation Account

An email will be sent to you on the email address that you have provided while registration to activate the account. The email will contain a link and as you click that link your account will be activated.

Step 3. Sign-up to the account


SignUp to the account by using the User name and the password Provided by you at the time of registration.

Step 4. Provide the Website details

As you login to the site first time a page will be opened where you need to provide the information like your time zone and the website details.

Step 5 . Google Analytics Code

Once you fill that information you will come with a page where you will get a User id as UID.
This is your Unique Identification page that you must use inside the script of your page.

Step 6. Write the Script int the Code just below the End of Form Tag

You need to put the Script inside the page just before the end tag of the form tag, because this is the fixed location,. if there are any Master pages, put them just before the Form End tag.


<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

script>


In the Below line You have to Provide the ID generated or given by the Google at the time of registration.

_gaq.push(['UID']);


In Place of UID post your Unique Identification No.

Thanks all, You Tracking and login code is ready, you may wish to view the traffic by simply login to the Google Analytic site and viewing the reports.




I hope You have understood all the step as these are very easy to do and clear steps. If you want any more information you can log in to the official Google Analytic site.

Hope You have Like this Post, If there are any Queried please feel free to post a Comment.


Thanks

Anil Kumar Pandey

Tuesday, February 1, 2011

Sorting a DropDownList using Array list

Hello All,
We frequently make use of the Dropdownlost to display some list items, that may be country name, city name, Postcode , User Name and so many other things. At time we do not have the option to SORT all the list item. In this Code snippet, With the help of the ArrayList we can sort the items inside a DropDown.

The Array List is having a Inbuilt Sorting method which we can make use to sort any list. We simply Copy the Text and Value field of the Dropdown items inside 2 separate ArrayList and then We will add the Items from the Arry List to the DropDown.

Here is the Sample Code.


SortDropDown(ref ddlName); //Calling Method


private void SortDropDown(ref DropDownList objDDL)
{
// Decalre 2 ArryList to Hold the Text and Value of Items
ArrayList alText= new ArrayList();
ArrayList alValue = new ArrayList();


//Copy the Text field in the First Arry List
foreach (ListItem li in objDDL.Items)
{
alTextt.Add(li.Text);
}

alText.Sort(); //Sort the First Array List


//Copy the value field in the Second Array List based on First ArrayList value
foreach (object item in alText)
{
string val = objDDL.Items.FindByText(item.ToString()).Value;
alValue.Add(val);
}
objDDL.Items.Clear(); //Clear the Dropdown

//Finally Add the Sorted Value in DropDown
for(int intIndex = 0; intIndex < textList.Count; intIndex++)
{
ListItem itm = new ListItem(alText[intIndex].ToString(), alValue[intIndex].ToString());
objDDL.Items.Add(itm);
}
}



Hope you got this Clear idea about sorting the Arraylist. In cvase of Any issue Please send a Message.


Thanks
Anil Kumare Pandey

Monday, January 10, 2011

A Chance To become MVP....

Hello All,
here is your chance to become the Community leader and get recognized as the MVP. A chance to be a part of the community leader across the globe. MVP, Please go through the below details and Nominate your self..



Yes, you are good...perhaps the best! You deserve to be with the best -networking and sharing to build the technology the way you know its best!
As MVP nominees, you need to undergo a review and evaluation process. You will be evaluated by a panel that comprises members of the MVP team and Microsoft product groups basis your technical expertise and voluntary community contributions for the past 12 months. The panel would consider the quality, quantity and impact of your contributions in the community.
Participate in closed Betas/ Alphas of Microsoft Software and give feedback to shape up future technology
Network with Product Teams over exclusive MVP Only webcasts and mailing lists
Network with MVPs worldwide with exclusive MVP Private Forums

Nominate yourself by registering here to become Microsoft MVP. The closing date for nominations is 21st January, 2011.
For details on MVP program, joins us for an exclusive session on 13th January, 2011 at 1.00 PM
Topic: How to get the Microsoft MVP Award by Abhishek Kant
Time: 1:00 pm – 2:00 pm

At Microsoft, we believe technical communities enhance people’s lives and the industry’s success every day.

The Microsoft MVP Award recognizes exceptional technical community leaders who foster the free and objective exchange of knowledge by actively sharing their real world expertise with the community and Microsoft.




Thanks,
Anil Kumar Pandey
MVP (Visual C# 2009-2011)

Tuesday, January 4, 2011

New MVP announced for Januray 2011

A Very Happy New Year to you all. Here are the list of new MVP's announced for the january 2011.

DESTIN N JOY -- SharePoint Server -- PATHANAMTHITTA

Sohel Rana -- SharePoint Server -- Dhaka

Diptimaya Patra -- Client App Dev -- Cuttack

Abhishek Sur -- Client App Dev -- Kolkata

Dilip Kumar Pandey-- Excel -- New Delhi

Prabu Kumar Kesavan--Windows Embedded--

Shyam Sasindran -- Windows Expert-IT Pro-- Chennai

SIDDHARTH MEHTA-- SQL Server -- Mumbai

Vinoth Balasubramanian-- Dynamics CRM -- Chennai

Soumya Sengupta -- Windows Expert-Consumer--Kolkata

Gaurav Mantri -- Windows Azure -- Udaipur

Ravi Vermula -- ASP.NET -- Hyderabad

Alwyn Duraisingh -- ASP.NET -- Chennai


Congratulation to all the new MVP's. Keep rocking in the respective community...


Thanks,
Anil Kumar Pandey
MVP (Visual C# 2009-2011)

Kontera