mirror of
https://git.oceanpay.cc/danial/kami_itunes_june.git
synced 2025-12-18 21:21:34 +00:00
feat: add System.Data.SQLite package reference and refactor data handling in API requests
This commit is contained in:
@@ -53,5 +53,6 @@
|
||||
<PackageReference Include="System.Text.Json" Version="8.0.0" />
|
||||
<PackageReference Include="System.Management" Version="8.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="System.Data.SQLite" Version="1.0.118" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -7,6 +7,7 @@ using System.Web;
|
||||
using System.Windows.Forms;
|
||||
using AppleBatch_June.Properties;
|
||||
using DotNet.Utilities;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace AppleBatch_June
|
||||
{
|
||||
@@ -46,78 +47,58 @@ namespace AppleBatch_June
|
||||
{
|
||||
using HttpHelper httpHelper = new HttpHelper();
|
||||
Stopwatch stopwatch = Stopwatch.StartNew();
|
||||
string text = "";
|
||||
lock (reqObj)
|
||||
|
||||
var requestData = new
|
||||
{
|
||||
if (reqCount >= 99)
|
||||
{
|
||||
reqCount = 0;
|
||||
}
|
||||
reqCount++;
|
||||
text = (Tools.GenerateTimeStamp() + reqCount + AppSysConfig.uid.ToString().PadLeft(4, '0') + reqCount).PadLeft(16, '0');
|
||||
}
|
||||
if (text.Length > 16)
|
||||
data = postData,
|
||||
retries = 3,
|
||||
start_now_fun = startNowFun.ToString(),
|
||||
type_ = type
|
||||
};
|
||||
|
||||
string jsonPostData = JsonConvert.SerializeObject(requestData);
|
||||
|
||||
HttpItem httpItem = new HttpItem
|
||||
{
|
||||
text = text.Substring(text.Length - 16, 16);
|
||||
}
|
||||
string mD5_ = Tools.GetMD5_32(AppSysConfig.saffMac + "by六月的风");
|
||||
string key = "7a588e60045849a1";
|
||||
string text2 = "90e7b0dc3ef2134c";
|
||||
string text3 = DESEncrypt.Encrypt(Tools.a(Tools.Toenjson(postData), key, text, operation: false, text2), text, text2).Trim();
|
||||
string text4 = "authentiString=" + HttpUtility.UrlEncode(Tools.EncodeBase64(Encoding.UTF8.GetBytes(text3)));
|
||||
string mD5_2 = Tools.GetMD5_32(text3 + type + mD5_ + "by六月的风_联系qq:1023092054");
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
webHeaderCollection.Add("timestamp", text);
|
||||
webHeaderCollection.Add("mac", mD5_);
|
||||
webHeaderCollection.Add("startNowFun", startNowFun.ToString());
|
||||
if (!string.IsNullOrEmpty(AppSysConfig.userToken))
|
||||
{
|
||||
string s = DESEncrypt.Encrypt(AppSysConfig.userToken, text, text2).Trim();
|
||||
webHeaderCollection.Add("token", HttpUtility.UrlEncode(Tools.EncodeBase64(Encoding.UTF8.GetBytes(s))));
|
||||
}
|
||||
webHeaderCollection.Add("version", FormLogin.versions);
|
||||
HttpItem httpItem = new HttpItem
|
||||
{
|
||||
URL = host + "/AppleClientApi/requestApi",
|
||||
Method = "post",
|
||||
Postdata = text4 + "&sign=" + mD5_2 + "&type=" + type
|
||||
};
|
||||
httpItem.Headers["User-Agent"] = "liuyeu_AppleBatch_June";
|
||||
httpItem.ContentType = "application/x-www-form-urlencoded";
|
||||
httpItem.Header = webHeaderCollection;
|
||||
httpItem.Timeout = 35000;
|
||||
httpItem.KeepAlive = true;
|
||||
HttpItem httpItem2 = httpItem;
|
||||
HttpResult html = httpHelper.GetHtml(httpItem2);
|
||||
URL = "http://192.168.31.94:8000/api/apple/june-post",
|
||||
Method = "post",
|
||||
Postdata = jsonPostData,
|
||||
ContentType = "application/json",
|
||||
Timeout = 35000,
|
||||
KeepAlive = true
|
||||
};
|
||||
|
||||
HttpResult html = httpHelper.GetHtml(httpItem);
|
||||
stopwatch.Stop();
|
||||
if (html.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
if (html.Header.AllKeys.Contains("sign"))
|
||||
{
|
||||
string text5 = html.Header["sign"];
|
||||
if (Tools.GetMD5_32("abc_" + html.Html + text + "by六月的风_联系qq:1023092054") != text5)
|
||||
{
|
||||
html.Html = "";
|
||||
html.StatusCode = HttpStatusCode.NotFound;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
html.Html = "";
|
||||
html.StatusCode = HttpStatusCode.NotFound;
|
||||
}
|
||||
}
|
||||
else if ((html.StatusCode == HttpStatusCode.NotFound || html.StatusCode == (HttpStatusCode)0) && !retry)
|
||||
|
||||
if (html.StatusCode != HttpStatusCode.OK && !retry)
|
||||
{
|
||||
return doPost(postData, type, retry: true);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(html.Html))
|
||||
{
|
||||
var jsonResponse = JsonConvert.DeserializeObject<dynamic>(html.Html);
|
||||
if (jsonResponse?.data != null)
|
||||
{
|
||||
html.Html = jsonResponse.data.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
}
|
||||
|
||||
APIUtlis.AppRequestHtml(html.Html);
|
||||
APIUtlis.requestUrl = "ApiNetReq_" + type;
|
||||
if (httpItem2 != null)
|
||||
|
||||
if (httpItem != null)
|
||||
{
|
||||
httpItem2.Postdata = string.Empty;
|
||||
httpItem.Postdata = string.Empty;
|
||||
}
|
||||
httpItem2 = null;
|
||||
|
||||
return html;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -613,7 +613,7 @@ namespace AppleBatch_June
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(val["Message"]);
|
||||
MessageBox.Show(val["Message"].ToString());
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace AppleBatch_June
|
||||
{
|
||||
int num = val["serverIndex"];
|
||||
dictionary2.Add("serviceIndex", num);
|
||||
dynamic datasetByString = GetDatasetByString(val["Data"]);
|
||||
dynamic datasetByString = GetDatasetByString(val["Data"].ToString());
|
||||
dynamic val2 = Tools.Todejosn<object>(datasetByString);
|
||||
string text = val2["code"];
|
||||
if (text == "0001")
|
||||
@@ -2255,7 +2255,7 @@ namespace AppleBatch_June
|
||||
if (val["Code"] == "0000")
|
||||
{
|
||||
serverIndex = val["serverIndex"];
|
||||
dynamic datasetByString = GetDatasetByString(val["Data"]);
|
||||
dynamic datasetByString = GetDatasetByString(val["Data"].ToString());
|
||||
val2 = Tools.Todejosn<object>(datasetByString);
|
||||
if (val2["msg"] == "0000")
|
||||
{
|
||||
@@ -2269,9 +2269,9 @@ namespace AppleBatch_June
|
||||
}
|
||||
return "";
|
||||
}
|
||||
string result = HttpUtility.UrlDecode(val2["signature"]);
|
||||
serverId = HttpUtility.UrlDecode(val2["serverId"]);
|
||||
userAgent = HttpUtility.UrlDecode(val2["userAgent"]);
|
||||
string result = HttpUtility.UrlDecode(val2["signature"].ToString());
|
||||
serverId = HttpUtility.UrlDecode(val2["serverId"].ToString());
|
||||
userAgent = HttpUtility.UrlDecode(val2["userAgent"].ToString());
|
||||
intptr_ = val2["adder1"];
|
||||
intPtr = val2["adder2"];
|
||||
return result;
|
||||
@@ -2302,7 +2302,7 @@ namespace AppleBatch_June
|
||||
if (val["Code"] == "0000")
|
||||
{
|
||||
serverIndex = val["serverIndex"];
|
||||
dynamic datasetByString = GetDatasetByString(val["Data"]);
|
||||
dynamic datasetByString = GetDatasetByString(val["Data"].ToString());
|
||||
val2 = Tools.Todejosn<object>(datasetByString);
|
||||
if (val2["msg"] == "0000")
|
||||
{
|
||||
@@ -2357,14 +2357,14 @@ namespace AppleBatch_June
|
||||
dynamic val = Tools.Todejosn<object>(httpResult.Html);
|
||||
if (val["Code"] == "0000")
|
||||
{
|
||||
dynamic datasetByString = GetDatasetByString(val["Data"]);
|
||||
dynamic datasetByString = GetDatasetByString(val["Data"].ToString());
|
||||
dynamic val2 = Tools.Todejosn<object>(datasetByString);
|
||||
string text = val2["msg"];
|
||||
if (text == "0000")
|
||||
{
|
||||
string result = HttpUtility.UrlDecode(val2["signature"]);
|
||||
post = HttpUtility.UrlDecode(val2["post"]);
|
||||
guid = HttpUtility.UrlDecode(val2["guid"]);
|
||||
string result = HttpUtility.UrlDecode(val2["signature"].ToString());
|
||||
post = HttpUtility.UrlDecode(val2["post"].ToString());
|
||||
guid = HttpUtility.UrlDecode(val2["guid"].ToString());
|
||||
return result;
|
||||
}
|
||||
if (text.Contains("重试") || text.Contains("失败"))
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SQLite;
|
||||
using System.Data.Common;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
@@ -19,50 +19,9 @@ namespace AppleBatch_June
|
||||
|
||||
private static void InstanceFactory()
|
||||
{
|
||||
string text = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "system.data.sqlite.dll");
|
||||
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "sqlite.interop.dll");
|
||||
string path2 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "x86/sqlite.interop.dll");
|
||||
string path3 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "x64/sqlite.interop.dll");
|
||||
if (!File.Exists(text) || (!File.Exists(path2) && !File.Exists(path)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
FileStream fileStream = new FileStream(text, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
byte[] array = new byte[fileStream.Length];
|
||||
fileStream.Read(array, 0, array.Length);
|
||||
fileStream.Close();
|
||||
string mD5_ = Tools.GetMD5_32(array);
|
||||
FileStream fileStream2 = null;
|
||||
fileStream2 = ((Environment.Is64BitOperatingSystem && File.Exists(path3)) ? new FileStream(path3, FileMode.Open, FileAccess.Read, FileShare.ReadWrite) : ((!File.Exists(path2)) ? new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite) : new FileStream(path2, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)));
|
||||
byte[] array2 = new byte[fileStream2.Length];
|
||||
fileStream2.Read(array2, 0, array2.Length);
|
||||
fileStream2.Close();
|
||||
string mD5_2 = Tools.GetMD5_32(array2);
|
||||
if (!(mD5_ == "d22a635632c52ddbcadba773e69a927d") || (!(mD5_2 == "25b81d1bde83d2299e73b57664dc3309") && !(mD5_2 == "0b03a5acd07d99daea0699e5bd8077a1")))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Assembly assembly = null;
|
||||
try
|
||||
{
|
||||
assembly = Assembly.UnsafeLoadFrom(text);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
assembly = Assembly.Load(array);
|
||||
}
|
||||
if (!(assembly != null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Type[] exportedTypes = assembly.GetExportedTypes();
|
||||
foreach (Type type in exportedTypes)
|
||||
{
|
||||
if (!(type.FullName == "System.Data.SQLite.SQLiteFactory"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
factory = (DbProviderFactory)Activator.CreateInstance(type);
|
||||
factory = SQLiteFactory.Instance;
|
||||
using DbConnection dbConnection = factory.CreateConnection();
|
||||
dbConnection.ConnectionString = str;
|
||||
using DbCommand dbCommand = dbConnection.CreateCommand();
|
||||
@@ -75,6 +34,10 @@ namespace AppleBatch_June
|
||||
}
|
||||
dbConnection.Close();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
factory = null;
|
||||
}
|
||||
}
|
||||
|
||||
static SqliteHelper()
|
||||
|
||||
Reference in New Issue
Block a user