Skip to content

Commit

Permalink
fixed bad file name generation
Browse files Browse the repository at this point in the history
  • Loading branch information
noah80 committed Jun 4, 2020
1 parent f367ec7 commit a18ee70
Show file tree
Hide file tree
Showing 41 changed files with 492 additions and 64 deletions.
1 change: 1 addition & 0 deletions Automation/Automation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
4 changes: 2 additions & 2 deletions Automation/HouseholdData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public HouseholdData([NotNull] string uniqueHouseholdId,
TransportationDeviceSet = transportationDeviceSet;
TravelRouteSet = travelRouteSet;
TransportationDistanceModifiers = transportationDistanceModifiers;
HouseholdDataSpecifictionType = householdDataSpecifictionType;
HouseholdDataSpecificationType = householdDataSpecifictionType;
}

[Obsolete("For json only")]
Expand Down Expand Up @@ -124,6 +124,6 @@ public HouseholdData()
[ItemNotNull]
public List<TransportationDistanceModifier>? TransportationDistanceModifiers { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public HouseholdDataSpecificationType HouseholdDataSpecifictionType { get; set; }
public HouseholdDataSpecificationType HouseholdDataSpecificationType { get; set; }
}
}
4 changes: 4 additions & 0 deletions Automation/JsonSumProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public JsonDeviceProfiles(TimeSpan timeResolution, DateTime startTime, string lo
LoadTypeInformation = loadTypeInformation;
}
[Obsolete("only for json")]
#pragma warning disable 8618
public JsonDeviceProfiles()
#pragma warning restore 8618
{
}

Expand All @@ -54,7 +56,9 @@ public JsonSumProfile(string name, TimeSpan timeResolution, DateTime startTime,
LoadTypeInformation = loadTypeInformation;
}
[Obsolete("only for json")]
#pragma warning disable 8618
public JsonSumProfile()
#pragma warning restore 8618
{
}

Expand Down
2 changes: 1 addition & 1 deletion Automation/LoadTypePriority.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public enum LoadTypePriority
Mandatory,
RecommendedForHouseholds,
RecommendedForHouses,
Optional,
OptionalLoadtypes,
All
}
}
19 changes: 18 additions & 1 deletion Automation/StrGuid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Automation
{
public struct StrGuid : IEquatable<StrGuid>, IComparable<StrGuid> {
public struct StrGuid : IEquatable<StrGuid>, IComparable<StrGuid>, IComparable {
public int CompareTo(StrGuid? other)
{
if (!other.HasValue) {
Expand All @@ -21,6 +21,23 @@ public bool Equals(StrGuid? other)
return StrVal == other.Value.StrVal;
}

public int CompareTo(object? obj)
{
if (ReferenceEquals(null, obj)) {
return 1;
}

return obj is StrGuid other ? CompareTo(other) : throw new ArgumentException($"Object must be of type {nameof(StrGuid)}");
}

public static bool operator <(StrGuid left, StrGuid right) => left.CompareTo(right) < 0;

public static bool operator >(StrGuid left, StrGuid right) => left.CompareTo(right) > 0;

public static bool operator <=(StrGuid left, StrGuid right) => left.CompareTo(right) <= 0;

public static bool operator >=(StrGuid left, StrGuid right) => left.CompareTo(right) >= 0;

public bool Equals(StrGuid other)
{
return StrVal == other.StrVal;
Expand Down
1 change: 1 addition & 0 deletions CalcPostProcessor/CalcPostProcessor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<ItemGroup>
<PackageReference Include="Autofac" Version="5.2.0" />
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ protected override void PerformActualStep(IStepParameters parameters)
var columns = efc.ColumnEntriesByColumn[p.LoadType].Values.Where(entry => entry.HouseholdKey == key).Select(entry => entry.Column)
.ToList();
var hhname = "." + key + ".";
StreamWriter normalfile = null;

normalfile = _fft.MakeFile<StreamWriter>("DeviceProfiles" + hhname + p.LoadType.Name + ".csv",
var normalfile = _fft.MakeFile<StreamWriter>("DeviceProfiles" + hhname + p.LoadType.Name + ".csv",
"Energy use by each device in each Timestep for " + p.LoadType.Name + " for " + hhname,
true,
ResultFileID.DeviceProfileForHouseholds,
Expand All @@ -62,11 +61,6 @@ protected override void PerformActualStep(IStepParameters parameters)

var time = dsc.MakeTimeString(efr.Timestep);
var indidivdual = time + efr.GetEnergyEntriesAsString(true, p.LoadType, columns, Repository.CalcParameters.CSVCharacter);
if (normalfile == null)
{
throw new LPGException("File is null, even though it shouldn't be. Please report.");
}

normalfile.WriteLine(indidivdual);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected override void PerformActualStep(IStepParameters parameters)
.Where(entry => entry.HouseholdKey == p.Key.HouseholdKey)
.Select(entry => entry.Column)
.ToList();
var hhname = "." + p.Key.HouseholdKey + ".";
var hhname = "." + p.Key.HouseholdKey ;
var calcParameters = Repository.CalcParameters;
var jrf = new JsonSumProfile("Sum profile", calcParameters.InternalStepsize,
calcParameters.OfficialStartTime, dstLoadType.Name, dstLoadType.UnitOfSum, dstLoadType.ConvertToLoadTypeInformation());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected override void PerformActualStep(IStepParameters parameters)
ResultFileID.SumProfileForHouseholds,
p.Key.HouseholdKey,
TargetDirectory.Results,
Repository.CalcParameters.InternalStepsize, CalcOption.HouseSumProfilesFromDetailedDats,
Repository.CalcParameters.InternalStepsize, CalcOption.HouseholdSumProfilesFromDetailedDats,
dstLoadType.ConvertToLoadTypeInformation());
sumfile.WriteLine(dstLoadType.Name + "." + dsc.GenerateDateStampHeader() + "Sum [" + dstLoadType.UnitOfSum +
"]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
using Common.SQLResultLogging;
using JetBrains.Annotations;

namespace CalcPostProcessor.LoadTypeHouseholdSteps {
namespace CalcPostProcessor.LoadTypeProcessingSteps {
public class HouseDeviceProfileFileProcessor: LoadTypeStepBase
{
[NotNull]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Common.SQLResultLogging;
using JetBrains.Annotations;

namespace CalcPostProcessor.LoadTypeHouseholdSteps {
namespace CalcPostProcessor.LoadTypeProcessingSteps {
public class HouseSumProfilesFromDetailedDatsProcessor : LoadTypeStepBase
{
[NotNull]
Expand Down
1 change: 1 addition & 0 deletions CalcPostProcessorTests/CalcPostProcessorTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<ItemGroup>
<PackageReference Include="FluentAssertions.Analyzers" Version="0.11.4" />
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
2 changes: 1 addition & 1 deletion CalcPostProcessorTests/PostProcessingManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void Run()
EnergyIntensityType.EnergySaving,
false,
null,
LoadTypePriority.Optional,
LoadTypePriority.OptionalLoadtypes,
null,
null,
null,
Expand Down
1 change: 1 addition & 0 deletions Calculation.Tests/Calculation.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<ItemGroup>
<PackageReference Include="FluentAssertions.Analyzers" Version="0.11.4" />
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
11 changes: 7 additions & 4 deletions Calculation.Tests/HouseholdElements/CalcHouseholdTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ public CalcHouseholdTests([NotNull] ITestOutputHelper testOutputHelper) : base(t
[Trait(UnitTestCategories.Category,UnitTestCategories.BasicTest)]
public void DumpHouseholdContentsToTextTest()
{
using (var wd1 = new WorkingDir(Utili.GetCurrentMethodAndClass()))
using (var db = new DatabaseSetup(Utili.GetCurrentMethodAndClass()))
{
using (var db = new DatabaseSetup(Utili.GetCurrentMethodAndClass()))
{
using (var wd1 = new WorkingDir(Utili.GetCurrentMethodAndClass()))
{

var sim = new Simulator(db.ConnectionString)
{
MyGeneralConfig = {
Expand Down Expand Up @@ -78,9 +79,11 @@ public void DumpHouseholdContentsToTextTest()
CalcManager.ExitCalcFunction = true;
cm.CalcObject.DumpHouseholdContentsToText();
cm.Dispose();

db.Cleanup();
wd1.CleanUp();
}
wd1.CleanUp();

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<ItemGroup>
<PackageReference Include="FluentAssertions.Analyzers" Version="0.11.4" />
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
1 change: 1 addition & 0 deletions CalculationController/CalculationController.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<ItemGroup>
<PackageReference Include="Autofac" Version="5.2.0" />
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
1 change: 1 addition & 0 deletions CalculationEngine/CalculationEngine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
4 changes: 2 additions & 2 deletions CalculationEngine/HouseholdElements/CalcHousehold.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public void DumpHouseholdContentsToText()
}

using (var sw = _calcRepo.FileFactoryAndTracker.MakeFile<StreamWriter>(
"HouseholdContents." + _householdKey + "." + ".txt",
"HouseholdContents." + _householdKey + ".txt",
"List of persons, locations, devices and affordances in this household", true, ResultFileID.HouseholdContentsDump,
_householdKey, TargetDirectory.Root, _calcRepo.CalcParameters.InternalStepsize, CalcOption.HouseholdContents)) {
sw.WriteLine("Name:" + _name);
Expand Down Expand Up @@ -628,7 +628,7 @@ private void DumpTimeProfiles()
}

var swTime = _calcRepo.FileFactoryAndTracker.MakeFile<StreamWriter>(
"TimeProfiles." + _householdKey + "." + ".txt",
"TimeProfiles." + _householdKey + ".txt",
"List of time profiles used in this household", true, ResultFileID.DumpTime, _householdKey,
TargetDirectory.Debugging, _calcRepo.CalcParameters.InternalStepsize, CalcOption.TimeProfileFile);
var c = _calcRepo.CalcParameters.CSVCharacter;
Expand Down
1 change: 1 addition & 0 deletions ChartCreator2.Tests/ChartCreator2.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<ItemGroup>
<PackageReference Include="FluentAssertions.Analyzers" Version="0.11.4" />
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
1 change: 1 addition & 0 deletions ChartCreator2/ChartCreator2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<ItemGroup>
<PackageReference Include="Autofac" Version="5.2.0" />
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
1 change: 1 addition & 0 deletions ChartPDFCreator/ChartPDFCreator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
1 change: 1 addition & 0 deletions Common.Tests/Common.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="FluentAssertions.Analyzers" Version="0.11.4" />
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
1 change: 1 addition & 0 deletions Common/Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
4 changes: 2 additions & 2 deletions Common/Enums/LoadTypePriority.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static class LoadTypePriorityHelper {
{LoadTypePriority.Mandatory, "Mandatory"},
{LoadTypePriority.RecommendedForHouseholds, "Recommended for households"},
{LoadTypePriority.RecommendedForHouses, "Recommended for households and houses"},
{LoadTypePriority.Optional, "Optional"},
{LoadTypePriority.OptionalLoadtypes, "Optional"},
{LoadTypePriority.All, "All"}
};

Expand All @@ -20,7 +20,7 @@ public static class LoadTypePriorityHelper {
{LoadTypePriority.Mandatory, "Mandatory"},
{LoadTypePriority.RecommendedForHouseholds, "Recommended for households"},
{LoadTypePriority.RecommendedForHouses, "Recommended for households and houses"},
{LoadTypePriority.Optional, "Optional"}
{LoadTypePriority.OptionalLoadtypes, "Optional"}
};
}
}
1 change: 1 addition & 0 deletions Database.Tests/Database.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="FluentAssertions.Analyzers" Version="0.11.4" />
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
3 changes: 1 addition & 2 deletions Database.Tests/DatabaseSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
using Automation.ResultFiles;
using Common;
using Database.Database;
using Database.Helpers;
using Database.Tables;
using Database.Tables.BasicElements;
using Database.Tables.BasicHouseholds;
Expand Down Expand Up @@ -123,7 +122,7 @@ public DatabaseSetup([JetBrains.Annotations.NotNull] string testname,
Logger.Info("Working with " + FileName + " copied from " + SourcePath);
Config.IsInUnitTesting = true;
ConnectionString = "Data Source=" + FileName;
DatabaseVersionChecker.CheckVersion(ConnectionString);
//DatabaseVersionChecker.CheckVersion(ConnectionString);
}

public string SourcePath { get; set; }
Expand Down
1 change: 1 addition & 0 deletions Database/Database.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
1 change: 1 addition & 0 deletions IntegrationTests/IntegrationTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<ItemGroup>
<PackageReference Include="FluentAssertions.Analyzers" Version="0.11.4" />
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Loading

0 comments on commit a18ee70

Please sign in to comment.