Compare commits
10 Commits
88fb4935b5
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| e10663c8c0 | |||
| cd03b39c20 | |||
| 9d8a7b3100 | |||
| e99479d8fb | |||
| a9150ff58c | |||
| fba822a0af | |||
| 73407e5867 | |||
| 91664406c4 | |||
| bc95ef157d | |||
| 454c12a5a9 |
@@ -19,7 +19,7 @@ jobs:
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
# Semantic version range syntax or exact version of a dotnet version
|
||||
dotnet-version: '6.x'
|
||||
dotnet-version: '8.x'
|
||||
|
||||
- run: echo "Build."
|
||||
- name: Check out repository code
|
||||
@@ -36,8 +36,8 @@ jobs:
|
||||
dotnet build --configuration Release --os win LaDOSE.DesktopApp.Avalonia
|
||||
- name: Zip file
|
||||
run: |
|
||||
zip -rj build-winx64.zip ./LaDOSE.Src/LaDOSE.DesktopApp.Avalonia/bin/Release/net6.0/win-x64/
|
||||
zip -rj build-linux64.zip ./LaDOSE.Src/LaDOSE.DesktopApp.Avalonia/bin/Release/net6.0/linux-x64/
|
||||
zip -rj build-winx64.zip ./LaDOSE.Src/LaDOSE.DesktopApp.Avalonia/bin/Release/net8.0/win-x64/
|
||||
zip -rj build-linux64.zip ./LaDOSE.Src/LaDOSE.DesktopApp.Avalonia/bin/Release/net8.0/linux-x64/
|
||||
- name: Upload Artifact Windows
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
@@ -54,10 +54,15 @@ jobs:
|
||||
retention-days: 30
|
||||
overwrite: true
|
||||
|
||||
- name: Get current date
|
||||
id: date
|
||||
run: echo "date=$(echo $(date +'%Y-%m-%d'))" >> $GITHUB_OUTPUT
|
||||
- name: Release
|
||||
if: github.ref_name == 'master'
|
||||
uses: akkuman/gitea-release-action@v1
|
||||
env:
|
||||
with:
|
||||
tag_name: release-${{ steps.date.outputs.date }}
|
||||
files: |-
|
||||
build-winx64.zip
|
||||
build-linux64.zip
|
||||
|
||||
@@ -17,8 +17,17 @@ namespace LaDOSE.Api.Controllers
|
||||
[Produces("application/json")]
|
||||
public class GameController : GenericControllerDTO<IGameService, Game, GameDTO>
|
||||
{
|
||||
public GameController(IMapper mapper,IGameService service) : base(mapper,service)
|
||||
private IExternalProviderService provider;
|
||||
public GameController(IMapper mapper,IGameService service, IExternalProviderService service2) : base(mapper,service)
|
||||
{
|
||||
provider = service2;
|
||||
}
|
||||
[HttpGet("smash/{name}")]
|
||||
public async Task<List<GameDTO>> GetIdFromSmash(string name)
|
||||
{
|
||||
var smashGame = await provider.GetSmashGame(name);
|
||||
|
||||
return _mapper.Map<List<GameDTO>>(smashGame);;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace LaDOSE.Api.Controllers
|
||||
|
||||
private IMapper _mapper;
|
||||
|
||||
// GET
|
||||
// GETawa
|
||||
public TournamentController(IMapper mapper, IExternalProviderService service)
|
||||
{
|
||||
_mapper = mapper;
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace LaDOSE.Api.Controllers
|
||||
[HttpGet("UpdateDb")]
|
||||
public bool UpdateDb()
|
||||
{
|
||||
return _service.UpdateBooking();
|
||||
return false;
|
||||
}
|
||||
|
||||
[HttpGet("CreateChallonge/{gameId:int}/{wpEventId:int}")]
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<LangVersion>12</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -10,13 +11,13 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="10.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.8" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.8" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.8" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.4" />
|
||||
<PackageReference Include="AutoMapper" Version="13.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.12" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.12" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.7" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.11" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.11" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -24,6 +24,7 @@ using LaDOSE.Entity.Wordpress;
|
||||
using Result = LaDOSE.Entity.Challonge.Result;
|
||||
using LaDOSE.Entity.BotEvent;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace LaDOSE.Api
|
||||
{
|
||||
@@ -163,7 +164,7 @@ namespace LaDOSE.Api
|
||||
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
||||
public void Configure(IApplicationBuilder app, IHostEnvironment env, ILoggerFactory loggerFactory)
|
||||
{
|
||||
//loggerFactory.AddConsole(Configuration.GetSection("Logging"));
|
||||
//loggerFactory.AddDebug();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace LaDOSE.DTO
|
||||
{
|
||||
public class GameDTO
|
||||
{
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string LongName { get; set; }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ namespace LaDOSE.DTO
|
||||
public List<GameDTO> Games { get; set; }
|
||||
|
||||
public List<ResultDTO> Results { get; set; }
|
||||
|
||||
public string Slug { get; set; }
|
||||
}
|
||||
public class ResultDTO
|
||||
{
|
||||
|
||||
@@ -3,6 +3,8 @@ using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using LaDOSE.DesktopApp.Avalonia.ViewModels;
|
||||
using LaDOSE.DesktopApp.Avalonia.Views;
|
||||
using LaDOSE.REST;
|
||||
using MsBox.Avalonia;
|
||||
using ReactiveUI;
|
||||
using Splat;
|
||||
|
||||
@@ -10,6 +12,10 @@ namespace LaDOSE.DesktopApp.Avalonia;
|
||||
|
||||
public partial class App : Application
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
||||
<LangVersion>12</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -15,16 +16,17 @@
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="11.0.10"/>
|
||||
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.0.10" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.0.10"/>
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.10"/>
|
||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.10"/>
|
||||
<PackageReference Include="Avalonia" Version="11.2.3" />
|
||||
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.2.3" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.2.3" />
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.3" />
|
||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.3" />
|
||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.10"/>
|
||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.10"/>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
|
||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.3" />
|
||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.2.3" />
|
||||
<PackageReference Include="MessageBox.Avalonia" Version="3.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using LaDOSE.REST;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MsBox.Avalonia;
|
||||
using MsBox.Avalonia.Enums;
|
||||
using Splat;
|
||||
// using Xilium.CefGlue;
|
||||
// using Xilium.CefGlue.Common;
|
||||
@@ -22,23 +24,36 @@ sealed class Program
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
RegisterDependencies(Locator.CurrentMutable, Locator.Current);
|
||||
BuildAvaloniaApp()
|
||||
.StartWithClassicDesktopLifetime(args);
|
||||
|
||||
var app = BuildAvaloniaApp();
|
||||
app.StartWithClassicDesktopLifetime(args);
|
||||
}
|
||||
|
||||
private static void RegisterDependencies(IMutableDependencyResolver currentMutable, IReadonlyDependencyResolver current)
|
||||
{
|
||||
var builder = new ConfigurationBuilder()
|
||||
.AddJsonFile("settings.json", optional: true, reloadOnChange: true).Build();
|
||||
var restUrl = builder["REST:Url"].ToString();
|
||||
var restUser = builder["REST:User"].ToString();
|
||||
var restPassword = builder["REST:Password"].ToString();
|
||||
currentMutable.RegisterLazySingleton<RestService>(()=>
|
||||
{
|
||||
var restService = new RestService();
|
||||
restService.Connect(new Uri(restUrl),restUser,restPassword);
|
||||
return restService;
|
||||
});
|
||||
|
||||
var builder = new ConfigurationBuilder()
|
||||
.AddJsonFile("settings.json", optional: true, reloadOnChange: true).Build();
|
||||
var restUrl = builder["REST:Url"].ToString();
|
||||
var restUser = builder["REST:User"].ToString();
|
||||
var restPassword = builder["REST:Password"].ToString();
|
||||
|
||||
currentMutable.Register<RestService>(() =>
|
||||
{
|
||||
var restService = new RestService(new Uri(restUrl), restUser, restPassword);
|
||||
try
|
||||
{
|
||||
restService.Connect(new Uri(restUrl), restUser, restPassword);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
|
||||
}
|
||||
|
||||
return restService;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Avalonia configuration, don't remove; also used by visual designer.
|
||||
@@ -48,13 +63,5 @@ sealed class Program
|
||||
.UsePlatformDetect()
|
||||
.WithInterFont()
|
||||
.LogToTrace()
|
||||
.AfterSetup(_ =>
|
||||
{
|
||||
// CefRuntimeLoader.Initialize(new CefSettings()
|
||||
// {
|
||||
// WindowlessRenderingEnabled = true,
|
||||
// NoSandbox = true,
|
||||
// });
|
||||
})
|
||||
.UseReactiveUI();
|
||||
}
|
||||
@@ -14,14 +14,14 @@ namespace LaDOSE.DesktopApp.Avalonia.Utils
|
||||
_compare = c;
|
||||
}
|
||||
|
||||
public bool Equals(T x, T y)
|
||||
public bool Equals(T? x, T? y)
|
||||
{
|
||||
return _compare(x, y);
|
||||
}
|
||||
|
||||
public int GetHashCode(T obj)
|
||||
{
|
||||
return 0;
|
||||
return obj.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
|
||||
private GameDTO _currentGame;
|
||||
private List<GameDTO> _games;
|
||||
private List<GameDTO> _Searchgames;
|
||||
private RestService RestService { get; set; }
|
||||
public GamesViewModel(IScreen screen): base(screen,"Games")
|
||||
{
|
||||
@@ -26,6 +27,7 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
OnInitialize();
|
||||
}
|
||||
|
||||
|
||||
void OnInitialize()
|
||||
{
|
||||
LoadGames();
|
||||
@@ -49,6 +51,15 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public List<GameDTO> SearchGame
|
||||
{
|
||||
get => _Searchgames;
|
||||
set
|
||||
{
|
||||
_Searchgames = value;
|
||||
RaisePropertyChanged(nameof(this.SearchGame));
|
||||
}
|
||||
}
|
||||
public GameDTO CurrentGame
|
||||
{
|
||||
get => _currentGame;
|
||||
@@ -79,6 +90,10 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
LoadGames();
|
||||
}
|
||||
|
||||
public void GetGame()
|
||||
{
|
||||
SearchGame = this.RestService.GetSmashGames(this.CurrentGame.LongName);
|
||||
}
|
||||
public bool CanDeleteGame => CurrentGame != null;
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ public class MainWindowViewModel : Window
|
||||
|
||||
public void CloseApp()
|
||||
{
|
||||
if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime)
|
||||
((IClassicDesktopStyleApplicationLifetime)Application.Current.ApplicationLifetime).Shutdown();
|
||||
if (Application.Current != null && Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime)
|
||||
((Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)!).Shutdown();
|
||||
}
|
||||
}
|
||||
@@ -21,16 +21,16 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
{
|
||||
public string DisplayName => "Tournament Result";
|
||||
|
||||
private RestService RestService { get; set; }
|
||||
private RestService? RestService { get; set; }
|
||||
//Dictionary<string, Dictionary<int, int>> _computedResult;
|
||||
|
||||
#region Properties
|
||||
|
||||
private string css = string.Empty;
|
||||
|
||||
private String _selectRegex;
|
||||
private string? _selectRegex;
|
||||
|
||||
public String SelectRegex
|
||||
public string? SelectRegex
|
||||
{
|
||||
get { return _selectRegex; }
|
||||
set
|
||||
@@ -40,9 +40,9 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private String _selectEventRegex;
|
||||
private string? _selectEventRegex;
|
||||
|
||||
public String SelectEventRegex
|
||||
public string? SelectEventRegex
|
||||
{
|
||||
get { return _selectEventRegex; }
|
||||
set
|
||||
@@ -51,8 +51,8 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
RaisePropertyChanged(nameof(SelectEventRegex));
|
||||
}
|
||||
}
|
||||
private string _slug;
|
||||
public String Slug
|
||||
private string? _slug;
|
||||
public string? Slug
|
||||
{
|
||||
get { return _slug; }
|
||||
set
|
||||
@@ -62,9 +62,9 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private String _html;
|
||||
private string? _html;
|
||||
|
||||
public String Html
|
||||
public string? Html
|
||||
{
|
||||
get { return $"<html><head><style>{this.css}</style></head><body>{HtmlContent}</body></html>"; }
|
||||
set
|
||||
@@ -72,9 +72,9 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
_html = value;
|
||||
}
|
||||
}
|
||||
private String _htmlContent;
|
||||
private string? _htmlContent;
|
||||
|
||||
public String HtmlContent
|
||||
public string? HtmlContent
|
||||
{
|
||||
get { return _htmlContent; }
|
||||
set
|
||||
@@ -112,12 +112,12 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
}
|
||||
|
||||
|
||||
private TournamentsResultDTO _results;
|
||||
private TournamentsResultDTO? _results;
|
||||
public List<TournamentDTO> Tournaments { get; set; }
|
||||
|
||||
public List<EventDTO> Events { get; set; }
|
||||
|
||||
public TournamentsResultDTO Results
|
||||
public TournamentsResultDTO? Results
|
||||
{
|
||||
get => _results;
|
||||
set
|
||||
@@ -151,10 +151,10 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private GameDTO _selectedGame;
|
||||
private GameDTO? _selectedGame;
|
||||
|
||||
|
||||
public GameDTO SelectedGame
|
||||
public GameDTO? SelectedGame
|
||||
{
|
||||
get { return _selectedGame; }
|
||||
set
|
||||
@@ -172,9 +172,9 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private ObservableCollection<ResultDTO> _selectedGameResult;
|
||||
private ObservableCollection<ResultDTO>? _selectedGameResult;
|
||||
|
||||
public ObservableCollection<ResultDTO> SelectedGameResult
|
||||
public ObservableCollection<ResultDTO>? SelectedGameResult
|
||||
{
|
||||
get { return _selectedGameResult; }
|
||||
set
|
||||
@@ -184,11 +184,11 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private String _first;
|
||||
private DataTable _gridDataTable;
|
||||
private string _error;
|
||||
private string? _first;
|
||||
private DataTable? _gridDataTable;
|
||||
private string? _error;
|
||||
|
||||
public String First
|
||||
public string? First
|
||||
{
|
||||
get { return _first; }
|
||||
set
|
||||
@@ -223,8 +223,8 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
this.To = new DateTimeOffset(DateTime.Now);
|
||||
this.From = new DateTimeOffset(DateTime.Now.AddMonths(-1));
|
||||
this.SelectRegex = "Ranking";
|
||||
this.SelectEventRegex = @"Ranking #10\d{2}";
|
||||
this.Slug = "ranking-1001";
|
||||
this.SelectEventRegex = @"Ranking #13\d{2}";
|
||||
this.Slug = "ranking-130";
|
||||
|
||||
LoadTournaments();
|
||||
LoadEvents();
|
||||
@@ -244,7 +244,7 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
public void LoadEvents()
|
||||
{
|
||||
|
||||
var eventsDtos = this.RestService
|
||||
List<EventDTO> eventsDtos = this.RestService
|
||||
.GetAllEvents().ToList();
|
||||
this.Events = eventsDtos;
|
||||
|
||||
@@ -252,7 +252,7 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
|
||||
}
|
||||
|
||||
public DataTable GridDataTable
|
||||
public DataTable? GridDataTable
|
||||
{
|
||||
get => _gridDataTable;
|
||||
set
|
||||
@@ -262,7 +262,7 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
RaisePropertyChanged(nameof(GridDataTableView));
|
||||
}
|
||||
}
|
||||
public DataView GridDataTableView
|
||||
public DataView? GridDataTableView
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -274,8 +274,8 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
public void Select()
|
||||
{
|
||||
|
||||
var tournamentsIds = SelectedEvents.Select(e => e.Id).ToList();
|
||||
var resultsDto = this.RestService.GetResults(tournamentsIds);
|
||||
List<int> tournamentsIds = SelectedEvents.Select(e => e.Id).ToList();
|
||||
TournamentsResultDTO? resultsDto = this.RestService.GetResults(tournamentsIds);
|
||||
this.Results = resultsDto;
|
||||
ComputeDataGrid();
|
||||
ComputeHtml();
|
||||
@@ -285,7 +285,7 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
{
|
||||
|
||||
|
||||
var resultsDto = this.RestService.ParseSmash(Slug);
|
||||
bool resultsDto = this.RestService.ParseSmash(Slug);
|
||||
if (!resultsDto)
|
||||
{
|
||||
Error = "Error getting Smash";
|
||||
@@ -293,7 +293,7 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
|
||||
}
|
||||
|
||||
public string Error
|
||||
public string? Error
|
||||
{
|
||||
get => _error;
|
||||
set
|
||||
@@ -307,8 +307,8 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
public void GetChallonge()
|
||||
{
|
||||
|
||||
var ids = SelectedTournaments.Select(e => e.ChallongeId).ToList();
|
||||
var resultsDto = this.RestService.ParseChallonge(ids);
|
||||
List<int> ids = SelectedTournaments.Select(e => e.ChallongeId).ToList();
|
||||
bool resultsDto = this.RestService.ParseChallonge(ids);
|
||||
if (!resultsDto)
|
||||
{
|
||||
Error = "Fail";
|
||||
@@ -334,14 +334,14 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
|
||||
public void SelectRegexp()
|
||||
{
|
||||
var selectedTournaments = this.Tournaments.Where(e => Regex.IsMatch(e.Name, this.SelectRegex)).ToList();
|
||||
List<TournamentDTO> selectedTournaments = this.Tournaments.Where(e => Regex.IsMatch(e.Name, this.SelectRegex)).ToList();
|
||||
this.SelectedTournaments.Clear();
|
||||
if (selectedTournaments.Count > 0)
|
||||
selectedTournaments.ForEach(e => this.SelectedTournaments.Add(e));
|
||||
}
|
||||
public void SelectEvent()
|
||||
{
|
||||
var selectedEvents = this.Events.Where(e => Regex.IsMatch(e.Name, this.SelectEventRegex)).ToList();
|
||||
List<EventDTO> selectedEvents = this.Events.Where(e => Regex.IsMatch(e.Name, this.SelectEventRegex)).ToList();
|
||||
this.SelectedEvents.Clear();
|
||||
if (selectedEvents.Count > 0)
|
||||
selectedEvents.ForEach(e => this.SelectedEvents.Add(e));
|
||||
@@ -349,15 +349,15 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
//This could be simplified the Dictionary was for a previous usage, but i m too lazy to rewrite it.
|
||||
private void ComputeDataGrid()
|
||||
{
|
||||
var resultsParticipents = this.Results.Participents.Select(e=>e.Name).Distinct(new CustomListExtension.EqualityComparer<String>((a, b) => a.ToUpperInvariant()== b.ToUpperInvariant())).OrderBy(e=>e).ToList();
|
||||
List<string> resultsParticipents = this.Results.Participents.Select(e=>e.Name).Distinct(new CustomListExtension.EqualityComparer<String>((a, b) => a.ToUpperInvariant()== b.ToUpperInvariant())).OrderBy(e=>e).ToList();
|
||||
//At start the dictionnary was for some fancy dataviz things, but since the point are inside
|
||||
//i m to lazy to rewrite this functions (this is so ugly...)
|
||||
//_computedResult = ResultsToDataDictionary(resultsParticipents);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
DataTable grid = new DataTable();
|
||||
var games = Results.Games.Distinct().OrderBy(e => e.Order).ToList();
|
||||
DataTable? grid = new DataTable();
|
||||
List<GameDTO> games = Results.Games.Distinct().OrderBy(e => e.Order).ToList();
|
||||
grid.Columns.Add("Players");
|
||||
games.ForEach(e => grid.Columns.Add(e.Name.Replace('.', ' '),typeof(Int32)));
|
||||
grid.Columns.Add("Total").DataType = typeof(Int32);
|
||||
@@ -365,16 +365,17 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
|
||||
for (int i = 0; i < resultsParticipents.Count; i++)
|
||||
{
|
||||
var dataRow = grid.Rows.Add();
|
||||
var resultsParticipent = resultsParticipents[i];
|
||||
DataRow dataRow = grid.Rows.Add();
|
||||
string resultsParticipent = resultsParticipents[i];
|
||||
int total = 0;
|
||||
dataRow["Players"] = resultsParticipent;
|
||||
|
||||
|
||||
for (int j = 0; j < games.Count; j++)
|
||||
{
|
||||
var resultsGame = Results.Games[j];
|
||||
var points = GetPlayerPoint(resultsParticipent, resultsGame.Id);
|
||||
GameDTO? resultsGame = Results.Games[j];
|
||||
int points = GetPlayerPoint(resultsParticipent, resultsGame.Id);
|
||||
var o = dataRow[resultsGame.Name.Replace('.', ' ')];
|
||||
dataRow[resultsGame.Name.Replace('.', ' ')] = points!=0?points:0;
|
||||
total += points;
|
||||
}
|
||||
@@ -434,10 +435,10 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
|
||||
int columns = 0;
|
||||
|
||||
var distinct = Results.Results.Select(e => e.GameId).Distinct();
|
||||
IEnumerable<int> distinct = Results.Results.Select(e => e.GameId).Distinct();
|
||||
|
||||
var gamePlayed = Results.Games.Where(e=> distinct.Contains(e.Id)).OrderBy(e=>e.Order);
|
||||
foreach (var game in gamePlayed)
|
||||
IOrderedEnumerable<GameDTO> gamePlayed = Results.Games.Where(e=> distinct.Contains(e.Id)).OrderBy(e=>e.Order);
|
||||
foreach (GameDTO game in gamePlayed)
|
||||
{
|
||||
List<ResultDTO> enumerable = Results.Results.Where(r => r.GameId == game.Id).ToList();
|
||||
List<string> top3 = enumerable.OrderBy(e => e.Rank).Take(3).Select(e => e.Player).ToList();
|
||||
@@ -451,7 +452,7 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
sb.Append("<tr>");
|
||||
}
|
||||
columns++;
|
||||
var span = 1;
|
||||
int span = 1;
|
||||
if (columns == gamePlayed.Count())
|
||||
{
|
||||
if (columns % 2 != 0)
|
||||
@@ -468,10 +469,10 @@ namespace LaDOSE.DesktopApp.Avalonia.ViewModels
|
||||
{
|
||||
sb.AppendLine($"<br> 1/ {top3[0]}<br> 2/ {top3[1]}<br> 3/ {top3[2]} <br>");
|
||||
//<a href=\"https://challonge.com/fr/{enumerable.First().TournamentUrl}\" target=\"_blank\">https://challonge.com/fr/{enumerable.First().TournamentUrl}</a>
|
||||
var url = enumerable.FirstOrDefault().TournamentUrl;
|
||||
string url = enumerable.FirstOrDefault()?.TournamentUrl;
|
||||
url = url.Replace(" ", "-");
|
||||
url = url.Replace(".", "-");
|
||||
sb.AppendLine($"<a href=\"https://smash.gg/tournament/ranking-1002/event/{url}\" target=\"_blank\">Voir le Bracket</p></td>");
|
||||
sb.AppendLine($"<a href=\"https://start.gg/tournament/{Results.Slug}/event/{url}\" target=\"_blank\">Voir le Bracket</p></td>");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="650"
|
||||
x:Class="LaDOSE.DesktopApp.Avalonia.Views.GamesView"
|
||||
xmlns:vm="using:LaDOSE.DesktopApp.Avalonia.ViewModels"
|
||||
xmlns:dto="clr-namespace:LaDOSE.DTO;assembly=LaDOSE.DTO"
|
||||
x:DataType="vm:GamesViewModel"
|
||||
>
|
||||
<Grid Row="4" Column="1">
|
||||
@@ -42,6 +43,7 @@
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
|
||||
@@ -71,11 +73,19 @@
|
||||
<Label Grid.Row="6" Grid.Column="0">WpTagOs</Label>
|
||||
<TextBox Grid.Row="6" Grid.Column="1" Text="{Binding Path=CurrentGame.WordPressTagOs,Mode=TwoWay}" ></TextBox>
|
||||
<Label Grid.Row="7" Grid.Column="0">SmashId</Label>
|
||||
<TextBox Grid.Row="7" Grid.Column="1" Text="{Binding Path=CurrentGame.SmashId,Mode=TwoWay}">
|
||||
<AutoCompleteBox Grid.Row="7" Grid.Column="1" Text="{Binding Path=CurrentGame.SmashId,Mode=TwoWay}" ItemsSource="{Binding Path=SearchGame}">
|
||||
<AutoCompleteBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<DockPanel LastChildFill="True" Margin="2" x:DataType="dto:GameDTO">
|
||||
<TextBox Text="{Binding Id}"></TextBox>
|
||||
<TextBlock Text="{Binding Name}" DockPanel.Dock="Left"/>
|
||||
</DockPanel>
|
||||
</DataTemplate>
|
||||
</AutoCompleteBox.ItemTemplate>
|
||||
</AutoCompleteBox>
|
||||
|
||||
</TextBox>
|
||||
|
||||
<Button Grid.Row="9" Grid.ColumnSpan="2" x:Name="Update" Command="{Binding Update}">Update</Button>
|
||||
<Button Grid.Row="9" x:Name="Update" Command="{Binding Update}">Update</Button>
|
||||
<Button Grid.Row="9" Grid.Column="1" x:Name="SmashGame" Command="{Binding GetGame}">Get Game From Smash</Button>
|
||||
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
@@ -207,6 +207,6 @@
|
||||
|
||||
|
||||
</Grid>
|
||||
<Button Grid.Column="0" Grid.Row="4" Grid.ColumnSpan="3" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" x:Name="Export" Command="{Binding Export}">Export</Button>
|
||||
<Button Grid.Column="0" Grid.Row="4" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" x:Name="Export" Command="{Binding Export}">Export</Button>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -24,7 +24,7 @@ namespace LaDOSE.DesktopApp.Avalonia.Views
|
||||
object? IViewFor.ViewModel
|
||||
{
|
||||
get => ViewModel;
|
||||
set => ViewModel = (TournamentResultViewModel)value;
|
||||
set => ViewModel = (TournamentResultViewModel)value!;
|
||||
}
|
||||
|
||||
public TournamentResultViewModel? ViewModel { get; set; }
|
||||
|
||||
7
LaDOSE.Src/LaDOSE.DesktopApp.Avalonia/build.android.sh
Executable file
7
LaDOSE.Src/LaDOSE.DesktopApp.Avalonia/build.android.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
export ANDROID_HOME=/home/tom/src/android/
|
||||
export PATH=$PATH:$ANDROID_HOME/build-tools/34.0.0:$ANDROID_HOME/platforms/android-34
|
||||
|
||||
dotnet build LaDOSE.DesktopApp.Avalonia.csproj -p:TargetFramework=net6.0-android -p:AndroidSdkDirectory=$ANDROID_HOME/build-tools/34.0.0
|
||||
|
||||
@@ -1,58 +1,55 @@
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using DSharpPlus.CommandsNext;
|
||||
using DSharpPlus.CommandsNext.Attributes;
|
||||
using LaDOSE.DiscordBot.Service;
|
||||
using LaDOSE.DTO;
|
||||
|
||||
namespace LaDOSE.DiscordBot.Command
|
||||
{
|
||||
public class BotEvent : BaseCommandModule
|
||||
{
|
||||
private WebService dep;
|
||||
public BotEvent(WebService d)
|
||||
{
|
||||
dep = d;
|
||||
}
|
||||
|
||||
[RequireRolesAttribute(RoleCheckMode.Any, "Staff")]
|
||||
[Command("newevent")]
|
||||
public async Task NewEventAsync(CommandContext ctx, string command)
|
||||
{
|
||||
|
||||
await ctx.RespondAsync(dep.RestService.CreateBotEvent(command).ToString());
|
||||
}
|
||||
[RequireRolesAttribute(RoleCheckMode.Any,"Staff")]
|
||||
[Command("staffs")]
|
||||
public async Task StaffAsync(CommandContext ctx)
|
||||
{
|
||||
BotEventDTO currentEvent = dep.RestService.GetLastBotEvent();
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
var present = currentEvent.Results.Where(x => x.Result).ToList();
|
||||
var absent = currentEvent.Results.Where(x => !x.Result).ToList();
|
||||
|
||||
stringBuilder.AppendLine($"Pour {currentEvent.Name} : ");
|
||||
present.ForEach(x => stringBuilder.AppendLine($":white_check_mark: {x.Name}"));
|
||||
absent.ForEach(x => stringBuilder.AppendLine($":x: {x.Name}"));
|
||||
|
||||
await ctx.RespondAsync(stringBuilder.ToString());
|
||||
|
||||
}
|
||||
[RequireRolesAttribute(RoleCheckMode.Any, "Staff")]
|
||||
[Command("present")]
|
||||
public async Task PresentAsync(CommandContext ctx)
|
||||
{
|
||||
await ctx.RespondAsync(dep.RestService.ResultBotEvent(new DTO.BotEventSendDTO() { DiscordId = ctx.Member.Id.ToString(), DiscordName = ctx.Member.DisplayName, Present = true }).ToString());
|
||||
|
||||
|
||||
}
|
||||
[RequireRolesAttribute(RoleCheckMode.Any, "Staff")]
|
||||
[Command("absent")]
|
||||
public async Task AbsentAsync(CommandContext ctx)
|
||||
{
|
||||
await ctx.RespondAsync(dep.RestService.ResultBotEvent(new DTO.BotEventSendDTO() { DiscordId = ctx.Member.Id.ToString(), DiscordName = ctx.Member.DisplayName, Present = false }).ToString());
|
||||
}
|
||||
}
|
||||
// public class BotEvent : BaseCommandModule
|
||||
// {
|
||||
// private WebService dep;
|
||||
// public BotEvent(WebService d)
|
||||
// {
|
||||
// dep = d;
|
||||
// }
|
||||
//
|
||||
// [Command("newevent")]
|
||||
// public async Task NewEventAsync(CommandContext ctx, string command)
|
||||
// {
|
||||
//
|
||||
// await ctx.RespondAsync(dep.RestService.CreateBotEvent(command).ToString());
|
||||
// }
|
||||
// [RequireRolesAttribute(RoleCheckMode.Any,"Staff")]
|
||||
// [Command("staffs")]
|
||||
// public async Task StaffAsync(CommandContext ctx)
|
||||
// {
|
||||
// BotEventDTO currentEvent = dep.RestService.GetLastBotEvent();
|
||||
// StringBuilder stringBuilder = new StringBuilder();
|
||||
//
|
||||
// var present = currentEvent.Results.Where(x => x.Result).ToList();
|
||||
// var absent = currentEvent.Results.Where(x => !x.Result).ToList();
|
||||
//
|
||||
// stringBuilder.AppendLine($"Pour {currentEvent.Name} : ");
|
||||
// present.ForEach(x => stringBuilder.AppendLine($":white_check_mark: {x.Name}"));
|
||||
// absent.ForEach(x => stringBuilder.AppendLine($":x: {x.Name}"));
|
||||
//
|
||||
// await ctx.RespondAsync(stringBuilder.ToString());
|
||||
//
|
||||
// }
|
||||
// [RequireRolesAttribute(RoleCheckMode.Any, "Staff")]
|
||||
// [Command("present")]
|
||||
// public async Task PresentAsync(CommandContext ctx)
|
||||
// {
|
||||
// await ctx.RespondAsync(dep.RestService.ResultBotEvent(new DTO.BotEventSendDTO() { DiscordId = ctx.Member.Id.ToString(), DiscordName = ctx.Member.DisplayName, Present = true }).ToString());
|
||||
//
|
||||
//
|
||||
// }
|
||||
// [RequireRolesAttribute(RoleCheckMode.Any, "Staff")]
|
||||
// [Command("absent")]
|
||||
// public async Task AbsentAsync(CommandContext ctx)
|
||||
// {
|
||||
// await ctx.RespondAsync(dep.RestService.ResultBotEvent(new DTO.BotEventSendDTO() { DiscordId = ctx.Member.Id.ToString(), DiscordName = ctx.Member.DisplayName, Present = false }).ToString());
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -2,14 +2,15 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using DSharpPlus.CommandsNext;
|
||||
using DSharpPlus.CommandsNext.Attributes;
|
||||
using DSharpPlus.Commands;
|
||||
using DSharpPlus.Commands.ArgumentModifiers;
|
||||
using DSharpPlus.Commands.Processors.TextCommands;
|
||||
using DSharpPlus.Entities;
|
||||
|
||||
namespace LaDOSE.DiscordBot.Command
|
||||
{
|
||||
|
||||
public class Hokuto : BaseCommandModule
|
||||
public class Hokuto
|
||||
{
|
||||
|
||||
private static List<string> Games = new List<string> { "2X", "3.3", "Karnov" };
|
||||
@@ -21,14 +22,21 @@ namespace LaDOSE.DiscordBot.Command
|
||||
|
||||
|
||||
[Command("hokuto")]
|
||||
public async Task HokutoUserAsync(CommandContext ctx, params DiscordMember[] user)
|
||||
public async ValueTask HokutoUserAsync(TextCommandContext ctx)
|
||||
{
|
||||
|
||||
|
||||
var i = r.Next(0, 3);
|
||||
if (user!=null && user.Length>0)
|
||||
if (ctx.Message.MentionedUsers is { Count: 1 } )
|
||||
{
|
||||
await ctx.RespondAsync(ctx.User?.Mention + " vs " + user[0].Mention + " : " + Games[i].ToString());
|
||||
foreach (var arg in ctx.Message.MentionedUsers)
|
||||
{
|
||||
if (arg is DiscordUser member)
|
||||
{
|
||||
await ctx.RespondAsync(ctx.User?.Mention + " vs " + member.Mention + " : " + Games[i].ToString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -4,12 +4,11 @@ using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using DSharpPlus.CommandsNext;
|
||||
using DSharpPlus.CommandsNext.Attributes;
|
||||
using DSharpPlus.Commands;
|
||||
|
||||
namespace LaDOSE.DiscordBot.Command
|
||||
{
|
||||
public class Public : BaseCommandModule
|
||||
public class Public
|
||||
{
|
||||
|
||||
private static List<string> Quotes { get; set; }
|
||||
|
||||
@@ -2,16 +2,17 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DSharpPlus" Version="4.2.0" />
|
||||
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.2.0" />
|
||||
<PackageReference Include="DSharpPlus.Interactivity" Version="4.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.8" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.8" />
|
||||
<PackageReference Include="DSharpPlus" Version="5.0.0-alpha.5" />
|
||||
<PackageReference Include="DSharpPlus.Commands" Version="5.0.0-alpha.5" />
|
||||
<PackageReference Include="DSharpPlus.Interactivity" Version="5.0.0-alpha.5" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -4,8 +4,12 @@ using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using DSharpPlus;
|
||||
using DSharpPlus.Commands;
|
||||
using DSharpPlus.Commands.Processors.SlashCommands;
|
||||
using DSharpPlus.Commands.Processors.TextCommands;
|
||||
using DSharpPlus.Commands.Processors.TextCommands.Parsing;
|
||||
using DSharpPlus.Entities;
|
||||
using DSharpPlus.Interactivity;
|
||||
using DSharpPlus.CommandsNext;
|
||||
using DSharpPlus.EventArgs;
|
||||
using DSharpPlus.Interactivity.Extensions;
|
||||
//using DSharpPlus.SlashCommands;
|
||||
@@ -20,7 +24,6 @@ namespace LaDOSE.DiscordBot
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static DiscordClient discord;
|
||||
|
||||
//static InteractivityModule Interactivity { get; set; }
|
||||
static void Main(string[] args)
|
||||
@@ -42,107 +45,37 @@ namespace LaDOSE.DiscordBot
|
||||
var restUrl = builder["REST:Url"].ToString();
|
||||
var restUser = builder["REST:User"].ToString();
|
||||
var restPassword = builder["REST:Password"].ToString();
|
||||
|
||||
var service = new ServiceCollection()
|
||||
.AddSingleton(typeof(WebService), new WebService(new Uri(restUrl), restUser, restPassword))
|
||||
.BuildServiceProvider();
|
||||
|
||||
|
||||
|
||||
Console.WriteLine($"LaDOSE.Net Discord Bot");
|
||||
|
||||
|
||||
discord = new DiscordClient(new DiscordConfiguration
|
||||
{
|
||||
Token = discordToken,
|
||||
TokenType = TokenType.Bot,
|
||||
//AutoReconnect = true,
|
||||
//MinimumLogLevel = LogLevel.Debug,
|
||||
//MessageCacheSize = 0,
|
||||
});
|
||||
|
||||
discord.UseInteractivity(new InteractivityConfiguration
|
||||
{
|
||||
|
||||
// default pagination behaviour to just ignore the reactions
|
||||
//PaginationBehaviour = TimeoutBehaviour.Ignore,
|
||||
|
||||
// default pagination timeout to 5 minutes
|
||||
//PaginationTimeout = TimeSpan.FromMinutes(5),
|
||||
|
||||
// default timeout for other actions to 2 minutes
|
||||
Timeout = TimeSpan.FromMinutes(2)
|
||||
});
|
||||
|
||||
DiscordClientBuilder builder2 =
|
||||
DiscordClientBuilder.CreateDefault(discordToken, DiscordIntents.AllUnprivileged | DiscordIntents.MessageContents | DiscordIntents.GuildMessages| TextCommandProcessor.RequiredIntents | SlashCommandProcessor.RequiredIntents);
|
||||
|
||||
var cts = new CancellationTokenSource();
|
||||
|
||||
var _cnext = discord.UseCommandsNext(new CommandsNextConfiguration()
|
||||
// Setup the commands extension
|
||||
builder2.UseCommands((IServiceProvider serviceProvider, CommandsExtension extension) =>
|
||||
{
|
||||
//CaseSensitive = false,
|
||||
//EnableDefaultHelp = true,
|
||||
//EnableDms = false,
|
||||
//EnableMentionPrefix = true,
|
||||
StringPrefixes = new List<string>() { "/", "!" },
|
||||
//IgnoreExtraArguments = true,
|
||||
Services = service
|
||||
extension.AddCommands([typeof(Hokuto), typeof(Public)]);
|
||||
TextCommandProcessor textCommandProcessor = new();
|
||||
extension.AddProcessor(textCommandProcessor);
|
||||
}, new CommandsConfiguration()
|
||||
{
|
||||
// The default value is true, however it's shown here for clarity
|
||||
RegisterDefaultCommandProcessors = true,
|
||||
UseDefaultCommandErrorHandler = false
|
||||
// DebugGuildId = Environment.GetEnvironmentVariable("DEBUG_GUILD_ID") ?? 0,
|
||||
});
|
||||
|
||||
DiscordClient client = builder2.Build();
|
||||
|
||||
//var slashCommands = discord.UseSlashCommands(new SlashCommandsConfiguration() {Services = service});
|
||||
//slashCommands.RegisterCommands<SlashCommand>(guildId:null);
|
||||
|
||||
|
||||
//_cnext.RegisterCommands<Result>();
|
||||
_cnext.RegisterCommands<Public>();
|
||||
//_cnext.RegisterCommands<Shutdown>();
|
||||
//_cnext.RegisterCommands<Todo>();
|
||||
_cnext.RegisterCommands<Hokuto>();
|
||||
_cnext.RegisterCommands<BotEvent>();
|
||||
|
||||
foreach (var registeredCommandsKey in discord.GetCommandsNext().RegisteredCommands.Keys)
|
||||
{
|
||||
Console.WriteLine(registeredCommandsKey);
|
||||
}
|
||||
|
||||
|
||||
discord.Ready += (sender, eventArgs) =>
|
||||
{
|
||||
Console.WriteLine($"Bot READY.");
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
discord.GuildAvailable += (sender, eventArgs) =>
|
||||
{
|
||||
|
||||
Console.WriteLine($"Joined Guild " + eventArgs.Guild.Name);
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
await discord.ConnectAsync();
|
||||
// We can specify a status for our bot. Let's set it to "playing" and set the activity to "with fire".
|
||||
DiscordActivity status = new("Street Fighter", DiscordActivityType.Playing);
|
||||
await client.ConnectAsync(status,DiscordUserStatus.Online);
|
||||
|
||||
|
||||
await Task.Delay(Timeout.Infinite);
|
||||
|
||||
//while (!cts.IsCancellationRequested)
|
||||
//{
|
||||
// await Task.Delay(200);
|
||||
// //if(discord.GetConnectionsAsync().Result.Count)
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//internal class SlashCommand : ApplicationCommandModule
|
||||
//{
|
||||
// [SlashCommand("test", "A slash command made to test the DSharpPlusSlashCommands library!")]
|
||||
|
||||
// public async Task TestCommand(InteractionContext ctx)
|
||||
// {
|
||||
|
||||
// await ctx.CreateResponseAsync("Lol");
|
||||
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
@@ -9,6 +9,7 @@ namespace LaDOSE.Entity.Challonge
|
||||
public List<Game> Games{ get; set; }
|
||||
|
||||
public List<Result> Results { get; set; }
|
||||
public string Slug { get; set; }
|
||||
}
|
||||
|
||||
public class Result
|
||||
|
||||
@@ -2,12 +2,18 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.12" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.EntityFrameworkCore">
|
||||
<HintPath>..\..\..\..\.nuget\packages\microsoft.entityframeworkcore\8.0.11\lib\net8.0\Microsoft.EntityFrameworkCore.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<LangVersion>12</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="RestSharp" Version="110.2.0" />
|
||||
<PackageReference Include="RestSharp" Version="112.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -24,16 +24,33 @@ namespace LaDOSE.REST
|
||||
|
||||
public event EventHandler<UpdatedJwtEventHandler> UpdatedJwtEvent;
|
||||
|
||||
|
||||
public RestService()
|
||||
{
|
||||
|
||||
}
|
||||
public RestService(Uri url, string user, string password)
|
||||
{
|
||||
Client = new RestClient(url);
|
||||
this.username = user;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
|
||||
public void Connect(Uri url, string user, string password)
|
||||
{
|
||||
Client = new RestClient(url);
|
||||
string token = GetToken(user, password);
|
||||
// Client = new RestClient(url);
|
||||
// this.username = user;
|
||||
// this.password = password;
|
||||
string token;
|
||||
try
|
||||
{
|
||||
token = GetToken(user, password);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Client = new RestClient(url, options =>
|
||||
{
|
||||
#if DEBUG
|
||||
@@ -42,8 +59,7 @@ namespace LaDOSE.REST
|
||||
options.Authenticator = new JwtAuthenticator(token);
|
||||
});
|
||||
|
||||
this.username = user;
|
||||
this.password = password;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -69,7 +85,7 @@ namespace LaDOSE.REST
|
||||
|
||||
private void CheckToken()
|
||||
{
|
||||
if (this.Auth == null || this.Auth.Expire <= DateTime.Now)
|
||||
if (this.Auth == null || this.Auth.Expire.ToUniversalTime() <= DateTime.Now.ToUniversalTime())
|
||||
{
|
||||
GetToken(this.username,this.password);
|
||||
}
|
||||
@@ -204,6 +220,14 @@ namespace LaDOSE.REST
|
||||
var restResponse = Client.Get<List<GameDTO>>(restRequest);
|
||||
return restResponse;
|
||||
}
|
||||
|
||||
public List<GameDTO> GetSmashGames(string name)
|
||||
{
|
||||
CheckToken();
|
||||
var restRequest = new RestRequest($"/api/Game/Smash/{name}", Method.Get);
|
||||
var restResponse = Client.Get<List<GameDTO>>(restRequest);
|
||||
return restResponse;
|
||||
}
|
||||
|
||||
public GameDTO UpdateGame(GameDTO game)
|
||||
{
|
||||
|
||||
@@ -10,6 +10,9 @@ namespace LaDOSE.Business.Interface
|
||||
{
|
||||
Task<List<ChallongeTournament>> GetTournaments(DateTime? start, DateTime? end);
|
||||
Task<Event> ParseSmash(string tournamentSlug);
|
||||
|
||||
Task<List<Game>> GetSmashGame(string name);
|
||||
|
||||
//Task<List<Event>> ParseChallonge(List<int> ids);
|
||||
|
||||
//Task<TournamentsResult> GetChallongeTournamentsResult(List<int> ids);
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace LaDOSE.Business.Interface
|
||||
|
||||
Task<TournamentResponse> GetNames(string slug);
|
||||
|
||||
Task<List<Game>> GetGames(string name);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ namespace LaDOSE.Business.Interface
|
||||
List<WPEvent> GetWpEvent();
|
||||
List<WPUser> GetBooking(int wpEventId, Game game);
|
||||
List<WPUser> GetBookingOptions(int wpEventId, Game game);
|
||||
bool UpdateBooking();
|
||||
string CreateChallonge(int gameId, int wpEventId, IList<WPUser> additionPlayers);
|
||||
|
||||
Task<string> GetLastChallonge();
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<AssemblyName>LaDOSE.Business</AssemblyName>
|
||||
<RootNamespace>LaDOSE.Business</RootNamespace>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="GraphQL.Client" Version="4.0.2" />
|
||||
<PackageReference Include="GraphQL.Client.Serializer.Newtonsoft" Version="4.0.2" />
|
||||
<PackageReference Include="GraphQL.Client" Version="6.1.0" />
|
||||
<PackageReference Include="GraphQL.Client.Serializer.Newtonsoft" Version="6.1.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.12" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace LaDOSE.Business.Provider.SmashProvider
|
||||
{
|
||||
public class SmashProvider : ISmashProvider
|
||||
{
|
||||
private static string API_FQDN = "api.start.gg";
|
||||
public string ApiKey { get; set; }
|
||||
//public SmashProvider(string apiKey)
|
||||
//{
|
||||
@@ -34,7 +35,7 @@ namespace LaDOSE.Business.Provider.SmashProvider
|
||||
|
||||
private async Task<T> QuerySmash<T>(GraphQLRequest req)
|
||||
{
|
||||
var graphQLClient = new GraphQLHttpClient("https://api.smash.gg/gql/alpha", new NewtonsoftJsonSerializer());
|
||||
var graphQLClient = new GraphQLHttpClient($"https://{API_FQDN}/gql/alpha", new NewtonsoftJsonSerializer());
|
||||
graphQLClient.HttpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {ApiKey}");
|
||||
|
||||
var graphQLResponse = await graphQLClient.SendQueryAsync<T>(req);
|
||||
@@ -47,6 +48,37 @@ namespace LaDOSE.Business.Provider.SmashProvider
|
||||
return graphQLResponse.Data;
|
||||
}
|
||||
|
||||
public async Task<List<Game>> GetGames(string game)
|
||||
{
|
||||
var query = new GraphQLRequest()
|
||||
{
|
||||
Query = @"
|
||||
query VideogameQuery($name:String) {
|
||||
videogames(query: { filter: { name: $name }, perPage: 5 }) {
|
||||
nodes {
|
||||
id
|
||||
name
|
||||
displayName
|
||||
}
|
||||
}
|
||||
}
|
||||
",
|
||||
OperationName = "VideogameQuery",
|
||||
Variables = new
|
||||
{
|
||||
name = game,
|
||||
}
|
||||
};
|
||||
VideoGamesResponse querySmash = await QuerySmash<VideoGamesResponse>(query);
|
||||
if (querySmash.videogames != null)
|
||||
{
|
||||
return querySmash.videogames.nodes.Select(e => new Game() { Id = e.id, Name = e.Name }).ToList();
|
||||
}
|
||||
|
||||
return new List<Game>();
|
||||
|
||||
}
|
||||
|
||||
public async Task<Event> GetEvent(string slug)
|
||||
{
|
||||
|
||||
@@ -315,7 +347,7 @@ namespace LaDOSE.Business.Provider.SmashProvider
|
||||
public async Task<TournamentResponse> GetNames(string slug)
|
||||
{
|
||||
|
||||
var graphQLClient = new GraphQLHttpClient("https://api.smash.gg/gql/alpha", new NewtonsoftJsonSerializer());
|
||||
var graphQLClient = new GraphQLHttpClient($"https://{API_FQDN}/gql/alpha", new NewtonsoftJsonSerializer());
|
||||
graphQLClient.HttpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {ApiKey}");
|
||||
var Event = new GraphQLRequest
|
||||
{
|
||||
@@ -381,7 +413,7 @@ namespace LaDOSE.Business.Provider.SmashProvider
|
||||
public async Task<TournamentResponse> GetTournament(string slug)
|
||||
{
|
||||
|
||||
var graphQLClient = new GraphQLHttpClient("https://api.smash.gg/gql/alpha", new NewtonsoftJsonSerializer());
|
||||
var graphQLClient = new GraphQLHttpClient($"https://{API_FQDN}/gql/alpha", new NewtonsoftJsonSerializer());
|
||||
graphQLClient.HttpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {ApiKey}");
|
||||
var Event = new GraphQLRequest
|
||||
{
|
||||
|
||||
@@ -120,7 +120,10 @@ namespace LaDOSE.Business.Provider.SmashProvider
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class VideoGamesResponse
|
||||
{
|
||||
public Node<VideoGameType>? videogames {get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class TournamentResponse
|
||||
|
||||
@@ -6,6 +6,7 @@ using LaDOSE.Entity.BotEvent;
|
||||
using LaDOSE.Entity.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
|
||||
namespace LaDOSE.Business.Service
|
||||
{
|
||||
public class BotEventService : BaseService<BotEvent>, IBotEventService
|
||||
|
||||
@@ -78,6 +78,10 @@ namespace LaDOSE.Business.Service
|
||||
//}
|
||||
}
|
||||
|
||||
public async Task<List<Game>> GetSmashGames(string name)
|
||||
{
|
||||
return await _smashProvider.GetGames(name);
|
||||
}
|
||||
public async Task<Event> ParseSmash(string tournamentSlug)
|
||||
{
|
||||
Event eventExist = GetBySlug(tournamentSlug);
|
||||
@@ -109,6 +113,11 @@ namespace LaDOSE.Business.Service
|
||||
|
||||
}
|
||||
|
||||
public Task<List<Game>> GetSmashGame(string name)
|
||||
{
|
||||
return _smashProvider.GetGames(name);
|
||||
}
|
||||
|
||||
private Event GetBySlug(string tournamentSlug)
|
||||
{
|
||||
return _context.Event.FirstOrDefault(e => e.SmashSlug == tournamentSlug);
|
||||
@@ -139,10 +148,14 @@ namespace LaDOSE.Business.Service
|
||||
players = players.Concat(e.Tournaments.SelectMany(e => e.Results.Select(e => e.Player)).Distinct().ToList()).ToList();
|
||||
cevent.Tournaments = cevent.Tournaments.Concat(e.Tournaments).ToList();
|
||||
}
|
||||
|
||||
|
||||
var games = _context.Game.ToList();
|
||||
|
||||
TournamentsResult result = new TournamentsResult();
|
||||
if (id.Count == 1)
|
||||
{
|
||||
result.Slug = _context.Event.Where(e=> e.Id == id.First()).First().SmashSlug;
|
||||
}
|
||||
result.Results = new List<Result>();
|
||||
result.Games = new List<Game>();
|
||||
result.Participents = new List<ChallongeParticipent>();
|
||||
|
||||
@@ -42,14 +42,7 @@ namespace LaDOSE.Business.Service
|
||||
.Include(e => e.WPBookings).ThenInclude(e => e.WPUser).FirstOrDefault(e => Enumerable.Count<WPBooking>(e.WPBookings) != 0);
|
||||
return wpEvents;
|
||||
}
|
||||
|
||||
public bool UpdateBooking()
|
||||
{
|
||||
_context.Database.SetCommandTimeout(60);
|
||||
_context.Database.ExecuteSqlRaw("call ladoseapi.ImportEvent();");
|
||||
_context.Database.SetCommandTimeout(30);
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<WPUser> GetBooking(int wpEventId, Game game)
|
||||
{
|
||||
var selectedGameWpId = game.WordPressTag.Split(';');
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>12</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
internal class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Rest Test");
|
||||
var p = new LaDOSE.REST.RestService();
|
||||
Console.WriteLine("[+] Connect");
|
||||
|
||||
p.Connect(new Uri("http://localhost:5000/"),"dev","dev");
|
||||
Console.WriteLine("[+] Test");
|
||||
var games = p.GetGames();
|
||||
foreach (var ga in games)
|
||||
{
|
||||
Console.WriteLine(ga.Name);
|
||||
}
|
||||
// Console.WriteLine("Rest Test");
|
||||
// var p = new LaDOSE.REST.RestService();
|
||||
// Console.WriteLine("[+] Connect");
|
||||
//
|
||||
// p.Connect(new Uri("http://localhost:5000/"),"dev","dev");
|
||||
// Console.WriteLine("[+] Test");
|
||||
// var games = p.GetGames();
|
||||
// foreach (var ga in games)
|
||||
// {
|
||||
// Console.WriteLine(ga.Name);
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"sdk": {
|
||||
"version": "6.0.0",
|
||||
"version": "8.0.0",
|
||||
"rollForward": "latestMajor",
|
||||
"allowPrerelease": true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user