mirror of
https://github.com/JuniorDark/RustyHearts-Launcher.git
synced 2026-05-07 05:21:44 -04:00
Add more error handling
This commit is contained in:
parent
7917f223e1
commit
8cf88ab0e4
5 changed files with 33 additions and 12 deletions
|
|
@ -19,15 +19,31 @@ namespace RHLauncher.RHLauncher.Helper
|
||||||
string md5 = CalculateMD5(service);
|
string md5 = CalculateMD5(service);
|
||||||
|
|
||||||
string serviceDatPath = Path.Combine(_installDirectory, "Service.dat");
|
string serviceDatPath = Path.Combine(_installDirectory, "Service.dat");
|
||||||
string[] lines = File.ReadAllLines(serviceDatPath);
|
|
||||||
|
|
||||||
string currentMd5 = lines[0];
|
try
|
||||||
string currentService = string.Join(Environment.NewLine, lines, 1, lines.Length - 1);
|
|
||||||
|
|
||||||
if (currentMd5 != md5)
|
|
||||||
{
|
{
|
||||||
lines[0] = md5;
|
if (File.Exists(serviceDatPath))
|
||||||
File.WriteAllLines(serviceDatPath, lines);
|
{
|
||||||
|
string[] lines = File.ReadAllLines(serviceDatPath);
|
||||||
|
|
||||||
|
string currentMd5 = lines[0];
|
||||||
|
string currentService = string.Join(Environment.NewLine, lines, 1, lines.Length - 1);
|
||||||
|
|
||||||
|
if (currentMd5 != md5)
|
||||||
|
{
|
||||||
|
lines[0] = md5;
|
||||||
|
File.WriteAllLines(serviceDatPath, lines);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MsgBoxForm.Show("Service.dat file does not exist. Please check if the Install Directory is correct.", LocalizedStrings.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MsgBoxForm.Show("An error occurred while updating service: " + ex.Message, LocalizedStrings.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -145,6 +145,11 @@ namespace RHLauncher
|
||||||
LaunchButton.Click -= LaunchGameButton_Click;
|
LaunchButton.Click -= LaunchGameButton_Click;
|
||||||
LaunchButton.Click += LaunchGameButton_Click;
|
LaunchButton.Click += LaunchGameButton_Click;
|
||||||
break;
|
break;
|
||||||
|
case UpdateState.Error:
|
||||||
|
LaunchButton.Text = LocalizedStrings.Launch;
|
||||||
|
LaunchButton.Click -= LaunchGameButton_Click;
|
||||||
|
LaunchButton.Click += LaunchGameButton_Click;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ namespace RHLauncher
|
||||||
private async Task<string> SendEmailRequestAsync()
|
private async Task<string> SendEmailRequestAsync()
|
||||||
{
|
{
|
||||||
using HttpClient client = new();
|
using HttpClient client = new();
|
||||||
HttpResponseMessage response = await client.PostAsync(SendCodeUrl, new FormUrlEncodedContent(new[]
|
using HttpResponseMessage response = await client.PostAsync(SendCodeUrl, new FormUrlEncodedContent(new[]
|
||||||
{
|
{
|
||||||
new KeyValuePair<string, string>("email", EmailTextBox.Text),
|
new KeyValuePair<string, string>("email", EmailTextBox.Text),
|
||||||
|
|
||||||
|
|
@ -99,7 +99,7 @@ namespace RHLauncher
|
||||||
private async Task<string> VerifyCodeSendRequestAsync()
|
private async Task<string> VerifyCodeSendRequestAsync()
|
||||||
{
|
{
|
||||||
using HttpClient client = new();
|
using HttpClient client = new();
|
||||||
HttpResponseMessage response = await client.PostAsync(VerifyCodeUrl, new FormUrlEncodedContent(new[]
|
using HttpResponseMessage response = await client.PostAsync(VerifyCodeUrl, new FormUrlEncodedContent(new[]
|
||||||
{
|
{
|
||||||
new KeyValuePair<string, string>("email", EmailTextBox.Text),
|
new KeyValuePair<string, string>("email", EmailTextBox.Text),
|
||||||
new KeyValuePair<string, string>("verification_code", CodeTextBox.Text),
|
new KeyValuePair<string, string>("verification_code", CodeTextBox.Text),
|
||||||
|
|
@ -113,7 +113,7 @@ namespace RHLauncher
|
||||||
private async Task<string> SendRequestAsync()
|
private async Task<string> SendRequestAsync()
|
||||||
{
|
{
|
||||||
using HttpClient client = new();
|
using HttpClient client = new();
|
||||||
HttpResponseMessage response = await client.PostAsync(RegisterUrl, new FormUrlEncodedContent(new[]
|
using HttpResponseMessage response = await client.PostAsync(RegisterUrl, new FormUrlEncodedContent(new[]
|
||||||
{
|
{
|
||||||
new KeyValuePair<string, string>("windyCode", NameTextBox.Text),
|
new KeyValuePair<string, string>("windyCode", NameTextBox.Text),
|
||||||
new KeyValuePair<string, string>("email", EmailTextBox.Text),
|
new KeyValuePair<string, string>("email", EmailTextBox.Text),
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
<AssemblyName>Launcher</AssemblyName>
|
<AssemblyName>Launcher</AssemblyName>
|
||||||
<Description>Rusty Hearts Launcher</Description>
|
<Description>Rusty Hearts Launcher</Description>
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
<AssemblyVersion>1.0.0</AssemblyVersion>
|
<AssemblyVersion>1.0.1</AssemblyVersion>
|
||||||
<FileVersion>1.0.0</FileVersion>
|
<FileVersion>1.0.0</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ namespace RHLauncher
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using HttpClient client = new();
|
using HttpClient client = new();
|
||||||
HttpResponseMessage response = await client.GetAsync(LauncherVersionUrl);
|
using HttpResponseMessage response = await client.GetAsync(LauncherVersionUrl);
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
string json = await response.Content.ReadAsStringAsync();
|
string json = await response.Content.ReadAsStringAsync();
|
||||||
dynamic result = JsonConvert.DeserializeObject(json);
|
dynamic result = JsonConvert.DeserializeObject(json);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue