1拼多多接口上传及相关功能(不含部分功能) 2拼多多选品
This commit is contained in:
1 parent
ff42506091
commit
07b912e9eb
37 files changed
+21117
-206
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 删除文件夹及子文件内文件
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
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<string> contentList = new List<string> { 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<AssemblyTitleAttribute>().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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unicode解码
|
||||
/// </summary>
|
||||
/// <param name="html"></param>
|
||||
/// <returns></returns>
|
||||
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<string> ResoveList(string html, string prefix, string subfix)
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
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<string> ResoveListByAT(string html)
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// 清除HTML代码
|
||||
/// </summary>
|
||||
/// <param name="html"></param>
|
||||
public static string ClearHtml(string html)
|
||||
{
|
||||
html = html.ParseToString();
|
||||
html = Regex.Replace(html, @"(<head[\w\W]*?</head>|<script[\w\W]*?</script>|<style[\w\W]*?</style>|<!--[\w\W]*?-->)", string.Empty);
|
||||
html = Regex.Replace(html, @"(<span[\w\W]*?</span>)", string.Empty);
|
||||
html = Regex.Replace(html, "(<[^>]*?>)", string.Empty);
|
||||
return html;
|
||||
}
|
||||
|
||||
public static string GetHtmlText(string html)
|
||||
{
|
||||
html = html.ParseToString();
|
||||
html = Regex.Replace(html, "<.*?>", string.Empty);
|
||||
return html;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清除HTML代码A标签
|
||||
/// </summary>
|
||||
/// <param name="html"></param>
|
||||
/// <returns></returns>
|
||||
public static string ClearHtmlA(string html)
|
||||
{
|
||||
html = html.ParseToString();
|
||||
html = Regex.Replace(html, "(</?a[^>]*>)", "", RegexOptions.IgnoreCase);
|
||||
return html.Trim();
|
||||
}
|
||||
|
||||
public static string AddEscapeCharacter(string html)
|
||||
{
|
||||
html = html.ParseToString();
|
||||
html = html.Replace("\"", "\\\"");
|
||||
html = html.Replace("'", "\\'");
|
||||
return html;
|
||||
}
|
||||
|
||||
public static string TrimBOM(string html)
|
||||
{
|
||||
html = html.Trim(new char[] { '\uFEFF' });
|
||||
return html;
|
||||
}
|
||||
|
||||
public static string TrimJsonp(string json)
|
||||
{
|
||||
int start = json.IndexOf("{");
|
||||
int end = json.LastIndexOf("}");
|
||||
if (start > 0 && end > 0)
|
||||
{
|
||||
return json.Substring(start, end - start + 1);
|
||||
}
|
||||
return json;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,145 @@
|
||||
using AllBase.Extension;
|
||||
using NaiBa.Util.Extension;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AllBase.Helper
|
||||
{
|
||||
public class LogHelper
|
||||
{
|
||||
private static object lockHelper = new object();
|
||||
|
||||
#region 写文本日志
|
||||
/// <summary>
|
||||
/// 写日志 异步
|
||||
/// 默认路径:根目录/Log/yyyy-MM/
|
||||
/// 默认文件:yyyy-MM-dd.log
|
||||
/// </summary>
|
||||
/// <param name="logContent">日志内容 自动附加时间</param>
|
||||
public static void Write(string logContent)
|
||||
{
|
||||
string logPath = DateTime.Now.ToString("yyyy-MM");
|
||||
Write(logPath, logContent);
|
||||
}
|
||||
|
||||
public static void WriteWithTime(string logContent)
|
||||
{
|
||||
string logPath = DateTime.Now.ToString("yyyy-MM");
|
||||
logContent = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + Environment.NewLine + logContent;
|
||||
Write(logPath, logContent);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 写异常日志
|
||||
/// <summary>
|
||||
/// 写异常日志
|
||||
/// </summary>
|
||||
/// <param name="ex"></param>
|
||||
public static void Write(Exception ex)
|
||||
{
|
||||
string logContent = string.Empty;
|
||||
string logPath = DateTime.Now.ToString("yyyy-MM");
|
||||
logContent += GetExceptionMessage(ex);
|
||||
Write(logPath, logContent);
|
||||
}
|
||||
|
||||
public static void WriteWithTime(Exception ex, string messageExtend = "")
|
||||
{
|
||||
string logContent = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + Environment.NewLine;
|
||||
string logPath = DateTime.Now.ToString("yyyy-MM");
|
||||
logContent += GetExceptionMessage(ex, messageExtend);
|
||||
Write(logPath, logContent);
|
||||
}
|
||||
|
||||
private static string GetExceptionMessage(Exception ex, string messageExtend = "")
|
||||
{
|
||||
string message = string.Empty;
|
||||
if (ex != null)
|
||||
{
|
||||
message += ex.Message;
|
||||
message += Environment.NewLine;
|
||||
if (!string.IsNullOrEmpty(messageExtend))
|
||||
{
|
||||
message += messageExtend;
|
||||
message += Environment.NewLine;
|
||||
}
|
||||
Exception originalException = ex.GetOriginalException();
|
||||
if (originalException != null)
|
||||
{
|
||||
if (originalException.Message != ex.Message)
|
||||
{
|
||||
message += originalException.Message;
|
||||
message += Environment.NewLine;
|
||||
}
|
||||
}
|
||||
message += ex.StackTrace;
|
||||
message += Environment.NewLine;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 写日志到指定路径
|
||||
/// <summary>
|
||||
/// 写日志 异步
|
||||
/// 默认文件:yyyy-MM-dd.log
|
||||
/// </summary>
|
||||
/// <param name="logPath">日志目录[默认程序根目录\Log\下添加,故使用相对路径,如:营销任务]</param>
|
||||
/// <param name="logContent">日志内容 自动附加时间</param>
|
||||
public static void Write(string logPath, string logContent)
|
||||
{
|
||||
string logFileName = DateTime.Now.ToString("yyyy-MM-dd") + ".log";
|
||||
Write(logPath, logFileName, logContent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 写日志 异步
|
||||
/// </summary>
|
||||
/// <param name="logPath">日志目录</param>
|
||||
/// <param name="logFileName">日志文件名</param>
|
||||
/// <param name="logContent">日志内容 自动附加时间</param>
|
||||
public static void Write(string logPath, string logFileName, string logContent)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(logContent))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(logPath))
|
||||
{
|
||||
logPath = Path.Combine(FileHelper.GetApplicationDir(), NaiBaGlobalConfig.Log, DateTime.Now.ToString("yyyy-MM"));
|
||||
}
|
||||
else
|
||||
{
|
||||
logPath = Path.Combine(FileHelper.GetApplicationDir(), NaiBaGlobalConfig.Log, logPath.Trim('\\'));
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(logFileName))
|
||||
{
|
||||
logFileName = DateTime.Now.ToString("yyyy-MM-dd") + ".log";
|
||||
}
|
||||
if (!Directory.Exists(logPath))
|
||||
{
|
||||
Directory.CreateDirectory(logPath);
|
||||
}
|
||||
string fileName = Path.Combine(logPath, logFileName);
|
||||
Action taskAction = () =>
|
||||
{
|
||||
lock (lockHelper)
|
||||
{
|
||||
using (StreamWriter sw = File.AppendText(fileName))
|
||||
{
|
||||
sw.WriteLine(logContent + Environment.NewLine);
|
||||
sw.Flush();
|
||||
sw.Close();
|
||||
}
|
||||
}
|
||||
};
|
||||
Task task = new Task(taskAction);
|
||||
task.Start();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
using NaiBa.Util.Extension;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AllBase.Helper
|
||||
{
|
||||
public class NaiBaGlobalConfig
|
||||
{
|
||||
public static bool IsDevelopment { get; set; } // 判断是否是开发环境
|
||||
public static bool IsNewFeature { get; set; }
|
||||
public static bool IsNotNeedLogin = false;
|
||||
public static DateTime DefaultDateTime = "2000-01-01 00:00:00".ParseToDateTime();
|
||||
public static string Proxy = "127.0.0.1:8888"; // 请求Fiddler代理,仅做开发测试使用
|
||||
public static string VersionUrl = "https://update.qixiaoke.com/updatex/kingdragorse.php";
|
||||
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 List<string> NoProxyDomainList = new List<string>(); // 不走系统代理的域名
|
||||
public static string ResourcesFileRelativeDir = @"Resources\file\";
|
||||
public static string ResourcesFileAbsolutePath = Path.Combine(FileHelper.GetApplicationDir(), ResourcesFileRelativeDir);
|
||||
|
||||
public const string Data = "data"; // data 文件目录
|
||||
public const string Config = "config"; // config 文件目录
|
||||
public const string Image = "image"; // image 文件目录
|
||||
public const string Log = "log";
|
||||
public const string Cache = "cache"; // cache 文件目录
|
||||
public const int MillisecondsClose = 3000; // 默认3秒钟自动关闭信息弹出框
|
||||
public const string DefaultDateFormat = "yyyy-MM-dd";
|
||||
public const string DefaultTimeFormat = "HH:mm:ss";
|
||||
public const string DefaultDateTimeFormat = "yyyy-MM-dd HH:mm:ss";
|
||||
public const string NoYearDateTimeFormat = "MM-dd HH:mm:ss";
|
||||
public const string HtmlBR = "<br>";
|
||||
|
||||
public const string ConfirmDeleteText = "确认删除[{0}]条数据吗?";
|
||||
public const string ConfirmClearText = "确认清空吗?";
|
||||
public const string NoSelectDataText = "您还未选择任何数据";
|
||||
public const string NoDataText = "没有需要处理的数据";
|
||||
public const string ProcessingText = "正在{0}...";
|
||||
|
||||
public const string ChinaCountryCode = "cn";
|
||||
|
||||
public const char NumberSignSplitChar = '#';
|
||||
public const char SplitChar = '♯';
|
||||
public const char Tab = '\t';
|
||||
|
||||
public static List<string> UserAgentList { get; set; } // https://developers.whatismybrowser.com/useragents/explore/software_name/chrome/ $(".useragent").each(function(){console.log($(this).text()+'\r\n')});
|
||||
|
||||
#region 全局委托
|
||||
public static Func<string, string> EvaluateScript; // 执行 JavaScript
|
||||
#endregion
|
||||
|
||||
|
||||
#region 开发代理
|
||||
public static IWebProxy GetDevelopProxy(string url = "")
|
||||
{
|
||||
// 请求Fiddler代理,仅做开发测试使用
|
||||
if (IsDevelopment && !string.IsNullOrEmpty(Proxy) && Process.GetProcessesByName("FF").Length > 0)
|
||||
{
|
||||
var proxyArr = Proxy.Split(':');
|
||||
return new WebProxy(proxyArr[0], proxyArr[1].ParseToInt());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
{
|
||||
string host = new Uri(url).Host;
|
||||
if (NoProxyDomainList.Contains(host))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return WebRequest.DefaultWebProxy;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 计算软件版本
|
||||
public static string GetVersionString(int major, int minor)
|
||||
{
|
||||
string versionNo = major + "." + minor.ToString().PadLeft(2, '0');
|
||||
return versionNo;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user