1拼多多接口上传及相关功能(不含部分功能) 2拼多多选品
This commit is contained in:
1 parent
ff42506091
commit
07b912e9eb
37 files changed
+21117
-206
No files matched your search
@@ -165,6 +165,12 @@
|
||||
<Compile Include="FileBase.cs" />
|
||||
<Compile Include="GetHtml.cs" />
|
||||
<Compile Include="GetProxyHtml.cs" />
|
||||
<Compile Include="HelperXiaoNaimao\DebugHelper.cs" />
|
||||
<Compile Include="HelperXiaoNaimao\FileHelper.cs" />
|
||||
<Compile Include="HelperXiaoNaimao\HtmlHelper.cs" />
|
||||
<Compile Include="HelperXiaoNaimao\HttpHelper.cs" />
|
||||
<Compile Include="HelperXiaoNaimao\LogHelper.cs" />
|
||||
<Compile Include="HelperXiaoNaimao\NaiBaGlobalConfig.cs" />
|
||||
<Compile Include="Helper\CommonSimRequest.cs" />
|
||||
<Compile Include="Helper\DataOpenSSL.cs" />
|
||||
<Compile Include="Helper\FissionDataBaseConfig.cs" />
|
||||
@@ -204,6 +210,7 @@
|
||||
<Compile Include="Model\Result\1688\_1688OneProductListInfo.cs" />
|
||||
<Compile Include="Model\Result\JST\JSTOrderInfo.cs" />
|
||||
<Compile Include="Model\Result\JST\JSTListProductSkuInfo.cs" />
|
||||
<Compile Include="Model\Result\PDDResult\ApiPddGoodsCatRuleInfo.cs" />
|
||||
<Compile Include="Model\Result\WXResult\WXAddressInfo.cs" />
|
||||
<Compile Include="Model\Result\WXResult\WXClientProductInfoLite.cs" />
|
||||
<Compile Include="Model\Result\WXResult\WXFinderTalentInfo.cs" />
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ProjectView>ProjectFiles</ProjectView>
|
||||
<ProjectView>ShowAllFiles</ProjectView>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -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'
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 随机返回指定位数的字母数字组合
|
||||
/// </summary>
|
||||
/// <param name="iLength"></param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取Unix毫秒级时间戳
|
||||
/// </summary>
|
||||
/// <returns>当前时间戳</returns>
|
||||
public static long ConvertDateTimeLong()
|
||||
{
|
||||
return (GetServerTimeString().ToUniversalTime().Ticks - 621355968000000000) / 10000;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取两个标题相似度
|
||||
/// </summary>
|
||||
/// <param name="refererTitle">参照标题</param>
|
||||
/// <param name="checkTitle">检测标题</param>
|
||||
/// <returns>相似度</returns>
|
||||
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
|
||||
|
||||
@@ -33,5 +33,9 @@ namespace AllBase.Helper
|
||||
public static string cAgentIpCode { get; } = "AFZ94w3a";
|
||||
|
||||
public static List<SameProductCheckParam> 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";
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AllBase.Model.Param.ToolsManage
|
||||
{
|
||||
public class ADSLAccountParam
|
||||
{
|
||||
public bool IsUseAdsl { get; set; }
|
||||
public string Account { get; set; }
|
||||
public string Password { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AllBase.Model.Param.ToolsManage
|
||||
{
|
||||
public class ProductMappingExportInfo : ProductMappingImportParam
|
||||
{
|
||||
/// <summary>
|
||||
/// 虚拟上家来源,淘宝,京东,苏宁
|
||||
/// </summary>
|
||||
public string FakeMappingFrom { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 找到的真实的虚假上家商品ID
|
||||
/// </summary>
|
||||
public string FakeMappingProductId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 商品真实上家数据Json
|
||||
/// </summary>
|
||||
public string ProductDataJson { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 虚拟上家产品价格
|
||||
/// </summary>
|
||||
public int FakeMappingProductPrice { get; set; }
|
||||
|
||||
public string FakeMappingProductMaxPrice { get; set; }
|
||||
|
||||
public string FakeMappingProductMinPrice { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 苏宁上家时的商家ID(搜索价格用)
|
||||
/// </summary>
|
||||
public string FakeMappingVendorId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 运费
|
||||
/// </summary>
|
||||
public string PostFee { get; set; }
|
||||
|
||||
public string MappingQuery {get;set;}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AllBase.Model.Param.ToolsManage
|
||||
{
|
||||
public class ProductMappingImportParam
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品来源,目前支持淘宝,拼多多(搜款网),阿里巴巴
|
||||
/// </summary>
|
||||
public string From { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 商品ID
|
||||
/// </summary>
|
||||
public string ProductId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 记录当商品来源为搜款网(实际为拼多多)时对应的真实Id
|
||||
/// </summary>
|
||||
public string RealProductId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 商品标题
|
||||
/// </summary>
|
||||
public string ProductTitle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上家类目
|
||||
/// </summary>
|
||||
public string CatId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 类目4
|
||||
/// </summary>
|
||||
public string CatId4 { get; set; }
|
||||
/// <summary>
|
||||
/// 类目3
|
||||
/// </summary>
|
||||
public string CatId3 { get; set; }
|
||||
/// <summary>
|
||||
/// 类目2
|
||||
/// </summary>
|
||||
public string CatId2 { get; set; }
|
||||
/// <summary>
|
||||
/// 类目1
|
||||
/// </summary>
|
||||
public string CatId1 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 商品主类目
|
||||
/// </summary>
|
||||
public string MainCid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用来搜索同款的图片网址
|
||||
/// </summary>
|
||||
public string Image { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 映射关系建立的结果
|
||||
/// </summary>
|
||||
public string MappingResult { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 微店分成推广金设置结果
|
||||
/// </summary>
|
||||
public string CPSResult { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最低价格
|
||||
/// </summary>
|
||||
public int MinPrice { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最高价格
|
||||
/// </summary>
|
||||
public int MaxPrice { get; set; }
|
||||
/// <summary>
|
||||
/// 数据来源0 是其他 1是净化数据
|
||||
/// </summary>
|
||||
public int dataSoure { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 转换成功来源 未知,Api,模拟,缓存等 统计用
|
||||
/// </summary>
|
||||
public string MappingResourceType { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AllBase.Model.Result.PDDResult
|
||||
{
|
||||
public class ApiPddGoodsCatRuleInfo
|
||||
{
|
||||
public int? input_max_spec_num { get; set; } // 0,
|
||||
public List<ApiPddProperty> properties { get; set; }
|
||||
public bool? choose_all_qualify_spec { get; set; } // false
|
||||
}
|
||||
|
||||
public class ApiPddProperty
|
||||
{
|
||||
public bool? is_sale { get; set; } // false,
|
||||
public bool? is_important { get; set; } // true,
|
||||
public bool? is_sku { get; set; } // false,
|
||||
public List<ApiPddPropertyValue> values { get; set; } // Array[11],
|
||||
public int? value_precision { get; set; } // 0,
|
||||
public int? input_max_num { get; set; } // 0,
|
||||
public bool? required { get; set; } // false,
|
||||
public object required_rule { get; set; }
|
||||
public int? required_rule_type { get; set; } // 0,
|
||||
public int? choose_max_num { get; set; } // 1,
|
||||
public string min_value { get; set; } // "",
|
||||
public bool? can_note { get; set; } // false,
|
||||
public long? ref_pid { get; set; } // 1366,
|
||||
public string name { get; set; } // "穿耳材质",
|
||||
public List<string> value_unit { get; set; } // [ "" ],
|
||||
public string max_value { get; set; } // "",
|
||||
public int? property_value_type { get; set; } // 0
|
||||
|
||||
}
|
||||
|
||||
public class ApiPddPropertyValue
|
||||
{
|
||||
public long? vid { get; set; } // 10629, // 12854,
|
||||
public string value { get; set; } // "其它", // "塑料",
|
||||
|
||||
}
|
||||
}
|
||||
@@ -99,9 +99,10 @@ namespace AllBase.Model.Result
|
||||
public string GroupName { get; set; }
|
||||
public DateTime AddTime { get; set; }
|
||||
public string LastRefreshDate { get; set; }
|
||||
public string AccessToken { get { return CurrentAuthInfo?.AccessToken; } }
|
||||
public string RefreshToken { get { return CurrentAuthInfo?.RefreshToken; } }
|
||||
public string AppKey { get { return CurrentAuthInfo?.AppKey; } }
|
||||
public string AccessToken { get { return (CurrentAuthInfo?.AccessToken).ParseToString(); } }
|
||||
public string RefreshToken { get { return (CurrentAuthInfo?.RefreshToken).ParseToString(); } }
|
||||
public string AppKey { get { return (CurrentAuthInfo?.AppKey).ParseToString(); } }
|
||||
public string AppSecret { get { return (CurrentAuthInfo?.AppSecret).ParseToString(); } }
|
||||
public DateTime AuthAddTime { get { return CurrentAuthInfo?.AddTime == null ? new DateTime() : CurrentAuthInfo.AddTime; } }
|
||||
public DateTime AuthExpiresTime { get { return CurrentAuthInfo?.ExpiresTime == null ? new DateTime() : CurrentAuthInfo.ExpiresTime; } }
|
||||
/// <summary>
|
||||
@@ -206,6 +207,7 @@ namespace AllBase.Model.Result
|
||||
public string AccessToken { get; set; } = "";
|
||||
public string RefreshToken { get; set; } = "";
|
||||
public string AppKey { get; set; } = "";
|
||||
public string AppSecret { get; set; } = "";
|
||||
public DateTime ExpiresTime { get; set; }
|
||||
public DateTime AddTime { get; set; } = DateTime.MinValue;
|
||||
public string ApiAuthStatus { get; set; } = "未授权";
|
||||
|
||||
Reference in new issue
Block a user