Refactoring

pull/1/head
Ogoun 5 years ago
parent 9aded11788
commit eff1deaaef

@ -1,22 +0,0 @@
using System.Collections.Generic;
namespace ConfigurationTests
{
public class AppConfig
{
public string Url;
public int BatchSize;
public IEnumerable<string> Sheme;
public int[] Port;
public ServiceConfig Service;
public IEnumerable<int> List;
}
public class ServiceConfig
{
public string AppName;
public string AppKey;
public string ServiceGroup;
public string ServiceType;
}
}

@ -1,18 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ZeroLevel\ZeroLevel.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="config.ini">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

@ -1,36 +0,0 @@
using System;
using System.Collections.Generic;
using ZeroLevel;
namespace ConfigurationTests
{
class Program
{
static void Main(string[] args)
{
var config = Configuration.ReadSetFromIniFile("config.ini").Bind<AppConfig>();
Console.WriteLine(config.Url);
Console.WriteLine(config.BatchSize);
Console.WriteLine("Ports");
foreach (var port in config.Port)
{
Console.WriteLine($"\t{port}");
}
Console.WriteLine("Shemes");
foreach (var sheme in config.Sheme)
{
Console.WriteLine($"\t{sheme}");
}
Console.WriteLine($"Range list: {string.Join(", ", config.List)}");
Console.WriteLine("Service");
Console.WriteLine($"\tAppKey: {config.Service.AppKey}");
Console.WriteLine($"\tAppName: {config.Service.AppName}");
Console.WriteLine($"\tServiceGroup: {config.Service.ServiceGroup}");
Console.WriteLine($"\tServiceType: {config.Service.ServiceType}");
Console.ReadKey();
}
}
}

@ -1,15 +0,0 @@
url=https://habr.ru
batchSize=1000
sheme=socks
sheme=http
sheme=https
port=80
port=90
port=8800
list=1-5,7,9
[service]
AppName=TestApp
AppKey=test.app
ServiceGroup=System
ServiceType=service

@ -1,18 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ZeroLevel\ZeroLevel.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="config.ini">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>
</configuration>

@ -8,12 +8,13 @@
<OutputType>WinExe</OutputType>
<RootNamespace>FileTransferClient</RootNamespace>
<AssemblyName>FileTransferClient</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -34,6 +35,28 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
@ -95,7 +118,7 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ZeroLevel\ZeroLevel.csproj">
<ProjectReference Include="..\..\ZeroLevel\ZeroLevel.csproj">
<Project>{06c9e60e-d449-41a7-9bf0-a829aaf5d214}</Project>
<Name>ZeroLevel</Name>
</ProjectReference>

@ -8,10 +8,10 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace FileTransferClient.Properties
{
namespace FileTransferClient.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
@ -19,51 +19,43 @@ namespace FileTransferClient.Properties
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FileTransferClient.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set
{
set {
resourceCulture = value;
}
}

@ -8,21 +8,17 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace FileTransferServer.Properties
{
namespace FileTransferClient.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.4.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
public static Settings Default {
get {
return defaultInstance;
}
}

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>
</configuration>

@ -8,12 +8,13 @@
<OutputType>WinExe</OutputType>
<RootNamespace>FileTransferServer</RootNamespace>
<AssemblyName>FileTransferServer</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -34,6 +35,28 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
@ -95,7 +118,7 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ZeroLevel\ZeroLevel.csproj">
<ProjectReference Include="..\..\ZeroLevel\ZeroLevel.csproj">
<Project>{06c9e60e-d449-41a7-9bf0-a829aaf5d214}</Project>
<Name>ZeroLevel</Name>
</ProjectReference>

@ -8,10 +8,10 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace FileTransferServer.Properties
{
namespace FileTransferServer.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
@ -19,51 +19,43 @@ namespace FileTransferServer.Properties
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FileTransferServer.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set
{
set {
resourceCulture = value;
}
}

@ -8,21 +8,17 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace FileTransferClient.Properties
{
namespace FileTransferServer.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.4.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
public static Settings Default {
get {
return defaultInstance;
}
}

@ -1,7 +0,0 @@
namespace Lemmatization
{
public class Sentence
{
public Token[] Tokens;
}
}

@ -1,8 +0,0 @@
namespace Lemmatization
{
public class Token
{
public TokenType Type;
public string Value;
}
}

@ -1,35 +0,0 @@
namespace Lemmatization
{
public enum TokenType
{
Unknown,
/// <summary>
/// Знак пукнтуации
/// </summary>
Punctuation,
/// <summary>
/// Аббревиатура
/// </summary>
Аbbreviation,
/// <summary>
/// Слово
/// </summary>
Word,
/// <summary>
/// Идентификатор (может содержать не только буквы)
/// </summary>
Identity,
/// <summary>
/// Число
/// </summary>
Number,
/// <summary>
/// Номер телефона
/// </summary>
PhoneNumber,
/// <summary>
/// Ссылка
/// </summary>
Link
}
}

@ -1,21 +0,0 @@
using LemmaSharp;
using ZeroLevel.Services.Semantic;
namespace Lemmatization
{
public class LemmaLexer
: ILexer
{
private readonly ILemmatizer _lemmatizer;
public LemmaLexer()
{
_lemmatizer = new LemmatizerPrebuiltFull(LanguagePrebuilt.Russian);
}
public string Lex(string word)
{
return _lemmatizer.Lemmatize(word.Trim().ToLowerInvariant());
}
}
}

@ -1,206 +0,0 @@
using System;
using System.Collections.Generic;
namespace Lemmatization
{
public class SpecTextReader
{
private int _position;
private readonly string _template;
public bool EOF => _position >= _template?.Length;
public bool StartPosition => _position == 0;
public bool LastPosition => _position == _template?.Length - 1;
public char Current => EOF ? char.MinValue : _template[_position];
public char Next => EOF || LastPosition ? char.MinValue : _template[_position + 1];
public char Preview => StartPosition ? char.MinValue : _template[_position - 1];
public SpecTextReader(string template)
{
_template = template;
_position = 0;
}
public bool Move(int offset = 1)
{
if (EOF) return false;
if (LastPosition) { _position = _template.Length; return false; }
_position += offset;
if (_position >= _template.Length)
{
_position = _template.Length;
}
return true;
}
public int SkipSpaces()
{
int count = 0;
while (EOF == false && char.IsWhiteSpace(Current)) { Move(); count++; }
return count;
}
public void SkipBreaks()
{
while (EOF == false && char.IsWhiteSpace(Current)) Move();
}
public bool MoveBack()
{
_position = _position - 1;
if (_position < 0)
{
_position = 0;
return false;
}
return true;
}
public int FindOffsetTo(char symbol)
{
if (_position == -1 || EOF || LastPosition) return -1;
var search_position = _position;
var sym = _template[search_position];
while (search_position < _template.Length && false == sym.Equals(symbol))
{
search_position++;
sym = _template[search_position];
}
return sym.Equals(symbol) ? search_position - _position : -1;
}
public bool Test(char sym, int offset = 0)
{
var index = _position + offset;
if (index < 0 || index >= _template.Length) return false;
return _template[index].Equals(sym);
}
public string ReadIdentity()
{
string identity = string.Empty;
var offset = _position;
if (offset < _template.Length && char.IsLetter(_template[offset]))
{
var index = offset + 1;
while (index < _template.Length && (char.IsLetterOrDigit(_template[index]) || _template[index] == '_' || _template[index] == '-'))
index++;
identity = _template.Substring(offset, index - offset);
}
return identity.ToLowerInvariant();
}
public string ReadWord()
{
string identity = string.Empty;
var offset = _position;
if (offset < _template.Length && char.IsLetterOrDigit(_template[offset]))
{
var index = offset + 1;
while (index < _template.Length && char.IsLetterOrDigit(_template[index]))
index++;
identity = _template.Substring(offset, index - offset);
}
return identity;
}
public static Token[] ParseToTokens(string line)
{
var list = new List<Token>();
char[] buffer = new char[64];
int count = 0;
var add = new Action<char>(ch =>
{
buffer[count++] = ch;
if (buffer.Length == count)
{
// При нехватке места в буфере, расширяем в два раза место
var arr = new char[buffer.Length * 2];
for (var k = 0; k < buffer.Length; k++) { arr[k] = buffer[k]; }
buffer = arr;
}
});
TokenType tt = TokenType.Unknown;
for (int i = 0; i < line.Length; i++)
{
if (char.IsLetter(line[i]))
{
if (tt == TokenType.Unknown) tt = TokenType.Word;
else if (tt == TokenType.Number) tt = TokenType.Identity;
add(line[i]);
}
else if (char.IsDigit(line[i]))
{
if (tt == TokenType.Unknown) tt = TokenType.Number;
else if (tt == TokenType.Word) tt = TokenType.Identity;
add(line[i]);
}
else if (char.IsWhiteSpace(line[i]) && tt != TokenType.Unknown)
{
if (count > 0)
{
list.Add(new Token { Type = tt, Value = new string(buffer, 0, count) });
count = 0;
}
}
else
{
if (count > 0)
{
list.Add(new Token { Type = tt, Value = new string(buffer, 0, count) });
count = 0;
}
if (char.IsWhiteSpace(line[i]) == false)
{
list.Add(new Token { Type = TokenType.Punctuation, Value = line[i].ToString() });
}
}
}
if (count > 0)
{
list.Add(new Token { Type = tt, Value = new string(buffer, 0, count) });
}
return list.ToArray();
}
public static IEnumerable<Sentence> ReadSentenses(string text)
{
if (false == string.IsNullOrEmpty(text))
{
char[] buffer = new char[512];
int count = 0;
var add = new Action<char>(ch =>
{
buffer[count++] = ch;
if (buffer.Length == count)
{
// При нехватке места в буфере, расширяем в два раза место
var arr = new char[buffer.Length * 2];
for (var k = 0; k < buffer.Length; k++) { arr[k] = buffer[k]; }
buffer = arr;
}
});
for (int i = 0; i < text.Length; i++)
{
switch (text[i])
{
case '.':
if (count > 0)
{
yield return new Sentence { Tokens = ParseToTokens(new string(buffer, 0, count)) };
count = 0;
}
break;
default:
add(text[i]);
break;
}
}
}
}
}
}

@ -1,61 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29709.97
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TFIDFbee", "TFIDFbee\TFIDFbee.csproj", "{7B39E0A1-3DE4-4702-8D61-5C9A6CF164C6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lemmatization", "..\Lemmatization\Lemmatization.csproj", "{98102DAA-F649-45FD-BBE9-F393DBF82275}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZeroLevel", "..\ZeroLevel\ZeroLevel.csproj", "{6AF46F95-EA67-4258-96B1-7BBC57EB965D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{41061774-D2A1-4291-8909-62E4A63B03B4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7B39E0A1-3DE4-4702-8D61-5C9A6CF164C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7B39E0A1-3DE4-4702-8D61-5C9A6CF164C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7B39E0A1-3DE4-4702-8D61-5C9A6CF164C6}.Debug|x64.ActiveCfg = Debug|x64
{7B39E0A1-3DE4-4702-8D61-5C9A6CF164C6}.Debug|x64.Build.0 = Debug|x64
{7B39E0A1-3DE4-4702-8D61-5C9A6CF164C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7B39E0A1-3DE4-4702-8D61-5C9A6CF164C6}.Release|Any CPU.Build.0 = Release|Any CPU
{7B39E0A1-3DE4-4702-8D61-5C9A6CF164C6}.Release|x64.ActiveCfg = Release|Any CPU
{7B39E0A1-3DE4-4702-8D61-5C9A6CF164C6}.Release|x64.Build.0 = Release|Any CPU
{98102DAA-F649-45FD-BBE9-F393DBF82275}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{98102DAA-F649-45FD-BBE9-F393DBF82275}.Debug|Any CPU.Build.0 = Debug|Any CPU
{98102DAA-F649-45FD-BBE9-F393DBF82275}.Debug|x64.ActiveCfg = Debug|Any CPU
{98102DAA-F649-45FD-BBE9-F393DBF82275}.Debug|x64.Build.0 = Debug|Any CPU
{98102DAA-F649-45FD-BBE9-F393DBF82275}.Release|Any CPU.ActiveCfg = Release|Any CPU
{98102DAA-F649-45FD-BBE9-F393DBF82275}.Release|Any CPU.Build.0 = Release|Any CPU
{98102DAA-F649-45FD-BBE9-F393DBF82275}.Release|x64.ActiveCfg = Release|Any CPU
{98102DAA-F649-45FD-BBE9-F393DBF82275}.Release|x64.Build.0 = Release|Any CPU
{6AF46F95-EA67-4258-96B1-7BBC57EB965D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6AF46F95-EA67-4258-96B1-7BBC57EB965D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6AF46F95-EA67-4258-96B1-7BBC57EB965D}.Debug|x64.ActiveCfg = Debug|x64
{6AF46F95-EA67-4258-96B1-7BBC57EB965D}.Debug|x64.Build.0 = Debug|x64
{6AF46F95-EA67-4258-96B1-7BBC57EB965D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6AF46F95-EA67-4258-96B1-7BBC57EB965D}.Release|Any CPU.Build.0 = Release|Any CPU
{6AF46F95-EA67-4258-96B1-7BBC57EB965D}.Release|x64.ActiveCfg = Release|x64
{6AF46F95-EA67-4258-96B1-7BBC57EB965D}.Release|x64.Build.0 = Release|x64
{41061774-D2A1-4291-8909-62E4A63B03B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{41061774-D2A1-4291-8909-62E4A63B03B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41061774-D2A1-4291-8909-62E4A63B03B4}.Debug|x64.ActiveCfg = Debug|Any CPU
{41061774-D2A1-4291-8909-62E4A63B03B4}.Debug|x64.Build.0 = Debug|Any CPU
{41061774-D2A1-4291-8909-62E4A63B03B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{41061774-D2A1-4291-8909-62E4A63B03B4}.Release|Any CPU.Build.0 = Release|Any CPU
{41061774-D2A1-4291-8909-62E4A63B03B4}.Release|x64.ActiveCfg = Release|Any CPU
{41061774-D2A1-4291-8909-62E4A63B03B4}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F440F94E-537A-44F4-9103-BD6C7BCAF6E3}
EndGlobalSection
EndGlobal

@ -1,8 +0,0 @@
namespace TFIDFbee
{
public class Document
{
public string Title { get; set; }
public string Text { get; set; }
}
}

@ -1,178 +0,0 @@
using Lemmatization;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using TFIDFbee.Reader;
using ZeroLevel.Services.Semantic;
namespace TFIDFbee
{
class Program
{
private const string source = @"D:\Desktop\lenta-ru-data-set_19990901_20171204_limit_1000.json";
private readonly static ILexProvider _lexer = new LexProvider(new LemmaLexer());
private readonly static ConcurrentDictionary<string, double> _scoring = new ConcurrentDictionary<string, double>();
static void Main(string[] args)
{
IDF idf = new IDF();
IDocumentReader reader = new JsonByLineReader(source, _lexer);
foreach (var batch in reader.ReadBatches(1000))
{
foreach (var doc in batch)
{
idf.Append(doc);
}
}
foreach (var batch in reader.ReadBatches(1000))
{
foreach (var doc in batch)
{
var tfidf = TFIDF.TfIdf(doc, idf);
Console.WriteLine(String.Join(" ", tfidf.OrderByDescending(p => p.Value).Take(10).Select(p => p.Key)));
Console.WriteLine();
Console.WriteLine(" ***");
Console.WriteLine();
Thread.Sleep(1000);
}
}
/*
Log.AddConsoleLogger(ZeroLevel.Logging.LogLevel.FullDebug);
Configuration.Save(Configuration.ReadFromApplicationConfig());
IDocumentReader reader = new JsonByLineReader(source, s => ExtractLemmas(s));
ZeroLevel.Services.Semantic.Helpers.BagOfTerms codebook;
if (File.Exists("model.bin"))
{
Log.Info("Load model from file");
using (var stream = new FileStream("model.bin", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
codebook = MessageSerializer.Deserialize<ZeroLevel.Services.Semantic.Helpers.BagOfTerms>(stream);
}
}
else
{
Log.Info("Create and train model");
codebook = new ZeroLevel.Services.Semantic.Helpers.BagOfTerms();
foreach (var batch in reader.ReadBatches(1000))
{
codebook.Learn(batch);
Log.Info($"\r\n\tDocuments: {codebook.NumberOfDocuments}\r\n\tWords: {codebook.NumberOfWords}");
}
using (var stream = new FileStream("model.bin", FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
{
MessageSerializer.Serialize<ZeroLevel.Services.Semantic.Helpers.BagOfTerms>(stream, codebook);
}
}
Log.Info("Create vectors");
foreach (var docs in reader.ReadRawDocumentBatches(1000))
{
foreach (var doc in docs)
{
var words = ExtractLemmas(doc.Item2).Concat(ExtractLemmas(doc.Item1)).Distinct().ToArray();
var vector = codebook.Transform(words);
for (var i = 0; i< words.Length; i++)
{
var word = words[i];
if (false == _scoring.ContainsKey(word))
{
_scoring.TryAdd(word, vector)
}
}
}
}
using (var stream = new FileStream("vectors.bin", FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
{
MessageSerializer.SerializeCompatible<List<SparceVector>>(stream, vectors);
}
Log.Info("Find similar documents");
var list = new List<Tuple<double, int, int>>();
long total_count = ((long)vectors.Count * (long)vectors.Count);
long count = 0;
double d = (double.Epsilon * 2.0d);
for (int i = 0; i < vectors.Count; i++)
{
for (int j = i + 1; j < vectors.Count - 1; j++)
{
count++;
if (count % 10000000 == 0)
{
Log.Info($"Progress: {((count * 100.0d) / total_count)} %.\tFound similars: {list.Count}.");
}
if (i == j) continue;
var diff = vectors[i].Measure(vectors[j]);
if (diff > d && diff < 0.0009d)
{
list.Add(Tuple.Create(diff, i, j));
}
}
}
Log.Info("Prepare to show similar documents");
var to_present = list.OrderBy(e => e.Item1).Take(2000).ToArray();
var to_present_map = new Dictionary<int, Tuple<string, string>>();
foreach (var e in to_present)
{
if (!to_present_map.ContainsKey(e.Item2))
{
to_present_map.Add(e.Item2, null);
}
if (!to_present_map.ContainsKey(e.Item3))
{
to_present_map.Add(e.Item3, null);
}
}
int index = 0;
foreach (var docs in reader.ReadRawDocumentBatches(1000))
{
foreach (var doc in docs)
{
if (to_present_map.ContainsKey(index))
{
to_present_map[index] = doc;
}
index++;
}
}
Log.Info("Show similar documents");
index = 0;
using (var output = new StreamWriter("out.txt"))
{
foreach (var e in to_present)
{
output.WriteLine($"#{index++}: {e.Item1}");
output.WriteLine("-------------1--------------");
output.WriteLine(to_present_map[e.Item2].Item1);
output.WriteLine(to_present_map[e.Item2].Item2);
output.WriteLine("-------------2--------------");
output.WriteLine(to_present_map[e.Item3].Item1);
output.WriteLine(to_present_map[e.Item3].Item2);
output.WriteLine("#############################");
output.WriteLine();
}
}
*/
Console.WriteLine("Completed");
Console.ReadKey();
}
private static IEnumerable<string> ExtractLemmas(string text)
{
return
_lexer.ExtractUniqueLexTokensWithoutStopWords(text)
.Select(t => t.Token)
.Where(s => s.Any(c => char.IsLetter(c)));
}
}
}

@ -1,10 +0,0 @@
using System.Collections.Generic;
using ZeroLevel.Services.Semantic.Helpers;
namespace TFIDFbee.Reader
{
public interface IDocumentReader
{
IEnumerable<IEnumerable<BagOfTerms>> ReadBatches(int size);
}
}

@ -1,72 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using ZeroLevel.Services.Semantic;
using ZeroLevel.Services.Semantic.Helpers;
namespace TFIDFbee.Reader
{
public class JsonByLineReader
: IDocumentReader
{
private readonly string _file;
private readonly ILexProvider _lexer;
public JsonByLineReader(string file, ILexProvider lexer)
{
_file = file;
_lexer = lexer;
}
public IEnumerable<IEnumerable<BagOfTerms>> ReadBatches(int size)
{
string line;
var batch = new List<BagOfTerms>();
string title = null;
string text = null;
using (StreamReader reader = new StreamReader(_file))
{
while ((line = reader.ReadLine()) != null)
{
var titleIndex = line.IndexOf("\"metaTitle\":");
if (titleIndex >= 0)
{
var start = line.IndexOf("\"", titleIndex + 12);
var end = line.LastIndexOf("\"");
if (start < end && start != -1 && end != -1)
{
title = line.Substring(start + 1, end - start - 1);
}
}
else
{
var textIndex = line.IndexOf("\"plaintext\":");
if (textIndex >= 0 && title != null)
{
var start = line.IndexOf("\"", textIndex + 12);
var end = line.LastIndexOf("\"");
if (start < end && start != -1 && end != -1)
{
text = line.Substring(start + 1, end - start - 1);
batch.Add(new BagOfTerms(title + " " + text, _lexer));
if (batch.Count >= size)
{
yield return batch;
batch.Clear();
GC.Collect(2);
}
title = null;
text = null;
}
}
}
}
}
if (batch.Count > 0)
{
yield return batch;
}
}
}
}

@ -1,67 +0,0 @@
using System.Collections.Generic;
using System.IO;
using ZeroLevel.Services.Semantic;
using ZeroLevel.Services.Semantic.Helpers;
namespace TFIDFbee.Reader
{
public class StateMachineReader
: IDocumentReader
{
private readonly string _file;
private readonly ILexProvider _lexer;
public StateMachineReader(string file, ILexProvider lexer)
{
_file = file;
_lexer = lexer;
}
private IEnumerable<string[]> Parse()
{
var result = new string[2];
var parser = new RecordParser((k, v) =>
{
switch (k)
{
case "metaTitle": result[0] = v; break;
case "plaintext": result[1] = v; break;
}
});
char[] buffer = new char[16536];
int count = 0;
using (StreamReader reader = new StreamReader(_file))
{
while ((count = reader.Read(buffer, 0, buffer.Length)) > 0)
{
parser.Append(new string(buffer, 0, count));
if (!string.IsNullOrEmpty(result[0]) && !string.IsNullOrEmpty(result[1]))
{
yield return result;
result[0] = null;
result[1] = null;
}
}
}
}
public IEnumerable<IEnumerable<BagOfTerms>> ReadBatches(int size)
{
var list = new List<BagOfTerms>();
foreach (var record in Parse())
{
list.Add(new BagOfTerms(record[0] + " " + record[1], _lexer));
if (list.Count > size)
{
yield return list.ToArray();
list.Clear();
}
}
if (list.Count > 0)
{
yield return list.ToArray();
}
}
}
}

@ -1,108 +0,0 @@
using System;
using System.Text;
namespace TFIDFbee
{
public class RecordParser
{
private enum RPState
{
WaitKey,
ParseKey,
WaitKeyConfirm,
WaitValue,
ParseValue
}
private readonly StringBuilder _builder = new StringBuilder();
private RPState State = RPState.WaitKey;
private char _previous = '\0';
private string _key;
private string _value;
private readonly Action<string, string> _callback;
public RecordParser(Action<string, string> callback)
{
_callback = callback;
}
public void Append(string text)
{
foreach (var ch in text)
{
switch (State)
{
case RPState.WaitKey:
if (ch.Equals('"'))
{
State = RPState.ParseKey;
_builder.Clear();
}
break;
case RPState.ParseKey:
if (ch.Equals('"') && _previous != '\\')
{
if (_builder.Length > 0)
{
State = RPState.WaitKeyConfirm;
}
else
{
State = RPState.WaitKey;
}
}
else
{
_builder.Append(ch);
}
break;
case RPState.WaitKeyConfirm:
if (ch.Equals(':'))
{
_key = _builder.ToString();
State = RPState.WaitValue;
}
else if (ch == ' ' || ch == '\r' || ch == '\n')
{
// nothing
}
else
{
State = RPState.WaitKey;
}
break;
case RPState.WaitValue:
if (ch.Equals('"'))
{
State = RPState.ParseValue;
_builder.Clear();
}
else if (ch == ' ' || ch == '\r' || ch == '\n')
{
// nothing
}
else
{
State = RPState.WaitKey;
}
break;
case RPState.ParseValue:
if (ch.Equals('"') && _previous != '\\')
{
if (_builder.Length > 0)
{
_value = _builder.ToString();
_callback(_key, _value);
}
State = RPState.WaitKey;
}
else
{
_builder.Append(ch);
}
break;
}
_previous = ch;
}
}
}
}

@ -1,14 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Lemmatization\Lemmatization.csproj" />
<ProjectReference Include="..\..\ZeroLevel\ZeroLevel.csproj" />
</ItemGroup>
</Project>

@ -1,57 +0,0 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using ZeroLevel.Services.Web;
namespace Tests
{
class Program
{
public String responseToWords(String response)
{
response = response
.ToLowerInvariant()
.Replace("<title>", ",")
.Replace("</title>", ",")
.Replace("<meta name=\"description\" content=", ",")
.Replace("<meta name=\"keywords\" content=", ",");
response = response
.Replace("[^a-zA-Zа-яА-Я\\w\\s]]*", ",")
.Replace(" ", ",");
var array = new List<string>();
foreach (String word in response.Split(","))
{
if (!string.IsNullOrWhiteSpace(word) && word.Length > 1)
{
array.Add(word);
}
}
array.Sort();
response = string.Join(' ', array);
return response;
}
private HttpClient GetClient()
{
var handler = new HttpClientHandler
{
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate,
UseDefaultCredentials = ZeroLevel.Configuration.Default.FirstOrDefault<bool>("useDefaultCredentianls"),
ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => { return true; }
};
if (ZeroLevel.Configuration.Default.FirstOrDefault<bool>("useDefaultCredentianls"))
{
handler.DefaultProxyCredentials = CredentialCache.DefaultCredentials;
}
var httpClient = new HttpClient(handler);
httpClient.DefaultRequestHeaders.Add("user-agent", UserAgents.Next());
return httpClient;
}
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}

@ -1,12 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\ZeroLevel\ZeroLevel.csproj" />
</ItemGroup>
</Project>

@ -1,6 +1,12 @@
using Newtonsoft.Json;
using System;
using System.IO;
using System.Text;
using ZeroLevel;
using ZeroLevel.Implementation.Semantic.Helpers;
using ZeroLevel.Logging;
using ZeroLevel.Services.Serialization;
using ZeroLevel.Services.Trees;
namespace TestApp
{

@ -3,6 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup>

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
<appSettings>
<add key="ServiceName" value="Test consumer" />
<add key="ServiceKey" value="test.consumer" />
<add key="ServiceType" value="Destination" />
<add key="ServiceGroup" value="Test" />
<add key="Version" value="1.0.0.1" />
<add key="ServiceName" value="Test consumer"/>
<add key="ServiceKey" value="test.consumer"/>
<add key="ServiceType" value="Destination"/>
<add key="ServiceGroup" value="Test"/>
<add key="Version" value="1.0.0.1"/>
<add key="discovery" value="127.0.0.1:5012"/>
</appSettings>
</configuration>
</configuration>

@ -8,10 +8,11 @@
<OutputType>Exe</OutputType>
<RootNamespace>Consumer</RootNamespace>
<AssemblyName>Consumer</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -32,6 +33,28 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
<appSettings>
<add key="ServiceName" value="Test processor" />
<add key="ServiceKey" value="test.processor" />
<add key="ServiceType" value="Core" />
<add key="ServiceGroup" value="Test" />
<add key="Version" value="1.0.0.1" />
<add key="ServiceName" value="Test processor"/>
<add key="ServiceKey" value="test.processor"/>
<add key="ServiceType" value="Core"/>
<add key="ServiceGroup" value="Test"/>
<add key="Version" value="1.0.0.1"/>
<add key="discovery" value="127.0.0.1:5012"/>
</appSettings>
</configuration>
</configuration>

@ -8,10 +8,11 @@
<OutputType>Exe</OutputType>
<RootNamespace>Processor</RootNamespace>
<AssemblyName>Processor</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -32,6 +33,28 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
<appSettings>
<add key="ServiceName" value="Test source" />
<add key="ServiceKey" value="test.source" />
<add key="ServiceType" value="Sources" />
<add key="ServiceGroup" value="Test" />
<add key="Version" value="1.0.0.1" />
<add key="ServiceName" value="Test source"/>
<add key="ServiceKey" value="test.source"/>
<add key="ServiceType" value="Sources"/>
<add key="ServiceGroup" value="Test"/>
<add key="Version" value="1.0.0.1"/>
<add key="discovery" value="127.0.0.1:5012"/>
</appSettings>
</configuration>
</configuration>

@ -8,10 +8,11 @@
<OutputType>Exe</OutputType>
<RootNamespace>Source</RootNamespace>
<AssemblyName>Source</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -32,6 +33,28 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
<appSettings>
<add key="ServiceName" value="Watcher" />
<add key="ServiceKey" value="test.watcher" />
<add key="ServiceType" value="System" />
<add key="ServiceGroup" value="Test" />
<add key="Version" value="1.0.0.1" />
<add key="ServiceName" value="Watcher"/>
<add key="ServiceKey" value="test.watcher"/>
<add key="ServiceType" value="System"/>
<add key="ServiceGroup" value="Test"/>
<add key="Version" value="1.0.0.1"/>
<add key="discovery" value="127.0.0.1:5012"/>
</appSettings>
</configuration>
</configuration>

@ -8,10 +8,11 @@
<OutputType>Exe</OutputType>
<RootNamespace>Watcher</RootNamespace>
<AssemblyName>Watcher</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -32,6 +33,28 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />

@ -20,6 +20,7 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms;
namespace ZeroLevel.WPF
{

@ -43,12 +43,12 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath>..\..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="ZeroLevel, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>C:\Users\a.bozhenov\Desktop\SEOPortal\Utils\Semantic\packages\ZeroLevel.3.0.0\lib\netstandard2.0\ZeroLevel.dll</HintPath>
<Reference Include="ZeroLevel, Version=3.3.3.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\..\packages\ZeroLevel.3.3.3\lib\netstandard2.0\ZeroLevel.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net47" />
<package id="ZeroLevel" version="3.0.0" targetFramework="net472" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" />
<package id="ZeroLevel" version="3.3.3" targetFramework="net472" />
</packages>

@ -46,23 +46,23 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Owin, Version=4.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Owin.4.0.1\lib\net45\Microsoft.Owin.dll</HintPath>
<Reference Include="Microsoft.Owin, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Owin.4.1.0\lib\net45\Microsoft.Owin.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.FileSystems, Version=4.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Owin.FileSystems.4.0.1\lib\net45\Microsoft.Owin.FileSystems.dll</HintPath>
<Reference Include="Microsoft.Owin.FileSystems, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Owin.FileSystems.4.1.0\lib\net45\Microsoft.Owin.FileSystems.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.Host.HttpListener, Version=4.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Owin.Host.HttpListener.4.0.1\lib\net45\Microsoft.Owin.Host.HttpListener.dll</HintPath>
<Reference Include="Microsoft.Owin.Host.HttpListener, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Owin.Host.HttpListener.4.1.0\lib\net45\Microsoft.Owin.Host.HttpListener.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.Hosting, Version=4.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Owin.Hosting.4.0.1\lib\net45\Microsoft.Owin.Hosting.dll</HintPath>
<Reference Include="Microsoft.Owin.Hosting, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Owin.Hosting.4.1.0\lib\net45\Microsoft.Owin.Hosting.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.StaticFiles, Version=4.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Owin.StaticFiles.4.0.1\lib\net45\Microsoft.Owin.StaticFiles.dll</HintPath>
<Reference Include="Microsoft.Owin.StaticFiles, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Owin.StaticFiles.4.1.0\lib\net45\Microsoft.Owin.StaticFiles.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath>..\..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
<HintPath>..\..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
@ -82,8 +82,8 @@
<Reference Include="System.Web.Http.Owin, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.Owin.5.2.7\lib\net45\System.Web.Http.Owin.dll</HintPath>
</Reference>
<Reference Include="ZeroLevel, Version=2.0.8.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\ZeroLevel.2.0.8\lib\netstandard2.0\ZeroLevel.dll</HintPath>
<Reference Include="ZeroLevel, Version=3.3.3.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\..\packages\ZeroLevel.3.3.3\lib\netstandard2.0\ZeroLevel.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>

@ -41,8 +41,8 @@
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="ZeroLevel, Version=2.0.8.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\ZeroLevel.2.0.8\lib\netstandard2.0\ZeroLevel.dll</HintPath>
<Reference Include="ZeroLevel, Version=3.3.3.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\..\..\packages\ZeroLevel.3.3.3\lib\netstandard2.0\ZeroLevel.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ZeroLevel" version="2.0.8" targetFramework="net472" />
<package id="ZeroLevel" version="3.3.3" targetFramework="net472" />
</packages>

@ -23,7 +23,7 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />

@ -4,12 +4,12 @@
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Owin" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.OwinSelfHost" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.Owin" version="4.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.FileSystems" version="4.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Host.HttpListener" version="4.0.1" targetFramework="net472" />
<package id="Microsoft.Owin.Hosting" version="4.0.1" targetFramework="net472" />
<package id="Microsoft.Owin.StaticFiles" version="4.0.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net472" />
<package id="Microsoft.Owin" version="4.1.0" targetFramework="net472" />
<package id="Microsoft.Owin.FileSystems" version="4.1.0" targetFramework="net472" />
<package id="Microsoft.Owin.Host.HttpListener" version="4.1.0" targetFramework="net472" />
<package id="Microsoft.Owin.Hosting" version="4.1.0" targetFramework="net472" />
<package id="Microsoft.Owin.StaticFiles" version="4.1.0" targetFramework="net472" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" />
<package id="Owin" version="1.0" targetFramework="net45" />
<package id="ZeroLevel" version="2.0.8" targetFramework="net472" />
<package id="ZeroLevel" version="3.3.3" targetFramework="net472" />
</packages>

@ -2,7 +2,8 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup>

@ -1,23 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.112.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ZeroLevel.SqLite\ZeroLevel.SqLite.csproj" />
<ProjectReference Include="..\ZeroLevel\ZeroLevel.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="config.ini">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

@ -1 +0,0 @@
discovery=localhost:9030

@ -2,14 +2,11 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="LemmaSharp-std" Version="1.0.1" />
<PackageReference Include="LemmaSharpPreBuilt-std" Version="1.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ZeroLevel.SqLite\ZeroLevel.SqLite.csproj" />
<ProjectReference Include="..\ZeroLevel\ZeroLevel.csproj" />
</ItemGroup>

@ -3,6 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup>

@ -1,5 +1,5 @@
using System;
using System.Data.SQLite;
using System.Data.SQLite;
using System;
using System.IO;
using ZeroLevel.Services.FileSystem;

@ -11,11 +11,11 @@ Based on System.Data.SQLite.Core</Description>
<RepositoryUrl>https://github.com/ogoun/Zero</RepositoryUrl>
<PackageIcon>zero.png</PackageIcon>
<PackageIconUrl />
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.112.1" />
<PackageReference Include="ZeroLevel" Version="3.3.2" />
</ItemGroup>
<ItemGroup>
@ -25,4 +25,8 @@ Based on System.Data.SQLite.Core</Description>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ZeroLevel\ZeroLevel.csproj" />
</ItemGroup>
</Project>

@ -1,187 +0,0 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
namespace ZeroLevel.SqlServer
{
public abstract class BaseSqlDbMapper
{
protected abstract IDbMapper Mapper { get; }
protected readonly string _tableName;
public string TableName { get { return _tableName; } }
protected BaseSqlDbMapper(string tableName)
{
_tableName = tableName;
}
public object GetIdentity(object entity)
{
if (Mapper.IdentityField != null)
return Mapper.IdentityField.Getter(entity);
return null;
}
public string IdentityName
{
get
{
return Mapper.IdentityField?.Name;
}
}
#region QUERIES
#region INDEXES
public string GetIndexExistsQuery(IDbField field)
{
if (field.IsIndexed)
{
return string.Format(
"SELECT COUNT(*) FROM sys.indexes WHERE name = 'idx_{0}_{1}' AND object_id = OBJECT_ID('{2}')",
_tableName, field.Name, _tableName);
}
return null;
}
public string GetCreateIndexQuery(IDbField field)
{
if (field.IsIndexed)
{
return string.Format("CREATE INDEX idx_{0}_{1} ON [{2}]({3});", _tableName, field.Name, _tableName, field.Name);
}
return null;
}
#endregion
#region CREATE
public static HashSet<DbType> FieldsHasSize = new HashSet<DbType>
{
DbType.String, DbType.Decimal, DbType.AnsiString, DbType.AnsiStringFixedLength,
DbType.StringFixedLength, DbType.VarNumeric
};
private string _createString = null;
private readonly object _createStringBuildLocker = new object();
public string GetCreateQuery(bool rebuild = false)
{
lock (_createStringBuildLocker)
{
if (_createString == null || rebuild)
{
StringBuilder create = new StringBuilder("CREATE TABLE [" + _tableName + "]");
create.Append("(");
Mapper.TraversalFields(f =>
{
var sqlType = DbTypeMapper.ToSqlDbType(f.ClrType);
create.Append("[" + f.Name + "] " + sqlType);
if (FieldsHasSize.Contains(f.DbType) && f.Size != 0)
{
if (f.DbType == DbType.Decimal)
{
int p = 19, s = 4;
if (f.Size > 0)
{
p = (int)f.Size;
if (s >= p)
{
if (p <= 2) s = 0;
else s = p - 1;
}
}
create.AppendFormat("({0},{1})", p, s);
}
else
{
create.AppendFormat("({0})", ((f.Size == -1) ? "max" : f.Size.ToString()));
}
}
if (f.IsIdentity)
{
create.Append(" PRIMARY KEY");
}
if (f.AllowNull)
{
create.Append(" NULL");
}
else
{
create.Append(" NOT NULL");
}
if (f.AutoIncrement)
{
create.Append(" IDENTITY (0, 1)");
}
create.Append(",");
});
_createString = create.ToString().TrimEnd(',') + ")";
}
}
return _createString;
}
#endregion
#endregion
public SqlParameter[] CreateSqlDbParameters(object entity)
{
if (entity.GetType() != Mapper.EntityType)
throw new InvalidCastException("Entity type is different from serializer entity type");
var list = new List<SqlParameter>();
Mapper.TraversalFields(field =>
{
var par = new SqlParameter();
par.Value = ValueToSqlServerObject(field.Getter(entity), field.ClrType);
// ADO.NET bug
// https://connect.microsoft.com/VisualStudio/feedback/details/381934/sqlparameter-dbtype-dbtype-time-sets-the-parameter-to-sqldbtype-datetime-instead-of-sqldbtype-time
if (field.DbType == DbType.Time)
{
par.SqlDbType = SqlDbType.Time;
}
else
{
par.DbType = field.DbType; // Если задать в конструкторе, то тип может переопределиться при задании значения
}
par.ParameterName = field.Name;
list.Add(par);
});
return list.ToArray();
}
#region Datetime helper
private static DateTime MinSqlDbDateTimeValue = new DateTime(1753, 01, 01);
protected object ValueToSqlServerObject(object obj, Type type)
{
if (type == typeof(DateTime))
{
return DateTimeToSqlDbValue((DateTime)obj);
}
return obj ?? DBNull.Value;
}
/// <summary>
/// Подготовка даты к записи в SQLServer
/// (минимальные значения даты в .NET и SQL Server отличаются)
/// </summary>
protected object DateTimeToSqlDbValue(DateTime dt)
{
if (DateTime.Compare(dt, MinSqlDbDateTimeValue) <= 0)
return DBNull.Value;
return dt;
}
/// <summary>
/// Конвертер из элементов строки DataTable в DonNet тип
/// </summary>
/// <typeparam name="Tout">Тип на выходе</typeparam>
/// <param name="value">Значение из БД</param>
/// <returns>Результат</returns>
protected Tout Convert<Tout>(object value)
{
if (null == value || DBNull.Value == value)
return default(Tout);
return (Tout)System.Convert.ChangeType(value, typeof(Tout));
}
#endregion
}
}

@ -1,72 +0,0 @@
using System;
using System.Runtime.Serialization;
namespace ZeroLevel.SqlServer
{
[DataContract]
[Serializable]
public abstract class BaseEntity : IEntity
{
#region Properties
[DataMember]
[DbMember(false, true, false)]
public Guid Id
{
get;
set;
}
#endregion
#region Ctors
protected BaseEntity()
{
Id = Guid.NewGuid();
}
protected BaseEntity(Guid id)
{
if (id == Guid.Empty)
throw new ArgumentException("Entity id must not be empty");
Id = id;
}
protected BaseEntity(BaseEntity other)
{
if (other == null)
throw new ArgumentNullException(nameof(other));
Id = other.Id;
}
#endregion
public abstract object Clone();
#region Equal
public bool Equals(BaseEntity other)
{
if (this == null) // и так бывает
throw new NullReferenceException();
if (other == null)
return false;
if (ReferenceEquals(this, other))
return true;
if (this.GetType() != other.GetType())
return false;
return Id == other.Id;
}
public override bool Equals(object obj)
{
if (this == null)
throw new NullReferenceException();
return Equals(obj as BaseEntity);
}
public static bool operator ==(BaseEntity first, BaseEntity second) => Equals(first, second);
public static bool operator !=(BaseEntity first, BaseEntity second) => !Equals(first, second);
#endregion
public override int GetHashCode()
{
return Id.GetHashCode();
}
}
}

@ -1,55 +0,0 @@
using System;
using System.Runtime.Serialization;
namespace ZeroLevel.SqlServer
{
[DataContract]
[Serializable]
public abstract class BaseVersionedEntity : BaseEntity, IVersionedEntity
{
#region Properties
[DataMember]
[DbMember(false)]
public long Version
{
get;
internal set;
}
#endregion
#region Ctors
protected BaseVersionedEntity()
: base()
{
}
// Конструктор protected BaseVersionedEntity(Guid id) исключен, т.к. без версии нет смысла создавать обхект с известным ID
protected BaseVersionedEntity(Guid id, long version)
: base(id)
{
Version = version;
}
protected BaseVersionedEntity(BaseVersionedEntity other)
: base(other)
{
Version = other.Version;
}
#endregion
public bool Equals(BaseVersionedEntity other)
{
if (base.Equals(other) == false) return false;
return Version == other.Version;
}
public override bool Equals(object obj)
{
return Equals(obj as BaseVersionedEntity);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
}

@ -1,9 +0,0 @@
using System;
namespace ZeroLevel.SqlServer
{
public class DbIndexAttribute : Attribute
{
public DbIndexAttribute() { }
}
}

@ -1,39 +0,0 @@
using System;
namespace ZeroLevel.SqlServer
{
public class DbMemberAttribute : Attribute
{
#region Properties
public bool AllowNull { get; }
public bool AutoIncrement { get; }
public bool IsIdentity { get; }
public long Size { get; }
#endregion
#region Ctors
public DbMemberAttribute(bool allowNull)
: this(allowNull, -1, false, false) { }
public DbMemberAttribute(bool allowNull, long size)
: this(allowNull, size, false, false) { }
public DbMemberAttribute(bool allowNull, bool isIdentity)
: this(allowNull, -1, isIdentity, false) { }
public DbMemberAttribute(bool allowNull, bool isIdentity, bool autoIncrement)
: this(allowNull, -1, isIdentity, autoIncrement) { }
public DbMemberAttribute(bool allowNull, long size, bool isIdentity)
: this(allowNull, size, isIdentity, false) { }
public DbMemberAttribute(bool allowNull, long size, bool isIdentity, bool autoIncrement)
{
AllowNull = allowNull;
AutoIncrement = autoIncrement;
IsIdentity = isIdentity;
Size = size;
}
#endregion
}
}

@ -1,16 +0,0 @@
using System.Data;
using ZeroLevel.Services.ObjectMapping;
namespace ZeroLevel.SqlServer
{
public interface IDbField:
IMemberInfo
{
bool AutoIncrement { get; }
bool IsIdentity { get; }
bool IsIndexed { get; }
bool AllowNull { get; }
long Size { get; }
DbType DbType { get; }
}
}

@ -1,29 +0,0 @@
using System;
using System.Data;
using System.Data.Common;
namespace ZeroLevel.SqlServer
{
public interface IDbMapper
{
IDbField this[string name] { get; }
IDbField IdentityField { get; }
Type EntityType { get; }
object Id(object entity);
void TraversalFields(Action<IDbField> callback);
void TraversalFields(Func<IDbField, bool> callback);
void SetTypeConverter(Func<IDbField, object, object> converter);
bool Exists(string name);
#region Serialization
object Deserialize(DataRow row);
object Deserialize(DbDataReader reader);
#endregion
}
public interface IDbMapper<T> : IDbMapper
{
new T Deserialize(DataRow row);
new T Deserialize(DbDataReader reader);
}
}

@ -1,23 +0,0 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
namespace ZeroLevel.SqlServer
{
public interface IDbProvider
{
bool ExistsTable(string tableName);
DataTable ExecuteQueryDataTable(string query);
DataTable ExecuteQueryDataTable(string query, DbParameter[] par);
DataSet ExecuteQuerySqlDataSet(string query);
DataSet ExecuteQuerySqlDataSet(string query, DbParameter[] par);
object ExecuteScalar(string query);
object ExecuteScalar(string query, DbParameter[] par);
void ExecuteNonResult(IEnumerable<ZSqlCommand> commands);
int ExecuteNonResult(string query);
int ExecuteNonResult(string query, DbParameter[] par);
void LazySelect(string query, DbParameter[] par, Func<DbDataReader, bool> readHandler, int timeout);
void LazySelectWithParameters(string query, IEnumerable<KeyValuePair<string, object>> par, Func<DbDataReader, bool> readHandler, int timeout);
}
}

@ -1,14 +0,0 @@
using System;
namespace ZeroLevel.SqlServer
{
public interface IEntity : ICloneable
{
Guid Id { get; }
}
public interface IEntity<TKey> : ICloneable
{
TKey Id { get; }
}
}

@ -1,7 +0,0 @@
namespace ZeroLevel.SqlServer
{
public interface IVersionedEntity : IEntity
{
long Version { get; }
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save

Powered by TurnKey Linux.