diff --git a/AllBase/AllBase.csproj b/AllBase/AllBase.csproj
index 6d0c79d..ec7b2e3 100644
--- a/AllBase/AllBase.csproj
+++ b/AllBase/AllBase.csproj
@@ -165,6 +165,12 @@
+
+
+
+
+
+
@@ -204,6 +210,7 @@
+
diff --git a/AllBase/AllBase.csproj.user b/AllBase/AllBase.csproj.user
index 301324e..1777006 100644
--- a/AllBase/AllBase.csproj.user
+++ b/AllBase/AllBase.csproj.user
@@ -4,6 +4,6 @@
false
- ProjectFiles
+ ShowAllFiles
\ No newline at end of file
diff --git a/AllBase/BaseClass.cs b/AllBase/BaseClass.cs
index e587e21..055c27a 100644
--- a/AllBase/BaseClass.cs
+++ b/AllBase/BaseClass.cs
@@ -750,6 +750,61 @@ namespace AllBase
{
return LoginApiUrl + "/wxxd_" + file + "?obj=" + BaseClass.MainPath + "/wxxd_" + file;
}
+
+ private static char[] constant =
+ {
+ '0','1','2','3','4','5','6','7','8','9',
+ 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
+ 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
+ };
+
+ ///
+ /// 随机返回指定位数的字母数字组合
+ ///
+ ///
+ ///
+ public static string GetRandomAlphanumeric(int iLength)
+ {
+ System.Text.StringBuilder newRandom = new System.Text.StringBuilder(62);
+ for (int i = 0; i < iLength; i++)
+ {
+ newRandom.Append(constant[Randomx.GetId(62)]);
+ }
+ return newRandom.ToString();
+ }
+
+ public static long ConvertDateTimeLong(DateTime time)
+ {
+ System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
+ return (long)(time - startTime).TotalMilliseconds;
+ }
+ ///
+ /// 获取Unix毫秒级时间戳
+ ///
+ /// 当前时间戳
+ public static long ConvertDateTimeLong()
+ {
+ return (GetServerTimeString().ToUniversalTime().Ticks - 621355968000000000) / 10000;
+ }
+
+ ///
+ /// 获取两个标题相似度
+ ///
+ /// 参照标题
+ /// 检测标题
+ /// 相似度
+ public static double GetSimularityBetween2Text(string refererTitle, string checkTitle)
+ {
+ double sameCnt = 0;
+ for (int i = 0; i < refererTitle.Length; i++)
+ {
+ if (checkTitle.IndexOf(refererTitle.Substring(i, 1)) != -1)
+ {
+ sameCnt += 1;
+ }
+ }
+ return Math.Round(sameCnt / Convert.ToDouble(refererTitle.Length), 2);
+ }
}
public class KeyValueBase
diff --git a/AllBase/Helper/GlobalConfig.cs b/AllBase/Helper/GlobalConfig.cs
index be6e543..a67c3ba 100644
--- a/AllBase/Helper/GlobalConfig.cs
+++ b/AllBase/Helper/GlobalConfig.cs
@@ -33,5 +33,9 @@ namespace AllBase.Helper
public static string cAgentIpCode { get; } = "AFZ94w3a";
public static List SameProductCheckParamList { get; set; }
+
+
+ //public static string UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36";
+ public static string UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36";
}
}
diff --git a/AllBase/HelperXiaoNaimao/DebugHelper.cs b/AllBase/HelperXiaoNaimao/DebugHelper.cs
new file mode 100644
index 0000000..3249a33
--- /dev/null
+++ b/AllBase/HelperXiaoNaimao/DebugHelper.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AllBase.Helper
+{
+ public class DebugHelper
+ {
+ public static void WriteLine(string message, bool all = false)
+ {
+ Debug.WriteLine(message);
+ if (all)
+ {
+ Console.WriteLine(message);
+ }
+ }
+ }
+}
diff --git a/AllBase/HelperXiaoNaimao/FileHelper.cs b/AllBase/HelperXiaoNaimao/FileHelper.cs
new file mode 100644
index 0000000..d7f1362
--- /dev/null
+++ b/AllBase/HelperXiaoNaimao/FileHelper.cs
@@ -0,0 +1,283 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Security.Cryptography;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AllBase.Helper
+{
+ public class FileHelper
+ {
+ ///
+ /// 删除文件夹及子文件内文件
+ ///
+ ///
+ public static void DeleteFolder(string path)
+ {
+ try
+ {
+ if (Directory.Exists(path)) //如果存在这个文件夹删除之
+ {
+ foreach (string d in Directory.GetFileSystemEntries(path))
+ {
+ if (File.Exists(d))
+ File.Delete(d); //直接删除其中的文件
+ else
+ DeleteFolder(d); //递归删除子文件夹
+ }
+ Directory.Delete(path, true); //删除已空文件夹
+ }
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteWithTime(ex);
+ }
+ }
+
+ public static void DeleteFile(string filePath)
+ {
+ try
+ {
+ if (File.Exists(filePath))
+ {
+ File.Delete(filePath);
+ }
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteWithTime(ex);
+ }
+ }
+
+ public static void CopyFolder(string sourceFolder, string destFolder)
+ {
+ CreateDirectory(destFolder);
+ string[] files = Directory.GetFiles(sourceFolder);
+ foreach (string file in files)
+ {
+ string name = Path.GetFileName(file);
+ string dest = Path.Combine(destFolder, name);
+ File.Copy(file, dest);
+ }
+ string[] folders = Directory.GetDirectories(sourceFolder);
+ foreach (string folder in folders)
+ {
+ string name = Path.GetFileName(folder);
+ string dest = Path.Combine(destFolder, name);
+ CopyFolder(folder, dest);
+ }
+ }
+
+ public static void MoveFolder(string sourceFolder, string destFolder)
+ {
+ CreateDirectory(destFolder);
+ string[] files = Directory.GetFiles(sourceFolder);
+ foreach (string file in files)
+ {
+ string name = Path.GetFileName(file);
+ string dest = Path.Combine(destFolder, name);
+ if (File.Exists(dest))
+ {
+ File.Delete(dest);
+ }
+ File.Move(file, dest);
+ }
+ string[] folders = Directory.GetDirectories(sourceFolder);
+ foreach (string folder in folders)
+ {
+ string name = Path.GetFileName(folder);
+ string dest = Path.Combine(destFolder, name);
+ if (File.Exists(dest))
+ {
+ File.Delete(dest);
+ }
+ MoveFolder(folder, dest);
+ }
+ }
+
+ public static string Execute(string command, int seconds)
+ {
+ string output = string.Empty; //输出字符串
+ if (command != null && !command.Equals(string.Empty))
+ {
+ Process process = new Process();//创建进程对象
+ ProcessStartInfo startInfo = new ProcessStartInfo();
+ startInfo.FileName = "cmd.exe";//设定需要执行的命令
+ startInfo.Arguments = "/C " + command;//“/C”表示执行完命令后马上退出
+ startInfo.UseShellExecute = false;//不使用系统外壳程序启动
+ startInfo.RedirectStandardInput = false;//不重定向输入
+ startInfo.RedirectStandardOutput = true; //重定向输出
+ startInfo.CreateNoWindow = true;//不创建窗口
+ process.StartInfo = startInfo;
+ try
+ {
+ if (process.Start())//开始进程
+ {
+ if (seconds == 0)
+ {
+ process.WaitForExit();//这里无限等待进程结束
+ }
+ else
+ {
+ process.WaitForExit(seconds); //等待进程结束,等待时间为指定的毫秒
+ }
+ output = process.StandardOutput.ReadToEnd();//读取进程的输出
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex.Message);//捕获异常,输出异常信息
+ }
+ finally
+ {
+ if (process != null)
+ {
+ process.Close();
+ }
+ }
+ }
+ return output;
+ }
+
+ public static void CreateDirectory(string dir)
+ {
+ if (Path.HasExtension(dir))
+ {
+ dir = Path.GetDirectoryName(dir);
+ }
+ if (!Directory.Exists(dir))
+ {
+ Directory.CreateDirectory(dir);
+ }
+ }
+
+ public static string ReadAllText(string filePath, Encoding encoding = null)
+ {
+ if (encoding == null)
+ {
+ return File.ReadAllText(filePath, Encoding.UTF8);
+ }
+ else
+ {
+ return File.ReadAllText(filePath, encoding);
+ }
+ }
+
+ public static void WriteAllText(string filePathOrName, string content, Encoding encoding = null)
+ {
+ string path = Path.Combine(GetApplicationDir(), filePathOrName);
+ CreateDirectory(path);
+ if (encoding == null)
+ {
+ File.WriteAllText(path, content, Encoding.UTF8);
+ }
+ else
+ {
+ File.WriteAllText(path, content, encoding);
+ }
+ }
+
+ public static void AppendAllText(string filePathOrName, string content, Encoding encoding = null)
+ {
+ string path = Path.Combine(GetApplicationDir(), filePathOrName);
+ CreateDirectory(path);
+ List contentList = new List { content };
+ if (encoding == null)
+ {
+ File.AppendAllLines(path, contentList, Encoding.UTF8);
+ }
+ else
+ {
+ File.AppendAllLines(path, contentList, encoding);
+ }
+ }
+
+ #region 获取软件所在目录
+ public static string GetApplicationDir()
+ {
+ return AppDomain.CurrentDomain.BaseDirectory;
+ }
+ #endregion
+
+ public static string GetParentDir(string dir)
+ {
+ dir = dir.Trim(Path.DirectorySeparatorChar);
+ int last = dir.LastIndexOf(Path.DirectorySeparatorChar);
+ if (last > 0)
+ {
+ return dir.Substring(0, last);
+ }
+ return dir;
+ }
+
+ public static string GetResourceFileContent(Assembly assembly, string resourceName)
+ {
+ using (Stream stream = assembly.GetManifestResourceStream(resourceName))
+ {
+ using (StreamReader reader = new StreamReader(stream))
+ {
+ string result = reader.ReadToEnd();
+ return result;
+ }
+ }
+ }
+
+ public static Stream GetResourceFileStream(Assembly assembly, string resourceName)
+ {
+ // 调用之后要释放 stream
+ Stream stream = assembly.GetManifestResourceStream(assembly.GetCustomAttribute().Title + "." + resourceName);
+ return stream;
+ }
+
+ public static void SaveStream(Stream stream, string destPath)
+ {
+ CreateDirectory(destPath);
+ using (var fileStream = new FileStream(destPath, FileMode.Create, FileAccess.Write))
+ {
+ stream.CopyTo(fileStream);
+ }
+ }
+
+ public static long GetDirectorySize(string folderPath)
+ {
+ DirectoryInfo di = new DirectoryInfo(folderPath);
+ if (!di.Exists)
+ {
+ return 0;
+ }
+ return di.EnumerateFiles("*", SearchOption.AllDirectories).Sum(fi => fi.Length);
+ }
+
+ public static void OpenUrl(string url)
+ {
+ try
+ {
+ Process.Start(url);
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteWithTime(ex);
+ }
+ }
+
+ public static void OpenDirectory(string dir)
+ {
+ Process.Start("explorer.exe", dir);
+ }
+
+ public static string GetFileName(string dir)
+ {
+ string fileName = Path.GetFileName(dir);
+ int questionMark = fileName.IndexOf("?");
+ if (questionMark > 0)
+ {
+ fileName = fileName.Substring(0, questionMark);
+ }
+ return fileName;
+ }
+ }
+}
diff --git a/AllBase/HelperXiaoNaimao/HtmlHelper.cs b/AllBase/HelperXiaoNaimao/HtmlHelper.cs
new file mode 100644
index 0000000..47ba4e1
--- /dev/null
+++ b/AllBase/HelperXiaoNaimao/HtmlHelper.cs
@@ -0,0 +1,214 @@
+using NaiBa.Util.Extension;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+
+namespace AllBase.Helper
+{
+ public class HtmlHelper
+ {
+ public static string HtmlEncode(string html)
+ {
+ if (string.IsNullOrEmpty(html))
+ {
+ return string.Empty;
+ }
+ else
+ {
+ return HttpUtility.HtmlEncode(html);
+ }
+ }
+
+ public static string HtmlDecode(string url)
+ {
+ if (string.IsNullOrEmpty(url))
+ {
+ return string.Empty;
+ }
+ else
+ {
+ return HttpUtility.HtmlDecode(url);
+ }
+ }
+
+ ///
+ /// Unicode解码
+ ///
+ ///
+ ///
+ public static string UnicodeDecode(string html)
+ {
+ html = WebUtility.HtmlDecode(html);
+
+ Regex reUnicode = new Regex(@"\\u([0-9a-fA-F]{4})", RegexOptions.Compiled);
+ return reUnicode.Replace(html, m =>
+ {
+ short c;
+ if (short.TryParse(m.Groups[1].Value, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out c))
+ {
+ return "" + (char)c;
+ }
+ return m.Value;
+ });
+ }
+
+ #region Resove
+ public static string Resove(string html, string prefix, string subfix)
+ {
+ int inl = html.IndexOf(prefix);
+ if (inl == -1)
+ {
+ prefix = prefix.Replace("\"", "'");
+ subfix = subfix.Replace("\"", "'");
+ inl = html.IndexOf(prefix);
+ }
+ if (inl == -1)
+ {
+ return null;
+ }
+ inl += prefix.Length;
+ if (!string.IsNullOrEmpty(subfix))
+ {
+ int inl2 = html.IndexOf(subfix, inl);
+ if (inl2 == -1)
+ {
+ return null;
+ }
+ string result = html.Substring(inl, inl2 - inl);
+ return result;
+ }
+ else
+ {
+ string result = html.Substring(inl);
+ return result;
+ }
+ }
+ #endregion
+
+ #region ResoveReverse
+ public static string ResoveReverse(string html, string subfix, string prefix)
+ {
+ int inl = html.IndexOf(subfix);
+ if (inl == -1)
+ {
+ return null;
+ }
+ string subString = html.Substring(0, inl);
+ int inl2 = subString.LastIndexOf(prefix);
+ if (inl2 == -1)
+ {
+ return null;
+ }
+ string s = subString.Substring(inl2 + prefix.Length, subString.Length - inl2 - prefix.Length);
+ return s;
+ }
+ #endregion
+
+ #region ResoveList
+ public static List ResoveList(string html, string prefix, string subfix)
+ {
+ List list = new List();
+ int index = 0;
+ do
+ {
+ index = html.IndexOf(prefix, index);
+ if (index == -1)
+ {
+ break;
+ }
+ index += prefix.Length;
+ int indexEnd = html.IndexOf(subfix, index);
+ if (indexEnd > 0)
+ {
+ string content = html.Substring(index, indexEnd - index);
+ list.Add(content);
+ }
+ index = indexEnd;
+ }
+ while (index > -1);
+ return list;
+ }
+ #endregion
+
+ #region ResoveListByAT
+ public static List ResoveListByAT(string html)
+ {
+ List list = new List();
+
+ int index = html.IndexOf('@');
+ while (index > 0)
+ {
+ int indexx = html.LastIndexOf("'", index); //向前一个单引号
+ int indexy = html.IndexOf("'", index + 1); //向后一个单引号
+ string s78 = html.Substring(indexx, indexy - indexx);
+ s78 = s78.Replace("'", "");
+ list.Add(s78);
+ index = html.IndexOf('@', indexy);
+ }
+ return list;
+ }
+ #endregion
+
+ ///
+ /// 清除HTML代码
+ ///
+ ///
+ public static string ClearHtml(string html)
+ {
+ html = html.ParseToString();
+ html = Regex.Replace(html, @"(|