Crystal Reports 2008 : hacking datetime parameter format

One would think that this should be a no-brainer : ability to specify an edit format for date/time parameter in Crystal Reports. Not so fast…

Problem is as following:

ASP.Net Web client with Crystal Reports Viewer control is used.

When our report is based of some stored procedure which uses datetime parameter, it will inherit it as is and when report parameter entry form is displayed we would be asked to enter both date and time portion.

While, in general, it is OK, some reports are really interested only in date part being entered and time should be always set to 00:00:00. So we are forced to type time every time because if it is not provided calendar control would try to set time part initially to current time.

After some research off the Internet, visiting SAP forums, it is appear to be engine limitation. But we would want to overcome it somehow.

DISCLAIMER: solution below could only be used as a last resort and only if your business logic requires using date only params. And while it is only applies to calendar control, it is not per se a generic solution. This is a first “rough” attempt of achieving desired result and may lack some features otherwise expected.

It has been reported that solution above only works for current month. Since we are now using Crystal Reports 2008 with SP1, I would address this issue in my new post below.

IMPORTANT! With release of Service Pack 1 for Crystal Reports 2008, method blow is no longer applicable since structure of the files has changed. Please refer to this new post for more information.

Otherwise, Where there is a will, there is a way…

Fortunately we have access to internals behind the parameter handlers in Crystal Report Viewer web control.

Navigate to one of following locations:

  • C:\Inetpub\wwwroot\aspnet_client\system_web\2_0_50727\crystalreportviewers12\
  • C:\windows\Microsoft.NET\Framework\v2.0.50727\ASP.NETClientFiles\crystalreportviewers12\
  • C:\Program Files\Business Objects\Common\4.0\crystalreportviewers12\

and locate the file called allInOne.js – this is our victim. This file contains all JS code behind for CRV control which would be used by your web-site.

IMPORTANT: always create a backup copy before making any modifications.

(more…)

.Net and Design Patterns

Evolution has a spiral nature… it is true for any science, process, or development.

Not long time ago Waterfall Model of development prevailed. Very formalized, well described and structured, very structured… and it was “too much” which killed it… like a grandpa, it collected a lot of knowledge and experience, but he was to old and slow to keep up with the grandson… So was WF model – developers wanted something better and simpler, with built-in flexibility and after few iterations we’ve got “Agile model” and “XP programming” emerged. “Spiral” development cycles… “loose” modeling… like with JPEG, developers got “loose compression” of software process definition.

Not that we are loosing quality of the development, but we define the development process with desired level of formality/quality.

Remember in “Pirates of Caribbean” – pirates have “the pirate code”. Not being the law, it was a code of conduct which was helping keep the structure and discipline.

Same for “free spirit” development models, there is the need for some “guidelines” or “rules” everybody can understand and follow if want to achieve structure and efficiency. For the process there is an Agile methodology, and for the code/architecture there are Design Patterns.

First introduced over 30 years ago, term “Patterns” surfaced in software industry several time: originally in 1977, then in 1987 and then finally in 1994.
Since that time and Object Oriented Design becoming main stream in Software Industry it transformed into a common terminology.
It still come in “waves” to one company or another, coming ashore and and then retracting back to the sea of the theories. But with Object Oriented Programming being a mainstream in evolution of software development, Patterns or Design Patterns knowledge become a common base.

Today you hear about it everywhere – “What design pattern did you use?”, “application blocks“, etc.

To think about it, there is nothing new here. As an OO developer you may used it just a minute ago.

So let’s name a few basic one (I am going to use pattern classification presented here or you can refer to The Source – “Design  Patterns” by Gamma/Helm/Johnson/Vlissides (Amazon)):

  • Abstract Factory – allows manage/create instances of several types of classes – generic access.
    A-ha! In .Net the perfect example would be generics and reflection – there you are working with objects without precise knowledge of their type or parameters.
  • Singleton – have you ever created global instance of the class? This is a one example for you.
  • Adapter – we heard it somewhere recently… Aaaa… OleDBDataAdapter… From MSDN: “The OleDbDataAdapter serves as a bridge between a DataSet and data source for retrieving and saving data”
  • Bridge – have you moved from Single/mono-design applications to C/S or created front-end ASP.Net page for your Application Server back-end? Then you have separated interface from implementation of the logic, or used a Bridge pattern.
  • Proxy – Accessing your web-service from your code? Then you have most likely using some sort of Proxy class.

(more…)