Fixed crash while trying to get DLC with invalid AppID
This commit is contained in:
parent
b68f45d4d7
commit
56e92924ed
2
.gitignore
vendored
2
.gitignore
vendored
@ -554,4 +554,4 @@ MigrationBackup/
|
||||
# End of https://www.toptal.com/developers/gitignore/api/visualstudio,jetbrains,windows,visualstudiocode,rider,dotnetcore
|
||||
|
||||
ConsoleApp1/
|
||||
/Utils/CsRinRuLogin.cs
|
||||
/Utils/Secrets.cs
|
||||
|
@ -48,8 +48,7 @@
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
<Button x:Name="Save" Content="Save" Margin="0,10,55,10" HorizontalAlignment="Right" Width="40" Height="20" VerticalAlignment="Bottom" Click="Save_Click" Grid.Row="11"/>
|
||||
<Button x:Name="Reset" Content="Reset" Margin="0,10,10,10" Height="20" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="40" Click="Reset_Click" Grid.Row="11"/>
|
||||
|
||||
<Button x:Name="Save" Content="Save" Margin="0,10,55,10" HorizontalAlignment="Right" Width="40" Height="20" VerticalAlignment="Bottom" Click="Save_Click" Grid.Row="6"/>
|
||||
<Button x:Name="Reset" Content="Reset" Margin="0,10,10,10" Height="20" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="40" Click="Reset_Click" Grid.Row="6"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using auto_creamapi.Model;
|
||||
using auto_creamapi.Utils;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace auto_creamapi
|
||||
@ -99,13 +100,20 @@ namespace auto_creamapi
|
||||
{
|
||||
if (int.TryParse(AppId.Text, out var appId))
|
||||
{
|
||||
var app = new POCOs.App() {AppId = appId, Name = Game.Text};
|
||||
var listOfDlc = await _cacheModel.GetListOfDlc(app,
|
||||
SteamDb.IsChecked != null && (bool) SteamDb.IsChecked);
|
||||
var result = "";
|
||||
listOfDlc.Sort((app1, app2) => app1.AppId.CompareTo(app2.AppId));
|
||||
listOfDlc.ForEach(x => result += $"{x.AppId}={x.Name}\n");
|
||||
ListOfDlcs.Text = result;
|
||||
if (appId > 0)
|
||||
{
|
||||
var app = new POCOs.App() {AppId = appId, Name = Game.Text};
|
||||
var listOfDlc = await _cacheModel.GetListOfDlc(app,
|
||||
SteamDb.IsChecked != null && (bool) SteamDb.IsChecked);
|
||||
var result = "";
|
||||
listOfDlc.Sort((app1, app2) => app1.AppId.CompareTo(app2.AppId));
|
||||
listOfDlc.ForEach(x => result += $"{x.AppId}={x.Name}\n");
|
||||
ListOfDlcs.Text = result;
|
||||
}
|
||||
else
|
||||
{
|
||||
MyLogger.Log.Error($"GetListOfDlc: Invalid AppID {appId}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,8 +162,22 @@ namespace auto_creamapi
|
||||
{
|
||||
if (int.TryParse(AppId.Text, out var appId))
|
||||
{
|
||||
var app = _cacheModel.GetAppById(appId);
|
||||
if (app != null) Game.Text = app.Name;
|
||||
if (appId > 0)
|
||||
{
|
||||
var app = _cacheModel.GetAppById(appId);
|
||||
if (app != null)
|
||||
{
|
||||
Game.Text = app.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
MyLogger.Log.Error($"No app found for ID {appId}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MyLogger.Log.Error($"SetNameById: Invalid AppID {appId}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ namespace auto_creamapi.Model
|
||||
if (!(File.Exists("steam_api.dll") && File.Exists("steam_api64.dll")))
|
||||
{
|
||||
MyLogger.Log.Information("Missing files, trying to download...");
|
||||
new Action(async() => await DownloadDll(CsRinRuLogin.Username, CsRinRuLogin.Password))();
|
||||
new Action(async() => await DownloadDll(Secrets.ForumUsername, Secrets.ForumPassword))();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2,10 +2,11 @@ namespace auto_creamapi.Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// To use this:
|
||||
/// Rename CsRinRuLogin_REMOVETHIS to CsRinRuLogin
|
||||
/// Rename file Secrets.EXAMPLE.cs to Secrets.cs
|
||||
/// Rename class Secrets_REMOVETHIS to Secrets
|
||||
/// Enter the relevant info below
|
||||
/// </summary>
|
||||
public class CsRinRuLogin_REMOVETHIS
|
||||
public class Secrets_REMOVETHIS
|
||||
{
|
||||
public const string Username = "Enter username here";
|
||||
public const string Password = "Enter password here";
|
Loading…
Reference in New Issue
Block a user