Skip to content

Commit

Permalink
Add command line arg -LC for locale
Browse files Browse the repository at this point in the history
  • Loading branch information
pkpapani committed Feb 12, 2021
1 parent 2757f5a commit d640d44
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 28 deletions.
11 changes: 7 additions & 4 deletions Source/CrystalReportsNinja.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.13
# Visual Studio Version 16
VisualStudioVersion = 16.0.30804.86
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrystalReportsNinja", "CrystalReportsNinja\CrystalReportsNinja.csproj", "{A9BC6CCB-AFD4-4B80-BDE0-DBC99C8D51C2}"
EndProject
Expand All @@ -11,12 +11,15 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A9BC6CCB-AFD4-4B80-BDE0-DBC99C8D51C2}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{A9BC6CCB-AFD4-4B80-BDE0-DBC99C8D51C2}.Debug|Any CPU.Build.0 = Release|Any CPU
{A9BC6CCB-AFD4-4B80-BDE0-DBC99C8D51C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A9BC6CCB-AFD4-4B80-BDE0-DBC99C8D51C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9BC6CCB-AFD4-4B80-BDE0-DBC99C8D51C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A9BC6CCB-AFD4-4B80-BDE0-DBC99C8D51C2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {93BFA9E8-368B-47E3-B75B-AC54B1E1EDF8}
EndGlobalSection
EndGlobal
43 changes: 24 additions & 19 deletions Source/CrystalReportsNinja/ArgumentContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CrystalReportsNinja
{
Expand All @@ -13,37 +11,37 @@ public class ArgumentContainer
/// -U Report database login username (mandatory unless integrated security login)
/// </summary>
public string UserName { get; set; }

/// <summary>
/// -P Report database login password (mandatory unless integrated security login)
/// </summary>
public string Password { get; set; }
public string Password { get; set; }

/// <summary>
/// -F Crystal Report path and filename (mandatory)
/// </summary>
public string ReportPath { get; set; }
public string ReportPath { get; set; }

/// <summary>
/// -O Output file path and filename
/// </summary>
public string OutputPath { get; set; }
public string OutputPath { get; set; }

/// <summary>
/// -S Server name of specified crystal Report (mandatory)
/// </summary>
public string ServerName { get; set; }
public string ServerName { get; set; }

/// <summary>
/// -D Database name of specified crystal Report
/// </summary>
public string DatabaseName { get; set; }
public string DatabaseName { get; set; }

/// <summary>
/// -E Crystal Report exported format (pdf,xls,htm). "print" to print to printer
/// </summary>
public string OutputFormat { get; set; }
public string OutputFormat { get; set; }

/// <summary>
/// -a Report Parameter set (small letter p). eg:{customer : "Microsoft Corporation"} or {customer : "Microsoft Corporation" | "Google Inc"}
/// </summary>
Expand All @@ -60,7 +58,7 @@ public class ArgumentContainer
/// -C number of copy to be printed out
/// </summary>
public int PrintCopy { get; set; }

/// <summary>
/// -I Printer name
/// </summary>
Expand All @@ -69,22 +67,27 @@ public class ArgumentContainer
/// To display Help message
/// </summary>
public bool GetHelp { get; set; }

/// <summary>
/// To produce log file
/// </summary>
public bool EnableLog { get; set; }

/// <summary>
/// Email address to email to
/// </summary>
public string MailTo { get; set; }

/// <summary>
/// To refresh report or not
/// </summary>
public bool Refresh { get; set; }

/// <summary>
/// The Locale ID to set in the ReportClientDocument
/// </summary>
public int? LCID { get; set; }

public ArgumentContainer()
{
// Assigning default values
Expand Down Expand Up @@ -141,6 +144,8 @@ public void ReadArguments(string[] parameters)
ParameterCollection.Add(parameters[i + 1]);
else if (parameters[i].ToUpper() == "-TO")
MailTo = parameters[i + 1];
else if (parameters[i].ToUpper() == "-LC")
LCID = int.Parse(parameters[i + 1]);
}
}

Expand Down
6 changes: 6 additions & 0 deletions Source/CrystalReportsNinja/CrystalReportsNinja.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="CrystalDecisions.CrystalReports.Engine, Version=13.0.4000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, processorArchitecture=MSIL" />
<Reference Include="CrystalDecisions.ReportAppServer.ClientDoc, Version=13.0.4000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304">
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="CrystalDecisions.ReportAppServer.DataDefModel, Version=13.0.4000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304">
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="CrystalDecisions.Shared, Version=13.0.4000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
7 changes: 3 additions & 4 deletions Source/CrystalReportsNinja/Helper.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using CrystalDecisions.Shared;
using System;
using System;
using System.Collections.Generic;
using System.Text;

namespace CrystalReportsNinja
{
Expand Down Expand Up @@ -30,10 +28,11 @@ public static void ShowHelpMessage()
Console.WriteLine("-N Printer Name (Network printer : \\\\PrintServer\\Printername or Local printer : printername)");
Console.WriteLine("-C Number of copy to be printed");
Console.WriteLine("-l To write a log file. filename ninja-yyyyMMddHHmmss.log");
Console.WriteLine("-LC specify LCID for report locale");
Console.WriteLine("---------------------------------------------------");
Console.WriteLine("\nExample: C:\\> CrystalReportsNinja -U user1 -P mypass -S Server01 -D \"ExtremeDB\" -F c:\\test.rpt -O d:\\test.pdf -a \"Supplier Name:Active Outdoors\" -a \"Date Range:(12-01-2001,12-04-2002)\"");
Console.WriteLine("Learn more in http://www.rainforestnet.com/crystal-reports-exporter/");

}

/// <summary>
Expand Down
12 changes: 11 additions & 1 deletion Source/CrystalReportsNinja/ReportProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System;
using System.Collections.Generic;
using System.Globalization;
using CeLocale = CrystalDecisions.ReportAppServer.DataDefModel.CeLocale;

namespace CrystalReportsNinja
{
Expand Down Expand Up @@ -43,6 +44,15 @@ private void LoadReport()
if (_sourceFilename.LastIndexOf(".rpt") == -1)
throw new Exception("Invalid Crystal Reports file");

if (ReportArguments.LCID.HasValue)
{
CultureInfo locale = CultureInfo.GetCultureInfo(ReportArguments.LCID.Value);
Console.WriteLine("Using locale {0} {1}", locale.LCID, locale.EnglishName);
_reportDoc.ReportClientDocument.LocaleID = (CeLocale)locale.LCID;
_reportDoc.ReportClientDocument.PreferredViewingLocaleID = (CeLocale)locale.LCID;
_reportDoc.ReportClientDocument.ProductLocaleID = (CeLocale)locale.LCID;
}

_reportDoc.Load(_sourceFilename, OpenReportMethod.OpenReportByDefault);
_logger.Write(string.Format("Report loaded successfully"));
Console.WriteLine("Report loaded successfully");
Expand Down

0 comments on commit d640d44

Please sign in to comment.