2021-12-08 09:44:23 +03:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
2021-12-08 14:45:14 +03:00
|
|
|
|
namespace RehauSku.Assistant
|
2021-12-08 09:44:23 +03:00
|
|
|
|
{
|
|
|
|
|
public static class RequestModifier
|
|
|
|
|
{
|
|
|
|
|
public static string CleanRequest(this string input)
|
|
|
|
|
{
|
|
|
|
|
string replace = new StringBuilder(input)
|
|
|
|
|
.Replace("+", " plus ")
|
|
|
|
|
.Replace("РХ", "")
|
|
|
|
|
.Replace("º", " ")
|
|
|
|
|
.Replace(".", " ")
|
|
|
|
|
.Replace("Ø", " ")
|
|
|
|
|
.ToString();
|
|
|
|
|
|
2021-12-08 12:03:33 +03:00
|
|
|
|
return replace._tPieceNormalize();
|
2021-12-08 09:44:23 +03:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-08 12:03:33 +03:00
|
|
|
|
private static string _tPieceNormalize(this string line)
|
2021-12-08 09:44:23 +03:00
|
|
|
|
{
|
2021-12-08 10:38:58 +03:00
|
|
|
|
Regex regex = new Regex(@"\d{2}.\d{2}.\d{2}");
|
|
|
|
|
|
|
|
|
|
if (!regex.IsMatch(line))
|
2021-12-08 09:44:23 +03:00
|
|
|
|
return line;
|
|
|
|
|
|
2021-12-08 10:38:58 +03:00
|
|
|
|
string match = regex.Match(line).Value;
|
2021-12-08 09:44:23 +03:00
|
|
|
|
|
2021-12-08 12:03:33 +03:00
|
|
|
|
int side = int.Parse($"{match[3]}{match[4]}");
|
|
|
|
|
int[] endFaces = new int[]
|
|
|
|
|
{
|
|
|
|
|
int.Parse($"{match[0]}{match[1]}"),
|
|
|
|
|
int.Parse($"{match[6]}{match[7]}")
|
|
|
|
|
};
|
2021-12-08 09:44:23 +03:00
|
|
|
|
|
2021-12-09 10:30:14 +03:00
|
|
|
|
if (new[] { endFaces[0], endFaces[1], side }.Any(x => x == 45 || x == 90 || x == 87))
|
|
|
|
|
return line;
|
|
|
|
|
|
2021-12-08 09:44:23 +03:00
|
|
|
|
List<string> additions = new List<string>();
|
|
|
|
|
|
|
|
|
|
if (endFaces.All(x => x < side))
|
|
|
|
|
additions.Add("увеличенный боковой");
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-12-08 12:03:33 +03:00
|
|
|
|
if (new[] { endFaces[0], endFaces[1], side }.Distinct().Count() == 1)
|
2021-12-08 09:44:23 +03:00
|
|
|
|
additions.Add("равнопроходной");
|
|
|
|
|
else
|
|
|
|
|
additions.Add("уменьшенный");
|
|
|
|
|
|
|
|
|
|
if (endFaces.Any(x => x > side))
|
|
|
|
|
additions.Add("боковой");
|
2021-12-08 10:38:58 +03:00
|
|
|
|
|
2021-12-08 12:03:33 +03:00
|
|
|
|
if (endFaces[0] != endFaces[1])
|
2021-12-08 09:44:23 +03:00
|
|
|
|
additions.Add("торцевой");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string piece = $" {endFaces.Max()}-{side}-{endFaces.Min()} ";
|
2021-12-08 10:38:58 +03:00
|
|
|
|
string modifiedMatch = string.Join(" ", additions) + piece;
|
2021-12-08 09:44:23 +03:00
|
|
|
|
|
2021-12-08 10:38:58 +03:00
|
|
|
|
return line.Replace(match, modifiedMatch);
|
2021-12-08 09:44:23 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|