194 lines
5.1 KiB
C#
194 lines
5.1 KiB
C#
namespace LaaProduction.Console
|
|
{
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
public class Program
|
|
{
|
|
public class CharCode
|
|
{
|
|
public int Stelle { get; set; }
|
|
|
|
public int Laenge { get; set; }
|
|
|
|
public string Code { get; set; }
|
|
}
|
|
|
|
private static void Main()
|
|
{
|
|
var charCodes = new List<CharCode>
|
|
{
|
|
new CharCode { Stelle = 45, Laenge = 2, Code = "N2" },
|
|
new CharCode { Stelle = 26, Laenge = 1, Code = "K" },
|
|
new CharCode { Stelle = 5, Laenge = 1, Code = "F" },
|
|
new CharCode { Stelle = 5, Laenge = 1, Code = "G" },
|
|
new CharCode { Stelle = 5, Laenge = 1, Code = "H" },
|
|
new CharCode { Stelle = 5, Laenge = 1, Code = "I" },
|
|
new CharCode { Stelle = 5, Laenge = 1, Code = "K" },
|
|
new CharCode { Stelle = 5, Laenge = 1, Code = "L" },
|
|
new CharCode { Stelle = 5, Laenge = 1, Code = "M" },
|
|
new CharCode { Stelle = 37, Laenge = 1, Code = "A" },
|
|
new CharCode { Stelle = 37, Laenge = 1, Code = "B" },
|
|
};
|
|
|
|
var orderedCharCodes = charCodes
|
|
.OrderBy(x => x.Stelle)
|
|
.GroupBy(x => x.Stelle)
|
|
.ToDictionary(x => x.Key, x => x.ToList());
|
|
var key = orderedCharCodes.Min(x => x.Key);
|
|
var patterns = new List<char[]>();
|
|
|
|
GenerateUniqueCombinations(orderedCharCodes, patterns, key);
|
|
|
|
foreach (var pattern in patterns)
|
|
{
|
|
Console.WriteLine($"'{new string(pattern)}%'");
|
|
}
|
|
}
|
|
|
|
private static void GenerateUniqueCombinations(Dictionary<int, List<CharCode>> charCodes, List<char[]> patterns, int key)
|
|
{
|
|
var nextKey = charCodes.FirstOrDefault(x => x.Key > key).Key;
|
|
|
|
if (nextKey > default(int))
|
|
{
|
|
var parameter = charCodes[nextKey].FirstOrDefault();
|
|
|
|
if (parameter != null)
|
|
{
|
|
var length = parameter.Stelle + parameter.Laenge - 1;
|
|
var tempalte = new char[length];
|
|
|
|
for (var ix = 0; ix < length; ix++)
|
|
{
|
|
tempalte[ix] = '_';
|
|
}
|
|
|
|
if (patterns.Count == 0)
|
|
{
|
|
patterns.Add(tempalte);
|
|
}
|
|
else
|
|
{
|
|
patterns[0] = tempalte;
|
|
}
|
|
}
|
|
|
|
GenerateUniqueCombinations(charCodes, patterns, nextKey);
|
|
}
|
|
|
|
var templatePatterns = new List<char[]>();
|
|
templatePatterns.AddRange(patterns);
|
|
patterns.Clear();
|
|
|
|
foreach (var parameter in charCodes[key])
|
|
{
|
|
foreach (var template in templatePatterns)
|
|
{
|
|
var pattern = new char[template.Length];
|
|
|
|
Array.Copy(template, 0, pattern, 0, pattern.Length);
|
|
|
|
var codeLength = parameter.Code.Length;
|
|
|
|
for (var charIX = 0; charIX < codeLength; charIX++)
|
|
{
|
|
pattern[parameter.Stelle + charIX - 1] = parameter.Code[charIX];
|
|
}
|
|
|
|
patterns.Add(pattern);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//public static void _____Main()
|
|
//{
|
|
// Console.WriteLine(-14 * 24 * 60 * 60);
|
|
|
|
// //var sentinel = new Sentinel(
|
|
// // new HttpConnection("http://10.49.40.25/")
|
|
// // , new HttpConnection("localhost")
|
|
// // , new CordonelDbContext(
|
|
// // new SqlConnection("Server=SLASQL01.emea.sensus.net; Database=Auftrag; User ID=sa; Password=sqlserver;")));
|
|
// //var sentinelDataFile = @"..\..\sentinel-data.json";
|
|
// //var result = sentinel.CheckVFMStatus(182100041);
|
|
|
|
// //Console.WriteLine("=========================================================");
|
|
// //foreach (var kvp in result)
|
|
// //{
|
|
// // Console.WriteLine($"{kvp.Key}: {kvp.Value}");
|
|
// //}
|
|
// //Console.WriteLine("=========================================================");
|
|
|
|
// //if (result.Succeeded && result.ContainsKey("UsedData"))
|
|
// //{
|
|
// // var jsonSerializerSettings = new JsonSerializerSettings
|
|
// // {
|
|
// // Formatting = Formatting.Indented,
|
|
// // TypeNameHandling = TypeNameHandling.Objects | TypeNameHandling.Arrays,
|
|
// // TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple
|
|
// // };
|
|
|
|
// // var json = JsonConvert.SerializeObject(result["UsedData"], jsonSerializerSettings);
|
|
// // File.WriteAllText(sentinelDataFile, json);
|
|
// //}
|
|
//}
|
|
|
|
//const string URL_PATTERN = "https://nodes.sms-esaap.com/keygenproxy/api/v2/keys/devices?orderNumber={0}&radioaddress={1}";
|
|
//const string X_NODE_TOKEN_HEADER = "X-Node-Token";
|
|
//const string X_NODE_TOKEN = "d5b8c0b2-81f6-4421-80d0-44eb2093e616"; |