Thursday, August 18, 2011

A better way to learn LINQ-to-CRM





In Microsoft Dynamics CRM 4.0, we introduced LINQ for our developers through the Advanced Developer Extensions for Microsoft Dynamics CRM 4.0 toolkit. We have further improved this support in Dynamics CRM 2011 by including LINQ as a first class data query mechanism. A better alternative to QueryExpression, LINQ provides a simple, intuitive and unified approach for data retrieval across different data sources.

Those of you who already use LINQ in some other .NET projects are possibly familiar with a great tool that makes LINQ developers’ life easier – LINQPad (www.linqpad.net). LINQPad is similar to SQL Management Studio – it lets you connect to various data sources (for which LINQ providers exist), examine their structure (just like you do with tables and columns in SQL Management Studio), and, finally, write and execute LINQ queries on a fly. LINQPad is a terrific tool to experiment with LINQ. It eliminates a need to create a separate sample C# project to test your queries.

I have written a new tool “LINQPad Plugin for Microsoft Dynamics CRM 2011” to help CRM developers learn and test LINQ queries against any CRM 2011 deployment. The project is available for download from its MSDN Code Gallery page - http://code.msdn.microsoft.com/crmlinqpad

The application is fairly easy to use. You create a connection to a CRM organization by entering organization URL and credentials, and then the plugin retrieves information about the organization’s entities. A tree-like structure of entity sets and entity attributes will be displayed on the left panel of the application. Once that is done, you can write and execute LINQ statements from the main application window. The results of the execution will be shown in a table on the bottom panel.


Features
1) Support of all Microsoft Dynamics CRM 2011 deployment types: Online, OnPremise and SPLA
2) Entity schema browsing – navigating through entity sets, entity attributes and relationships
3) Writing and executing LINQ queries against entity sets
4) Examining QueryExpression used for actual data retrieval

Installation instructions
1) Make sure you have .NET Framework 4.0 and Windows Identity Foundation installed
2) Download and install LINQPad for .NET Framework 4.0 from http://www.linqpad.net
3) Download CrmLINQPadPlugin.lpx from http://archive.msdn.microsoft.com/crmlinqpad/Release/ProjectReleases.aspx?ReleaseId=5329
4) Run LINQPad and register the plugin – go to "Add Connection\View More Drivers\Browse" and select CrmLINQPadPlugin.lpx
5) To create a CRM connection, click "Add Connection" and select "MS CRM 2011" in "Use a typed data context from your own assembly" section



The plugin supports all CRM deployment types – Online, OnPremise and SPLA.
More instructions on how to download and configure LINQPad and the plugin can be found in the Home section of the plugin’s MSDN Code Gallery page.


Friday, August 12, 2011

Some Changes in CRM 2011 plugin coding

There are a lot of syntax and functional changes in MSCRM 2011 plugins. I have listed some of them below:
1. New References
• System.ServiceModel
• System.Runtime.Serialization

2. Microsoft.Crm.Sdk has been replaced by Microsoft.Xrm.Sdk

3. The default parameter for execute method has been changed from
IPluginExecutionContext to IServiceProvide


public void Execute(IServiceProvider serviceProvider)

4. IpluginExecutionContext has been changed to a type of service and to get the reference use the following syntax.

IPluginExecutionContext context = (IPluginExecutionContext)
serviceProvider.GetService(typeof(IPluginExecutionContext));

5. ICrmService has been changed to IOrganizationService

IOrganizationServiceFactory serviceFactory =
IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

6. Dynamic entity has been changed to “Entity”

if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is Entity)
{
Entity entity = (Entity)context.InputParameters["Target"];
}


7. Dynamic Entity’s properties syntax has been changed to attributes


entity.Attributes.Contains("accountnumber")

8. Strongly typed classes (account, contact) are missing in Microsoft.XRM.Sdk assembly but there is an exception to this.

9. CRM 2011 provides the crm utility called “crmsvcutil” to generate strongly typed classes that can be used in plugins.

10. Strongly typed classes has been changed to use like loosely typed classes.
Task task = new Task();
Task[“description”] = ”test description”

11. No more soap exception
catch (FaultException ex)

Plugin Development in 2011

1. Create a class library project in vs2010.
2. Sign the assembly by using the Signing tab of the project's properties sheet.
3. Add references to microsoft.crm.sdk.proxy , Microsoft.xrm.sdk ,
System.ServiceModel and System.Runtime.Serialization.
4. Here is code for this tutorial. This plugin will check if the account number
field is empty, create a task for the user to fill this up.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// Microsoft Dynamics CRM namespace(s)
using Microsoft.Xrm.Sdk;
using System.ServiceModel;

namespace CRMPlugin1
{
public class createNote:IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{

// Obtain the execution context from the service provider.
IPluginExecutionContext context = (IPluginExecutionContext)
serviceProvider.GetService(typeof(IPluginExecutionContext));


// The InputParameters collection contains all the data passed in the message request.
if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is Entity)
{
// Obtain the target entity from the input parmameters.
Entity entity = (Entity)context.InputParameters["Target"];



try
{
//check if the account number exist

if (entity.Attributes.Contains("account number") == false)
{

//create a task
Entity task = new Entity("task");
task["subject"] = "Account number is missing";
task["regardingobjectid"] = new EntityReference("account",new Guid(context.OutputParameters["id"].ToString()));

//adding attribute using the add function
// task["description"] = "Account number is missng for the following account. Please enter the account number";
task.Attributes.Add("description", "Account number is missng for the following account. Please enter the account number");



// Obtain the organization service reference.
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);


// Create the task in Microsoft Dynamics CRM.
service.Create(task);


}
}

catch (FaultException ex)
{
throw new InvalidPluginExecutionException("An error occurred in the plug-in.", ex);
}

}

}
}//end class
}//end name space


5. Compile the code and register it on the registration tool provided with sdk.
6. Register it on the post create event of account entity.
Note :check the sdk for instructions to register a plugin

Tuesday, August 2, 2011

Sql server Integration Service


using the ssis(sql server integration service) we can easily intergrate the sql table with a excel sheet
sql table is source and excel sheet is destination

by running the new ssis import export wizard we can easily create the ssis integration project
in this it will automatically create the excel file in your specified path and it will be integrating with that file

problem in this is if we are again running the integration project means it will show erroror it
will create duplicate data in the destination excel for that we can add a script task before all the things and

we can write the code to delete the existing excel file so that our ssis project  wil be working smoothly


in C# we have a class for manipulating all the file operations ..


  System.IO.File

you can write the code like this in the script task



if(System.IO.File.Exist("path\filename.xls"))
{
   System.IO.File.Delete("path\filename.xls");
}

Thursday, July 28, 2011

Microsoft says that SQL Server Integration Services (SSIS) “is a platform for building high performance data integration solutions, including extraction, transformation, and load (ETL) packages for data warehousing.” A simpler way to think of SSIS is that it’s the solution for automating SQL Server. SSIS provides a way to build packages made up of tasks that can move data around from place to place and alter it on the way. There are visual designers (hosted within Business Intelligence Development Studio) to help you build these packages as well as an API for programming SSIS objects from other applications.








I have done the integration successfully ….if u want to try follow this link





Monday, July 25, 2011

File and Directory Commands in Ubuntu System

cd

The cd command changes directories. When you open a terminal you will be in your home directory. To move around the file system you will use cd.
  • To navigate into the root directory, type:
    cd /

  • To navigate to your home directory, type:
    cd
    or
    cd ~


    The ~ character represents the current user's home directory. As seen above, cd ~ is equivalent to cd /home/username/. However, when running a command as root (using sudo, for example), ~ points instead to /root. When running a command with sudo, the full path to your home directory must be given.
  • To navigate up one directory level, type:
    cd ..

  • To navigate to the previous directory (or back), type:
    cd -

  • To navigate through multiple levels of directories at once, specify the full directory path that you want to go to. For example, type:
    cd /var/www
    to go directly to the /www subdirectory of /var/. As another example, type:
    cd ~/Desktop
    to move you to the Desktop subdirectory inside your home directory.

pwd

The pwd command outputs which directory you are currently located in (pwd stands for “print working directory”). For example, typing
pwd
in the Desktop directory, will show /home/username/Desktop.




ls

The ls command outputs a list of the files in the current directory. For example, typing
ls ~
will show you the files that are in your home directory.
Used with the -l options, ls outputs various other information alongside the filename, such as the current permissions on the file, and the file's owner.

cp

The cp command makes a copy of a file. For example, type:
cp foo bar
to make an exact copy of foo and name it bar. foo will be unchanged.

mv

The mv command moves a file to a different location or will rename a file. Examples are as follows:
mv foo bar
will rename the file foo to bar.
mv foo ~/Desktop
will move the file foo to your Desktop directory but will not rename it.

rm

rm is used to delete files.
rm foo
deletes the file foo from the current directory.
By default, rm will not remove directories. To remove a directory, you must use the -R option. For example,
rm -R foobar
will remove the directory foobar, and all of its contents!

mkdir

The mkdir command allows you to create directories. For example, typing:
mkdir music
will create a directory named music in the current directory.

How to Enable and Disable Usb Drive in a Windows system

Dear Friends  
     
   Got to know about enabling and disabling usb in a windows System .You can also do this by following some easy steps ...please follow these steps

 Press Windows + r  
    you will get the run Window in that type regedit, and then click OK.


u will get to see registry editor window in that navigate to the following path
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor


in that u will see the Default file click on that and
In the Value data box, type 3  click OK
it will enable the USB access in your windows System

if you want to disable enter 4 click ok..  and it will disable your USB access on Windows System...