Good
This commit is contained in:
@@ -40,7 +40,7 @@ namespace ConsoleApp1
|
||||
|
||||
// ДОПОЛНИТЕЛЬНЫЕ (Казахстан, Узбекистан, Чехия)
|
||||
"KS112345678123456", "XWB12345678123456", "TMB12345678123456", "KZC12345678123456", "XW812345678123456",
|
||||
"3HG12345678123456", "8AW12345678123456", "6AB12345678123456", "VSS12345678123456", "Y3B12345678123456"
|
||||
"3HG12345678123456", "8AW12345678123456", "Z1B12345678123456", "Z5S12345678123456", "VF112345678123456"
|
||||
};
|
||||
/*
|
||||
string vin = "Z9111070060057018";
|
||||
|
||||
25
REG_MARK_LIB/REG_MARK_LIB.sln
Normal file
25
REG_MARK_LIB/REG_MARK_LIB.sln
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.13.35919.96 d17.13
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "REG_MARK_LIB", "REG_MARK_LIB\REG_MARK_LIB.csproj", "{A68921E6-EE5A-4F7F-AB75-812B3B7817DF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{A68921E6-EE5A-4F7F-AB75-812B3B7817DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A68921E6-EE5A-4F7F-AB75-812B3B7817DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A68921E6-EE5A-4F7F-AB75-812B3B7817DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A68921E6-EE5A-4F7F-AB75-812B3B7817DF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {E24455F6-B61A-44A5-9250-8B2126C7BF3F}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
33
REG_MARK_LIB/REG_MARK_LIB/Properties/AssemblyInfo.cs
Normal file
33
REG_MARK_LIB/REG_MARK_LIB/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// Общие сведения об этой сборке предоставляются следующим набором
|
||||
// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
|
||||
// связанные со сборкой.
|
||||
[assembly: AssemblyTitle("REG_MARK_LIB")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("HP Inc.")]
|
||||
[assembly: AssemblyProduct("REG_MARK_LIB")]
|
||||
[assembly: AssemblyCopyright("Copyright © HP Inc. 2026")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
|
||||
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
|
||||
// COM, задайте атрибуту ComVisible значение TRUE для этого типа.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
|
||||
[assembly: Guid("a68921e6-ee5a-4f7f-ab75-812b3b7817df")]
|
||||
|
||||
// Сведения о версии сборки состоят из указанных ниже четырех значений:
|
||||
//
|
||||
// Основной номер версии
|
||||
// Дополнительный номер версии
|
||||
// Номер сборки
|
||||
// Редакция
|
||||
//
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
151
REG_MARK_LIB/REG_MARK_LIB/REG_MARK.cs
Normal file
151
REG_MARK_LIB/REG_MARK_LIB/REG_MARK.cs
Normal file
@@ -0,0 +1,151 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace REG_MARK_LIB
|
||||
{
|
||||
public class REG_MARK
|
||||
{
|
||||
public static readonly string[] RussianRegions = {
|
||||
// Двузначные коды (основные)
|
||||
"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20",
|
||||
"21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40",
|
||||
"41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60",
|
||||
"61", "62", "63", "64", "65", "66", "67", "68", "69", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "80",
|
||||
"81", "82", "83", "84", "85", "86", "87", "89", "90", "92", "93", "94", "95", "96", "97", "98", "99",
|
||||
|
||||
// Трехзначные коды (расширения для крупных регионов)
|
||||
"102", "702", "105", "116", "716", "121", "123", "124", "125", "126", "134", "136", "138", "142", "147", "150", "190",
|
||||
"750", "790", "250", "550", "152", "252", "154", "754", "156", "159", "161", "761", "163", "763", "164", "172", "173",
|
||||
"174", "774", "177", "197", "199", "777", "797", "799", "178", "198", "778", "180", "181", "184", "185", "186", "196"
|
||||
};
|
||||
private static readonly char[] letters = { 'A', 'B', 'E', 'K', 'M', 'H', 'O', 'P', 'C', 'T', 'Y', 'X' };
|
||||
private static string pattern = @"^[ABEKMHOPCTYX]\d{3}[ABEKMHOPCTYX]{2}\d{2,3}$";
|
||||
public static bool CheckMark(string mark)
|
||||
{
|
||||
if (string.IsNullOrEmpty(mark))
|
||||
return false;
|
||||
mark = mark.ToUpper();
|
||||
|
||||
var match = Regex.Match(mark, pattern);
|
||||
|
||||
if (!match.Success)
|
||||
return false;
|
||||
|
||||
string regionCode = match.Groups[1].Value;
|
||||
return RussianRegions.Contains(regionCode);
|
||||
}
|
||||
public static string GetNextMarkAfter(string mark)
|
||||
{
|
||||
if (!CheckMark(mark)) return "Invalid Mark";
|
||||
|
||||
char l1 = mark[0]; // 9
|
||||
int num = int.Parse(mark.Substring(1, 3)); // aaa
|
||||
char l2 = mark[4]; // 9
|
||||
char l3 = mark[5]; // 9
|
||||
string region = mark.Substring(6);
|
||||
|
||||
// 001 -> 999
|
||||
if (num < 999)
|
||||
{
|
||||
num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
num = 1; // инкремент первой буквы
|
||||
|
||||
// Увеличиваем первую букву
|
||||
int i1 = Array.IndexOf(letters, l1);
|
||||
if (i1 < 11)
|
||||
{
|
||||
l1 = letters[i1 + 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
l1 = letters[0]; // Сброс первой буквы, инкремент второй
|
||||
|
||||
// Увеличиваем вторую букву
|
||||
int i2 = Array.IndexOf(letters, l2);
|
||||
if (i2 < 11)
|
||||
{
|
||||
l2 = letters[i2 + 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
l2 = letters[0]; // Сброс второй буквы, инкремент третьей
|
||||
|
||||
// Увеличиваем третью букву
|
||||
int i3 = Array.IndexOf(letters, l3);
|
||||
if (i3 < 11)
|
||||
{
|
||||
l3 = letters[i3 + 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
return "out of stock"; // Все комбинации региона исчерпаны (X999XX)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $"{l1}{num:D3}{l2}{l3}{region}";
|
||||
}
|
||||
public static string GetNextMarkAfterInRange(string prevMark, string rangeStart, string rangeEnd)
|
||||
{
|
||||
if (!CheckMark(prevMark) || !CheckMark(rangeStart) || !CheckMark(rangeEnd))
|
||||
return "Не верный номер!";
|
||||
|
||||
string nextMark = GetNextMarkAfter(prevMark);
|
||||
|
||||
if (nextMark == "out of stock")
|
||||
return "out of stock";
|
||||
bool isInRange = string.Compare(nextMark, rangeStart, StringComparison.Ordinal) >= 0 &&
|
||||
string.Compare(nextMark, rangeEnd, StringComparison.Ordinal) <= 0;
|
||||
|
||||
if (isInRange)
|
||||
{
|
||||
return nextMark;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "out of stock";
|
||||
}
|
||||
}
|
||||
private static long GetMarkIndex(string mark)
|
||||
{
|
||||
// Извлекаем части: A 123 BC 77
|
||||
char l1 = mark[0];
|
||||
int num = int.Parse(mark.Substring(1, 3));
|
||||
char l2 = mark[4];
|
||||
char l3 = mark[5];
|
||||
int region = int.Parse(mark.Substring(6));
|
||||
|
||||
int i1 = Array.IndexOf(letters, l1);
|
||||
int i2 = Array.IndexOf(letters, l2);
|
||||
int i3 = Array.IndexOf(letters, l3);
|
||||
|
||||
// Считаем вес номера внутри региона
|
||||
// Порядок множителей (1000, 12) определяет "скорость" вращения символов
|
||||
long index = num
|
||||
+ (long)i1 * 1000
|
||||
+ (long)i3 * 1000 * 12
|
||||
+ (long)i2 * 1000 * 12 * 12;
|
||||
|
||||
// Добавляем вес региона (в одном регионе 12*12*12*1000 = 1 728 000 номеров)
|
||||
return index + (long)region * 1728000;
|
||||
}
|
||||
|
||||
public static int GetCombinationsCountInRange(string mark1, string mark2)
|
||||
{
|
||||
if (!CheckMark(mark1) || !CheckMark(mark2)) return 0;
|
||||
|
||||
long index1 = GetMarkIndex(mark1.ToUpper());
|
||||
long index2 = GetMarkIndex(mark2.ToUpper());
|
||||
|
||||
// Возвращаем разницу (включая обе границы)
|
||||
return (int)Math.Abs(index2 - index1) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
48
REG_MARK_LIB/REG_MARK_LIB/REG_MARK_LIB.csproj
Normal file
48
REG_MARK_LIB/REG_MARK_LIB/REG_MARK_LIB.csproj
Normal file
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{A68921E6-EE5A-4F7F-AB75-812B3B7817DF}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>REG_MARK_LIB</RootNamespace>
|
||||
<AssemblyName>REG_MARK_LIB</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="REG_MARK.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
Reference in New Issue
Block a user