Nuget package updates

- Newtonsoft.Json
- changed arkdata code to only check NON STEAM players 10 times, then stop.
This commit is contained in:
Brett Hewitson 2022-06-21 21:36:55 +10:00
parent e069ecdfe7
commit e5327ac946
13 changed files with 35 additions and 24 deletions

View file

@ -168,8 +168,8 @@
<HintPath>..\packages\WindowsAPICodePack-Shell.1.1.1\lib\Microsoft.WindowsAPICodePack.Shell.dll</HintPath> <HintPath>..\packages\WindowsAPICodePack-Shell.1.1.1\lib\Microsoft.WindowsAPICodePack.Shell.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> <Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.5.0.1\lib\net46\NLog.dll</HintPath> <HintPath>..\packages\NLog.5.0.1\lib\net46\NLog.dll</HintPath>

View file

@ -127,6 +127,7 @@ namespace ServerManagerTool.Lib.ViewModel.RCON
if (PlayerData?.PlayerName != null) if (PlayerData?.PlayerName != null)
playerData.PlayerName = PlayerData.PlayerName; playerData.PlayerName = PlayerData.PlayerName;
playerData.LastPlatformUpdateUtc = PlayerData?.LastPlatformUpdateUtc ?? DateTime.MinValue; playerData.LastPlatformUpdateUtc = PlayerData?.LastPlatformUpdateUtc ?? DateTime.MinValue;
playerData.NoUpdateCount = PlayerData?.NoUpdateCount ?? 0;
} }
#region INotifyPropertyChanged #region INotifyPropertyChanged

View file

@ -5,7 +5,7 @@
<package id="Expression.Blend.Sdk" version="1.0.2" targetFramework="net462" /> <package id="Expression.Blend.Sdk" version="1.0.2" targetFramework="net462" />
<package id="Hardcodet.NotifyIcon.Wpf" version="1.1.0" targetFramework="net462" /> <package id="Hardcodet.NotifyIcon.Wpf" version="1.1.0" targetFramework="net462" />
<package id="Microsoft.Tpl.Dataflow" version="4.5.24" targetFramework="net462" /> <package id="Microsoft.Tpl.Dataflow" version="4.5.24" targetFramework="net462" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net462" /> <package id="Newtonsoft.Json" version="13.0.1" targetFramework="net462" />
<package id="NLog" version="5.0.1" targetFramework="net462" /> <package id="NLog" version="5.0.1" targetFramework="net462" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net462" /> <package id="System.ValueTuple" version="4.5.0" targetFramework="net462" />
<package id="TaskScheduler" version="2.10.1" targetFramework="net462" /> <package id="TaskScheduler" version="2.10.1" targetFramework="net462" />

View file

@ -11,7 +11,7 @@
<DebugSymbols>false</DebugSymbols> <DebugSymbols>false</DebugSymbols>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />

View file

@ -60,12 +60,13 @@ namespace ArkData
/// <returns>The async task context.</returns> /// <returns>The async task context.</returns>
public async Task<DateTime> LoadSteamAsync(string apiKey, int steamUpdateInterval = 0) public async Task<DateTime> LoadSteamAsync(string apiKey, int steamUpdateInterval = 0)
{ {
const int MAX_STEAM_IDS = 100;
// need to make multiple calls of 100 steam id's. // need to make multiple calls of 100 steam id's.
var lastSteamUpdateUtc = DateTime.UtcNow; var lastSteamUpdateUtc = DateTime.UtcNow;
var startIndex = 0; var startIndex = 0;
var playerSteamIds = Players.Where(p => p.LastPlatformUpdateUtc.AddMinutes(steamUpdateInterval) < DateTime.UtcNow).Select(p => p.PlayerId); var playerSteamIds = Players
.Where(p => p.LastPlatformUpdateUtc.AddMinutes(steamUpdateInterval) < DateTime.UtcNow && p.NoUpdateCount < MAX_INVALID_COUNT)
.Select(p => p.PlayerId)
.ToArray();
while (true) while (true)
{ {
@ -78,7 +79,7 @@ namespace ArkData
using (var client = new HttpClient()) using (var client = new HttpClient())
{ {
client.BaseAddress = new System.Uri("https://api.steampowered.com/"); client.BaseAddress = new Uri("https://api.steampowered.com/");
client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
@ -86,7 +87,7 @@ namespace ArkData
if (response.IsSuccessStatusCode) if (response.IsSuccessStatusCode)
using (var reader = new StreamReader(await response.Content.ReadAsStreamAsync())) using (var reader = new StreamReader(await response.Content.ReadAsStreamAsync()))
{ {
LinkSteamProfiles(await reader.ReadToEndAsync(), lastSteamUpdateUtc); LinkSteamProfiles(await reader.ReadToEndAsync(), lastSteamUpdateUtc, playerSteamIds);
} }
else else
throw new System.Net.WebException("The Steam API request was unsuccessful. Are you using a valid key?"); throw new System.Net.WebException("The Steam API request was unsuccessful. Are you using a valid key?");

View file

@ -13,6 +13,9 @@ namespace ArkData
{ {
public partial class DataContainer public partial class DataContainer
{ {
const int MAX_STEAM_IDS = 100;
const int MAX_INVALID_COUNT = 10;
/// <summary> /// <summary>
/// A list of all players registered on the server. /// A list of all players registered on the server.
/// </summary> /// </summary>
@ -86,7 +89,7 @@ namespace ArkData
/// Deserializes JSON from Steam API and links Steam profile to player profile. /// Deserializes JSON from Steam API and links Steam profile to player profile.
/// </summary> /// </summary>
/// <param name="jsonString">The JSON data string.</param> /// <param name="jsonString">The JSON data string.</param>
private void LinkSteamProfiles(string jsonString, DateTime lastSteamUpdateUtc) private void LinkSteamProfiles(string jsonString, DateTime lastSteamUpdateUtc, string[] playerSteamIds)
{ {
var profiles = JsonConvert.DeserializeObject<Models.SteamResponse<Models.SteamProfile>>(jsonString).response.players; var profiles = JsonConvert.DeserializeObject<Models.SteamResponse<Models.SteamProfile>>(jsonString).response.players;
@ -96,6 +99,13 @@ namespace ArkData
player.PlayerName = profiles[i].personaname; player.PlayerName = profiles[i].personaname;
player.LastPlatformUpdateUtc = lastSteamUpdateUtc; player.LastPlatformUpdateUtc = lastSteamUpdateUtc;
} }
for (var i = 0; i < playerSteamIds.Length; i++)
{
var player = Players.SingleOrDefault(p => p.PlayerId == playerSteamIds[i]);
if (player != null && player.LastPlatformUpdateUtc == DateTime.MinValue)
player.NoUpdateCount = Math.Min(MAX_INVALID_COUNT, player.NoUpdateCount + 1);
}
} }
} }
} }

View file

@ -58,12 +58,13 @@ namespace ArkData
/// <param name="apiKey">The Steam API key</param> /// <param name="apiKey">The Steam API key</param>
public DateTime LoadSteam(string apiKey, int steamUpdateInterval = 0) public DateTime LoadSteam(string apiKey, int steamUpdateInterval = 0)
{ {
const int MAX_STEAM_IDS = 100;
// need to make multiple calls of 100 steam id's. // need to make multiple calls of 100 steam id's.
var lastSteamUpdateUtc = DateTime.UtcNow; var lastSteamUpdateUtc = DateTime.UtcNow;
var startIndex = 0; var startIndex = 0;
var playerSteamIds = Players.Where(p => p.LastPlatformUpdateUtc.AddMinutes(steamUpdateInterval) < DateTime.UtcNow).Select(p => p.PlayerId); var playerSteamIds = Players
.Where(p => p.LastPlatformUpdateUtc.AddMinutes(steamUpdateInterval) < DateTime.UtcNow && p.NoUpdateCount < MAX_INVALID_COUNT)
.Select(p => p.PlayerId)
.ToArray();
while (true) while (true)
{ {
@ -76,7 +77,7 @@ namespace ArkData
using (var client = new HttpClient()) using (var client = new HttpClient())
{ {
client.BaseAddress = new System.Uri("https://api.steampowered.com/"); client.BaseAddress = new Uri("https://api.steampowered.com/");
client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
@ -84,7 +85,7 @@ namespace ArkData
if (response.IsSuccessStatusCode) if (response.IsSuccessStatusCode)
using (var reader = new StreamReader(response.Content.ReadAsStreamAsync().Result)) using (var reader = new StreamReader(response.Content.ReadAsStreamAsync().Result))
{ {
LinkSteamProfiles(reader.ReadToEnd(), lastSteamUpdateUtc); LinkSteamProfiles(reader.ReadToEnd(), lastSteamUpdateUtc, playerSteamIds);
} }
else else
throw new System.Net.WebException("The Steam API request was unsuccessful. Are you using a valid key?"); throw new System.Net.WebException("The Steam API request was unsuccessful. Are you using a valid key?");

View file

@ -20,5 +20,6 @@ namespace ArkData
public virtual List<TribeData> OwnedTribes { get; set; } public virtual List<TribeData> OwnedTribes { get; set; }
public DateTime LastPlatformUpdateUtc { get; set; } public DateTime LastPlatformUpdateUtc { get; set; }
} public int NoUpdateCount { get; set; }
}
} }

View file

@ -11,7 +11,6 @@
<DebugSymbols>false</DebugSymbols> <DebugSymbols>false</DebugSymbols>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.112.1" /> <PackageReference Include="System.Data.SQLite.Core" Version="1.0.112.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View file

@ -1,6 +1,4 @@
using Newtonsoft.Json; using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
/// <summary> /// <summary>

View file

@ -153,8 +153,8 @@
<Reference Include="Microsoft.WindowsAPICodePack.Shell, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Microsoft.WindowsAPICodePack.Shell, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\WindowsAPICodePack-Shell.1.1.1\lib\Microsoft.WindowsAPICodePack.Shell.dll</HintPath> <HintPath>..\packages\WindowsAPICodePack-Shell.1.1.1\lib\Microsoft.WindowsAPICodePack.Shell.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> <Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.5.0.1\lib\net46\NLog.dll</HintPath> <HintPath>..\packages\NLog.5.0.1\lib\net46\NLog.dll</HintPath>

View file

@ -5,7 +5,7 @@
<package id="Expression.Blend.Sdk" version="1.0.2" targetFramework="net462" /> <package id="Expression.Blend.Sdk" version="1.0.2" targetFramework="net462" />
<package id="Hardcodet.NotifyIcon.Wpf" version="1.1.0" targetFramework="net462" /> <package id="Hardcodet.NotifyIcon.Wpf" version="1.1.0" targetFramework="net462" />
<package id="Microsoft.Tpl.Dataflow" version="4.5.24" targetFramework="net462" /> <package id="Microsoft.Tpl.Dataflow" version="4.5.24" targetFramework="net462" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net462" /> <package id="Newtonsoft.Json" version="13.0.1" targetFramework="net462" />
<package id="NLog" version="5.0.1" targetFramework="net462" /> <package id="NLog" version="5.0.1" targetFramework="net462" />
<package id="System.Data.SQLite.Core" version="1.0.112.1" targetFramework="net462" /> <package id="System.Data.SQLite.Core" version="1.0.112.1" targetFramework="net462" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net462" /> <package id="System.ValueTuple" version="4.5.0" targetFramework="net462" />

View file

@ -18,7 +18,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="DotNetZip" Version="1.16.0" /> <PackageReference Include="DotNetZip" Version="1.16.0" />
<PackageReference Include="Microsoft.Tpl.Dataflow" Version="4.5.24" /> <PackageReference Include="Microsoft.Tpl.Dataflow" Version="4.5.24" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NLog" Version="5.0.1" /> <PackageReference Include="NLog" Version="5.0.1" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" /> <PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="TaskScheduler" Version="2.10.1" /> <PackageReference Include="TaskScheduler" Version="2.10.1" />