What is the easiest way to localize SSRS Report with VS2012 - visual-studio-2012

I'd like to know if there's a norm for this task since VS2012 SSRS does not support resx files. It would be so much easier this way but we just can't add resx files to a SSRS Report.
I know that you can create a custom assembly to do this, but is this the best approach?
Thanks

Write a custom assembly in .NET and a method to retrieve the localized string.
//Class to retrieve the localized value
public static class LocalizedValue
{
public static string GetString
(string localeSensitiveResource, string cultureInfoName)
{
//
}
}
In your report you would access it like this:
=Code.LocalizedValue("REPORTHEADER", Parameters!ReportCulture.Value)
Refer to this code project for more information:
Localization of SRS Reports

For Dynamics AX this is pretty simple.
If you keep your layout the same, add translations for the labels you are using in your expressions.
(=Label!#SYS1234)
If the layout differs, add a new design to your report, e.g. FreeTextInvoice.

Related

Is .xls workbook template based on dynamic parameters possible?

I'm part of a development team that uses JasperReports in our Java application to generate .pdf or .xls reports. Currently we are trying to extend our .xls reports with predefined print settings and macros.
I discovered the report property net.sf.jasperreports.export.xls.workbook.template, whose description seems like a perfect match for this requirement. In our case, the problem now seems to be, that this property cannot be set based on an expression or input parameter (or am I doing it wrong?).
Our server-side architecture (Java) is designed like this: we have a generic JasperReportController, that handles the preparation and exporting of every .jasper/.jrxml file. Reports are populated with default properties and parameters, which the reports designers can use in their reports. Some reports already have dynamic header images, based on language and customer. This was easily implemented with the powerful expression capabilities of JasperReports. But this doesn't seem to be possible with (global) report properties.
What we need:
A report designer should be able to define a workbook template per report: this one is simple, just define the previously mentioned property on the report
The specified template should be dynamic, preferably based on an expression (custom function) like: xlsTemplate('my-template.xls', $P{customer}, $P{language}) -> I have no idea how to do this at the moment
This leads to my question: is there a way to specify a report's property as an expression or is there an other approach to solve my requirements?
The solution should be generic, so that a report designer can define the dynamic .xls template just in the .jrxml file and doesn't need to modify Java code.
Try this, before you fill your report:
String thePath = "... get it from where you like also the jasper report see property map below...."
JRPropertiesMap properties = jasperReport.getPropertiesMap();
properties.put(XlsExporterConfiguration.PROPERTY_WORKBOOK_TEMPLATE,thePath);
Conclusion you edit your generic JasperController, check if there is a certain property in the report,request url, report name of what ever you prefeer, then in base of your logic set the PROPERTY_WORKBOOK_TEMPLATE to the selected template, then fillout the report.

Flexible customization - Generating word document using C#

Problem - Generate a word document from information retrieved from database.
My solution - Create a word document template add fields/tags in places where values need to be inserted. The template will require tables and charts as well. Using document reflector that comes with open office xml sdk reflect on the document template and extract the w:document section and port it to C#. The rest of the logic revolves simply around finding the fields/tags, replacing them, etc. Very simple approach but not very flexible!
Challenge - I want the user to have the ability to customize the template or the generated document output. But this will not be possible if I embed the template logic in code.
Any other possibilities - I looked around at Templating using T4 and RazorEngine but could not find any concrete examples of how to create word documents using these two technologies.
Now what is the best approach?
I would really appreciate your inputs on what is the best and most flexible way to generate word documents using C#.
I'm actually working a project where the business users are designing word template with mail merge fields and we are populating the values using a 3rd party software package Aspose Words. http://www.aspose.com/categories/.net-components/aspose.words-for-.net/default.aspx
The software includes a library for merging data from datatables into the mail merge fields in the word document.
I also wrote a customized word task pane add in that retrieves data views from the database and lists the fields in a drag/drop interface that mimics a crystal or sql report writing interface.
Probably would of been easier to just use crystal or sql reporting though...
It's certainly possible to generate the contents of an Office doc using T4 or Razor and then package it up. The TestScribe powertool for Visual Studio Test Manager does just that with T4. There is a thread by Sally Cavanagh in the Q&A on this page http://visualstudiogallery.msdn.microsoft.com/e79e4a0f-f670-47c2-9b8a-3b6f664bf4ae that suggests a way to look at the T4 templates that it uses, which might get you jump-started.
Here is sample to play word document template with C#
You could use a content control databinding approach.
XML Mapping Task Pane for Word 2007/2010 is an authoring tool.
To create an instance document, you just attach your XML data file.
If the resulting documents will be opened in Word, that is all that is required: Word will bind the data itself. If your consuming application is not Word, you might want to resolve the bindings yourself (eg via Open XML SDK).
Content control databinding isn't intended to support repeats and conditionals. For a way to do that, look at my OpenDoPE convention
Take a look at Templater. Disclamer: I'm the author.
Check out JODReports or Docmosis. They are Java based but some of the templating features and output options might be ideal. You can call the command line interfaces unless they also have something better to reach from C#.

Doing Documentation Using Excel Dna

I have used Excel Dna to create .NET xlls and use it in my addin and excel worksheet functions.
I also use ExcelDnaPack.exe to package my xll.
I was wondering if excel dna supports, any ways to generate documentation for my library API's.
Thanks,
Mani
Firstly, Excel-DNA allows you to integrate into the Excel function wizard with descriptions for the functions and the different arguments. These are added to your function using attributes:
[ExcelFunction(Category="My functions", Description="My useful function")]
public static double MyFunc(
[ExcelArgument(Description="is an important parameter.")] double param1,
[ExcelArgument(Description="is unimportant.")] double param2)
{...}
The function wizard also allows a help link for each function.
If you have a help file, say in .chm format, you can tell Excel-DNA to hook up the help link like this:
[ExcelFunction(HelpTopic="MyHelp.chm!102")]
public static double MyFunction() ...
How to get the help file? The C# or VB.NET compiler can generate an xml file from the xml /// comments in your code. This .xml file is processed by something like Sandcastle - here's a whole discussion on that part: Generating Documentation from C# XML Comments.
But Excel-DNA has nothing at the moment to automatically relate the functions and their topics. I'm not sure how hard it is to figure out the generated TopicIds from the Sandcastle output, or to set them from the code in the xml comment. If it's an issue, an automatic topic hookup or even a help generator tool might be a nice feature to add to Excel-DNA in future.
It is also common to add a ribbon to your Excel-DNA add-in with a button that displays a help file for the whole add-in.
Edit: There is now a user-contributed project that processes Excel-DNA to generate help files more easily. See https://github.com/mndrake/ExcelDnaDoc

C# 4.0 -- how to create & use project config with VS2010 SP1

I need to create a project config file(i.e. project.config or project.ini) so that I can later use it store the preference selected by the user. When the application launches, it will automatically load that config file and customize the application based on the previous settings.
Is there a good way to do this in C# 4.0?
I used to manually do all these labor work by manipulating a file in C++ and I expect to get a cleaner and easier solution with .NET.
Thank you
For WinForms and WPF, consider using the Application Settings built-in. No need to roll your own, in this case. This is a way to create and store settings data on behalf of your application and your users.
predefine the settings you'd like the user to be able to save. Let's say it's WindowSize, and BackgroundImage.
access these properties like so:
//get the value of WindowSize which is a string
string windowSize = Properties.Settings.Default.WindowSize;
MessageBox.Show("WindowSize setting value is :" + windowSize );
//set the new value of BackgroundImage
Properties.Settings.Default.BackgroundImage= "http://foo.org/bar.png";
Properties.Settings.Default.Save(); //apply the changes to the settings file
This persists to yourAppName.exe.config.
Not only in C#, the XML technologies are useful for these kind of task. You can create XML Schema that describes the format of you configuration file, then you can use xsd.exe to generate C# classes from this schema and then with a few lines of code you can serialize into/deserialize from an xml file.

How can I customize the generated classes in SubSonic 2.2

I'm using SubSonic 2.2 for my DAL. To match the requirement, I need to customize some of classes which generated by SubSonic. For sample:
public partial class Category : ActiveRecord, IActiveRecord, IOtherInterface
Could you please give me some clues. Where I can modify the generated template? Thanks!
Jim is incorrect you can add an Interface via the partial class. I keep one folder with all of the Generated Files and another one with the Altered class files and I am adding an interface to the altered class files and it works just fine.
public partial class ContainerSearch : IContainerSearch
{
}
above is an example from my code I am using now
(edit: see runxc1's post for better answer)
You can modify the templates used to generate the class files to add in your other interface. You can't add an interface to the partial classes. The only trick is that this will add it to all generated classes. You can also just go into your automatically generated classes and add your interface manually after you generate the class files.
SubSonic 2.2 templates are a bit tricker to work with than the 3.0 templates, but it's still really easy to modify the templates.
See below links for info:
how to modify SubSonic 2.1 code generation
http://johnnycoder.com/blog/2008/06/09/custom-templates-with-subsonic/
Your options:
Modify templates used for generation to add in your interface (all classes), or
Modify templates used for generation to add in if/switches to only add interfaces to certain classes that match specific names, etc., or
Edit generated classes to add in your interface (must redo edits after each auto-generation)
After you modified those aspx files. Then you'll just need to update your .config file of your DAL to specify the new path to your customized aspx files and regen as usual.

Resources