use common project

This commit is contained in:
Chomp 2021-08-24 12:08:30 +01:00
parent 554c86d7db
commit d8c905719c
10 changed files with 23 additions and 74 deletions

View File

@ -1,4 +1,6 @@
using Generator.Helpers;
using Common;
using Common.Extensions;
using Generator.Helpers;
using Generator.Models;
using Generator.Models.Input;
using Generator.Models.Output;

View File

@ -1,4 +1,5 @@
using Generator.Helpers;
using Common;
using Generator.Helpers;
using Generator.Helpers.Gear;
using Generator.Models.Input;
using Generator.Models.Output;

View File

@ -1,4 +1,6 @@
using Generator.Helpers;
using Common;
using Common.Extensions;
using Generator.Helpers;
using Generator.Models.Input;
using Generator.Models.Output;
using System;

View File

@ -1,6 +1,5 @@
using Generator.Helpers;
using Common;
using Generator.Models.Input;
using Generator.Models.Output;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
@ -25,7 +24,7 @@ namespace Generator
var stopwatch = Stopwatch.StartNew();
var failedFilesCount = 0;
CreateDirIfDoesntExist(_dumpPath);
DiskHelpers.CreateDirIfDoesntExist(_dumpPath);
var botFiles = Directory.GetFiles(_dumpPath, "*.json", SearchOption.TopDirectoryOnly).ToList();
Console.WriteLine($"{botFiles.Count} bot dump files found");
@ -88,15 +87,6 @@ namespace Generator
return o.ToString();
}
private void CreateDirIfDoesntExist(string path)
{
if (!Directory.Exists($"{path}"))
{
//create dump dir
Directory.CreateDirectory($"{path}");
}
}
private static List<Datum> ParseJson(string json, string file)
{
//Console.WriteLine($"parsing file {file}");

View File

@ -151,4 +151,8 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj" />
</ItemGroup>
</Project>

View File

@ -1,4 +1,5 @@
using Generator.Models.Input;
using Common.Extensions;
using Generator.Models.Input;
using Generator.Models.Output;
using Newtonsoft.Json;
using System.Collections.Generic;

View File

@ -1,28 +0,0 @@
using System;
namespace Generator.Helpers
{
public static class LoggingHelpers
{
internal static string LogTimeTaken(double totalSeconds)
{
return Math.Round(totalSeconds, 2, MidpointRounding.ToEven).ToString();
}
public static void LogToConsole(string message, ConsoleColor backgroundColour = ConsoleColor.Green)
{
Console.BackgroundColor = backgroundColour;
Console.ForegroundColor = ConsoleColor.Black;
Console.WriteLine(message);
ResetConsoleColours();
}
private static void ResetConsoleColours()
{
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.White;
}
}
}

View File

@ -3,6 +3,7 @@ using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using Common;
namespace Generator
{
@ -20,13 +21,13 @@ namespace Generator
public void WriteJson(List<Bot> bots)
{
var outputPath = $"{_workingPath}\\{_outputFolderName}";
CreateDirIfDoesntExist(outputPath);
DiskHelpers.CreateDirIfDoesntExist(outputPath);
foreach (var bot in bots)
{
if (bot.appearance.body.Count == 0) // only process files that have data in them, no body = no dumps
{
Helpers.LoggingHelpers.LogToConsole($"Unable to process bot type: {bot.botType}, skipping", ConsoleColor.DarkRed);
LoggingHelpers.LogToConsole($"Unable to process bot type: {bot.botType}, skipping", ConsoleColor.DarkRed);
continue;
}
var output = JsonConvert.SerializeObject(bot, Formatting.Indented);
@ -36,14 +37,5 @@ namespace Generator
}
}
private void CreateDirIfDoesntExist(string path)
{
if (!Directory.Exists($"{path}"))
{
//create dump dir
Directory.CreateDirectory($"{path}");
}
}
}
}

View File

@ -1,4 +1,5 @@
using System.IO;
using Common;
using System.IO;
namespace Generator
{
@ -41,8 +42,8 @@ namespace Generator
if (parsedBots.Count == 0)
{
Helpers.LoggingHelpers.LogToConsole("no bots found, unable to continue");
Helpers.LoggingHelpers.LogToConsole("Check your dumps are in 'Generator\\bin\\Debug\\netcoreapp3.1\\dumps' and start with 'resp.' NOT 'req.'");
LoggingHelpers.LogToConsole("no bots found, unable to continue");
LoggingHelpers.LogToConsole("Check your dumps are in 'Generator\\bin\\Debug\\netcoreapp3.1\\dumps' and start with 'resp.' NOT 'req.'");
return;
}

View File

@ -1,16 +0,0 @@
using System.Collections.Generic;
namespace Generator
{
public static class StringToolsExtensions
{
/// <summary>
/// Add a string to a list only if it doesnt already exist
/// </summary>
public static void AddUnique(this IList<string> self, string item)
{
if (!self.Contains(item))
self.Add(item);
}
}
}