Skip to content

Commit 1722c30

Browse files
committed
调整结构
1 parent d79754e commit 1722c30

File tree

93 files changed

+102
-629
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+102
-629
lines changed

src/DotnetSpider.Core/Infrastructure/AutomicInteger.cs src/DotnetSpider.Common/AutomicInteger.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Threading;
22

3-
namespace DotnetSpider.Core.Infrastructure
3+
namespace DotnetSpider.Common
44
{
55
/// <summary>
66
/// 线程安全的计数器

src/DotnetSpider.Core/Infrastructure/AutomicLong.cs src/DotnetSpider.Common/AutomicLong.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Threading;
22

3-
namespace DotnetSpider.Core.Infrastructure
3+
namespace DotnetSpider.Common
44
{
55
/// <summary>
66
/// 线程安全的计数器

src/DotnetSpider.Core/Infrastructure/CryptoUtil.cs src/DotnetSpider.Common/Cryptography.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
using System.Security.Cryptography;
44
using System.Text;
55

6-
namespace DotnetSpider.Core.Infrastructure
6+
namespace DotnetSpider.Common
77
{
88
/// <summary>
99
/// 加、解密帮助类
1010
/// </summary>
11-
public static class CryptoUtil
11+
public static class Cryptography
1212
{
1313
/// <summary>
1414
/// 计算32位MD5
1515
/// </summary>
1616
/// <param name="str">需要计算的字符串</param>
1717
/// <returns>32位的MD5值</returns>
18-
public static string Md5Encrypt32(string str)
18+
public static string ToMd5(this string str)
1919
{
2020
#if !NETSTANDARD
2121
MD5 md5 = new MD5CryptoServiceProvider();
@@ -33,9 +33,9 @@ public static string Md5Encrypt32(string str)
3333
/// </summary>
3434
/// <param name="str">需要计算的字符串</param>
3535
/// <returns>8位的MD5值</returns>
36-
public static string Md5Encrypt(string str)
36+
public static string ToShortMd5(this string str)
3737
{
38-
return Md5Encrypt32(str).Substring(8, 16).ToLower();
38+
return ToMd5(str).Substring(8, 16).ToLower();
3939
}
4040

4141
/// <summary>
@@ -44,7 +44,7 @@ public static string Md5Encrypt(string str)
4444
/// <param name="key">秘钥</param>
4545
/// <param name="str">需要加密的字符串</param>
4646
/// <returns>加密后的字符串</returns>
47-
public static string DesEncrypt(string key, string str)
47+
public static string ToDes(string key, string str)
4848
{
4949
DESCryptoServiceProvider cryptoProvider = new DESCryptoServiceProvider();
5050
var bytes = Encoding.ASCII.GetBytes(key);

src/DotnetSpider.Core/Infrastructure/Database/Database.cs src/DotnetSpider.Common/Database.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22

3-
namespace DotnetSpider.Core.Infrastructure.Database
3+
namespace DotnetSpider.Common
44
{
55
/// <summary>
66
/// Database type enum
@@ -36,6 +36,11 @@ public enum Database
3636
/// <summary>
3737
/// PostgreSql
3838
/// </summary>
39-
PostgreSql
39+
PostgreSql,
40+
41+
/// <summary>
42+
/// Clickhouse
43+
/// </summary>
44+
Clickhouse,
4045
}
4146
}

src/DotnetSpider.Core/Infrastructure/DirectoryExtensions.cs src/DotnetSpider.Common/DirectoryExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Collections.Generic;
22
using System.IO;
33

4-
namespace DotnetSpider.Core.Infrastructure
4+
namespace DotnetSpider.Common
55
{
66
/// <summary>
77
/// 文件夹扩展

src/DotnetSpider.Common/DotnetSpider.Common.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@
2828
<ItemGroup>
2929
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
3030
</ItemGroup>
31-
</Project>
31+
</Project>

src/DotnetSpider.Common/IAppBase.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
6-
namespace DotnetSpider.Common
1+
namespace DotnetSpider.Common
72
{
83
/// <summary>
94
/// 标准任务接口

src/DotnetSpider.Common/INamed.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public abstract class Named : INamed
2323
/// </summary>
2424
public string Name { get; set; }
2525

26-
public Named()
26+
protected Named()
2727
{
2828
var type = GetType();
2929
var nameAttribute = type.GetCustomAttributes(typeof(TaskName), true).FirstOrDefault() as TaskName;

src/DotnetSpider.Common/Logger.cs

-31
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,4 @@ public static class Logger
44
{
55
public static ILogger Default = new SilentLogger();
66
}
7-
8-
public class SilentLogger : ILogger
9-
{
10-
public void Error(string message)
11-
{
12-
}
13-
14-
public void Error(string message, object propertyValue1)
15-
{
16-
}
17-
18-
public void Information(string message)
19-
{
20-
}
21-
22-
public void Information(string message, object propertyValue1)
23-
{
24-
}
25-
26-
public void Verbose(string message)
27-
{
28-
}
29-
30-
public void Warning(string message)
31-
{
32-
}
33-
34-
public void Warning(string message, object propertyValue1)
35-
{
36-
}
37-
}
387
}

src/DotnetSpider.Common/Request.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class Request : IDisposable
6161
/// </summary>
6262
public string Url { get; set; }
6363

64-
public virtual string Identity => Md5Util.Md5Encrypt($"{Referer}.{Origin}.{Method}.{Content}.{Url}");
64+
public virtual string Identity => $"{Referer}.{Origin}.{Method}.{Content}.{Url}".ToShortMd5();
6565

6666
/// <summary>
6767
/// 构造方法
+28-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,33 @@
11
namespace DotnetSpider.Common
22
{
3-
public class SilentLogger
3+
public class SilentLogger : ILogger
44
{
5-
5+
public void Error(string message)
6+
{
7+
}
8+
9+
public void Error(string message, object propertyValue1)
10+
{
11+
}
12+
13+
public void Information(string message)
14+
{
15+
}
16+
17+
public void Information(string message, object propertyValue1)
18+
{
19+
}
20+
21+
public void Verbose(string message)
22+
{
23+
}
24+
25+
public void Warning(string message)
26+
{
27+
}
28+
29+
public void Warning(string message, object propertyValue1)
30+
{
31+
}
632
}
733
}

src/DotnetSpider.Core/Infrastructure/Singleton.cs src/DotnetSpider.Common/Singleton.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Linq;
33
using System.Reflection;
44

5-
namespace DotnetSpider.Core.Infrastructure
5+
namespace DotnetSpider.Common
66
{
77
/// <summary>
88
/// 单独的泛型实型

src/DotnetSpider.Core/ISpider.cs

-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
using DotnetSpider.Common;
22
using DotnetSpider.Core.Monitor;
3-
using DotnetSpider.Core.Pipeline;
4-
using DotnetSpider.Core.Processor;
53
using DotnetSpider.Core.Scheduler;
64
using DotnetSpider.Downloader;
75
using System;
8-
using System.Collections.Generic;
96

107
namespace DotnetSpider.Core
118
{

src/DotnetSpider.Core/Infrastructure/Cache.cs

-47
This file was deleted.

src/DotnetSpider.Core/Infrastructure/ConcurrentDictionaryExtensions.cs

-23
This file was deleted.

src/DotnetSpider.Core/Infrastructure/Database/DatabaseExtensions.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,22 @@ public static DbConnection CreateDbConnection(this ConnectionStringSettings conn
8484
/// <param name="source"><see cref="Database"/></param>
8585
/// <param name="connectString"></param>
8686
/// <returns></returns>
87-
public static DbConnection CreateDbConnection(Database source, string connectString)
87+
public static DbConnection CreateDbConnection(Common.Database source, string connectString)
8888
{
8989
DbProviderFactory factory;
9090
switch (source)
9191
{
92-
case Database.MySql:
92+
case Common.Database.MySql:
9393
{
9494
factory = DbProviderFactories.GetFactory(DbProviderFactories.MySqlProvider);
9595
break;
9696
}
97-
case Database.SqlServer:
97+
case Common.Database.SqlServer:
9898
{
9999
factory = DbProviderFactories.GetFactory(DbProviderFactories.SqlServerProvider);
100100
break;
101101
}
102-
case Database.PostgreSql:
102+
case Common.Database.PostgreSql:
103103
{
104104
factory = DbProviderFactories.GetFactory(DbProviderFactories.PostgreSqlProvider);
105105
break;
@@ -148,19 +148,19 @@ public static DbConnection CreateDbConnection(Database source, string connectStr
148148
/// <param name="source">数据库 <see cref="Database"/></param>
149149
/// <param name="connectString">连接字符串</param>
150150
/// <returns>数据库配置对象 <see cref="ConnectionStringSettings"/></returns>
151-
public static ConnectionStringSettings GetConnectionStringSettings(Database source, string connectString)
151+
public static ConnectionStringSettings GetConnectionStringSettings(Common.Database source, string connectString)
152152
{
153153
switch (source)
154154
{
155-
case Database.MySql:
155+
case Common.Database.MySql:
156156
{
157157
return new ConnectionStringSettings("MySql", connectString, DbProviderFactories.MySqlProvider);
158158
}
159-
case Database.SqlServer:
159+
case Common.Database.SqlServer:
160160
{
161161
return new ConnectionStringSettings("SqlServer", connectString, DbProviderFactories.SqlServerProvider);
162162
}
163-
case Database.PostgreSql:
163+
case Common.Database.PostgreSql:
164164
{
165165
return new ConnectionStringSettings("PostgreSql", connectString, DbProviderFactories.PostgreSqlProvider);
166166
}

src/DotnetSpider.Core/Infrastructure/FileUtil.cs

-21
This file was deleted.

0 commit comments

Comments
 (0)