mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
Nuget package updates
- Newtonsoft.Json - changed arkdata code to only check NON STEAM players 10 times, then stop.
This commit is contained in:
parent
e069ecdfe7
commit
e5327ac946
13 changed files with 35 additions and 24 deletions
|
|
@ -168,8 +168,8 @@
|
|||
<HintPath>..\packages\WindowsAPICodePack-Shell.1.1.1\lib\Microsoft.WindowsAPICodePack.Shell.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<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>
|
||||
|
|
|
|||
|
|
@ -127,6 +127,7 @@ namespace ServerManagerTool.Lib.ViewModel.RCON
|
|||
if (PlayerData?.PlayerName != null)
|
||||
playerData.PlayerName = PlayerData.PlayerName;
|
||||
playerData.LastPlatformUpdateUtc = PlayerData?.LastPlatformUpdateUtc ?? DateTime.MinValue;
|
||||
playerData.NoUpdateCount = PlayerData?.NoUpdateCount ?? 0;
|
||||
}
|
||||
|
||||
#region INotifyPropertyChanged
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<package id="Expression.Blend.Sdk" version="1.0.2" 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="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="System.ValueTuple" version="4.5.0" targetFramework="net462" />
|
||||
<package id="TaskScheduler" version="2.10.1" targetFramework="net462" />
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
<DebugSymbols>false</DebugSymbols>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
|
|
|
|||
|
|
@ -60,12 +60,13 @@ namespace ArkData
|
|||
/// <returns>The async task context.</returns>
|
||||
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.
|
||||
var lastSteamUpdateUtc = DateTime.UtcNow;
|
||||
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)
|
||||
{
|
||||
|
|
@ -78,7 +79,7 @@ namespace ArkData
|
|||
|
||||
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.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
|
||||
|
|
@ -86,7 +87,7 @@ namespace ArkData
|
|||
if (response.IsSuccessStatusCode)
|
||||
using (var reader = new StreamReader(await response.Content.ReadAsStreamAsync()))
|
||||
{
|
||||
LinkSteamProfiles(await reader.ReadToEndAsync(), lastSteamUpdateUtc);
|
||||
LinkSteamProfiles(await reader.ReadToEndAsync(), lastSteamUpdateUtc, playerSteamIds);
|
||||
}
|
||||
else
|
||||
throw new System.Net.WebException("The Steam API request was unsuccessful. Are you using a valid key?");
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ namespace ArkData
|
|||
{
|
||||
public partial class DataContainer
|
||||
{
|
||||
const int MAX_STEAM_IDS = 100;
|
||||
const int MAX_INVALID_COUNT = 10;
|
||||
|
||||
/// <summary>
|
||||
/// A list of all players registered on the server.
|
||||
/// </summary>
|
||||
|
|
@ -86,7 +89,7 @@ namespace ArkData
|
|||
/// Deserializes JSON from Steam API and links Steam profile to player profile.
|
||||
/// </summary>
|
||||
/// <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;
|
||||
|
||||
|
|
@ -96,6 +99,13 @@ namespace ArkData
|
|||
player.PlayerName = profiles[i].personaname;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,12 +58,13 @@ namespace ArkData
|
|||
/// <param name="apiKey">The Steam API key</param>
|
||||
public DateTime LoadSteam(string apiKey, int steamUpdateInterval = 0)
|
||||
{
|
||||
const int MAX_STEAM_IDS = 100;
|
||||
|
||||
// need to make multiple calls of 100 steam id's.
|
||||
var lastSteamUpdateUtc = DateTime.UtcNow;
|
||||
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)
|
||||
{
|
||||
|
|
@ -76,7 +77,7 @@ namespace ArkData
|
|||
|
||||
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.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
|
||||
|
|
@ -84,7 +85,7 @@ namespace ArkData
|
|||
if (response.IsSuccessStatusCode)
|
||||
using (var reader = new StreamReader(response.Content.ReadAsStreamAsync().Result))
|
||||
{
|
||||
LinkSteamProfiles(reader.ReadToEnd(), lastSteamUpdateUtc);
|
||||
LinkSteamProfiles(reader.ReadToEnd(), lastSteamUpdateUtc, playerSteamIds);
|
||||
}
|
||||
else
|
||||
throw new System.Net.WebException("The Steam API request was unsuccessful. Are you using a valid key?");
|
||||
|
|
|
|||
|
|
@ -20,5 +20,6 @@ namespace ArkData
|
|||
public virtual List<TribeData> OwnedTribes { get; set; }
|
||||
|
||||
public DateTime LastPlatformUpdateUtc { get; set; }
|
||||
}
|
||||
public int NoUpdateCount { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
<DebugSymbols>false</DebugSymbols>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.112.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -153,8 +153,8 @@
|
|||
<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>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<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>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<package id="Expression.Blend.Sdk" version="1.0.2" 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="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="System.Data.SQLite.Core" version="1.0.112.1" targetFramework="net462" />
|
||||
<package id="System.ValueTuple" version="4.5.0" targetFramework="net462" />
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="DotNetZip" Version="1.16.0" />
|
||||
<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="System.ValueTuple" Version="4.5.0" />
|
||||
<PackageReference Include="TaskScheduler" Version="2.10.1" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue