Modification Smash
Ajout Ecran Layout XSB
This commit is contained in:
@@ -80,6 +80,21 @@ namespace LaDOSE.Api.Controllers
|
||||
return false;
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpGet("GetPlayers/{slug}")]
|
||||
public async Task<List<String>> GetPlayer(string slug)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(slug))
|
||||
{
|
||||
var player = await _service.GetPlayer(slug);
|
||||
return player;
|
||||
}
|
||||
|
||||
throw new Exception("Erreur");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -127,11 +127,15 @@
|
||||
</Compile>
|
||||
<Compile Include="Utils\WpEventDeserialize.cs" />
|
||||
<Compile Include="Utils\WpfUtil.cs" />
|
||||
<Compile Include="ViewModels\EventPlayerViewModel.cs" />
|
||||
<Compile Include="ViewModels\ShellViewModel.cs" />
|
||||
<Compile Include="ViewModels\GameViewModel.cs" />
|
||||
<Compile Include="ViewModels\TournamentResultViewModel.cs" />
|
||||
<Compile Include="ViewModels\WebNavigationViewModel.cs" />
|
||||
<Compile Include="ViewModels\WordPressViewModel.cs" />
|
||||
<Compile Include="Views\EventPlayerView.xaml.cs">
|
||||
<DependentUpon>EventPlayerView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\WebNavigationView.xaml.cs">
|
||||
<DependentUpon>WebNavigationView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -159,6 +163,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\EventPlayerView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Views\WebNavigationView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
||||
107
LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/EventPlayerViewModel.cs
Normal file
107
LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/EventPlayerViewModel.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Caliburn.Micro;
|
||||
using LaDOSE.DesktopApp.Utils;
|
||||
using LaDOSE.DTO;
|
||||
using LaDOSE.REST;
|
||||
using Microsoft.Win32;
|
||||
using RestSharp.Serialization.Json;
|
||||
|
||||
namespace LaDOSE.DesktopApp.ViewModels
|
||||
{
|
||||
public class EventPlayerViewModel : Screen
|
||||
{
|
||||
public override string DisplayName => "EventPlayers";
|
||||
|
||||
|
||||
public class KiouzeFile
|
||||
{
|
||||
public String player { get; set; }
|
||||
public String character { get; set; }
|
||||
}
|
||||
|
||||
public ObservableCollection<KiouzeFile> Data { get; set; }
|
||||
|
||||
private List<string> _playersList;
|
||||
private List<string> _charList;
|
||||
private string _chars { get; set; }
|
||||
public string Slug { get; set; }
|
||||
|
||||
private RestService RestService { get; set; }
|
||||
public EventPlayerViewModel(RestService restService)
|
||||
{
|
||||
this.RestService = restService;
|
||||
Data = new ObservableCollection<KiouzeFile>();
|
||||
this.Slug = "tag-team-tuesdays-umvc3-team-tournament-2";
|
||||
this.Chars = "akuma;blanka;boxer;cammy;chunli;claw;deejay;dhalsim;dictator;feilong;guile;honda;ken;ryu;sagat;thawk;zangief";
|
||||
|
||||
}
|
||||
|
||||
protected override void OnInitialize()
|
||||
{
|
||||
|
||||
base.OnInitialize();
|
||||
}
|
||||
|
||||
public void GetPlayers()
|
||||
{
|
||||
WpfUtil.Await(() =>
|
||||
{
|
||||
|
||||
var resultsDto = this.RestService.GetPlayers(this.Slug);
|
||||
Players = resultsDto;
|
||||
Players.ForEach(p=> Data.AddUI(new KiouzeFile(){player = p}));
|
||||
});
|
||||
}
|
||||
|
||||
public void Export()
|
||||
{
|
||||
|
||||
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
||||
if (saveFileDialog.ShowDialog() == true)
|
||||
{
|
||||
JsonSerializer p = new JsonDeserializer();
|
||||
var json = p.Serialize(Data.ToList());
|
||||
File.WriteAllText(saveFileDialog.FileName, json);
|
||||
}
|
||||
}
|
||||
public List<String> Players
|
||||
{
|
||||
get => _playersList;
|
||||
set
|
||||
{
|
||||
_playersList = value;
|
||||
NotifyOfPropertyChange(() => this.Players);
|
||||
}
|
||||
}
|
||||
public List<String> CharList
|
||||
{
|
||||
get => _charList;
|
||||
set
|
||||
{
|
||||
_charList = value;
|
||||
NotifyOfPropertyChange(() => this.CharList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String Chars
|
||||
{
|
||||
get => _chars;
|
||||
set
|
||||
{
|
||||
_chars = value;
|
||||
_charList = _chars.Split(';').ToList();
|
||||
NotifyOfPropertyChange(()=>this.Players);
|
||||
NotifyOfPropertyChange(()=>this.CharList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -68,5 +68,9 @@ namespace LaDOSE.DesktopApp.ViewModels
|
||||
{
|
||||
ActivateItem(new TournamentResultViewModel(IoC.Get<RestService>()));
|
||||
}
|
||||
public void EventPlayers()
|
||||
{
|
||||
ActivateItem(new EventPlayerViewModel(IoC.Get<RestService>()));
|
||||
}
|
||||
}
|
||||
}
|
||||
53
LaDOSE.Src/LaDOSE.DesktopApp/Views/EventPlayerView.xaml
Normal file
53
LaDOSE.Src/LaDOSE.DesktopApp/Views/EventPlayerView.xaml
Normal file
@@ -0,0 +1,53 @@
|
||||
<UserControl x:Class="LaDOSE.DesktopApp.Views.EventPlayerView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:LaDOSE.DesktopApp.Views"
|
||||
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
||||
xmlns:behaviors="clr-namespace:LaDOSE.DesktopApp.Behaviors"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
x:Name ="EventPlayer">
|
||||
<Grid Row="4" Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0" Orientation="Horizontal">
|
||||
<TextBox Width="200" Text="{Binding Slug}"></TextBox>
|
||||
<Button x:Name="GetPlayers">Load Games</Button>
|
||||
</StackPanel>
|
||||
<DockPanel Grid.Row="1" >
|
||||
<Label> Char : </Label>
|
||||
<TextBox Text="{Binding Chars}"></TextBox>
|
||||
</DockPanel>
|
||||
|
||||
<ListView Grid.Row="2" ItemsSource="{Binding Data}" x:Name="GamesListView">
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Grid.Column="0" Content="{Binding player}" ></Label>
|
||||
<ComboBox Grid.Column="1" Text="{Binding character}" ItemsSource="{Binding DataContext.CharList, RelativeSource={RelativeSource AncestorType=UserControl}}"></ComboBox>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
|
||||
</ListView>
|
||||
<Button Grid.Row="3" Grid.ColumnSpan="2" x:Name="Export">Export</Button>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
28
LaDOSE.Src/LaDOSE.DesktopApp/Views/EventPlayerView.xaml.cs
Normal file
28
LaDOSE.Src/LaDOSE.DesktopApp/Views/EventPlayerView.xaml.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace LaDOSE.DesktopApp.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ShellView.xaml
|
||||
/// </summary>
|
||||
public partial class EventPlayerView : UserControl
|
||||
{
|
||||
public EventPlayerView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,14 @@
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</MenuItem>
|
||||
<MenuItem Header="_EventPlayers">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<cal:ActionMessage MethodName="EventPlayers">
|
||||
</cal:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Close" />
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
|
||||
@@ -305,5 +305,13 @@ namespace LaDOSE.REST
|
||||
var restResponse = Client.Get<List<EventDTO>>(restRequest);
|
||||
return restResponse.Data;
|
||||
}
|
||||
|
||||
public List<string> GetPlayers(string slug)
|
||||
{
|
||||
CheckToken();
|
||||
var restRequest = new RestRequest($"/api/Tournament/GetPLayers/{slug}", Method.GET);
|
||||
var restResponse = Client.Get<List<string>>(restRequest);
|
||||
return restResponse.Data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,5 +18,6 @@ namespace LaDOSE.Business.Interface
|
||||
Task<List<Event>> GetChallongeEvents(List<int> ids);
|
||||
|
||||
Task<TournamentsResult> GetEventsResult(List<int> ids);
|
||||
Task<List<String>> GetPlayer(string slug);
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ namespace LaDOSE.Business.Interface
|
||||
Task<Event> ParseEvent(string slug);
|
||||
Task<TournamentResponse> GetTournament(string sludge);
|
||||
|
||||
Task<TournamentResponse> GetNames(string slug);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -47,8 +47,6 @@ namespace LaDOSE.Business.Provider.ChallongProvider
|
||||
{
|
||||
var result = await new CreateTournamentQuery(name, startAt, TournamentType.Double_Elimination, url).call(ApiCaller);
|
||||
return result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public async Task<ParticipantResult> AddPlayer(int tournamentId, string userName)
|
||||
@@ -56,7 +54,6 @@ namespace LaDOSE.Business.Provider.ChallongProvider
|
||||
var p = new ParticipantEntry(userName);
|
||||
var result = await new AddParticipantQuery(tournamentId, p).call(ApiCaller);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
public async Task<List<ChallongeTournament>> GetTournaments(DateTime? start, DateTime? end)
|
||||
@@ -119,6 +116,7 @@ namespace LaDOSE.Business.Provider.ChallongProvider
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public async Task<ChallongeTournament> GetTournament(string urlTournament)
|
||||
{
|
||||
|
||||
|
||||
@@ -307,6 +307,74 @@ namespace LaDOSE.Business.Provider.SmashProvider
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task<TournamentResponse> GetNames(string slug)
|
||||
{
|
||||
|
||||
var graphQLClient = new GraphQLHttpClient("https://api.smash.gg/gql/alpha", new NewtonsoftJsonSerializer());
|
||||
graphQLClient.HttpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {ApiKey}");
|
||||
var Event = new GraphQLRequest
|
||||
{
|
||||
Query = @"query TournamentQuery($slug: String) {
|
||||
tournament(slug: $slug){
|
||||
id
|
||||
|
||||
name
|
||||
|
||||
events {
|
||||
id
|
||||
|
||||
name,
|
||||
state,
|
||||
videogame {
|
||||
id,
|
||||
name,
|
||||
displayName
|
||||
},
|
||||
entrants{
|
||||
nodes{
|
||||
id
|
||||
name,
|
||||
participants{
|
||||
id,
|
||||
gamerTag
|
||||
player{
|
||||
gamerTag
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
}"
|
||||
,
|
||||
OperationName = "TournamentQuery",
|
||||
Variables = new
|
||||
{
|
||||
slug = slug,
|
||||
}
|
||||
};
|
||||
|
||||
//GraphQLHttpRequest preprocessedRequest = await graphQLClient.Options.PreprocessRequest(EventType, graphQLClient);
|
||||
//var x = preprocessedRequest.ToHttpRequestMessage(graphQLClient.Options, new NewtonsoftJsonSerializer());
|
||||
//System.Diagnostics.Trace.WriteLine(x.Content.ReadAsStringAsync().Result);
|
||||
//var sendAsync = await graphQLClient.HttpClient.SendAsync(x);
|
||||
//System.Diagnostics.Trace.WriteLine(sendAsync.Content.ReadAsStringAsync().Result);
|
||||
|
||||
var graphQLResponse = await graphQLClient.SendQueryAsync<TournamentResponse>(Event);
|
||||
if (graphQLResponse.Errors != null)
|
||||
{
|
||||
//EventType not done ?
|
||||
//throw new Exception("Error");
|
||||
}
|
||||
System.Diagnostics.Trace.Write(graphQLResponse.Data.Tournament.Name);
|
||||
|
||||
return graphQLResponse.Data;
|
||||
}
|
||||
|
||||
|
||||
public async Task<TournamentResponse> GetTournament(string slug)
|
||||
{
|
||||
|
||||
|
||||
@@ -80,6 +80,8 @@ namespace LaDOSE.Business.Provider.SmashProvider
|
||||
public VideoGameType videogame { get; set; }
|
||||
public Node<StandingType> standings { get; set; }
|
||||
public Node<SetType> sets { get; set; }
|
||||
|
||||
public Node<EntrantType> entrants { get; set; }
|
||||
}
|
||||
|
||||
public class EntrantType
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Reactive.Subjects;
|
||||
using System.Threading.Tasks;
|
||||
using LaDOSE.Business.Helper;
|
||||
using LaDOSE.Business.Interface;
|
||||
using LaDOSE.Business.Provider.SmashProvider;
|
||||
using LaDOSE.Entity;
|
||||
using LaDOSE.Entity.Challonge;
|
||||
using LaDOSE.Entity.Context;
|
||||
@@ -360,6 +361,15 @@ namespace LaDOSE.Business.Service
|
||||
|
||||
return await Task.FromResult(result);
|
||||
}
|
||||
|
||||
public async Task<List<string>> GetPlayer(string slug)
|
||||
{
|
||||
var tournament = await _smashProvider.GetNames(slug);
|
||||
var players = tournament.Tournament.Events.SelectMany(e => e.entrants.nodes.SelectMany(x => x.participants.Select(e => e.gamerTag))).ToList();
|
||||
return players;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Result For one Event
|
||||
/// </summary>
|
||||
@@ -368,7 +378,7 @@ namespace LaDOSE.Business.Service
|
||||
public async Task<TournamentsResult> GetEventResult(int id)
|
||||
{
|
||||
|
||||
Event cevent = _context.Event.Include(e=>e.Tournaments).ThenInclude(t=>t.Results).ThenInclude(e=>e.Player).FirstOrDefault(e => e.Id == id);
|
||||
Event cevent = _context.Event.Include(e => e.Tournaments).ThenInclude(t => t.Results).ThenInclude(e => e.Player).FirstOrDefault(e => e.Id == id);
|
||||
var players = cevent.Tournaments.SelectMany(e => e.Results.Select(e => e.Player)).Distinct().ToList();
|
||||
var games = _context.Game.ToList();
|
||||
|
||||
@@ -407,18 +417,18 @@ namespace LaDOSE.Business.Service
|
||||
var Top8 = tournament.Results.Where(p => p.Rank > 4 && p.Rank < 9).ToList();
|
||||
var Top16 = tournament.Results.Where(p => p.Rank > 8 && p.Rank <= 16).ToList();
|
||||
|
||||
result.Results.Add(new Result(first.Player.Gamertag, tournament.Game?.Id??0, tournament.Id, tournament.Name, currentRule.FirstPoint, first.Rank));
|
||||
result.Results.Add(new Result(first.Player.Gamertag, tournament.Game?.Id ?? 0, tournament.Id, tournament.Name, currentRule.FirstPoint, first.Rank));
|
||||
lesSacs.Remove(first.Player);
|
||||
result.Results.Add(new Result(second.Player.Gamertag, tournament.Game?.Id ?? 0, tournament.Id, tournament.Name, currentRule.SecondPoint, second.Rank));
|
||||
lesSacs.Remove(second.Player);
|
||||
thirdFourth.ForEach(r =>
|
||||
result.Results.Add(new Result(r.Player.Gamertag, tournament.Game?.Id??0, tournament.Id, tournament.Name,
|
||||
result.Results.Add(new Result(r.Player.Gamertag, tournament.Game?.Id ?? 0, tournament.Id, tournament.Name,
|
||||
currentRule.ThirdFourthPoint, r.Rank)));
|
||||
thirdFourth.ForEach(p => lesSacs.Remove(p.Player));
|
||||
if (currentRule.Top8Point != 0)
|
||||
{
|
||||
Top8.ForEach(r =>
|
||||
result.Results.Add(new Result(r.Player.Gamertag, tournament.Game?.Id??0, tournament.Id, tournament.Name,
|
||||
result.Results.Add(new Result(r.Player.Gamertag, tournament.Game?.Id ?? 0, tournament.Id, tournament.Name,
|
||||
currentRule.Top8Point, r.Rank)));
|
||||
Top8.ForEach(p => lesSacs.Remove(p.Player));
|
||||
}
|
||||
@@ -427,20 +437,20 @@ namespace LaDOSE.Business.Service
|
||||
{
|
||||
Top16.ForEach(r =>
|
||||
result.Results.Add(
|
||||
new Result(r.Player.Gamertag, tournament.Game?.Id??0, tournament.Id, tournament.Name,
|
||||
new Result(r.Player.Gamertag, tournament.Game?.Id ?? 0, tournament.Id, tournament.Name,
|
||||
currentRule.Top16Point, r.Rank)));
|
||||
Top16.ForEach(p => lesSacs.Remove(p.Player));
|
||||
}
|
||||
|
||||
lesSacs.ForEach(r =>
|
||||
result.Results.Add(new Result(r.Gamertag, tournament.Game?.Id??0, tournament.Id, tournament.Name,
|
||||
currentRule.Participation, tournament.Results.FirstOrDefault(e=>e.Player == r)?.Rank??999)));
|
||||
result.Results.Add(new Result(r.Gamertag, tournament.Game?.Id ?? 0, tournament.Id, tournament.Name,
|
||||
currentRule.Participation, tournament.Results.FirstOrDefault(e => e.Player == r)?.Rank ?? 999)));
|
||||
|
||||
}
|
||||
|
||||
if (result.Results.Any(e => e.GameId == 0))
|
||||
{
|
||||
result.Games.Add(new Game(){Id = 0,Name = "GAME NOT FOUND",LongName = "GAME NOT FOUND",Order = 999});
|
||||
result.Games.Add(new Game() { Id = 0, Name = "GAME NOT FOUND", LongName = "GAME NOT FOUND", Order = 999 });
|
||||
}
|
||||
|
||||
var enumerable = result.Results.Select(e => e.GameId).Distinct();
|
||||
|
||||
Reference in New Issue
Block a user