Tuesday, May 17, 2011

BigInteger Data Type In Framwork 4

While searching on the Internet and reading material regarding what is new in the framework 4 I come across the new data type which I have not see in the previous version of the dot net framework. The new data type is the BigInteger type. The BigInteger data type is used to store large amount of data. Like the other data type such as Int16, Int32 etc which has the MixValue and the MaxValue properties which define the lower bound and upper bound supported by that data type. In contrast, the BigInteger structure has no lower or upper bound, and can contain the value of any integer. The BigInteger data type is defined in the System.Numerics namespace. The System.Numerics namespace can be added as shown in the Image 1 as  System.Numerics is not added by default in the project you have to add the reference in your project.

Image 1

The System.Numerics has only two data type one is the BigInteger (Represents an arbitrarily large signed integer.) and the second one is the Complex (Represents a complex number).For this post I will discuss only the BigInteger data type. The BigInteger type is an immutable (e.g if you increment or decrement the value of the BigInteger object value then the common language run time actually creates a new BigInteger object and assigns it a value one greater/ one less than its previous value. This new object is then returned to the caller.) type that represents an arbitrarily large integer whose value in theory has no upper or lower bounds.



List 1

Image 2

The IsPowerOfTwo property will return true false depending on the value of the bigInteger object value.The sign property return the integer value which indicate the sign with the bigInteger object. Sign property is only return the sign you can't set the sign. The sign property will return three values depending on the sign with the bigInteger object. -1 (minus one) indicate the -ve sign with the bigInteger object , 0 indicate the value of the bigInteger value is 0 and 1 indicate +ve sign with the bigInteger object.

All and any comments / bugs / suggestions are welcomed !

Monday, May 16, 2011

jQuery Visual Cheat Sheet 1.6

The new edition of jQuery Visual Cheat Sheet (1.6), the most popular cheat sheet about jQuery over the internet, is here! The new edition includes all the reference you will ever need for jQuery 1.6 API. You can download the latest version from here.


All and any comments / bugs / suggestions are welcomed !

Wednesday, May 11, 2011

Differences Between WPF and Silverlight

While searching and reading article on the internet regarding silverlight I have found interested article which give the linke to the white paper regarding the Difference between silverlight and WPF. Wintellect, in collaboration with Microsoft, has released a whitepaper at CodePlex that fully explains the differences between these two technologies. You can get the latest version from the CodePlex site.

You can also download the version 1.1 from here which has the release date of Fri Jul 17 2009.

All and any comments / bugs / suggestions are welcomed !

Monday, May 9, 2011

Selected Specific Columns when Using OData using JSON In Microsoft CRM 2011

In this post I will show you about getting the required columns of the two entities which are fetch in one json request. For this example what I want to achieved is to get full name, first name , last name and the title of the system user and then from system user role I want to fetch the roles of the user which are associated with the system users. The Javascript code is listed in the List 1 as you can see in below. Here you can see code is simple the only thing which need some discussion here is the formation of the serverURL.


List 1

In the serverURL I have used the $expand keyword with the systemuserroles_association entity the $expand is query string options defined in the OData protocol that are implemented in the REST endpoint for Microsoft Dynamics CRM.The $expand
Directs that related records should be retrieved in the record or collection being retrieved. for example, to retrieve opportunity records related to accounts, use the opportunity_customer_accounts entity relationship. The query like /AccountSet?$expand=opportunity_customer_accounts returns the opportunity records and the account records.
Note: By default maixmum six relationships can be expanded.
Next I have to get the Full name , first name, last name and title for the system user and only the name of the roles which are assigned to the user. For that I have use the $select which is one of the query string options defined in the OData protocol which Specifies a subset of properties to return and the order in which the columns of data will be organized. The default is to return all columns that corresponds to $select=*.
You can see the order of the columns selection. Here I have used the $select and then first I have selected the column name for the systemuser pluse the systemuserroles_association entity name and the forward slash (/) and the column name of the systemuserroles_association which in this case is the name as I want to retrieve the name of the role(s) which are assigned to the user.
Image 1

In the retrieveSystemUserCallBack function I have parse the result using Json.parse and assign the .d property to the new variable. Then in the next statement I have used 2 loops to read the roles of the user as the system user roles filled in the collection with the name systemuserroles_association which you can see in the Image 1. You can see the whole structure of the one record which is shown in the Image 1.

All and any comments / bugs / suggestions are welcomed !

Thursday, May 5, 2011

Using JSON to retreive Data IN Microsoft CRM 2011

Ajax is always one of my favorite area of working for fetching and saving data in the database.It allows me to connect to server by staying on the client machine and the send request and after successfully return data from the server end working on the data to display on the user screen. In this post I will show you how to get the all the user using JSON in Microsoft CRM 2011. Let us start with our javascript code to fetch the information of the system user. JavaScript code for to fetch the system user information is listed in List 1. Here you can see that I have declare serverURL first in the beginning of the GetUserInformation function and assign it the value by concatenating the value of the getServerUrl which return the base server URL and then the end point of the service which in this case is the OrganizationData.svc. At the end of the serverURL you can see the name of the entity which is used to fetch the record here I have used the SystemUserSet. Each Microsoft Dynamics CRM entity is represented in the conceptual schema definition language (CSDL) as a collection using the element. The name of each collection follows the naming convention of [Entity Schema Name]+ Set. This name is used in the URL to access a collection of entity records


List 1
If you want to do operation such as retrieve , delete, insert and update on the account entity then you use the name AccountSet and same for the other entities as well. After setting the serverURL in the next statement I have created XMLHttpRequest object with the name getSystemUser and then set the properties of the getSystemUser object.
In the open function of the getSystemUser object I have passed the type which is either GET or POST as I am retrieving data so my request will be GET and the URL of the server which I have store in the serverURL which is either a relative or absolute URL may be used here. If an absolute URL is being used, most browsers implement a same-origin policy, meaning the URL being requested must be on the same domain as the domain from which the URL is being requested. and last parameter is for how request should be issued: True for asynchronous; False for synchronous.
In the next statement I have set the Header of the getSystemuser object and set the return type to json. and then set the onreadystatechange event for the asynchronous operation and then send the request by passing the null object.

Image 1

In the retrieveSystemUserCallBack function first is to check the readystate of the request which is the 4 for complete and then check for the status of the request which is 200 for successfully return of the request. Then in the next statement JSON.parse will be use which is used to Deserializes JavaScript Object Notation (JSON) text to produce a JavaScript value. JSON.parse is defined in Json2 which you can download from here. I have added the Json2.js file as web resource in the Microsoft CRM 2011. For those who don't have idea of how to add web resource and use them in the Microsoft CRM 2011 see the post by Ayaz Ahmed.  As we have specify that return value will be Json the results will be in the d property of the data object returned. When you are creating a record or retrieving a single record using the unique identifier, d will represent the data for the record. In every other case d will be an array. As you can see in the List 1 that after the Json.parse I have used the d property to get the value which is store in the retrievedUsers object.
At the end I have loop throught the retrievedUser collection and shown the full name of the user.The output of the request can be seen in the Image 1 which is displayed using the Json Viewer which is used to show the Json data in tree format. Hope you get idea of how to use the Json in OData to retrieved data using Microsoft CRM 2011.

All and any comments / bugs / suggestions are welcomed !