Latest Entries »

Open Xml on Azure

I was once deploying a project (that involves Open Xml operations) on Azure. The project would run fine locally on my machine and but the code just wouldn’t run. After lots of scratching, I discovered the 2 problematic situations faced most widely that leads to this problems. The root cause here is that Azure doesn’t support the OpenXml operation directly since the required dlls are not available on Azure. The solution to the problem is changing the configuration of your project references, so whenever you get stuck in this problem, just check out which of the following situations apply to you and make the necessary changes to make your code work.

Scenario 1: The excel operations are performed in your main web project (i.e. the project being deployed on the cloud):

  1. Expand the project’s “References” folder
  2. Select the “DocumentFormat.OpenXml” and “WindowsBase” dlls
  3. Right click on them and then select “Properties”
  4. Set “Copy Local = True
Scenario 2: The Open Xml operations are being done inside a dll and then this custom dll is being referenced in your web project. If this is the case, do the following:
  1. Add References to “DocumentFormat.OpenXml” and “WindowsBase” dll in your main web project
  2. In your web project, expand the “References” folder
  3. Select your custom dll and the “DocumentFormat.OpenXml” and “WindowsBase” dlls
  4. Right click on them and then select “Properties”
  5. Set “Copy Local = True
Rebuild your project and deploy again, and this time it’ll work!

Silverlight 5 Toolkit is here!

Good news for all those facing problems with SL5 RC projects and the SL4 Toolkit issues! The Toolkit for SL5 RC projects is available here.

Happy coding! 🙂

Yesterday was one of those days, when a guy thinks “It couldn’t get more stupid than this”. It happened with me while I was trying to remove some features from my SQL Server 2008 R2 installation. I ran the SQL Server setup around a million times and I just could not find an option from where I could select the features I wished to remove, like the “Add/remove features” options we get in the old version of SQL Server or the Visual Studio installation.

After almost scratching my head for 3-4 hours, I decided to re-install it completely with the desired features only and just when I clicked on “Remove”, to my shock..I got the option “Select the features to remove”. I almost wanted to break my screen but its quite expensive so I refrained myself ;).

Long story short…MS surely has created some great products recently but the stupid changes like this certainly waste a lot of time of a lot of people!

An awesome blog post demonstrating how to harness the power of the new Pivot Viewer (released as a part of SL5 RC).

Joris Dries started a Twitter conversation this morning about getting decent performance out of the PivotViewer in SL5RC. So, I thought now would be a good time to gather a bunch of ideas I've had over the past few months and put them all in one post. This might not answer Joris' question directly, but it does satisfy the title. You can download the complete source code of the examples here. What I'll do is build a number of scenarios and compare … Read More

via Good Coffee Good Code

 

 

Check out the photographs and vote for them by clicking on “Vote for Me” on the top right corner!

Gaurav Sharma | One Life Photos 2011.

After playing with Pivot Viewer for long time, I decided to take one more step of going towards a decentralized approach i.e. storing data in different servers. So, I created 3 servers, one for images another for data (about facets) and one server for Pivot Viewer JIT Collection generation. Everything was well set and all communication working fine and suddenly I couldn’t see images any more in the Pivot Viewer. I checked all the images that my images were accessible from my machine, the data was going to the JIT server properly and also checked all the possible options where an exception could be raised and I didnt find anything…and still no images!

Then I compared the CXML files from the version before and this new setup and I found out that there was no information about the images and I was really pissed…as to what in the world went wrong? Then it struck into my mind to try an access the images on the server where the CXML is being generated and BINGO! The error was even though the images existed and were accessible from the my machine…they were not accessible on the JIT server and as soon as I enabled the access of the images on this server, the images started to show up on the pivot viewer as well.

Come to think about it, its pretty logical and I should have known that this would happen but I didn’t realize until I faced the issue. And sharing this, might help some other poor soul like mine was for the last 2 days.

Cheers!

This post comes from a field I dont work on regularly but it is a part of my explorations. Its about a CMS system that I use “Alfresco”  which was installed on Ubuntu and the problem I was facing was with integration between Alfresco and Open Ldap. After I had performed steps for integrating the Ldap and Alfreso’s authentication system, alfresco system was not getting started properly. So when I checked for any exceptions (using Catalina, of course), I was getting the error

“WQS unable to connect to repository: Unauthorized”

To solve this problem you will have to go to the following director (this would depend on your installation):

\Alfresco34\tomcat\shared\classes\alfresco\extension\wqsapi-custom.properties.

and in here, go to the line that says “alfresco.server.password=” and make sure that the password mentioned is same as the password of the Ldap’s Admin user, as shown below:

# Admin level user and password to connect to login to Alfresco server.
#
alfresco.server.user=admin
alfresco.server.password=admin’s password

Then reboot your alfresco and you will be able to login directly using the users of open ldap.

If you are using a Mac OS, you may come across a situation where you are not able to see the collection in the Pivot viewer, while you will be able to see the same collection in Windows/Linux. And this can happen in the case of both when the cxml comes from a file or it is generated dynamically using the PivotServerTools JIT collection. There can be multiple reasons for this:

  1. The website that hosts the cxml doesn’t have anonymous access on. If this is case, just switch on the anonymous access and you should see the collection now.
  2. This case is usually found to be obstacle. It comes because of an incompatibility between Mac and PivotViewer’s DeepZoom. The DeepZoom bug is reproduced on all the Mac browsers if the “source” attribute for your items in the collection’s dzc file is empty. To see if you are the victim of this, do the following:

    1. Try to navigate to your .cxml from a browser on the mac. Make sure it comes back i.e. if the URL of your collection is http://www.abc.com/collection.cxml, visit this URL and see if the cxml is populated in your browser. In case of chrome, you’ll have to right click on the page and click on “View Page Source” to see if the collection is coming back.
    2. b. If the cxml is returned, find out the dzc from it. You can find it in the “ImgBase” attribute of the “Items” tag; it’ll look something like “collection-5f7c6a376516425598d3d822d2bd3cbf.dzc”.
    3. c. Then try to navigate to your .dzc file from the same browser, the URL will now be http://www.abc.com/collection-5f7c6a376516425598d3d822d2bd3cbf.dzc and see if the dzc is sent back. Again in chrome, check the Page’s source to see the result. The collection returned will now be something like this:

	<?xml version="1.0" encoding="utf-8" ?>
	<Collection MaxLevel="8" TileSize="256" Format="jpg" NextItemId="183" xmlns="http://schemas.microsoft.com/deepzoom/2008">
	  <Items>
		<I Id="0" N="0" IsPath="1" Source="items-5f7c6a376516425598d3d822d2bd3cbf/dzi/0.dzi">
		  <Size Width="256" Height="256" />
		</I>
		<I Id="1" N="1" IsPath="1" Source="items-5f7c6a376516425598d3d822d2bd3cbf/dzi/1.dzi">
		  <Size Width="256" Height="256" />
		</I>
		<I Id="2" N="2" IsPath="1" Source="items-5f7c6a376516425598d3d822d2bd3cbf/dzi/2.dzi">
		  <Size Width="256" Height="256" />
		</I>
		<I Id="3" N="3" IsPath="1" Source="items-5f7c6a376516425598d3d822d2bd3cbf/dzi/3.dzi">
		  <Size Width="256" Height="256" />
		</I>
		<I Id="4" N="4" IsPath="1" Source="items-5f7c6a376516425598d3d822d2bd3cbf/dzi/4.dzi">
		  <Size Width="256" Height="256" />
		</I>
		<I Id="5" N="5" IsPath="1" Source="items-5f7c6a376516425598d3d822d2bd3cbf/dzi/5.dzi">
		  <Size Width="256" Height="256" />
		</I>
	  </Items>
	</Collection>

This dzc file contains the information about the DeepZoom for the collection items. Here what you have to check is that for an item you have the value in the Source attribute. If there’s no value in the Source attribute i.e. Source=””, then we have a problem. And this is what brings us to the DeepZoom bug on the Mac OS. So if you can be put a value to this Source attribute even though a fake one (Yes, I said fake), you will start seeing the collection. It’s funny how an attribute whose value doesn’t matter can be so problematic (FYI, the source attribute is used for getting the DZI). If you are doing a JIT collection, the reason for this could be that the size of your images used for the collection items is 256 by 256. You can check this by debugging the “PivotServerTools” project, go to PivotServerTools Ă  Internal Ă  MakeItemContent


	string source = string.Empty;
	if ((null != item.ImageProvider) && (null != item.ImageProvider.DziPath))
	{
		source = item.ImageProvider.DziPath;
	}
	else if (IsAutoGenerateDzi)
	{
		//Only provide an auto-DZI if the image is larger than a collection tile
		if (null != item.ImageProvider)
		{
			Size size = item.ImageProvider.Size;
			if ((size.Width >= TileDimension) || (size.Height >= TileDimension))
			{
				source = DziSerializer.MakeDziPath(m_collection.CollectionKey, id);
			}
		}
	}

	yield return new XAttribute("Source", source);


Check here what the exact reason is and correct it else you can use a fake URL to get it working. Enjoy!

When you are using dynamic collections with PivotViewer i.e. JIT collections generated using the PivotServerTools, there comes a situation when the Pivot Viewer stops taking the fresh data from the server. This is because the Pivot Viewer caches the collection, so when you reload the collection again (in the same session), it doesn’t ask the JIT server for the cxml again and instead uses the cxml from the cache. This is good in terms of the performance however it’s bad if your data keeps on updating at the server and you are not able to reflect the latest data in your collection. What you should know is that the PivotViewer caches the collection based on the URL that you pass in the PivotViewer’s LoadCollection method, so if you call the method:

PivotViewer.LoadCollection(“url”, “viewerstate”);

again and again without changing the url parameter, only for the first call data will be fetched from your server, for all subsequent calls PivotViewer will take the collection from the cache. To avoid this, you have to keep changing the URL, whenever you call the above method. The best way to do it, is to add a query string parameter which you may/may not use and update it every time you load the collection. You can do something like below:

PivotViewer.LoadCollection(“url”+ “?guid=”+Guid.NewGuid(), “viewerstate”);

this adds a new query string parameter “guid” to your url who’s value change every time you load the collection and since it’s a different url, PivotViewer doesn’t find the collection in its cache and hence sends a call to the JIT server to get the new collection. Therefore, you will always see fresh data in your collection but what you should keep in mind is that this will degrade the performance of the PivotViewer (but only at the time of loading), so what you can do as a further tweak is only change the guid parameter when you need fresh data in your collection and in all the other cases you can use the url with the same guid parameter which will help in keeping the performance of the PivotViewer intact, this tweak will be a boon if your JIT server takes time for generating the collection and the data is not updated always.

Happy Coding 🙂

I have been working around with the Silverlight Pivot Viewer for long time now and I have noticed that whenever I use a JIT collection I dont see Description in the facet panel but when I use a static collection, Description is available. First I thought maybe description facet is not allowed in JIT collections but then I remembered that the Collection class constructor does ask for Description in its parameter, this made my curious and I started dive into the code of PivotServerTools Project and I found that there’s no place in the code where this Description is used apart from when creating the default item images. After a lot of searching I was able to find a solution using which Description can be made visible. To do so, follow the below steps:

1. Go to the PivotServerTools project.
2. Open the Internal folder.
3. There you’ll see a “CxmlSerializer” class, this class is used when the method Collection.ToCXML() is invoked, which is done by the Pivot Viewer. Open this class and navigate to the method “MakeItemContent”. In this method add the following line:

if (!string.IsNullOrEmpty(item.Description)){
	yield return new XStreamingElement(Xmlns + "Description", item.Description);
}

This way Description will start showing up in the Facet panel of every collection provided you specified a value for it in the Item’s collection class constructor.