Saturday, December 1, 2012

Using Infragistics while working with  WebUpload I faced following issues and here are the solutions for them.

Error:
The Infragistics WebUpload requires jQuery to be loaded.

Solution:

You have missed including the Jquery.js file download it form  Jquery Website

Error:
The Infragistics WebUpload requires its own script to be loaded.

Solution:
You are missing including the Infragistics.js located in ig_ui. Search  for ig_ui folder on you system and you will find it where infragistics installed files are located. Include this in your project


Its better to read the Webupload Overview at Infragistics

Thursday, September 20, 2012

Fast list to list Items transfer

I have to store an Object List in entity object List which already contains some items to be updated in Database.
The item count was 50k and default c# method were too slow which we use normally to fill entity framework.

So here is a comparison and a best method based on object list comparison.


Solution 1(Slowest):


foreach (KeyValuePair<long, Item> objItem in FirstList)
                {
                 if (!SecondList.Any(x => x.Id== objItem .Value.Id))
                      {
                            SecondList.Add(objItem.Value);
                      }
               }

Solution 2(Good):

foreach (KeyValuePair<long, Item> objItem in FirstList)
                {
                 if (!SecondList.Contains(objItem.Key))
                      {
                            SecondList.Add(objItem.Value);
                      }
               }

Solution 3(Best):

Create a list of keys say keyList of SecondList.
foreach(long key in  keyList )
                {
                    FirstList.Remove(key);
                }
                SecondList.AddRange( FirstList .Values);

Graphs Comparison (Time in seconds)

Item Count               First List = 50k , Second List = 0


Item Count             First List = 16k , Second List = 17k


Online Graphing


Sunday, June 17, 2012

Json Implementation issues in Zend

I have spent much time on searching the Json service implementation in Zend framework.
I have tried all online help to get the Json response using Zend_Rest_Server and Zend_Json_Server but was unable to convert response to Json or get a response from the service.
So here is a post to save you all from the sample less Zend Framework.

Use Zend_Json_Server to make your service based on Json and don't follow sample with Zend_Rest_Router and Zend_Rest_Controller to convert Rest response to Json as much of my time was wasted on implementing this way.

But Zend_Json_Server will never give you response and you will never know why in any way.
Zend_Json_Server will always give response with header 204 No Content.
Its a hidden logic inside the Zend_Json_Server and Zend_Json_Server_Response_Http code Which I have to explore to get the response and here is the details.

Put echo before Handle method to get the result in response.
Here is code for a Registration class with signup method


        $service =new Zend_JSON_Server();
        $service->setClass("Registration");
        echo $service->handle();


Use RestClient extension in browser for creating Json request and  testing Json service.

You are getting the 204 No Content header due to an Id validation in Zend_Json_Server_Response_Http due to following code


if (!$this->isError() && (null === $this->getId())) {
            header('HTTP/1.1 204 No Content');
            return;
        }

So you have to put an Id in Json Request.
Here is the sample request.
Paste it in rest client and set method to be invoked and send Post Request and you will get a response


{
"method":"signup",
"Id":2,
"Params":{
"user":"test"
"email":"abc@def.com",
}
}



And here is the response screenshot with result and Id parameters.



Note: If you are developing a business critical services do consider the Microsoft  WCF framework.


Friday, June 15, 2012

Entity Framework 4 Issue

Format of the initialization string does not conform to specification starting at index 99.

Solution:
This issue is mostly caused by the incorrect connection string.If you change connection string manually you will probably get this error and solution is very simple.
  • Go on App.config and remove exiting connection string.
  • No open edmx and right click as shown in figure below



  • Fill your database credential



You connection string issue is resolved and you will not get issue
Format of the initialization string does not conform to specification starting at index 99.

Friday, June 8, 2012

When cookies are disabled you cannot login to Google account because Google stores token information in cookies.
This also happened when cookies were enabled but I cleared all browsing data and when I tried to login I got the same following issue.

Its strange that Google does not work with out cookies by storing information in other ways like query string or  hidden fields in encrypted form.