About Me

My photo
Software Developer and ideas man!

Thursday, June 11, 2015

Ant Regex for updating SCOM MP version information in mpproj file

One think I had fun doing today was using ant's Perl v5 regex expressions to write in the version info of our build process into the SCOM Management Pack prior to building with MSBuild - I could have used the auto-increment feature of VSAE but this would not have been synchronized with the ant build properties we use for our other binaries that is part of a wider build deployment.

So, looking for a solution I thought I'd explore ant's regexs - the statement below works by matching on the version xml tags and groups them along with existing version info before substituting in the ant version properties used as part of the wider build process in the management pack project file.  

 <replaceregexp file="${SCOM.dir}/Pauls.mpproj"                     
byline="true"
match="(<Version>)([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*)(<\/Version>)"
replace="\1${VersionMajorNo}\.${VersionMinorNo}\.${VersionPatchNo}\.${VersionBuildNo}\3"/>

So
  1.0.0.5
becomes
  11.2.0.278

Monday, June 8, 2015

Localizing Legends in Crystal Reports

To localize the legends in my Crystal Reports Graphs I had effectively change my SQL "select statements" at runtime to incorporate column aliases.

For example, my original sql statement looks like this

SELECT `Copy_of_ivv`.`Trading_Date`, `Copy_of_ivv`.`High`, `Copy_of_ivv`.`Low`
 FROM   `Copy of ivv`

To get the legends to display in chinese, you have to alias the columns returned which appears to drive the legend names

 SELECT `Copy_of_ivv`.`Trading_Date` as '交易日', `Copy_of_ivv`.`High` as '高', `Copy_of_ivv`.`Low` as '低'
 FROM   `Copy of ivv` 


Tuesday, June 24, 2014

Localizing Crystal Reports in C# - I demonstrate one way of doing it despite the hurdles!

How hard should it be to localize a Crystal Report in Visual Studio. You should be able to specify the "localize" property on the control, change language to what you are localizing to, build the solution and hey presto! have a new localized resource and satellite assembly ready for deploying.

Well, this is not the case for the Crystal Reports controls including the almost "black box" charts as I soon discovered.

So, I thought I'd setup a test app. to demonstrate what hurdles you have to overcome to localize a report.

Some users duplicate reports and create localized versions but I thought my way would be more self contained and hopefully there would be less ongoing maintenance required.

First off, I created a sample app, that reads share prices for a given stock from an Oracle database and prints a chart of the Highs and Lows over the trading lifetime of the stock. It also prints some basic summary stats below the chart.

The localization goal is to translate the wording of the titles, chart objects to Simplified Chinese.


Secondly,  I updated the locale in my code to "zn-CN" or Simplified Chinese - straight off the bat, Crystal picks this up and changes the Crystal Reports Viewer elements, such as tab name and status bar info to localized versions.



Thirdly, to change report headings such as "Average Volume", the report title etc., I had to resort to the code and directly reference each object in the reportdefinition - this is an arduous process especially if you have many languages that you have to cater for.


Note: normally, these would be constants and the strings would be in a string resource file



Now, the tricky bit is in updating the Chart elements.  This cannot be done directly and I have raised an"Idea" with SAP to expose more properties in their charts.  PLEASE, visit the link below and vote up the idea so the CR product manager has a case for implementing it!


Because the chart elements cannot be directly referenced, the idea here is to turn off the titles for the chart and superimpose a text object on the Chart which can be directly referenced in code. 




Finished Product


So what I've covered here is the localizing of the main elements of a Crystal Report.  You will have noticed that numeric values and dates will be formatted according to the CultureInfo set by the program or OS. I'll cover changing the legends another time.

If you have any comments, feel free to provide them in the box below and please vote up my idea :).

SAP Idea Place - Expose more properties of ChartObject in Crystal Reports for Visual Studio 2010/2012 .Net


For a copy of the code click on the link below.  I have included an excel spreadsheet of the share values that can be used as the datasource.  Let me know if you need a hand with this.

Crystal Report Localization Sample code developed in Visual Studio 2010 - C#

Sunday, February 19, 2012

Hmmm - vi being a little bit handy!

Just discovered the "!!" and its usage in vi.  Very handy and much easier to use than redirecting output to a text file.  Effectively, if you type "!!" in command mode, it executes the current line as input and inserts the command output in the file.  For example, if I press "!" twice on the keyboard and then type "hostname" at the prompt, the hostname of the machine will be inserted in the file I'm editing. Very nice!

I never knew this until I put on my Unix hat and tried it!

I discovered by chance that you could put in an environment variable into the Window's Explorer address bar and it resolves to the location - path that I typically use daily include %TNS_ADMIN%, %TEMP%, %USERPROFILE%. I only considered doing this when I became frustrated with trying to remember locations - how easy is it on Unix - cd $ORACLE_HOME.  Now, it is just as easy on Windows.



P.S. Some of my work mates said they use this all the time - doh!