Skip to content

Commit

Permalink
调整结构
Browse files Browse the repository at this point in the history
  • Loading branch information
zlzforever committed Jul 21, 2018
1 parent d79754e commit 1722c30
Show file tree
Hide file tree
Showing 93 changed files with 102 additions and 629 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Threading;

namespace DotnetSpider.Core.Infrastructure
namespace DotnetSpider.Common
{
/// <summary>
/// 线程安全的计数器
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Threading;

namespace DotnetSpider.Core.Infrastructure
namespace DotnetSpider.Common
{
/// <summary>
/// 线程安全的计数器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
using System.Security.Cryptography;
using System.Text;

namespace DotnetSpider.Core.Infrastructure
namespace DotnetSpider.Common
{
/// <summary>
/// 加、解密帮助类
/// </summary>
public static class CryptoUtil
public static class Cryptography
{
/// <summary>
/// 计算32位MD5
/// </summary>
/// <param name="str">需要计算的字符串</param>
/// <returns>32位的MD5值</returns>
public static string Md5Encrypt32(string str)
public static string ToMd5(this string str)
{
#if !NETSTANDARD
MD5 md5 = new MD5CryptoServiceProvider();
Expand All @@ -33,9 +33,9 @@ public static string Md5Encrypt32(string str)
/// </summary>
/// <param name="str">需要计算的字符串</param>
/// <returns>8位的MD5值</returns>
public static string Md5Encrypt(string str)
public static string ToShortMd5(this string str)
{
return Md5Encrypt32(str).Substring(8, 16).ToLower();
return ToMd5(str).Substring(8, 16).ToLower();
}

/// <summary>
Expand All @@ -44,7 +44,7 @@ public static string Md5Encrypt(string str)
/// <param name="key">秘钥</param>
/// <param name="str">需要加密的字符串</param>
/// <returns>加密后的字符串</returns>
public static string DesEncrypt(string key, string str)
public static string ToDes(string key, string str)
{
DESCryptoServiceProvider cryptoProvider = new DESCryptoServiceProvider();
var bytes = Encoding.ASCII.GetBytes(key);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace DotnetSpider.Core.Infrastructure.Database
namespace DotnetSpider.Common
{
/// <summary>
/// Database type enum
Expand Down Expand Up @@ -36,6 +36,11 @@ public enum Database
/// <summary>
/// PostgreSql
/// </summary>
PostgreSql
PostgreSql,

/// <summary>
/// Clickhouse
/// </summary>
Clickhouse,
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.IO;

namespace DotnetSpider.Core.Infrastructure
namespace DotnetSpider.Common
{
/// <summary>
/// 文件夹扩展
Expand Down
2 changes: 1 addition & 1 deletion src/DotnetSpider.Common/DotnetSpider.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
</ItemGroup>
</Project>
</Project>
7 changes: 1 addition & 6 deletions src/DotnetSpider.Common/IAppBase.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DotnetSpider.Common
namespace DotnetSpider.Common
{
/// <summary>
/// 标准任务接口
Expand Down
2 changes: 1 addition & 1 deletion src/DotnetSpider.Common/INamed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public abstract class Named : INamed
/// </summary>
public string Name { get; set; }

public Named()
protected Named()
{
var type = GetType();
var nameAttribute = type.GetCustomAttributes(typeof(TaskName), true).FirstOrDefault() as TaskName;
Expand Down
31 changes: 0 additions & 31 deletions src/DotnetSpider.Common/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,4 @@ public static class Logger
{
public static ILogger Default = new SilentLogger();
}

public class SilentLogger : ILogger
{
public void Error(string message)
{
}

public void Error(string message, object propertyValue1)
{
}

public void Information(string message)
{
}

public void Information(string message, object propertyValue1)
{
}

public void Verbose(string message)
{
}

public void Warning(string message)
{
}

public void Warning(string message, object propertyValue1)
{
}
}
}
2 changes: 1 addition & 1 deletion src/DotnetSpider.Common/Request.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class Request : IDisposable
/// </summary>
public string Url { get; set; }

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

/// <summary>
/// 构造方法
Expand Down
30 changes: 28 additions & 2 deletions src/DotnetSpider.Common/SilentLogger.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,33 @@
namespace DotnetSpider.Common
{
public class SilentLogger
public class SilentLogger : ILogger
{

public void Error(string message)
{
}

public void Error(string message, object propertyValue1)
{
}

public void Information(string message)
{
}

public void Information(string message, object propertyValue1)
{
}

public void Verbose(string message)
{
}

public void Warning(string message)
{
}

public void Warning(string message, object propertyValue1)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Linq;
using System.Reflection;

namespace DotnetSpider.Core.Infrastructure
namespace DotnetSpider.Common
{
/// <summary>
/// 单独的泛型实型
Expand Down
3 changes: 0 additions & 3 deletions src/DotnetSpider.Core/ISpider.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using DotnetSpider.Common;
using DotnetSpider.Core.Monitor;
using DotnetSpider.Core.Pipeline;
using DotnetSpider.Core.Processor;
using DotnetSpider.Core.Scheduler;
using DotnetSpider.Downloader;
using System;
using System.Collections.Generic;

namespace DotnetSpider.Core
{
Expand Down
47 changes: 0 additions & 47 deletions src/DotnetSpider.Core/Infrastructure/Cache.cs

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,22 @@ public static DbConnection CreateDbConnection(this ConnectionStringSettings conn
/// <param name="source"><see cref="Database"/></param>
/// <param name="connectString"></param>
/// <returns></returns>
public static DbConnection CreateDbConnection(Database source, string connectString)
public static DbConnection CreateDbConnection(Common.Database source, string connectString)
{
DbProviderFactory factory;
switch (source)
{
case Database.MySql:
case Common.Database.MySql:
{
factory = DbProviderFactories.GetFactory(DbProviderFactories.MySqlProvider);
break;
}
case Database.SqlServer:
case Common.Database.SqlServer:
{
factory = DbProviderFactories.GetFactory(DbProviderFactories.SqlServerProvider);
break;
}
case Database.PostgreSql:
case Common.Database.PostgreSql:
{
factory = DbProviderFactories.GetFactory(DbProviderFactories.PostgreSqlProvider);
break;
Expand Down Expand Up @@ -148,19 +148,19 @@ public static DbConnection CreateDbConnection(Database source, string connectStr
/// <param name="source">数据库 <see cref="Database"/></param>
/// <param name="connectString">连接字符串</param>
/// <returns>数据库配置对象 <see cref="ConnectionStringSettings"/></returns>
public static ConnectionStringSettings GetConnectionStringSettings(Database source, string connectString)
public static ConnectionStringSettings GetConnectionStringSettings(Common.Database source, string connectString)
{
switch (source)
{
case Database.MySql:
case Common.Database.MySql:
{
return new ConnectionStringSettings("MySql", connectString, DbProviderFactories.MySqlProvider);
}
case Database.SqlServer:
case Common.Database.SqlServer:
{
return new ConnectionStringSettings("SqlServer", connectString, DbProviderFactories.SqlServerProvider);
}
case Database.PostgreSql:
case Common.Database.PostgreSql:
{
return new ConnectionStringSettings("PostgreSql", connectString, DbProviderFactories.PostgreSqlProvider);
}
Expand Down
21 changes: 0 additions & 21 deletions src/DotnetSpider.Core/Infrastructure/FileUtil.cs

This file was deleted.

Loading

0 comments on commit 1722c30

Please sign in to comment.