Monday, December 27, 2010

Mozilla Addons

Firebug

https://addons.mozilla.org/en-US/firefox/addon/1843/

CopyAllURLs
https://addons.mozilla.org/en-US/firefox/addon/934/

ColorZilla

https://addons.mozilla.org/en-US/firefox/addon/271/

FireShot 0.87


https://addons.mozilla.org/en-US/firefox/addon/5648/

Find All Addons
https://addons.mozilla.org/en-US/firefox/

Monday, November 29, 2010

Arun Kumar Sabat: ADO.NET Entity Framework Extensions

Arun Kumar Sabat: ADO.NET Entity Framework Extensions

ADO.NET Entity Framework Extensions

Normal Entity Framework Shipped with VisualStudio 2010 does not support if the stored procedure returns multiple result sets. We can use EntityFramework Extensions for this.

Wednesday, September 29, 2010

About Hadoop Framework

Following is the details on the what is Hadoop?
http://serverfault.com/questions/27829/what-is-hadoop-and-what-is-it-used-for

Details :

Hadoop is a framework for running applications on large clusters built of commodity hardware. The Hadoop framework transparently provides applications both reliability and data motion. Hadoop implements a computational paradigm named Map/Reduce, where the application is divided into many small fragments of work, each of which may be executed or reexecuted on any node in the cluster. In addition, it provides a distributed file system (HDFS) that stores data on the compute nodes, providing very high aggregate bandwidth across the cluster. Both Map/Reduce and the distributed file system are designed so that node failures are automatically handled by the framework.

Map/Reduce is a programming paradigm that was made popular by Google where in a task is divided in to small portions and distributed to a large number of nodes for processing (map), and the results are then summarized in to the final answer (reduce). Google and Yahoo use this for their search engine technology, among other things.

Hadoop is a generic framework for implementing this kind of processing scheme. As for why it kicks ass, mostly because it provides neat features such as fault tolerance and lets you bring together pretty much any kind of hardware to do the processing. It also scales extremely well, provided your problem fits the paradigm.

You can read all about it on the website (http://hadoop.apache.org/).

As for some examples, Paul gave a few, but here's a few more you could do that are not so web-centric:

•Rendering a 3D film. The "map" step distributes the geometry for every frame to a different node, the nodes render it, and the rendered frames are recombined in the "reduce" step.
•Computing the energy in a system in a molecular model. Each frame of a system trajectory is distributed to a node in the "map" step. The nodes compute the the energy for each frame,
and then the results are summarized in the "reduce" step.
Essentially the model works very well for a problem that can be broken down in to similar discrete computations that are completely independent, and can be recombined to produce a final result.

Lists of sites where Hadoop is used.

http://wiki.apache.org/hadoop/PoweredBy

Friday, August 27, 2010

Wednesday, August 18, 2010

How to use Sql Server Stored Procedure in .Net Entity Framework

Following URLs will help

Using Stored Procedure in ADO.NET Entity Framework 4.0

http://channel9.msdn.com/posts/wriju/Using-Stored-Procedure-in-ADONET-Entity-Framework-40/

--
How to Retrieve Stored Procedure Output Parameters in Entity Framework

http://dotnet.dzone.com/news/how-retrieve-stored-procedure?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+zones%2Fdotnet+%28.NET+Zone%29

or

How to Retrieve Stored Procedure Output Parameters in Entity Framework

http://blogs.microsoft.co.il/blogs/gilf/archive/2010/05/09/how-to-retrieve-stored-procedure-output-parameters-in-entity-framework.aspx

Alternate to Dynamic Sql in Sql Server

Following in the Example having an alternate to Dynamic Sql in Sql Server
----------------------------------
create table testtable

( col1 int, col2 int)

insert into testtable(col1, col2)
Values
(10,20),
(30,40),
(11, 15),
(17, 16)
----------------------
Show 1
-----------------------
Declare @col1 int
Declare @col2 int

Set @col1 = 15
SET @col2 = null

Select * from testtable
Where (col1 > @col1 OR @col1 IS NULL)
AND (col2 > @col2 OR @col2 IS NULL)

--------------------------------
Show 2
--------------
Declare @col11 int
Declare @col12 int

SET @col11 = 10
set @col12 = 30
Select * from testtable
Where (col1 = @col11 OR @col11 IS NULL)
or (col1 = @col12 OR @col12 IS NULL)
---------------------------------
Drop table testtable
------------------------

Also you can check the following article from the code project by John P Harris, which have different ways of avoiding Dynamic Sql such as

* Using COALESCE
* Using ISNULL
* Using CASE
* Alternative

Implementing Dynamic WHERE-Clause in Static SQL

Tuesday, August 10, 2010

Installing Sql Server 2008 Express Management Studio in Windows 7

Ooops!!! This was tough part for me. After lot of surfing on this topic, i found a way to do this.
1. Uninstall the Sql Server Express 2005.
First uninstall the Sql Server 2005 from the Control Panel options
Then remove the "HKLM\Software\Wow6432Node\Microsoft\Microsoft SQL Server\90" key from the registry.
Reference :
Can't Uninstall SQL Server 2005 Express Tools
sql-server-2008-rc0-install-sql2005ssmsexpressfacet

2. Install the Sql Server 2008 Express Management Studio as given in this Article

Following are some articles those may help you to resolve this:
Can't Install Microsoft SQL Server 2008 Management Studio Express

-- In this article, it is suggested that
i. Install Sql Server Management Studio first and then Install Sql Server Express 2008
ii. Else use the "Sql Server Express with Tools" to Install.

Cheers...

Friday, August 6, 2010

Select and Copy only Visible Cells, Columns or Rows in MS Excel 2007 and 2003?

To get the menu for only selcting visible rows, Please follow below link

Select and Copy only Visible Cells, Columns or Rows in MS Excel 2007 and 2003?

The Steps are given as below

So how to select only visible cells, or in other words how to not select hidden cells, rows or columns while copying?

In MS Excel 2007, to add the Select Visible Cells Command, do the following steps:
Step 1: Right click on the toolbar on top and click Customize Quick Access toolbar.
Step 2: Under Choose Command From drop down menu, select Commands Not in the Ribbon.
Step 3: Scroll down and click on Select Visible Cells.
Step 4: Click on Add and OK.

How to Delete Empty Rows those are in between in MS Office Excel?

I had a problem on deleting the empty rows from a excel. I found the below article that was helpful.
How to Delete Empty Rows those are in between in MS Office Excel?

The Steps are as below.

Note: Make sure you already don’t have any cells or rows hidden. If you have hidden items, you may lose that data.

Step 1: Select the column from which you want to choose those empty or blank cells. (Let’s say Column A)
Step 2: Press F5 (Function Key). Click on Special and Select Blanks and Click OK.

Step 3: The Blank Cells will be highlighted now.

Step 4: Use the keyboard shortcut key (Ctrl + 9) to hide the rows which has highlighted cells. (Click here for keyboard shortcuts for hiding and unhiding rows and columns in Excel.)

Step 5: Use Select Visible Commands, to select only rows that are visible and Press Ctrl + C to copy the entire worksheet. This doesn’t copy the hidden rows. (Select Visible Command is a hidden option in Excel, if you don’t know how to use it or where it is, read ‘How to select only visible cells in Excel?’)

Note :Follow this To Select only rows that are visible.

Step 6: Paste (Ctrl + V) it in a new sheet. Now you have a new sheet which doesn’t have any empty rows. You can delete the old sheet if you want!

Wednesday, August 4, 2010

ObservableCollection Class in .Net (WPF)

WPF provides the ObservableCollection class, which is a built-in implementation of a data collection that implements the INotifyCollectionChanged interface.

We can enumerate over any collection that implements the IEnumerable interface. However, to set up dynamic bindings so that insertions or deletions in the collection update the UI automatically, the collection must implement the INotifyCollectionChanged interface. This interface exposes the CollectionChanged event, an event that should be raised whenever the underlying collection changes.

So, by using ObservableCollection, we no need to Implement the INotifyCollectionChanged interface.

References

ObservableCollection Class

List vs ObservableCollection vs INotifyPropertyChanged in Silverlight

Silverlight Databinding – The Observable Collection

What is INotifyPropertyChanged Interface

The INotifyPropertyChanged interface is used to notify clients, typically binding clients, that a property value has changed.

To Understand more on INotifyPropertyChanged Inteface, follow these links

INotifyPropertyChanged Interface

AutomagicallyImplementingINotifyPropertyChanged

View Models: POCOs versus DependencyObjects

Bind Better with INotifyPropertyChanged

INotifyPropertyChanged Is Obsolete

Difference Between .Net 4 Framework And .Net 4 Framework Client Profile

NET4 Client Profile is smaller and faster to install compared to the NET4 Full Framework (NET4 is 7-8MB smaller in size than the Full Framework), the main reasons are not just better deployment size/time but also:

•Reduce the Framework deployment failures.
•By keeping ASP.Net and other components (that are mostly needed for servers) out of the Client Profile, we can reduce the attack surface and the number of future servicing events which may be caused by server component (such as ASP.Net) and are not needed for desktop scenarios.
•Making NET4 Client Profile available on Windows Update will make sure that most desktop machines will include NET4 Client Profile over time and apps that target the Client Profile will not need to carry or install the Framework which will improve the overall deployment experience.
•Enable us to add features and grow the size of overall Framework in future versions but still have a smaller core.

Reference:

http://blogs.msdn.com/b/jgoldb/archive/2010/04/12/what-s-new-in-net-framework-4-client-profile-rtm.aspx

Stop Folder Sharing in Windows 7

Kindly follow below steps to stop sharing a folder in Windows 7

1.Open Computer Management. To do so, click Start, then right-click Computer, and then click Manage.

2.If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Yes.

3.In the console tree, click System Tools, then click Shared Folders, and then click Shares.

4.In the details pane, right-click a shared folder, and then click Stop Sharing (this item only appears if you launched Computer Management using an account that is a member of the local Administrators group).

To stop sharing multiple files, press the CTRL key while clicking the file names, right-click any one of the selected files, and then click Stop Sharing. This removes shared network access to the selected files.

Reference

http://technet.microsoft.com/en-us/library/cc753475.aspx

Wednesday, June 2, 2010

Consume WCF Service Without creating Proxy ( Use of ChannelFactory Class)

In the old classic way, we used to refer the services using “Add Service reference” to the application and use the services. There are so many de-merits with this approach. One of them is, once we change the definition of the service, we have to update the service in the client layer.

To avoid this, we can use the ChannelFactory class. But how to use this class? Following sample may help us on this.

1. Create a Service Project WCFProxyService
2. Move the service Interface IService (ServiceContract) to another project, For this add a class library project called WCFContrcat and move the ServiceContract
3. Add Reference to the following assemblies
a. System.Runtime.Serialization
b. System.ServiceModel
4. Let us see the ServiceContract and DataContract code in this Interface

using System.Runtime.Serialization;
using System.ServiceModel;


// NOTE: If you change the interface name "IService" here, you must also update the reference to "IService" in Web.config.
[ServiceContract]
public interface IService
{

[OperationContract]
string GetData(int value);

[OperationContract]
CompositeType GetDataUsingDataContract(CompositeType composite);

// TODO: Add your service operations here
}

// Use a data contract as illustrated in the sample below to add composite types to service operations.
[DataContract]
public class CompositeType
{
bool boolValue = true;
string stringValue = "Hello ";

[DataMember]
public bool BoolValue
{
get { return boolValue; }
set { boolValue = value; }
}

[DataMember]
public string StringValue
{
get { return stringValue; }
set { stringValue = value; }
}
}


5. The implementation of the Service class will be as below

// NOTE: If you change the class name "Service" here, you must also update the reference to "Service" in Web.config and in the associated .svc file.
public class Service : IService
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}

public CompositeType GetDataUsingDataContract(CompositeType composite)
{
if (composite.BoolValue)
{
composite.StringValue += "Suffix";
}
return composite;
}
}

6. Create the Client Project “WCFProxy” and refer the “WCFContract” project to this project.
7. Modify the App.config file, Configuration section as below



8. Now add a new class “ProxyHelper.cs” to the Client Project “WCFProxy”
Use of this class is to create the Proxy on the fly.
9. Following is the code will help us to create the proxy on the fly using ChannelFactory class

using System.ServiceModel;

namespace WCFProxy
{
public class ProxyHelper
{
IService channel = null;
ChannelFactory factory = null;

public ProxyHelper()
{
factory = new ChannelFactory("WSHttpBinding_IService");
channel = factory.CreateChannel();
}

public string GetData()
{
string value = channel.GetData(1);
factory.Close();
return value;
}

public CompositeType GetDataUsingDataContract(CompositeType cType)
{
CompositeType returnType = channel.GetDataUsingDataContract(cType);
factory.Close();
return returnType;
}


}
}


10. Add reference to the same two Assemblies as specified in step 3
11. Please check the above code, how the ChannelFactory is used to call the service methods
12. Using the Helper class we can call the service methods

Usally this helper class will be used as the Proxy class, that dynamically create the proxy at Runtime. Below is the code shows the way Helper class is being used.

ProxyHelper pHelper=new ProxyHelper();
MessageBox.Show(pHelper.GetData());

CompositeType cType = new CompositeType();
cType.BoolValue = true;

cType.StringValue = "Arun ";

pHelper = new ProxyHelper();
cType = pHelper.GetDataUsingDataContract(cType);

MessageBox.Show(cType.StringValue);

Hope the above will help and will improve the maintainability of your application.

Tuesday, May 25, 2010

JQuery For VS 2008

What is Jquery?

jQuery is a library written using JavaScript and created by
Jquery team.

How to use JQuery in VS 2008 ?

1. Download JQuery from the JQuery site 2. Download both the .js and -vdsoc.js file. Ex. if you are using Jquery Version 1.4.1. Then download both jquery-1.4.1.js (JQuery Library) and jquery-1.4.1-vsdoc.js (jQuery VS 2008 Intellisense documentation) file. The -vsdoc.js file is for the intellisense support. 3. Make sure the we have installed the hotfix for the VS2008. If not please download from hotfix-url and install it 4.
Open Visual Studio 2008 > File > New > Website > Choose ‘ASP.NET 3.5 website’ from the templates > Choose your language (C# or VB) > Enter the location > Ok. In the Solution Explorer, right click your project > New Folder > rename the folder as ‘Scripts’.
Right click the Scripts folder > Add Existing Item > Browse to the path where you downloaded the jQuery library (jquery-1.2.6.js) and the intellisense documentation (jquery-1.2.6-vsdoc.js) > Select the files and click Add.

Now drag and drop the jquery-1.2.6.js file from the Solution Explorer on to your page to create a reference.

Note: Since you have applied the hotfix, you do not have to manually add a reference to the jquery-1.2.6-vsdoc.js file in your page. Once the reference to the runtime library has been added, Visual Studio automatically searches for the ‘vsdoc’ file and loads it. You just need to keep both the runtime library and the documentation file next to each other.
Else use following line of code as shown in the figure below to get the intellisense in VS 2008

To test intellisense, add a script
block and key in ‘$(‘. You will get an intellisense.

Example 1 – Display an alert on asp:Button click using jQuery
Add a Button element to the page as shown below:
<asp:Button ID="Button1" runat="server" Text="Button" />
Now in order to tell the browser to perform some action using jQuery as soon as the document is ready or loaded, use this block:
<script type="text/javascript">
$(document).ready(function() {
// add code here
});
script>
Add your code in the function block
<script type="text/javascript">
$(document).ready(function() {
$("#Button1").click(function() {
alert("Hello world!");
});
});
script>

Reference URL : Using jQuery with ASP.NET - A Beginner's Guide

Monday, February 1, 2010

Creating Lists using Sharepoint Object Model

  1. Open Visual Studio. Create a new Windows Forms project.
  2. Add a textboxes, one to accept the name of the site collection and another to accept the name of the new site to be created under the site collection.
  3. Add a button that creates the new site.
  4. Add reference to Microsoft.Sharepoint dll. This dll is represented by the name Windows Sharepoint Services in the Add Reference dialog box.
  5. Add the namespace of Microsoft.Sharepoint dll like this.
    • using Microsoft.Sharepoint;
  6. In the button click event, open the site collection.
    • SPSite siteCollection = new SPSite(txtSiteCollectionUrl.Text);
  7. Now open the top level site of the site collection.
    • SPWeb site = siteCollection.OpenWeb();
    • If you want to open a different site under the site collection other than the top level site, you can use the overloaded methods of the OpenWeb() method that accepts the name of the site as argument.
  8. The Lists property present in the SPWeb object will return all the lists that are present in that site as an SPListCollection object
    • SPListCollection listCollection = site.Lists;
  9. In order to add a new list, use the add method of the SPListCollection object.
    • listCollection.Add(“listname”, “list description”, SPListTemplateType.GenericList);
    • Note that the third argument accepts the template in which the list should be created. GenericTemplate represents the custom list. We can choose the template we need from the SPListTemplateType enum.
  10. Close and dispose and the site and site collection
    • site.dispose();
    • siteCollection.close();

The complete code can be found below..

using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.SharePoint;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

SPSite siteCollection;
SPWeb site;

private void btnCreateSite_Click(object sender, EventArgs e)
{

try
{
siteCollection = new SPSite(txtSiteCollection.Text);
site = siteCollection.OpenWeb();
SPListCollection listCollection = site.Lists;

listCollection.Add(txtListName.Text, “list description”, SPListTemplateType.GenericList);
}
catch (Exception)
{ }
finally
{
site.Dispose();
siteCollection.Close();
}
}

}
}

Creating Sites using Sharepoint Object Model


MOSS 2007 provides rich set of API’s that allows developers to programatically accomplish almost everything that can be done in sharepoint. Sharepoint Object Model comes with 10 different dll’s comprising 30 namespaces.

The aim of this post is to show the sharepoint object model to create a new sharepoint site programatically.

Before start, lets look at the sharepoint site structure in the following diagram.

SiteArchitecture



Each layer in the above architecture diagram is represented by an object in the sharepoint object model. The object mapping is represented in the following table.
Sharepoint Site Architecture Component Object in Sharepoint Object Model

Sharepoint Site Architecture Component Object in Sharepoint Object Model
Site Collection SPSite
Site SPWeb
List Collection SPListCollection
List SPList
List Field Collection SPFieldCollection
List Field SPField
List Item Collection SPListItemCollection
List Item SPListItem


Steps to create a new Sharepoint Site:

1. Open Visual Studio. Create a new Windows Forms project.
2. Add a textboxes, one to accept the name of the site collection and another to accept the name of the new site to be created under the site collection.
3. Add a button that creates the new site.
4. Add reference to Microsoft.Sharepoint dll. This dll is represented by the name Windows Sharepoint Services in the Add Reference dialog box.
5. Add the namespace of Microsoft.Sharepoint dll like this.
* using Microsoft.Sharepoint;
6. In the button click event, open the site collection.
* SPSite siteCollection = new SPSite(txtSiteCollectionUrl.Text);
7. Now open the top level site of the site collection.
* SPWeb site = siteCollection.OpenWeb();
* If you want to open a different site under the site collection other than the top level site, you can use the overloaded methods of the OpenWeb() method that accepts the name of the site as argument.
8. SPWeb object has a property called ‘Webs’ that contains a collection of all the sites present under that site.
9. Inorder to add a new site, use the following code.
* site.Webs.Add(txtSiteName.Text, txtSiteName.Text, Convert.ToUInt32(1033),site.WebTemplate, , false,false);
10. Close and dispose and the site and site collection
* site.dispose();
* siteCollection.close();

The complete code can be found in this file.using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.SharePoint;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

SPSite siteCollection;
SPWeb site;

private void btnCreateSite_Click(object sender, EventArgs e)
{

try
{
siteCollection = new SPSite(txtSiteCollection.Text);
site = siteCollection.OpenWeb();
site.Webs.Add(txtSiteName.Text, txtSiteName.Text,
txtSiteName.Text + ” Desc”, Convert.ToUInt32(1033), site.WebTemplate,
false, false);
}
catch (Exception)
{ }
finally
{
site.Dispose();
siteCollection.Close();
}
}

}
}

Sunday, January 31, 2010

Share Point Exception : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPSite mysite = new SPSite(txtURL.Text.Trim());

mysite.AllowUnsafeUpdates = true;
mysite.CatchAccessDeniedException = false;

foreach (SPWeb myweb in mysite.AllWebs)
{
//myweb.Title;
cboSites.Items.Add(myweb.Title);
}
});