Skip to content

Commit f235e94

Browse files
authored
Merge pull request #270 from CAST-projects/develop
REPORTGEN-348: fix double.parse in french
2 parents 06ab157 + 4e93869 commit f235e94

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

CastReporting.Reporting/Block/Text/PortfolioCustomExpression.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public override string Content(ReportData reportData, Dictionary<string, string>
4848

4949
if (_aggregator == "SUM")
5050
{
51-
double sumValues = strValues.Where(val => val != Labels.NoData).Sum(val => double.Parse(val));
51+
double sumValues = strValues.Where(val => val != Labels.NoData).Sum(val => double.Parse(val, System.Globalization.CultureInfo.CurrentCulture));
5252
return sumValues.ToString(_metricFormat);
5353
}
5454
else
@@ -59,7 +59,7 @@ public override string Content(ReportData reportData, Dictionary<string, string>
5959
{
6060
if (val == Labels.NoData) continue;
6161
nbValues++;
62-
sumValues += double.Parse(val);
62+
sumValues += double.Parse(val, System.Globalization.CultureInfo.CurrentCulture);
6363
}
6464
if (nbValues == 0) return Labels.NoData;
6565
var avgValues = sumValues / nbValues;

CastReporting.Reporting/Helper/GenericContent.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ public static TableDefinition Content(ReportData reportData, Dictionary<string,
423423
string curValue = MetricsUtility.CustomExpressionEvaluation(reportData, options, lstParams, reportData.CurrentSnapshot, expr, _metricFormat, null, string.Empty);
424424
string prevValue = reportData.PreviousSnapshot != null ? MetricsUtility.CustomExpressionEvaluation(reportData, options, lstParams, reportData.PreviousSnapshot, expr, _metricFormat, null, string.Empty) : Labels.NoData;
425425
if (positionSnapshots != -1) _posResults[positionSnapshots] = Labels.EvolutionPercent;
426-
string evolPercentValue = FormatHelper.FormatPercent(double.Parse(MetricsUtility.ComputeExpression(curValue + " - " + prevValue, _metricFormat, false)));
426+
string evolPercentValue = FormatHelper.FormatPercent(double.Parse(MetricsUtility.ComputeExpression(curValue + " - " + prevValue, _metricFormat, false),System.Globalization.CultureInfo.CurrentCulture));
427427
results.Add(Tuple.Create(_posResults[0], _posResults[1], _posResults[2], _posResults[3]), evolPercentValue);
428428
break;
429429
default:
@@ -633,7 +633,7 @@ public static TableDefinition Content(ReportData reportData, Dictionary<string,
633633
string curValue = MetricsUtility.CustomExpressionEvaluation(reportData, options, lstParams, reportData.CurrentSnapshot, expr, _metricFormat, module, string.Empty);
634634
string prevValue = reportData.PreviousSnapshot != null ? MetricsUtility.CustomExpressionEvaluation(reportData, options, lstParams, reportData.PreviousSnapshot, expr, _metricFormat, module, string.Empty) : Labels.NoData;
635635
if (positionSnapshots != -1) _posResults[positionSnapshots] = Labels.EvolutionPercent;
636-
string evolPercentValue = FormatHelper.FormatPercent(double.Parse(MetricsUtility.ComputeExpression(curValue + " - " + prevValue, _metricFormat, false)));
636+
string evolPercentValue = FormatHelper.FormatPercent(double.Parse(MetricsUtility.ComputeExpression(curValue + " - " + prevValue, _metricFormat, false), System.Globalization.CultureInfo.CurrentCulture));
637637
results.Add(Tuple.Create(_posResults[0], _posResults[1], _posResults[2], _posResults[3]), evolPercentValue);
638638
break;
639639
default:
@@ -855,7 +855,7 @@ public static TableDefinition Content(ReportData reportData, Dictionary<string,
855855
string curValue = MetricsUtility.CustomExpressionEvaluation(reportData, options, lstParams, reportData.CurrentSnapshot, expr, _metricFormat, null, techno);
856856
string prevValue = reportData.PreviousSnapshot != null ? MetricsUtility.CustomExpressionEvaluation(reportData, options, lstParams, reportData.PreviousSnapshot, expr, _metricFormat, null, techno) : Labels.NoData;
857857
if (positionSnapshots != -1) _posResults[positionSnapshots] = Labels.EvolutionPercent;
858-
string evolPercentValue = FormatHelper.FormatPercent(double.Parse(MetricsUtility.ComputeExpression(curValue + " - " + prevValue, _metricFormat, false)));
858+
string evolPercentValue = FormatHelper.FormatPercent(double.Parse(MetricsUtility.ComputeExpression(curValue + " - " + prevValue, _metricFormat, false), System.Globalization.CultureInfo.CurrentCulture));
859859
results.Add(Tuple.Create(_posResults[0], _posResults[1], _posResults[2], _posResults[3]), evolPercentValue);
860860
break;
861861
default:
@@ -1085,7 +1085,7 @@ public static TableDefinition Content(ReportData reportData, Dictionary<string,
10851085
string curValue = MetricsUtility.CustomExpressionEvaluation(reportData, options, lstParams, reportData.CurrentSnapshot, expr, _metricFormat, module, techno);
10861086
string prevValue = reportData.PreviousSnapshot != null ? MetricsUtility.CustomExpressionEvaluation(reportData, options, lstParams, reportData.PreviousSnapshot, expr, _metricFormat, module, techno) : Labels.NoData;
10871087
if (positionSnapshots != -1) _posResults[positionSnapshots] = Labels.EvolutionPercent;
1088-
string evolPercentValue = FormatHelper.FormatPercent(double.Parse(MetricsUtility.ComputeExpression(curValue + " - " + prevValue, _metricFormat, false)));
1088+
string evolPercentValue = FormatHelper.FormatPercent(double.Parse(MetricsUtility.ComputeExpression(curValue + " - " + prevValue, _metricFormat, false), System.Globalization.CultureInfo.CurrentCulture));
10891089
results.Add(Tuple.Create(_posResults[0], _posResults[1], _posResults[2], _posResults[3]), evolPercentValue);
10901090
break;
10911091
default:

CastReporting.Reporting/Helper/MetricsUtility.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ public static string ComputeExpression(string expr, string metricFormat, bool po
869869
DataTable dt = new DataTable();
870870
try
871871
{
872-
double? res = double.Parse(dt.Compute(expr, "").ToString());
872+
double? res = double.Parse(dt.Compute(expr, "").ToString(), System.Globalization.CultureInfo.CurrentCulture);
873873
return res.Value.Equals(double.NaN) ? Labels.NoData : res.Value.ToString(metricFormat);
874874
}
875875
catch (EvaluateException e)
@@ -885,7 +885,7 @@ public static string ComputeExpression(string expr, string metricFormat, bool po
885885
DataTable dt = new DataTable();
886886
try
887887
{
888-
return double.Parse(dt.Compute(expr, "").ToString());
888+
return double.Parse(dt.Compute(expr, "").ToString(), System.Globalization.CultureInfo.CurrentCulture);
889889
}
890890
catch (EvaluateException e)
891891
{

0 commit comments

Comments
 (0)