ResultAllInOneSubdirectoryLength
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
using View_by_Distance.Shared.Models.Properties;
|
||||
|
||||
namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
|
||||
internal abstract class XPath
|
||||
@ -257,15 +259,31 @@ internal abstract class XPath
|
||||
}
|
||||
}
|
||||
|
||||
internal static Dictionary<string, string[]> GetKeyValuePairs(string resultAllInOne, string? resultsFullGroupDirectory, string[]? directories, int maxValue = 12)
|
||||
internal static (string, int) GetDirectoryNameAndIndex(int resultAllInOneSubdirectoryLength, string fileName)
|
||||
{
|
||||
int converted;
|
||||
string result;
|
||||
string check = fileName.Length < resultAllInOneSubdirectoryLength ? new('-', resultAllInOneSubdirectoryLength) : fileName.Split('.')[0][^resultAllInOneSubdirectoryLength..];
|
||||
if (check.Any(l => !char.IsNumber(l)))
|
||||
{
|
||||
result = new('-', resultAllInOneSubdirectoryLength);
|
||||
converted = int.Parse($"1{new string('0', resultAllInOneSubdirectoryLength)}");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = check;
|
||||
converted = int.Parse(check);
|
||||
}
|
||||
return (result, converted);
|
||||
}
|
||||
|
||||
internal static Dictionary<string, string[]> GetKeyValuePairs(IPropertyConfiguration propertyConfiguration, string? resultsFullGroupDirectory, string[]? directories)
|
||||
{
|
||||
Dictionary<string, string[]> results = new();
|
||||
int converted = int.Parse($"1{new string('0', propertyConfiguration.ResultAllInOneSubdirectoryLength)}");
|
||||
string checkDirectory;
|
||||
int minusOne = maxValue - 1;
|
||||
int minusTwo = maxValue - 2;
|
||||
int minusThree = maxValue - 3;
|
||||
int plusOne = converted + 1;
|
||||
List<string> collection = new();
|
||||
int length = minusThree.ToString().Length;
|
||||
if (directories is not null)
|
||||
{
|
||||
foreach (string key in directories)
|
||||
@ -273,14 +291,12 @@ internal abstract class XPath
|
||||
if (resultsFullGroupDirectory is null)
|
||||
continue;
|
||||
collection.Clear();
|
||||
for (int i = 0; i < maxValue; i++)
|
||||
for (int i = 0; i < plusOne; i++)
|
||||
{
|
||||
if (i == minusTwo)
|
||||
checkDirectory = Path.Combine(resultsFullGroupDirectory, key, resultAllInOne, new('-', length));
|
||||
else if (i == minusOne)
|
||||
checkDirectory = Path.Combine(resultsFullGroupDirectory, key, resultAllInOne, new('_', length));
|
||||
if (i == converted)
|
||||
checkDirectory = Path.GetFullPath(Path.Combine(resultsFullGroupDirectory, key, propertyConfiguration.ResultAllInOne, new('-', propertyConfiguration.ResultAllInOneSubdirectoryLength)));
|
||||
else
|
||||
checkDirectory = Path.Combine(resultsFullGroupDirectory, key, resultAllInOne, i.ToString().PadLeft(length, '0'));
|
||||
checkDirectory = Path.GetFullPath(Path.Combine(resultsFullGroupDirectory, key, propertyConfiguration.ResultAllInOne, i.ToString().PadLeft(propertyConfiguration.ResultAllInOneSubdirectoryLength, '0')));
|
||||
if (!Directory.Exists(checkDirectory))
|
||||
_ = Directory.CreateDirectory(checkDirectory);
|
||||
collection.Add(checkDirectory);
|
||||
|
Reference in New Issue
Block a user