Skip to content

Commit

Permalink
v4.10.0.0 made independent from OS number formatting settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Wigman committed Feb 7, 2020
1 parent 8292c85 commit 5b6e621
Show file tree
Hide file tree
Showing 38 changed files with 190 additions and 144 deletions.
18 changes: 9 additions & 9 deletions 06_Tools/ReportTool/sources/rpg.common/Intermediate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public class Intermediate : Dictionary<string, string>
{
public static string NOENTITY = "-";

// intermediate standard separators
public const char DECIMALSEPARATORINTERMEDIATE = '.';
public const char DECIMALSEPARATORMEASURES = '.';

/// <summary> key-value pair separator </summary>
public const char KEYVALUESEPARATOR = '=';
/// <summary> list value separator character </summary>
Expand Down Expand Up @@ -132,7 +136,7 @@ public int ReadFromFile(string filename)
/// <param name="key"></param>
/// <param name="prefix"></param>
/// <returns></returns>
public int ReadFromDatabaseValue(string project, string testrun, string category, string key, string prefix)
public int ReadFromDatabaseValues(string project, string testrun, string category, string key, string prefix)
{
DataAccess da = new DataAccess(project);
//Log.Write(string.Format("readfromdatabasevalue {0}/{1}/{2}/{3}/{4} :", project, testrun, category, entity, prefix));
Expand All @@ -150,9 +154,9 @@ public int ReadFromDatabaseValue(string project, string testrun, string category
/// <param name="category"></param>
/// <param name="entity"></param>
/// <returns></returns>
public int ReadFromDatabaseValue(string project, string testrun, string category, string entity)
public int ReadFromDatabaseValues(string project, string testrun, string category, string entity)
{
return ReadFromDatabaseValue(project, testrun, category, entity, "");
return ReadFromDatabaseValues(project, testrun, category, entity, "");
}

/// <summary>
Expand Down Expand Up @@ -234,7 +238,7 @@ public void AddValue(string key, string value)
/// </summary>
public void Normalize()
{
Log.WriteLine("normalize intermediate...");
//Log.WriteLine("normalize intermediate...");

int cnt;
int maxCnt = 0;
Expand All @@ -256,18 +260,14 @@ public void Normalize()
// if new value: fill left
if ((NumOfElements(newValue) == 1) && (maxCnt>1))
{
//Log.Write("left fill:[" + pair.Key + "=" + pair.Value + "]");
while (NumOfElements(newValue) < maxCnt)
newValue = LISTSEPARATOR + newValue;
//Log.WriteLine("->[" + newValue + "]");
}
// if already present: fill right
else
{
//Log.Write("right fill:[" + pair.Key + "=" + pair.Value + "]");
while (NumOfElements(newValue) < maxCnt)
newValue = newValue + LISTSEPARATOR;
//Log.WriteLine("->[" + newValue + "]");
}

tmpList.Add(pair.Key, newValue);
Expand Down Expand Up @@ -432,7 +432,7 @@ private int MergeDatabaseKeyValueResult(List<object> dbResult, string prefix)
cnt++;
}
else
Log.WriteLine(string.Format("WARNING ignore intermediate duplicate [{0}]", prefix+row[0]));
Log.WriteLine(string.Format("WARNING ignoring intermediate duplicate [{0}]", prefix+row[0]));
}
return cnt; // num of rows matching rows
}
Expand Down
26 changes: 14 additions & 12 deletions 06_Tools/ReportTool/sources/rpg.common/Thresholds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ public static double StringValueToDouble(string value)
{
try
{
return double.Parse(Utils.ToSystemFloatString(value));

// normale decimal separator
if (value.Contains( decimalSeparator ))
{
Expand All @@ -186,8 +188,8 @@ public static double StringValueToDouble(string value)
return double.Parse( value.Replace( thousandSeparator, decimalSeparator) );
}

// of integer getal, of lege string
return double.Parse(value);
//// of integer getal, of lege string
//return double.Parse(value);
}
catch (Exception)
{
Expand All @@ -198,15 +200,15 @@ public static double StringValueToDouble(string value)
return double.NaN;
}

/// <summary>
/// Convert double to a string value with .000 format
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static string DoubleValueToSTring(double value)
{
string formatString = string.Format("0{0}000", decimalSeparator);
return value.ToString(formatString);
}
///// <summary>
///// Convert double to a string value with .000 format
///// </summary>
///// <param name="value"></param>
///// <returns></returns>
//public static string DoubleValueToSTring(double value)
//{
// string formatString = string.Format("0{0}000", decimalSeparator);
// return value.ToString(formatString);
//}
}
}
6 changes: 3 additions & 3 deletions 06_Tools/ReportTool/sources/rpg.common/TransactionValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private double LowestStrDouble(double baseValue, string value)
{
try
{
double d = double.Parse(Utils.NormalizeFloatString(value));
double d = double.Parse(Utils.ToSystemFloatString(value));
return d < baseValue ? d : baseValue;
}
catch
Expand All @@ -185,7 +185,7 @@ private double AddStrDouble(double baseValue, string value)
{
try
{
double d = double.Parse(Utils.NormalizeFloatString(value));
double d = double.Parse(Utils.ToSystemFloatString(value));
return baseValue + d;
}
catch
Expand All @@ -198,7 +198,7 @@ private double HighestStrDouble(double baseValue, string value)
{
try
{
double d = double.Parse(Utils.NormalizeFloatString(value));
double d = double.Parse(Utils.ToSystemFloatString(value));
return baseValue > d ? baseValue : d;
}
catch
Expand Down
66 changes: 53 additions & 13 deletions 06_Tools/ReportTool/sources/rpg.common/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,32 +156,58 @@ public static DateTime ParseJMeterEpoch(string s)
}

/// <summary>
/// Convert malformed decimal string to workable decimal string (acc to system locale)
/// Convert any decimal string to decimal string according to System Locale
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static string NormalizeFloatString(string value)
public static string ToSystemFloatString(string value)
{
return ToAnyFloatString(value, System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator[0]);
}

/// <summary>
/// Convert any decimal string to intermediate general float string
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static string ToIntermediateFloatString(string value)
{
return ToAnyFloatString(value, Intermediate.DECIMALSEPARATORINTERMEDIATE);
}

/// <summary>
/// convert any decimal string to intermediate measure float string
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static string ToMeasureFloatString(string value)
{
return ToAnyFloatString(value, Intermediate.DECIMALSEPARATORMEASURES);
}

public static string ToAnyFloatString(string value, char separator)
{
string outValue;
char systemDecimalSeparator = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator[0];
// maakt niet uit wat er binnen komt (. of , als decimal separator): vervangen door system decimalseparator
outValue = value.Replace(',', systemDecimalSeparator);
outValue = outValue.Replace('.', systemDecimalSeparator);
// maakt niet uit wat er binnen komt (. of , als decimal separator): vervangen door decimalseparator
outValue = value.Replace(',', separator);
outValue = outValue.Replace('.', separator);
return outValue;
}

/// <summary>
/// Convert Jmeter time to intermediate seconds
/// </summary>
/// <returns></returns>
public static string jmeterTimeToSeconds(string jmValueStr)
public static string jmeterTimeToIntermediateSecondsString(string jmValueStr)
{
//values: 01003_linkhelp,87,58,20,29,91,385,14,2445,0.00,0.1,17.8,262.78
float f;
string strVal;
try
{
strVal = NormalizeFloatString(jmValueStr);
//strVal = ToIntermediateFloatString(jmValueStr);
strVal = ToSystemFloatString(jmValueStr);

if (float.TryParse(strVal, out f))
f = f / 1000;
else
Expand All @@ -192,27 +218,31 @@ public static string jmeterTimeToSeconds(string jmValueStr)
Log.WriteLine(string.Format("WARNING cannot parse value [{0}]", jmValueStr));
return jmValueStr;
}
return f.ToString("0.000");

//return f.ToString("0.000");

// elk formaat naar Intermediate float format
return ToIntermediateFloatString(f.ToString());
}

/// <summary>
/// Number format to report measure format (. as decimal)
/// </summary>
/// <param name="val"></param>
/// <returns></returns>
public static string ToMeasureFormat(string val)
public static string ToMeasureFormatString(string value)
{
return val.Replace(",", ".");
return ToMeasureFloatString(value);
}

/// <summary>
/// Float string to intermediate float string
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static string NormalizeFloat(string value)
public static string NormalizeFloatString(string value)
{
return NormalizeFloatString(value);
return ToIntermediateFloatString(value);
}

/// <summary>
Expand Down Expand Up @@ -282,5 +312,15 @@ public static string NormalizeTransactionName(string suggestedName)
return newName;
}

/// <summary>
/// Discover and return the decimal separator character in value
/// </summary>
/// <param name="returnValue"></param>
/// <returns></returns>
public static char GetDecimalChar(string value)
{
// return first non-numeric character
return Regex.Match(value, "[^\\d]").Value[0];
}
}
}
8 changes: 4 additions & 4 deletions 06_Tools/ReportTool/sources/rpg.common/rpg.common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<Version>4.9.3.0</Version>
<Version>4.10.0.0</Version>
<Company>ICTU</Company>
<Product>Report Generator - common</Product>
<Authors>ISR</Authors>
<Copyright>ICTU 2019</Copyright>
<Copyright>ICTU 2020</Copyright>
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />
<AssemblyVersion>4.9.2.0</AssemblyVersion>
<FileVersion>4.9.2.0</FileVersion>
<AssemblyVersion>4.10.0.0</AssemblyVersion>
<FileVersion>4.10.0.0</FileVersion>
<PackageId></PackageId>
<Description>Shared library for report generator binaries</Description>
</PropertyGroup>
Expand Down
8 changes: 4 additions & 4 deletions 06_Tools/ReportTool/sources/rpg.console/rpg.console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<Version>4.9.3.0</Version>
<Version>4.10.0.0</Version>
<Authors>ISR</Authors>
<Company>ICTU</Company>
<Product>Report Generator - console tool</Product>
<Copyright>ICTU 2019</Copyright>
<Copyright>ICTU 2020</Copyright>
<ApplicationIcon />
<StartupObject />
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.10.0.0</AssemblyVersion>
<PackageId></PackageId>
<FileVersion>4.2.0.0</FileVersion>
<FileVersion>4.10.0.0</FileVersion>
<Description>Data manipulation in reportgenerator database via the console</Description>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AssemblyVersion>4.3.0.0</AssemblyVersion>
<FileVersion>4.3.0.0</FileVersion>
<AssemblyVersion>4.10.0.0</AssemblyVersion>
<FileVersion>4.10.0.0</FileVersion>
<Company>ICTU</Company>
<Product>Report Generator - load intermediate</Product>
<Copyright>ICTU 2019</Copyright>
<Version>4.9.3.0</Version>
<Copyright>ICTU 2020</Copyright>
<Version>4.10.0.0</Version>
<Authors>ISR</Authors>
<PackageId></PackageId>
<Description>Load intermediate csv data into the reportgenerator database</Description>
Expand Down
2 changes: 1 addition & 1 deletion 06_Tools/ReportTool/sources/rpg.merge/JoinController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ internal void JoinIntermediateFromDatabase(string project, string testrun, strin

// read testrun intermediate from database
Intermediate srcIntermediate = new Intermediate();
int cnt = srcIntermediate.ReadFromDatabaseValue(project, testrun, category, entity);
int cnt = srcIntermediate.ReadFromDatabaseValues(project, testrun, category, entity);
Log.WriteLine(string.Format("num of values read for entity [{0}/{1}]: {2}", category, entity, cnt));

// filter only one indexed value per key
Expand Down
Loading

0 comments on commit 5b6e621

Please sign in to comment.