diff --git a/CastIt.Server/.config/dotnet-tools.json b/CastIt.Server/.config/dotnet-tools.json deleted file mode 100644 index 4ab94945..00000000 --- a/CastIt.Server/.config/dotnet-tools.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "version": 1, - "isRoot": true, - "tools": { - "dotnet-ef": { - "version": "5.0.2", - "commands": [ - "dotnet-ef" - ] - } - } -} \ No newline at end of file diff --git a/CastIt.Server/Common/Extensions/LoggingExtensions.cs b/CastIt.Server/Common/Extensions/LoggingExtensions.cs index 81f31da4..d8f1d94f 100644 --- a/CastIt.Server/Common/Extensions/LoggingExtensions.cs +++ b/CastIt.Server/Common/Extensions/LoggingExtensions.cs @@ -1,4 +1,5 @@ using CastIt.Domain.Models.Logging; +using CastIt.GoogleCast; using CastIt.Server.Controllers; using CastIt.Server.Hubs; using CastIt.Server.Services; @@ -26,7 +27,10 @@ public static List AddServerLogs(this List logs) //Services new FileToLog(typeof(ServerCastService), "service_cast"), new FileToLog(typeof(AppDataService), "service_appdata"), - new FileToLog(typeof(ServerAppSettingsService), "service_appsettings") + new FileToLog(typeof(ServerAppSettingsService), "service_appsettings"), + + //Others + new FileToLog(typeof(Player), "castit_player") }); return logs; } diff --git a/CastIt.Server/Common/MappingProfile.cs b/CastIt.Server/Common/MappingProfile.cs index 2dd360df..83a11e7b 100644 --- a/CastIt.Server/Common/MappingProfile.cs +++ b/CastIt.Server/Common/MappingProfile.cs @@ -1,6 +1,7 @@ using AutoMapper; using CastIt.Domain.Dtos.Responses; using CastIt.Domain.Entities; +using CastIt.GoogleCast; using CastIt.Infrastructure.Models; namespace CastIt.Server.Common @@ -17,6 +18,8 @@ public MappingProfile() CreateMap(); CreateMap(); CreateMap(); + + CreateMap(); } } } diff --git a/CastIt.Server/Common/ServerConstants.cs b/CastIt.Server/Common/ServerConstants.cs deleted file mode 100644 index acd728ed..00000000 --- a/CastIt.Server/Common/ServerConstants.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace CastIt.Server.Common -{ - public static class ServerConstants - { - public const int NoStreamSelectedId = -1; - public const int DefaultSelectedStreamId = 0; - public const int DefaultQualitySelected = 360; - } -} diff --git a/CastIt.Server/Services/AppDataService.cs b/CastIt.Server/Services/AppDataService.cs index f1cb4651..ccf154a4 100644 --- a/CastIt.Server/Services/AppDataService.cs +++ b/CastIt.Server/Services/AppDataService.cs @@ -1,11 +1,13 @@ using CastIt.Application.Common.Utils; using CastIt.Domain.Entities; +using CastIt.Infrastructure.Models; using CastIt.Server.Interfaces; using CastIt.Server.Migrations; using FluentMigrator.Runner; using Microsoft.Extensions.DependencyInjection; using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; namespace CastIt.Server.Services @@ -131,12 +133,6 @@ public Task GetNumberOfFiles(long playlistId) return _db.Select().Where(f => f.PlayListId == playlistId).CountAsync(); } - public void SaveChangesBeforeClosingApp(Dictionary playListsPositions, List vms) - { - SavePlayListsPositions(playListsPositions); - SaveFileChanges(vms); - } - public Task UpdatePlayList(long id, string name, int position) { return _db.Update(id) @@ -156,33 +152,33 @@ public Task UpdateFile(long id, string name, string description, double duration .ExecuteAffrowsAsync(); } - private void SavePlayListsPositions(Dictionary positions) + public async Task SavePlayListChanges(List playLists) { - if (positions.Count == 0) + if (playLists.Count == 0) return; - foreach (var (vm, position) in positions) - { - _db.Update(vm.Id) - .Set(p => p.Position, position) - .Set(p => p.Shuffle, vm.Shuffle) - .Set(p => p.Loop, vm.Loop) - .ExecuteAffrows(); - } + var tasks = playLists.Select(playList => _db.Update(playList.Id) + .Set(p => p.Position, playList.Position) + .Set(p => p.Shuffle, playList.Shuffle) + .Set(p => p.Loop, playList.Loop) + .ExecuteAffrowsAsync() + ); + + await Task.WhenAll(tasks); } - private void SaveFileChanges(List vms) + public async Task SaveFileChanges(List files) { - if (vms.Count == 0) + if (files.Count == 0) return; - foreach (var vm in vms) - { - _db.Update(vm.Id) - .Set(f => f.PlayedPercentage, vm.PlayedPercentage) - .Set(f => f.Position, vm.Position) - .ExecuteAffrows(); - } + var tasks = files.Select(file => _db.Update(file.Id) + .Set(f => f.PlayedPercentage, file.PlayedPercentage) + .Set(f => f.Position, file.Position) + .ExecuteAffrowsAsync() + ); + + await Task.WhenAll(tasks); } private void ApplyMigrations()