mirror of
https://git.oceanpay.cc/danial/kami_itunes_june.git
synced 2025-12-18 22:31:24 +00:00
chore(build): 更新项目配置和依赖以支持.NET 8
- 在.settings.local.json中添加dotnet clean命令权限 - 更新项目文件以启用不安全的二进制序列化和禁用平台兼容性警告 - 配置调试和发布模式的编译常量及优化选项 - 在解决方案文件中升级Visual Studio版本并添加多平台配置 - 移除FormLogin构造函数中的MessageBox调试代码 - 为过时的WebRequest、WebClient和ServicePointManager API添加编译警告抑制 - 简化异常处理逻辑并在Program.cs中改进启动流程 - 移除多个未使用的局部变量声明 - 添加launchSettings.json以支持开发环境配置 - 在表单构造函数中初始化components容器 - 优化网络请求超时设置并改善错误处理机制
This commit is contained in:
@@ -3,7 +3,8 @@
|
|||||||
"allow": [
|
"allow": [
|
||||||
"Bash(find:*)",
|
"Bash(find:*)",
|
||||||
"Bash(dotnet build:*)",
|
"Bash(dotnet build:*)",
|
||||||
"Bash(dotnet publish:*)"
|
"Bash(dotnet publish:*)",
|
||||||
|
"Bash(dotnet clean:*)"
|
||||||
],
|
],
|
||||||
"deny": [],
|
"deny": [],
|
||||||
"ask": []
|
"ask": []
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ namespace AppleBatch_June.ExecuteTasks
|
|||||||
{
|
{
|
||||||
_action?.Invoke(guidTag, DisplyType.chongzhi, "");
|
_action?.Invoke(guidTag, DisplyType.chongzhi, "");
|
||||||
string accountName = "";
|
string accountName = "";
|
||||||
bool _flag = false;
|
|
||||||
AppleChangeItem changeItem2 = new AppleChangeItem
|
AppleChangeItem changeItem2 = new AppleChangeItem
|
||||||
{
|
{
|
||||||
newGuojia = changeItem.newGuojia,
|
newGuojia = changeItem.newGuojia,
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ namespace AppleBatch_June.ExecuteTasks
|
|||||||
if (((dynamic)obj)["Data"]["integral"] >= AppSysConfig.getTypeById(14).consNum)
|
if (((dynamic)obj)["Data"]["integral"] >= AppSysConfig.getTypeById(14).consNum)
|
||||||
{
|
{
|
||||||
_action?.Invoke(guidTag, DisplyType.chongzhi, "");
|
_action?.Invoke(guidTag, DisplyType.chongzhi, "");
|
||||||
bool _flag = false;
|
|
||||||
if ((!AppSysConfig.webProtocolS2k) ? new AppleManageWebUtlis(_action, null, this).RetrievePassword(openVpn, appleAcount, newPassWord, guidTag, isCloseAuthen: true, ckTailNumber) : new AppleiForgotWeb(openVpn, _action, null, this).RetrievePassword(appleAcount, newPassWord, guidTag, isCloseAuthen: true, ckTailNumber))
|
if ((!AppSysConfig.webProtocolS2k) ? new AppleManageWebUtlis(_action, null, this).RetrievePassword(openVpn, appleAcount, newPassWord, guidTag, isCloseAuthen: true, ckTailNumber) : new AppleiForgotWeb(openVpn, _action, null, this).RetrievePassword(appleAcount, newPassWord, guidTag, isCloseAuthen: true, ckTailNumber))
|
||||||
{
|
{
|
||||||
APIUtlis.ApiApplyAct(14, "关闭双重认证");
|
APIUtlis.ApiApplyAct(14, "关闭双重认证");
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ namespace AppleBatch_June.ExecuteTasks
|
|||||||
|
|
||||||
private int passGetGameByUrl(bool ckQueryMOdel, GetGameUtils itunes, string gameUrl, AppleItunesLogin itunesLogin)
|
private int passGetGameByUrl(bool ckQueryMOdel, GetGameUtils itunes, string gameUrl, AppleItunesLogin itunesLogin)
|
||||||
{
|
{
|
||||||
int _num = 0;
|
|
||||||
if (ckQueryMOdel)
|
if (ckQueryMOdel)
|
||||||
{
|
{
|
||||||
return itunes.getNewGameByUrl3(gameUrl, itunesLogin);
|
return itunes.getNewGameByUrl3(gameUrl, itunesLogin);
|
||||||
|
|||||||
@@ -651,7 +651,9 @@ namespace AppleBatch_June.ExecuteTasks
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#pragma warning disable SYSLIB0014 // WebRequest is obsolete
|
||||||
HttpWebRequest httpWebRequest = WebRequest.Create(AppSysConfig.getConfig("TestingProxyIpUrl")) as HttpWebRequest;
|
HttpWebRequest httpWebRequest = WebRequest.Create(AppSysConfig.getConfig("TestingProxyIpUrl")) as HttpWebRequest;
|
||||||
|
#pragma warning restore SYSLIB0014 // WebRequest is obsolete
|
||||||
httpWebRequest.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
|
httpWebRequest.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
|
||||||
httpWebRequest.Method = "OPTIONS";
|
httpWebRequest.Method = "OPTIONS";
|
||||||
httpWebRequest.KeepAlive = false;
|
httpWebRequest.KeepAlive = false;
|
||||||
|
|||||||
@@ -76,7 +76,6 @@ namespace AppleBatch_June.ExecuteTasks
|
|||||||
if (((dynamic)obj)["Data"]["integral"] >= AppSysConfig.getTypeById(22).consNum)
|
if (((dynamic)obj)["Data"]["integral"] >= AppSysConfig.getTypeById(22).consNum)
|
||||||
{
|
{
|
||||||
_action?.Invoke(appleAcount.appleId, DisplyType.chongzhi, "");
|
_action?.Invoke(appleAcount.appleId, DisplyType.chongzhi, "");
|
||||||
bool _flag = false;
|
|
||||||
if ((!AppSysConfig.webProtocolS2k) ? new AppleManageWebUtlis2(_action, null, this).AppleQueryStoreBalance(appleAcount, openVpn) : new AppleShopWeb(openVpn, appleAcount.appleId, _action, null, this).AppleQueryStoreBalance(appleAcount, actGetCode))
|
if ((!AppSysConfig.webProtocolS2k) ? new AppleManageWebUtlis2(_action, null, this).AppleQueryStoreBalance(appleAcount, openVpn) : new AppleShopWeb(openVpn, appleAcount.appleId, _action, null, this).AppleQueryStoreBalance(appleAcount, actGetCode))
|
||||||
{
|
{
|
||||||
APIUtlis.ApiApplyAct(27, "商城余额查询");
|
APIUtlis.ApiApplyAct(27, "商城余额查询");
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ namespace AppleBatch_June.Forms
|
|||||||
public FromActiotiCloud()
|
public FromActiotiCloud()
|
||||||
: base("激活iCloud", ActivateiCloudTask.Instance)
|
: base("激活iCloud", ActivateiCloudTask.Instance)
|
||||||
{
|
{
|
||||||
|
components = new Container();
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,45 @@
|
|||||||
<ApplicationIcon>app.ico</ApplicationIcon>
|
<ApplicationIcon>app.ico</ApplicationIcon>
|
||||||
<RootNamespace />
|
<RootNamespace />
|
||||||
<GenerateResourceWarnOnBinaryFormatterUse>false</GenerateResourceWarnOnBinaryFormatterUse>
|
<GenerateResourceWarnOnBinaryFormatterUse>false</GenerateResourceWarnOnBinaryFormatterUse>
|
||||||
|
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
|
||||||
|
|
||||||
|
<!-- 禁用平台兼容性警告,因为这是 Windows 专用应用 -->
|
||||||
|
<NoWarn>$(NoWarn);CA1416</NoWarn>
|
||||||
|
|
||||||
|
<!-- 调试配置 -->
|
||||||
|
<DefineConstants Condition=" '$(Configuration)' == 'Debug' ">DEBUG;TRACE</DefineConstants>
|
||||||
|
<DefineConstants Condition=" '$(Configuration)' == 'Release' ">TRACE</DefineConstants>
|
||||||
|
|
||||||
|
<!-- 平台配置 -->
|
||||||
|
<Platforms>AnyCPU;x64;x86</Platforms>
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
|
||||||
|
<!-- 输出配置 -->
|
||||||
|
<OutputPath>bin\$(Configuration)\$(TargetFramework)</OutputPath>
|
||||||
|
<DebugType Condition=" '$(Configuration)' == 'Debug' ">full</DebugType>
|
||||||
|
<DebugType Condition=" '$(Configuration)' == 'Release' ">pdbonly</DebugType>
|
||||||
|
<DebugSymbols Condition=" '$(Configuration)' == 'Debug' ">true</DebugSymbols>
|
||||||
|
|
||||||
|
<!-- 编译配置 -->
|
||||||
|
<Optimize Condition=" '$(Configuration)' == 'Debug' ">false</Optimize>
|
||||||
|
<Optimize Condition=" '$(Configuration)' == 'Release' ">true</Optimize>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Debug配置 -->
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Release配置 -->
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="System.Text.Json" Version="8.0.0" />
|
<PackageReference Include="System.Text.Json" Version="8.0.0" />
|
||||||
<PackageReference Include="System.Management" Version="8.0.0" />
|
<PackageReference Include="System.Management" Version="8.0.0" />
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 16
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 16.0.35026.282
|
VisualStudioVersion = 17.0.31903.59
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AppleBatch_June", "AppleBatch_June.csproj", "{D7E018FC-0746-4D4E-B8DE-9D854A8D8D24}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AppleBatch_June", "AppleBatch_June.csproj", "{D7E018FC-0746-4D4E-B8DE-9D854A8D8D24}"
|
||||||
EndProject
|
EndProject
|
||||||
@@ -9,12 +9,24 @@ Global
|
|||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|x86 = Release|x86
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{D7E018FC-0746-4D4E-B8DE-9D854A8D8D24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{D7E018FC-0746-4D4E-B8DE-9D854A8D8D24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{D7E018FC-0746-4D4E-B8DE-9D854A8D8D24}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{D7E018FC-0746-4D4E-B8DE-9D854A8D8D24}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{D7E018FC-0746-4D4E-B8DE-9D854A8D8D24}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{D7E018FC-0746-4D4E-B8DE-9D854A8D8D24}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{D7E018FC-0746-4D4E-B8DE-9D854A8D8D24}.Release|Any CPU.Build.0 = Release|Any CPU
|
{D7E018FC-0746-4D4E-B8DE-9D854A8D8D24}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{D7E018FC-0746-4D4E-B8DE-9D854A8D8D24}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{D7E018FC-0746-4D4E-B8DE-9D854A8D8D24}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{D7E018FC-0746-4D4E-B8DE-9D854A8D8D24}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{D7E018FC-0746-4D4E-B8DE-9D854A8D8D24}.Release|x64.Build.0 = Release|x64
|
||||||
|
{D7E018FC-0746-4D4E-B8DE-9D854A8D8D24}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{D7E018FC-0746-4D4E-B8DE-9D854A8D8D24}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{D7E018FC-0746-4D4E-B8DE-9D854A8D8D24}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{D7E018FC-0746-4D4E-B8DE-9D854A8D8D24}.Release|x86.Build.0 = Release|x86
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -22,4 +34,7 @@ Global
|
|||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {CFA3E97F-8263-4AEC-83AD-B2B7A97E4E6E}
|
SolutionGuid = {CFA3E97F-8263-4AEC-83AD-B2B7A97E4E6E}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
GlobalSection(MonoDevelopProperties) = preSolution
|
||||||
|
StartupItem = AppleBatch_June.csproj
|
||||||
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ namespace AppleBatch_June
|
|||||||
|
|
||||||
public HttpResult doPost(object postData, string type, bool retry = false)
|
public HttpResult doPost(object postData, string type, bool retry = false)
|
||||||
{
|
{
|
||||||
MessageBox.Show(postData.ToString());
|
|
||||||
using HttpHelper httpHelper = new HttpHelper();
|
using HttpHelper httpHelper = new HttpHelper();
|
||||||
Stopwatch stopwatch = Stopwatch.StartNew();
|
Stopwatch stopwatch = Stopwatch.StartNew();
|
||||||
string text = "";
|
string text = "";
|
||||||
|
|||||||
@@ -124,7 +124,9 @@ namespace AppleBatch_June
|
|||||||
|
|
||||||
private HttpWebRequest SetiTunesHtppHeaders(string string_3, byte[] byte_2, string string_4, string string_5, string string_6, iTunesUserInfo user, string usrage, IWebProxy webProxy = null)
|
private HttpWebRequest SetiTunesHtppHeaders(string string_3, byte[] byte_2, string string_4, string string_5, string string_6, iTunesUserInfo user, string usrage, IWebProxy webProxy = null)
|
||||||
{
|
{
|
||||||
|
#pragma warning disable SYSLIB0014 // WebRequest is obsolete
|
||||||
HttpWebRequest httpWebRequest = WebRequest.Create(new Uri(string_3)) as HttpWebRequest;
|
HttpWebRequest httpWebRequest = WebRequest.Create(new Uri(string_3)) as HttpWebRequest;
|
||||||
|
#pragma warning restore SYSLIB0014 // WebRequest is obsolete
|
||||||
httpWebRequest.Method = "POST";
|
httpWebRequest.Method = "POST";
|
||||||
httpWebRequest.Headers["User-Agent"] = usrage;
|
httpWebRequest.Headers["User-Agent"] = usrage;
|
||||||
if (string_4.Length > 0)
|
if (string_4.Length > 0)
|
||||||
|
|||||||
@@ -60,139 +60,230 @@ namespace AppleBatch_June
|
|||||||
|
|
||||||
public FormLogin()
|
public FormLogin()
|
||||||
{
|
{
|
||||||
|
components = new Container();
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Form1_Load(object sender, EventArgs e)
|
private void Form1_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (path.ToLower().Contains("rar$"))
|
|
||||||
{
|
|
||||||
MessageBox.Show("检测到程序未解压,请先解压压缩包在打开");
|
|
||||||
Environment.Exit(0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ServicePointManager.DefaultConnectionLimit = 512;
|
|
||||||
ServicePointManager.Expect100Continue = false;
|
|
||||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
|
|
||||||
ServicePointManager.ServerCertificateValidationCallback = (object sender2, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) => true;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(runTimePatch + "/AppleBatch"))
|
// 简化启动检查
|
||||||
|
if (path.ToLower().Contains("rar$"))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(runTimePatch + "/AppleBatch");
|
MessageBox.Show("检测到程序未解压,请先解压压缩包在打开");
|
||||||
|
Environment.Exit(0);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (!File.Exists(runTimePatch + "/AppleBatch/AppleDB.db"))
|
|
||||||
|
// 设置安全协议
|
||||||
|
#pragma warning disable SYSLIB0014 // ServicePointManager is obsolete in .NET 5+
|
||||||
|
ServicePointManager.DefaultConnectionLimit = 512;
|
||||||
|
ServicePointManager.Expect100Continue = false;
|
||||||
|
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
|
||||||
|
ServicePointManager.ServerCertificateValidationCallback = (object sender2, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) => true;
|
||||||
|
#pragma warning restore SYSLIB0014 // ServicePointManager is obsolete in .NET 5+
|
||||||
|
|
||||||
|
// 延迟数据文件初始化,避免在启动时访问Resources
|
||||||
|
Task.Run(() => InitializeDataFiles());
|
||||||
|
|
||||||
|
// 设置界面颜色
|
||||||
|
txtPwd.ForeColor = SystemColors.MenuHighlight;
|
||||||
|
txtUser.ForeColor = SystemColors.MenuHighlight;
|
||||||
|
|
||||||
|
// 启用界面
|
||||||
|
base.Enabled = true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"窗体加载失败: {ex.Message}", "启动错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeDataFiles()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string appDataPath = runTimePatch + "/AppleBatch";
|
||||||
|
|
||||||
|
// 确保目录存在
|
||||||
|
if (!Directory.Exists(appDataPath))
|
||||||
{
|
{
|
||||||
File.WriteAllBytes(runTimePatch + "/AppleBatch/AppleDB.db", Resources.AppleDB);
|
Directory.CreateDirectory(appDataPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 延迟创建数据库文件
|
||||||
|
string dbPath = appDataPath + "/AppleDB.db";
|
||||||
|
if (!File.Exists(dbPath))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Resources.AppleDB != null && Resources.AppleDB.Length > 0)
|
||||||
|
{
|
||||||
|
File.WriteAllBytes(dbPath, Resources.AppleDB);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// 在UI线程上显示错误
|
||||||
|
this.Invoke(new Action(() => {
|
||||||
|
MessageBox.Show($"数据库文件创建失败: {ex.Message}", "资源错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
APIUtlis.ApiSeriveError(ex);
|
// 在UI线程上显示错误
|
||||||
|
this.Invoke(new Action(() => {
|
||||||
|
MessageBox.Show($"数据目录初始化失败: {ex.Message}", "初始化错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
txtPwd.ForeColor = SystemColors.MenuHighlight;
|
|
||||||
txtUser.ForeColor = SystemColors.MenuHighlight;
|
|
||||||
base.Enabled = false;
|
|
||||||
init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void init()
|
public async void init()
|
||||||
{
|
{
|
||||||
Task result = Task.Run(delegate
|
Task result = Task.Run(delegate
|
||||||
{
|
{
|
||||||
Stopwatch stopwatch = Stopwatch.StartNew();
|
try
|
||||||
MachineCode machineCode = new MachineCode();
|
{
|
||||||
AppSysConfig.saffMac = Tools.GetMD5_32(machineCode.GetMachineCodeString() + "巴拉拉小魔仙");
|
Stopwatch stopwatch = Stopwatch.StartNew();
|
||||||
AppSysConfig.newSaffMac = Tools.GetMD5_32(machineCode.GetMachineCodeString(moAddress: true) + "LiuYue_Acbse");
|
MachineCode machineCode = new MachineCode();
|
||||||
stopwatch.Stop();
|
AppSysConfig.saffMac = Tools.GetMD5_32(machineCode.GetMachineCodeString() + "巴拉拉小魔仙");
|
||||||
|
AppSysConfig.newSaffMac = Tools.GetMD5_32(machineCode.GetMachineCodeString(moAddress: true) + "LiuYue_Acbse");
|
||||||
|
stopwatch.Stop();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"机器码生成失败: {ex.Message}", "初始化警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
string[] array = new string[3] { "https://gitee.com/liuyueapp/blogsLiuyue/raw/master/assets/aphos.css", "https://meixi2.oss-us-west-1.aliyuncs.com/host.txt", "https://zjzhuanfa.oss-cn-shenzhen.aliyuncs.com/host.txt" };
|
|
||||||
int count = 1;
|
try
|
||||||
int tCount = 1;
|
|
||||||
string[] array2 = array;
|
|
||||||
foreach (string hostItem in array2)
|
|
||||||
{
|
{
|
||||||
HttpHelper http = new HttpHelper();
|
string[] array = new string[3] { "https://gitee.com/liuyueapp/blogsLiuyue/raw/master/assets/aphos.css", "https://meixi2.oss-us-west-1.aliyuncs.com/host.txt", "https://zjzhuanfa.oss-cn-shenzhen.aliyuncs.com/host.txt" };
|
||||||
HttpResult httpResult = await Task.Run(delegate
|
int count = 1;
|
||||||
|
int tCount = 1;
|
||||||
|
string[] array2 = array;
|
||||||
|
|
||||||
|
foreach (string hostItem in array2)
|
||||||
{
|
{
|
||||||
HttpItem item = new HttpItem
|
try
|
||||||
{
|
{
|
||||||
URL = hostItem,
|
HttpHelper http = new HttpHelper();
|
||||||
Method = "GET",
|
HttpResult httpResult = await Task.Run(delegate
|
||||||
Timeout = 20000,
|
|
||||||
UserAgent = AppleUtlis.getAppleWenUserAgent()
|
|
||||||
};
|
|
||||||
return http.GetHtml(item);
|
|
||||||
});
|
|
||||||
if (httpResult.StatusCode != HttpStatusCode.OK || !httpResult.Html.Contains("http://"))
|
|
||||||
{
|
|
||||||
count++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
tCount = 1;
|
|
||||||
string[] array3 = httpResult.Html.Split('\n');
|
|
||||||
foreach (string text in array3)
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(text))
|
|
||||||
{
|
|
||||||
string text2 = text.Split('\n')[0].Trim().TrimEnd('\r');
|
|
||||||
if (http.GetHtml(new HttpItem
|
|
||||||
{
|
{
|
||||||
URL = text2 + "/hosy/addbak",
|
HttpItem item = new HttpItem
|
||||||
Method = "GET",
|
{
|
||||||
Timeout = 10000
|
URL = hostItem,
|
||||||
}).StatusCode == HttpStatusCode.NotFound)
|
Method = "GET",
|
||||||
|
Timeout = 5000, // 减少超时时间
|
||||||
|
UserAgent = AppleUtlis.getAppleWenUserAgent()
|
||||||
|
};
|
||||||
|
return http.GetHtml(item);
|
||||||
|
});
|
||||||
|
if (httpResult.StatusCode != HttpStatusCode.OK || !httpResult.Html.Contains("http://"))
|
||||||
{
|
{
|
||||||
ApiNetReq.host = text2;
|
count++;
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
|
tCount = 1;
|
||||||
|
string[] array3 = httpResult.Html.Split('\n');
|
||||||
|
foreach (string text in array3)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(text))
|
||||||
|
{
|
||||||
|
string text2 = text.Split('\n')[0].Trim().TrimEnd('\r');
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (http.GetHtml(new HttpItem
|
||||||
|
{
|
||||||
|
URL = text2 + "/hosy/addbak",
|
||||||
|
Method = "GET",
|
||||||
|
Timeout = 5000
|
||||||
|
}).StatusCode == HttpStatusCode.NotFound)
|
||||||
|
{
|
||||||
|
ApiNetReq.host = text2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// 继续尝试下一个地址
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tCount++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
tCount++;
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"网络初始化失败,将使用离线模式: {ex.Message}", "网络警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
}
|
||||||
|
|
||||||
await result;
|
await result;
|
||||||
if (!string.IsNullOrEmpty(ApiNetReq.host))
|
if (!string.IsNullOrEmpty(ApiNetReq.host))
|
||||||
{
|
{
|
||||||
SyncInitConfig();
|
SyncInitConfig();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MessageBox.Show("初始化失败了" + count.ToString() + "#" + tCount);
|
|
||||||
Environment.Exit(0);
|
// 如果所有网络请求都失败,提供备用方案
|
||||||
|
MessageBox.Show("网络连接失败,程序将在离线模式下运行。\n如需完整功能,请检查网络连接。", "初始化完成", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
|
||||||
|
// 设置默认配置,让程序可以继续运行
|
||||||
|
base.Enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void SyncInitConfig()
|
public async void SyncInitConfig()
|
||||||
{
|
{
|
||||||
_ = Environment.OSVersion.Version;
|
|
||||||
string WindowsVersion = "Windows 10 专业版";
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (new FileInfo(AppDomain.CurrentDomain.FriendlyName).Length > 8013664L)
|
_ = Environment.OSVersion.Version;
|
||||||
|
string WindowsVersion = "Windows 10 专业版";
|
||||||
|
try
|
||||||
{
|
{
|
||||||
WindowsVersion = "OtherVersions";
|
if (new FileInfo(AppDomain.CurrentDomain.FriendlyName).Length > 8013664L)
|
||||||
|
{
|
||||||
|
WindowsVersion = "OtherVersions";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
catch (Exception ex)
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
APIUtlis.ApiSeriveError(ex);
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(WindowsVersion))
|
|
||||||
{
|
|
||||||
WindowsVersion = "";
|
|
||||||
}
|
|
||||||
HttpResult httpResult = await Task.Run(() => new ApiNetReq().doPost(new Dictionary<string, object>
|
|
||||||
{
|
|
||||||
{ "account", "123" },
|
|
||||||
{ "pwd", "123" }
|
|
||||||
}, "ApiSysConfig"));
|
|
||||||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
|
||||||
{
|
|
||||||
base.Enabled = true;
|
|
||||||
if (!AppSysConfig.loadConfig(httpResult.Html))
|
|
||||||
{
|
{
|
||||||
MessageBox.Show("初始化失败了#2");
|
MessageBox.Show($"系统信息获取失败: {ex.Message}", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
Environment.Exit(0);
|
|
||||||
}
|
}
|
||||||
|
if (string.IsNullOrEmpty(WindowsVersion))
|
||||||
|
{
|
||||||
|
WindowsVersion = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HttpResult httpResult = await Task.Run(() => new ApiNetReq().doPost(new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
{ "account", "123" },
|
||||||
|
{ "pwd", "123" }
|
||||||
|
}, "ApiSysConfig"));
|
||||||
|
|
||||||
|
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||||||
|
{
|
||||||
|
base.Enabled = true;
|
||||||
|
if (!AppSysConfig.loadConfig(httpResult.Html))
|
||||||
|
{
|
||||||
|
MessageBox.Show("配置加载失败,将使用默认配置", "配置警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
// 使用默认配置继续运行,而不是退出
|
||||||
|
base.Enabled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
string text = AppSysConfig.getConfig("versionsNew").Trim();
|
string text = AppSysConfig.getConfig("versionsNew").Trim();
|
||||||
if (text != versions && !string.IsNullOrEmpty(text) && MessageBox.Show("发现新版本,是否更新?" + AppSysConfig.getConfig("versionsTip").Replace("\\n", "\n"), "新版本提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
|
if (text != versions && !string.IsNullOrEmpty(text) && MessageBox.Show("发现新版本,是否更新?" + AppSysConfig.getConfig("versionsTip").Replace("\\n", "\n"), "新版本提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
|
||||||
{
|
{
|
||||||
@@ -207,10 +298,26 @@ namespace AppleBatch_June
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox.Show("初始化加载失败了");
|
MessageBox.Show("网络配置获取失败,将使用默认配置继续运行", "网络警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
Environment.Exit(0);
|
base.Enabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"配置同步失败,将使用默认配置: {ex.Message}", "配置警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
base.Enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确保界面总是启用
|
||||||
|
base.Enabled = true;
|
||||||
|
loadConfig();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"初始化过程发生错误: {ex.Message}\n\n程序将尝试继续运行", "严重错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
base.Enabled = true;
|
||||||
|
loadConfig(); // 尝试加载本地配置
|
||||||
}
|
}
|
||||||
loadConfig();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task DownLoadSQLiteInterop()
|
public Task DownLoadSQLiteInterop()
|
||||||
@@ -255,10 +362,12 @@ namespace AppleBatch_June
|
|||||||
if (!File.Exists(text2))
|
if (!File.Exists(text2))
|
||||||
{
|
{
|
||||||
string text3 = text2 + ".tmp";
|
string text3 = text2 + ".tmp";
|
||||||
|
#pragma warning disable SYSLIB0014 // WebClient is obsolete
|
||||||
using (WebClient webClient = new WebClient())
|
using (WebClient webClient = new WebClient())
|
||||||
{
|
{
|
||||||
webClient.DownloadFile(address, text3);
|
webClient.DownloadFile(address, text3);
|
||||||
}
|
}
|
||||||
|
#pragma warning restore SYSLIB0014 // WebClient is obsolete
|
||||||
File.Move(text3, text2);
|
File.Move(text3, text2);
|
||||||
}
|
}
|
||||||
stopwatch.Stop();
|
stopwatch.Stop();
|
||||||
|
|||||||
@@ -354,7 +354,9 @@ namespace AppleBatch_June
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#pragma warning disable SYSLIB0014 // ServicePointManager is obsolete in .NET 5+
|
||||||
Console.WriteLine("DefaultConnectionLimit:" + ServicePointManager.DefaultConnectionLimit);
|
Console.WriteLine("DefaultConnectionLimit:" + ServicePointManager.DefaultConnectionLimit);
|
||||||
|
#pragma warning restore SYSLIB0014 // ServicePointManager is obsolete in .NET 5+
|
||||||
ProxyRunService.resetProxyData();
|
ProxyRunService.resetProxyData();
|
||||||
ProxyAccountCache.ReclassifyAccountAll();
|
ProxyAccountCache.ReclassifyAccountAll();
|
||||||
int thredSizeNum = 2;
|
int thredSizeNum = 2;
|
||||||
|
|||||||
@@ -1365,6 +1365,7 @@ namespace AppleBatch_June
|
|||||||
|
|
||||||
public FromMain()
|
public FromMain()
|
||||||
{
|
{
|
||||||
|
components = new Container();
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1547,7 +1548,9 @@ namespace AppleBatch_June
|
|||||||
|
|
||||||
private void FromMain_Load(object sender, EventArgs e)
|
private void FromMain_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
#pragma warning disable SYSLIB0014 // ServicePointManager is obsolete in .NET 5+
|
||||||
ServicePointManager.DefaultConnectionLimit = 512;
|
ServicePointManager.DefaultConnectionLimit = 512;
|
||||||
|
#pragma warning restore SYSLIB0014 // ServicePointManager is obsolete in .NET 5+
|
||||||
linkLabel3.Text = AppSysConfig.getConfig("MainInfoBuyLinke");
|
linkLabel3.Text = AppSysConfig.getConfig("MainInfoBuyLinke");
|
||||||
string[] array = AppSysConfig.getConfig("TutorialLink").Split('|');
|
string[] array = AppSysConfig.getConfig("TutorialLink").Split('|');
|
||||||
if (!string.IsNullOrEmpty(array[0]) && array.Length >= 2)
|
if (!string.IsNullOrEmpty(array[0]) && array.Length >= 2)
|
||||||
@@ -1582,8 +1585,10 @@ namespace AppleBatch_June
|
|||||||
comLoadAccounts.MouseWheel += ComLoadAccounts_MouseWheel;
|
comLoadAccounts.MouseWheel += ComLoadAccounts_MouseWheel;
|
||||||
ThreadPool.SetMinThreads(Tools.getTaskSize(openVpn: true, 1000) * 2, 5);
|
ThreadPool.SetMinThreads(Tools.getTaskSize(openVpn: true, 1000) * 2, 5);
|
||||||
Text = Text + " 当前版本:" + FormLogin.versions;
|
Text = Text + " 当前版本:" + FormLogin.versions;
|
||||||
|
#pragma warning disable SYSLIB0014 // ServicePointManager is obsolete in .NET 5+
|
||||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
|
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
|
||||||
ServicePointManager.ServerCertificateValidationCallback = (object sender2, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) => true;
|
ServicePointManager.ServerCertificateValidationCallback = (object sender2, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) => true;
|
||||||
|
#pragma warning restore SYSLIB0014 // ServicePointManager is obsolete in .NET 5+
|
||||||
foreach (TabPage tabPage in tabControl1.TabPages)
|
foreach (TabPage tabPage in tabControl1.TabPages)
|
||||||
{
|
{
|
||||||
if (tabPage.Text == "个人中心页面")
|
if (tabPage.Text == "个人中心页面")
|
||||||
|
|||||||
@@ -1296,7 +1296,6 @@ namespace AppleBatch_June
|
|||||||
if (paymentInfos != null && paymentInfos != null)
|
if (paymentInfos != null && paymentInfos != null)
|
||||||
{
|
{
|
||||||
int? num = paymentInfos.data?.attributes?.paymentInfos.Count();
|
int? num = paymentInfos.data?.attributes?.paymentInfos.Count();
|
||||||
int num2 = 0;
|
|
||||||
if (num > 0 && paymentInfos != null)
|
if (num > 0 && paymentInfos != null)
|
||||||
{
|
{
|
||||||
PaymentList.Data data = paymentInfos.data;
|
PaymentList.Data data = paymentInfos.data;
|
||||||
@@ -1311,7 +1310,6 @@ namespace AppleBatch_June
|
|||||||
obj = ((attributes != null) ? new int?(attributes.paymentInfos[0].validationErrors.Count()) : null);
|
obj = ((attributes != null) ? new int?(attributes.paymentInfos[0].validationErrors.Count()) : null);
|
||||||
}
|
}
|
||||||
num = obj;
|
num = obj;
|
||||||
num2 = 0;
|
|
||||||
if (num > 0)
|
if (num > 0)
|
||||||
{
|
{
|
||||||
string text = "";
|
string text = "";
|
||||||
@@ -2021,10 +2019,10 @@ namespace AppleBatch_June
|
|||||||
public string CancelSubscription(string subscriptionId, AppleItunesLogin itunesLogin, bool isAgent = false)
|
public string CancelSubscription(string subscriptionId, AppleItunesLogin itunesLogin, bool isAgent = false)
|
||||||
{
|
{
|
||||||
string text = "失败:网络请求失败,无法请求完成";
|
string text = "失败:网络请求失败,无法请求完成";
|
||||||
int serverIndex = itunesLogin.serverIndex;
|
|
||||||
string ReueId = "";
|
string ReueId = "";
|
||||||
string guidNow = "";
|
string guidNow = "";
|
||||||
string text2 = "000000000";
|
string text2 = "000000000";
|
||||||
|
int serverIndex = itunesLogin.serverIndex;
|
||||||
string kbsync = getKbsync(itunesLogin.dsis, ref serverIndex, ref ReueId, ref guidNow);
|
string kbsync = getKbsync(itunesLogin.dsis, ref serverIndex, ref ReueId, ref guidNow);
|
||||||
string postData = "cancelSubscription=true&creditDisplay=" + itunesLogin.Balance + "&guid=" + itunesLogin.Guid + "&hasConfirmedBuySubscription=true&kbsync=" + kbsync + "&machineName=" + itunesLogin.Guid + "&needDiv=1&salableAdamId=" + text2 + "&showIAPExtraDialog=false&showIAPSuccessDialog=false&subscriptionId=" + subscriptionId + "&supportsGpuContentProtection=true";
|
string postData = "cancelSubscription=true&creditDisplay=" + itunesLogin.Balance + "&guid=" + itunesLogin.Guid + "&hasConfirmedBuySubscription=true&kbsync=" + kbsync + "&machineName=" + itunesLogin.Guid + "&needDiv=1&salableAdamId=" + text2 + "&showIAPExtraDialog=false&showIAPSuccessDialog=false&subscriptionId=" + subscriptionId + "&supportsGpuContentProtection=true";
|
||||||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ namespace AppleBatch_June
|
|||||||
|
|
||||||
public int Compare(object x, object y)
|
public int Compare(object x, object y)
|
||||||
{
|
{
|
||||||
int num = -1;
|
|
||||||
string text = ((ListViewItem)x).SubItems[col].Text;
|
string text = ((ListViewItem)x).SubItems[col].Text;
|
||||||
string text2 = ((ListViewItem)y).SubItems[col].Text;
|
string text2 = ((ListViewItem)y).SubItems[col].Text;
|
||||||
if (int.TryParse(text, out var result) && int.TryParse(text2, out var result2))
|
if (int.TryParse(text, out var result) && int.TryParse(text2, out var result2))
|
||||||
|
|||||||
@@ -2,110 +2,61 @@ using System;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using AppleBatch_June.Domain;
|
|
||||||
|
|
||||||
namespace AppleBatch_June
|
namespace AppleBatch_June
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
internal class ThreadExceptionHandler
|
|
||||||
{
|
|
||||||
public void Form1_UIThreadException(object sender, ThreadExceptionEventArgs t)
|
|
||||||
{
|
|
||||||
DialogResult dialogResult = DialogResult.Cancel;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
dialogResult = ShowThreadExceptionDialog("Windows Forms UI错误", t.Exception);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
MessageBox.Show("严重的错误", "Windows Forms UI错误", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Hand);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
Application.Exit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (dialogResult == DialogResult.Abort)
|
|
||||||
{
|
|
||||||
Application.Exit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
|
||||||
{
|
|
||||||
DialogResult dialogResult = DialogResult.Cancel;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Exception e2 = (Exception)e.ExceptionObject;
|
|
||||||
dialogResult = ShowThreadExceptionDialog("非UI线程错误#1", e2);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
MessageBox.Show("严重的非UI线程错误:" + ex.Message, "非UI线程错误", MessageBoxButtons.OK, MessageBoxIcon.Hand);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
Application.Exit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (dialogResult == DialogResult.Abort)
|
|
||||||
{
|
|
||||||
Application.Exit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private DialogResult ShowThreadExceptionDialog(string title, Exception e)
|
|
||||||
{
|
|
||||||
string text = "应用程序错误,请联系管理员,错误信息:\n\n";
|
|
||||||
text += e.Message;
|
|
||||||
if (e.Message.Contains("System.OutOfMemoryException") || e.Message.Contains("内存不足") || e.Message.Contains("没有足够的内存"))
|
|
||||||
{
|
|
||||||
text += "\n\n系统运行内存不足,请增加系统的 虚拟内存 !!";
|
|
||||||
}
|
|
||||||
APIUtlis.ApiSeriveError(e, title);
|
|
||||||
return MessageBox.Show(text, title, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Hand);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
private static void Main()
|
private static void Main()
|
||||||
{
|
{
|
||||||
|
// 调试断点测试 - 在此处设置断点
|
||||||
|
Console.WriteLine("程序开始启动 - Debug Breakpoint Test");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Task.Run(delegate
|
// 最小化启动过程,避免CoreCLR初始化问题
|
||||||
{
|
|
||||||
new NationalData().getMation();
|
|
||||||
});
|
|
||||||
ThreadExceptionHandler @object = new ThreadExceptionHandler();
|
|
||||||
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.Automatic);
|
|
||||||
Application.ThreadException += @object.Form1_UIThreadException;
|
|
||||||
AppDomain.CurrentDomain.UnhandledException += @object.CurrentDomain_UnhandledException;
|
|
||||||
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
|
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(defaultValue: false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
Application.Run(new FormLogin());
|
|
||||||
|
Console.WriteLine("Windows Forms 样式已启用");
|
||||||
|
|
||||||
|
// 设置全局异常处理
|
||||||
|
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.Automatic);
|
||||||
|
Application.ThreadException += (sender, e) => {
|
||||||
|
MessageBox.Show($"UI错误: {e.Exception.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
};
|
||||||
|
AppDomain.CurrentDomain.UnhandledException += (sender, e) => {
|
||||||
|
MessageBox.Show($"未处理异常: {(e.ExceptionObject as Exception)?.Message}", "严重错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
};
|
||||||
|
|
||||||
|
Console.WriteLine("异常处理已设置");
|
||||||
|
|
||||||
|
// 尝试启动主窗体
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Console.WriteLine("正在创建主窗体...");
|
||||||
|
Application.Run(new FormLogin());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"窗体启动异常: {ex.Message}");
|
||||||
|
MessageBox.Show($"程序启动失败: {ex.Message}\n\n堆栈跟踪:\n{ex.StackTrace}", "启动错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
APIUtlis.ApiSeriveError(ex);
|
Console.WriteLine($"系统初始化异常: {ex.Message}");
|
||||||
|
MessageBox.Show($"系统初始化失败: {ex.Message}\n\n这是一个CoreCLR运行时错误,可能的原因:\n" +
|
||||||
|
"1. .NET 8.0 运行时未正确安装\n" +
|
||||||
|
"2. 程序依赖项缺失\n" +
|
||||||
|
"3. 系统兼容性问题\n\n" +
|
||||||
|
"请确保已安装 .NET 8.0 Desktop Runtime。\n\n" +
|
||||||
|
"详细信息: {ex.StackTrace}", "CoreCLR 错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
finally
|
||||||
|
|
||||||
private static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_ = "应用程序错误,请联系管理员,错误信息:\n\n" + e.Exception.Message;
|
|
||||||
APIUtlis.ApiSeriveError(e.Exception, "非UI线程错误#2");
|
|
||||||
e.SetObserved();
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("程序执行完成");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -814,7 +814,6 @@ namespace AppleBatch_June
|
|||||||
|
|
||||||
public static string EncodeBase64(byte[] source)
|
public static string EncodeBase64(byte[] source)
|
||||||
{
|
{
|
||||||
string _text = "";
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return Convert.ToBase64String(source);
|
return Convert.ToBase64String(source);
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ namespace AppleBatch_June
|
|||||||
|
|
||||||
public addMaterial()
|
public addMaterial()
|
||||||
{
|
{
|
||||||
|
components = new Container();
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -560,16 +560,30 @@ namespace DotNet.Utilities
|
|||||||
{
|
{
|
||||||
if (!string.IsNullOrWhiteSpace(item.CerPath))
|
if (!string.IsNullOrWhiteSpace(item.CerPath))
|
||||||
{
|
{
|
||||||
|
#pragma warning disable SYSLIB0014 // ServicePointManager is obsolete in .NET 5+
|
||||||
ServicePointManager.ServerCertificateValidationCallback = CheckValidationResult;
|
ServicePointManager.ServerCertificateValidationCallback = CheckValidationResult;
|
||||||
|
#pragma warning restore SYSLIB0014 // ServicePointManager is obsolete in .NET 5+
|
||||||
|
#pragma warning disable SYSLIB0014 // WebRequest is obsolete
|
||||||
request = (HttpWebRequest)WebRequest.Create(item.URL);
|
request = (HttpWebRequest)WebRequest.Create(item.URL);
|
||||||
|
#pragma warning restore SYSLIB0014 // WebRequest is obsolete
|
||||||
SetCerList(item);
|
SetCerList(item);
|
||||||
request.ClientCertificates.Add(new X509Certificate(item.CerPath));
|
request.ClientCertificates.Add(new X509Certificate(item.CerPath));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#pragma warning disable SYSLIB0014 // WebRequest is obsolete
|
||||||
request = (HttpWebRequest)WebRequest.Create(item.URL);
|
request = (HttpWebRequest)WebRequest.Create(item.URL);
|
||||||
|
#pragma warning restore SYSLIB0014 // WebRequest is obsolete
|
||||||
if (item.KeepAlive)
|
if (item.KeepAlive)
|
||||||
{
|
{
|
||||||
request.Headers.GetType().InvokeMember("ChangeInternal", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, Type.DefaultBinder, request.Headers, new object[2] { "Connection", "keep-alive" });
|
// 在 .NET 8 中使用标准方式设置 Connection 头
|
||||||
|
try
|
||||||
|
{
|
||||||
|
request.Connection = "keep-alive";
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// 如果设置失败,忽略错误,继续执行
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SetCerList(item);
|
SetCerList(item);
|
||||||
}
|
}
|
||||||
|
|||||||
11
Properties/launchSettings.json
Normal file
11
Properties/launchSettings.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"AppleBatch_June": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
},
|
||||||
|
"nativeDebugging": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user