From e078f47f7fbffe03e710c7478bcb3006b7112879 Mon Sep 17 00:00:00 2001 From: jliddev Date: Tue, 7 Jul 2020 11:55:38 -0500 Subject: [PATCH] V1.2.4 various improvements and fixes --- .../AddonProviders/CurseAddonProvider.cs | 17 +- WowUp.WPF/App.xaml.cs | 4 +- WowUp.WPF/Assets/changelog.json | 12 ++ WowUp.WPF/MainWindow.xaml | 1 + WowUp.WPF/Repositories/AddonRepository.cs | 20 ++- WowUp.WPF/Repositories/Base/BaseRepository.cs | 2 +- .../Repositories/Contracts/IDataStore.cs | 3 +- .../Repositories/PreferenceRepository.cs | 7 +- WowUp.WPF/Services/AddonDataStore.cs | 152 ------------------ WowUp.WPF/Services/AddonService.cs | 66 +++++--- WowUp.WPF/Services/Base/BaseDataStore.cs | 47 ------ WowUp.WPF/Services/Base/SingletonService.cs | 11 -- WowUp.WPF/Services/Contracts/IDataStore.cs | 24 --- .../Services/Contracts/IWarcraftService.cs | 1 + WowUp.WPF/Services/Contracts/IWowUpService.cs | 2 + WowUp.WPF/Services/DownloadService.cs | 1 - WowUp.WPF/Services/PreferenceDataStore.cs | 113 ------------- WowUp.WPF/Services/WarcraftService.cs | 16 +- WowUp.WPF/Services/WowUpService.cs | 8 +- WowUp.WPF/Utilities/FileUtilities.cs | 1 + WowUp.WPF/ViewModels/AddonsViewViewModel.cs | 1 - WowUp.WPF/ViewModels/MainWindowViewModel.cs | 10 +- WowUp.WPF/ViewModels/OptionsViewModel.cs | 14 +- WowUp.WPF/Views/OptionsView.xaml | 2 + WowUp.WPF/Views/OptionsView.xaml.cs | 5 + WowUp.WPF/WowUp.WPF.csproj | 2 +- 26 files changed, 148 insertions(+), 394 deletions(-) delete mode 100644 WowUp.WPF/Services/AddonDataStore.cs delete mode 100644 WowUp.WPF/Services/Base/BaseDataStore.cs delete mode 100644 WowUp.WPF/Services/Base/SingletonService.cs delete mode 100644 WowUp.WPF/Services/Contracts/IDataStore.cs delete mode 100644 WowUp.WPF/Services/PreferenceDataStore.cs diff --git a/WowUp.WPF/AddonProviders/CurseAddonProvider.cs b/WowUp.WPF/AddonProviders/CurseAddonProvider.cs index ab63ac40..d04feeaa 100644 --- a/WowUp.WPF/AddonProviders/CurseAddonProvider.cs +++ b/WowUp.WPF/AddonProviders/CurseAddonProvider.cs @@ -143,10 +143,6 @@ namespace WowUp.WPF.AddonProviders private CurseFile GetLatestFile(CurseSearchResult result, WowClientType clientType) { - if (result.Name.Contains("Details")) - { - - } var clientTypeStr = GetClientTypeString(clientType); return result.LatestFiles @@ -198,9 +194,16 @@ namespace WowUp.WPF.AddonProviders private string GetClientTypeString(WowClientType clientType) { - return clientType == WowClientType.Retail - ? "wow_retail" - : "wow_classic"; + switch (clientType) + { + case WowClientType.Classic: + case WowClientType.ClassicPtr: + return "wow_classic"; + case WowClientType.Retail: + case WowClientType.RetailPtr: + default: + return "wow_retail"; + } } diff --git a/WowUp.WPF/App.xaml.cs b/WowUp.WPF/App.xaml.cs index 5ea1e3c6..07f7156c 100644 --- a/WowUp.WPF/App.xaml.cs +++ b/WowUp.WPF/App.xaml.cs @@ -24,7 +24,7 @@ namespace WowUp.WPF { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ExceptionHandler); - var logFilePath = Path.Combine(FileUtilities.AppDataPath, "logs", "wowup-logs.txt"); + var logFilePath = Path.Combine(FileUtilities.AppLogsPath, "wowup-logs.txt"); Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() @@ -32,7 +32,7 @@ namespace WowUp.WPF .WriteTo.File(logFilePath, rollingInterval: RollingInterval.Day, retainedFileCountLimit: 7) .CreateLogger(); - Log.Information("Starting"); + Log.Information($"Starting {GetType().Assembly.GetName().Version}"); var serviceCollection = new ServiceCollection(); ConfigureServices(serviceCollection); diff --git a/WowUp.WPF/Assets/changelog.json b/WowUp.WPF/Assets/changelog.json index 3dc4723e..ff7cd626 100644 --- a/WowUp.WPF/Assets/changelog.json +++ b/WowUp.WPF/Assets/changelog.json @@ -1,5 +1,17 @@ { "ChangeLogs": [ + { + "Version": "1.2.4", + "Description": "More protection against weird toc files.\nImprovements to re-scan function." + }, + { + "Version": "1.2.3", + "Description": "Add some extra logging and error catching.\nFix some issues searching curse for addons for PTR clients." + }, + { + "Version": "1.2.2", + "Description": "Add Show Log Files button.\nAdd in recurring call to check for app updates every 10 minutes.\nBetter wow folder selection validation." + }, { "Version": "1.2.1", "Description": "Add correct task bar icon." diff --git a/WowUp.WPF/MainWindow.xaml b/WowUp.WPF/MainWindow.xaml index 3396112a..a6e35b73 100644 --- a/WowUp.WPF/MainWindow.xaml +++ b/WowUp.WPF/MainWindow.xaml @@ -196,6 +196,7 @@ HorizontalAlignment="Center"> + addons) + { + lock (_collisionLock) + { + foreach(var addon in addons) + { + _database.Delete(addon); + } + } + return true; } public IEnumerable Query(Func, TableQuery> action) diff --git a/WowUp.WPF/Repositories/Base/BaseRepository.cs b/WowUp.WPF/Repositories/Base/BaseRepository.cs index ed7a1c59..c7d9b466 100644 --- a/WowUp.WPF/Repositories/Base/BaseRepository.cs +++ b/WowUp.WPF/Repositories/Base/BaseRepository.cs @@ -31,7 +31,7 @@ namespace WowUp.WPF.Repositories.Base { _database.Execute("PRAGMA journal_mode = 'wal'"); } - catch (Exception ex) + catch (Exception) { // eat } diff --git a/WowUp.WPF/Repositories/Contracts/IDataStore.cs b/WowUp.WPF/Repositories/Contracts/IDataStore.cs index a175bb89..7c8a52d4 100644 --- a/WowUp.WPF/Repositories/Contracts/IDataStore.cs +++ b/WowUp.WPF/Repositories/Contracts/IDataStore.cs @@ -10,7 +10,8 @@ namespace WowUp.WPF.Repositories.Contracts bool AddItems(IEnumerable item); bool SaveItems(IEnumerable items); bool UpdateItem(T item); - bool DeleteItem(string id); + bool DeleteItem(T item); + bool DeleteItems(IEnumerable addons); IEnumerable Query(Func, TableQuery> action); T Query(Func, T> action); } diff --git a/WowUp.WPF/Repositories/PreferenceRepository.cs b/WowUp.WPF/Repositories/PreferenceRepository.cs index 3750ceba..7dfc9f84 100644 --- a/WowUp.WPF/Repositories/PreferenceRepository.cs +++ b/WowUp.WPF/Repositories/PreferenceRepository.cs @@ -53,7 +53,7 @@ namespace WowUp.WPF.Repositories return true; } - public bool DeleteItem(string id) + public bool DeleteItem(Preference preference) { throw new NotImplementedException(); } @@ -114,5 +114,10 @@ namespace WowUp.WPF.Repositories return true; } + + public bool DeleteItems(IEnumerable addons) + { + throw new NotImplementedException(); + } } } diff --git a/WowUp.WPF/Services/AddonDataStore.cs b/WowUp.WPF/Services/AddonDataStore.cs deleted file mode 100644 index 94c08e0d..00000000 --- a/WowUp.WPF/Services/AddonDataStore.cs +++ /dev/null @@ -1,152 +0,0 @@ -using SQLite; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using WowUp.WPF.Entities; -using WowUp.WPF.Repositories.Contracts; -using WowUp.WPF.Services.Base; -using WowUp.WPF.Utilities; - -namespace WowUp.WPF.Services -{ - public class AddonDataStore : SingletonService, IDataStore - { - private static object _collisionLock = new object(); - private SQLiteConnection _database; - - public ObservableCollection Addons { get; set; } - - public AddonDataStore() - { - _database = DbConnection(); - _database.CreateTable(); - - EnableWriteAheadLogging(); - - Addons = new ObservableCollection(_database.Table()); - } - - public bool AddItem(Addon item) - { - lock (_collisionLock) - { - item.UpdatedAt = DateTime.UtcNow; - - if (item.Id != 0) - { - _database.Update(item); - } - else - { - _database.Insert(item); - } - } - - return true; - } - - public bool UpdateItem(Addon item) - { - lock (_collisionLock) - { - item.UpdatedAt = DateTime.UtcNow; - - if (item.Id != 0) - { - _database.Update(item); - } - else - { - _database.Insert(item); - } - } - - return true; - } - - public bool DeleteItem(string id) - { - throw new NotImplementedException(); - } - - public IEnumerable Query(Func, TableQuery> action) - { - lock (_collisionLock) - { - var query = action.Invoke(_database.Table()); - return query.AsEnumerable(); - } - } - - public Addon Query(Func, Addon> action) - { - lock (_collisionLock) - { - return action.Invoke(_database.Table()); - } - } - - public bool AddItems(IEnumerable items) - { - lock (_collisionLock) - { - foreach (var item in items) - { - if (item.Id != 0) - { - _database.Update(item); - } - else - { - _database.Insert(item); - } - } - } - - return true; - } - - public bool SaveItems(IEnumerable items) - { - lock (_collisionLock) - { - foreach (var item in items) - { - if (item.Id != 0) - { - _database.Update(item); - } - else - { - _database.Insert(item); - } - } - } - - return true; - } - - private void EnableWriteAheadLogging() - { - // Enable write-ahead logging - try - { - _database.Execute("PRAGMA journal_mode = 'wal'"); - } - catch (Exception ex) - { - // eat - } - } - - private SQLiteConnection DbConnection() - { - var dbName = "WowUp.db3"; - var path = Path.Combine(FileUtilities.AppDataPath, dbName); - return new SQLiteConnection(path); - } - } -} diff --git a/WowUp.WPF/Services/AddonService.cs b/WowUp.WPF/Services/AddonService.cs index d3a01bc6..d7820708 100644 --- a/WowUp.WPF/Services/AddonService.cs +++ b/WowUp.WPF/Services/AddonService.cs @@ -9,7 +9,6 @@ using WowUp.WPF.AddonProviders.Contracts; using WowUp.WPF.Entities; using WowUp.WPF.Models; using WowUp.WPF.Repositories.Contracts; -using WowUp.WPF.Services.Base; using WowUp.WPF.Services.Contracts; using WowUp.WPF.Utilities; @@ -59,21 +58,24 @@ namespace WowUp.WPF.Services public async Task> GetAddons(WowClientType clientType, bool rescan = false) { var addons = GetAllStoredAddons(clientType); - if (!addons.Any()) + if (rescan || !addons.Any()) { + RemoveAddons(clientType); addons = await GetLocalAddons(clientType); SaveAddons(addons); } - else if (rescan) - { - addons = await RescanAddons(addons, clientType); - } await SyncAddons(clientType, addons); return addons; } + private void RemoveAddons(WowClientType clientType) + { + var addons = GetAllStoredAddons(clientType); + _addonRepository.DeleteItems(addons); + } + private async Task SyncAddons(WowClientType clientType, IEnumerable addons) { var addonIds = addons.Select(addon => addon.CurseAddonId); @@ -120,7 +122,7 @@ namespace WowUp.WPF.Services { updateAction?.Invoke(AddonInstallState.BackingUp, 0.50m); var backupZipFilePath = Path.Combine(BackupPath, $"{addon.Name}-{addon.InstalledVersion}.zip"); - await _downloadService.ZipFile(downloadedFilePath, backupZipFilePath); + //await _downloadService.ZipFile(downloadedFilePath, backupZipFilePath); } updateAction?.Invoke(AddonInstallState.Installing, 75m); @@ -227,18 +229,33 @@ namespace WowUp.WPF.Services public async Task> MapAll(IEnumerable addons, WowClientType clientType) { + if(addons == null) + { + Log.Warning("Addon list was null"); + return new List(); + } + foreach (var addon in addons) { - var searchResults = await Search(addon.Name, addon.FolderName, clientType); - var firstResult = searchResults.FirstOrDefault(); - if (firstResult == null) - { - return null; - } + Log.Debug($"Addon {addon.FolderName}"); - addon.LatestVersion = firstResult.Version; - addon.GameVersion = firstResult.GameVersion; - addon.Author = firstResult.Author; + try + { + var searchResults = await Search(addon.Name, addon.FolderName, clientType); + var firstResult = searchResults.FirstOrDefault(); + if (firstResult == null) + { + continue; + } + + addon.LatestVersion = firstResult.Version; + addon.GameVersion = firstResult.GameVersion; + addon.Author = firstResult.Author; + } + catch(Exception ex) + { + Log.Error(ex, "Failed to map addon"); + } } return addons.ToList(); @@ -250,13 +267,20 @@ namespace WowUp.WPF.Services foreach (var addonFolder in addonFolders) { - var addon = await Map(addonFolder.Toc.Title, addonFolder.Name, clientType); - if (addon == null) + try { - continue; - } + var addon = await Map(addonFolder.Toc.Title, addonFolder.Name, clientType); + if (addon == null) + { + continue; + } - results[addon.Name] = addon; + results[addon.Name] = addon; + } + catch(Exception ex) + { + Log.Error(ex, $"Failed to map addon folder {addonFolder.Name}"); + } } return results.Values diff --git a/WowUp.WPF/Services/Base/BaseDataStore.cs b/WowUp.WPF/Services/Base/BaseDataStore.cs deleted file mode 100644 index 8e08ce9e..00000000 --- a/WowUp.WPF/Services/Base/BaseDataStore.cs +++ /dev/null @@ -1,47 +0,0 @@ -using SQLite; -using System; -using System.Collections.ObjectModel; -using System.IO; -using WowUp.WPF.Utilities; - -namespace WowUp.WPF.Services.Base -{ - public class BaseDataStore - where T : new() - { - protected static object _collisionLock = new object(); - - protected SQLiteConnection _database; - protected ObservableCollection _entities; - - public BaseDataStore() - { - _database = DbConnection(); - _database.CreateTable(); - - EnableWriteAheadLogging(); - - _entities = new ObservableCollection(_database.Table()); - } - - private void EnableWriteAheadLogging() - { - // Enable write-ahead logging - try - { - _database.Execute("PRAGMA journal_mode = 'wal'"); - } - catch (Exception ex) - { - // eat - } - } - - private SQLiteConnection DbConnection() - { - var dbName = "WowUp.db3"; - var path = Path.Combine(FileUtilities.AppDataPath, dbName); - return new SQLiteConnection(path); - } - } -} diff --git a/WowUp.WPF/Services/Base/SingletonService.cs b/WowUp.WPF/Services/Base/SingletonService.cs deleted file mode 100644 index 407899ee..00000000 --- a/WowUp.WPF/Services/Base/SingletonService.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace WowUp.WPF.Services.Base -{ - public class SingletonService where T : new() - { - private static readonly Lazy lazy = new Lazy(() => new T()); - - public static T Instance { get { return lazy.Value; } } - } -} diff --git a/WowUp.WPF/Services/Contracts/IDataStore.cs b/WowUp.WPF/Services/Contracts/IDataStore.cs deleted file mode 100644 index ee3fdd18..00000000 --- a/WowUp.WPF/Services/Contracts/IDataStore.cs +++ /dev/null @@ -1,24 +0,0 @@ -using SQLite; -using System; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace WowUp.WPF.Services.Contracts -{ - public interface IDataStore - { - bool AddItem(T item); - bool AddItems(IEnumerable item); - bool UpdateItem(T item); - bool DeleteItem(string id); - IEnumerable Query(Func, TableQuery> action); - T Query(Func, T> action); - - - Task AddItemAsync(T item); - Task UpdateItemAsync(T item); - Task DeleteItemAsync(string id); - Task GetItemAsync(string id); - Task> GetItemsAsync(bool forceRefresh = false); - } -} diff --git a/WowUp.WPF/Services/Contracts/IWarcraftService.cs b/WowUp.WPF/Services/Contracts/IWarcraftService.cs index 5dfb7c81..7e884abb 100644 --- a/WowUp.WPF/Services/Contracts/IWarcraftService.cs +++ b/WowUp.WPF/Services/Contracts/IWarcraftService.cs @@ -9,6 +9,7 @@ namespace WowUp.WPF.Services.Contracts Task> GetWowClientNames(); Task> GetWowClients(); + bool ValidateWowFolder(string wowFolder); Task GetWowFolderPath(); Task SetWowFolderPath(string folderPath); Task GetRetailFolderPath(); diff --git a/WowUp.WPF/Services/Contracts/IWowUpService.cs b/WowUp.WPF/Services/Contracts/IWowUpService.cs index 450a4704..6b7d1ace 100644 --- a/WowUp.WPF/Services/Contracts/IWowUpService.cs +++ b/WowUp.WPF/Services/Contracts/IWowUpService.cs @@ -6,6 +6,8 @@ namespace WowUp.WPF.Services.Contracts { public interface IWowUpService { + void ShowLogsFolder(); + Version CurrentVersion { get; } string CurrentVersionString { get; } diff --git a/WowUp.WPF/Services/DownloadService.cs b/WowUp.WPF/Services/DownloadService.cs index 744bc5e9..dac9af65 100644 --- a/WowUp.WPF/Services/DownloadService.cs +++ b/WowUp.WPF/Services/DownloadService.cs @@ -3,7 +3,6 @@ using System; using System.IO; using System.IO.Compression; using System.Threading.Tasks; -using WowUp.WPF.Services.Base; using WowUp.WPF.Services.Contracts; namespace WowUp.WPF.Services diff --git a/WowUp.WPF/Services/PreferenceDataStore.cs b/WowUp.WPF/Services/PreferenceDataStore.cs deleted file mode 100644 index e943aa62..00000000 --- a/WowUp.WPF/Services/PreferenceDataStore.cs +++ /dev/null @@ -1,113 +0,0 @@ -using SQLite; -using System; -using System.Collections.Generic; -using System.Linq; -using WowUp.WPF.Entities; -using WowUp.WPF.Repositories.Contracts; -using WowUp.WPF.Services.Base; - -namespace WowUp.WPF.Services -{ - public class PreferenceDataStore : BaseDataStore, IDataStore - { - public bool AddItem(Preference item) - { - lock (_collisionLock) - { - item.UpdatedAt = DateTime.UtcNow; - - if (item.Id != 0) - { - _database.Update(item); - } - else - { - _database.Insert(item); - } - } - - return true; - } - - public bool UpdateItem(Preference item) - { - lock (_collisionLock) - { - item.UpdatedAt = DateTime.UtcNow; - - if (item.Id != 0) - { - _database.Update(item); - } - else - { - _database.Insert(item); - } - } - - return true; - } - - public bool DeleteItem(string id) - { - throw new NotImplementedException(); - } - - public IEnumerable Query(Func, TableQuery> action) - { - lock (_collisionLock) - { - var query = action.Invoke(_database.Table()); - return query.AsEnumerable(); - } - } - - public Preference Query(Func, Preference> action) - { - lock (_collisionLock) - { - return action.Invoke(_database.Table()); - } - } - - public bool AddItems(IEnumerable items) - { - lock (_collisionLock) - { - foreach (var item in items) - { - if (item.Id != 0) - { - _database.Update(item); - } - else - { - _database.Insert(item); - } - } - } - - return true; - } - - public bool SaveItems(IEnumerable items) - { - lock (_collisionLock) - { - foreach (var item in items) - { - if (item.Id != 0) - { - _database.Update(item); - } - else - { - _database.Insert(item); - } - } - } - - return true; - } - } -} diff --git a/WowUp.WPF/Services/WarcraftService.cs b/WowUp.WPF/Services/WarcraftService.cs index bb88c77a..1af16cc4 100644 --- a/WowUp.WPF/Services/WarcraftService.cs +++ b/WowUp.WPF/Services/WarcraftService.cs @@ -10,6 +10,7 @@ using WowUp.WPF.Repositories.Contracts; using WowUp.WPF.Services.Contracts; using WowUp.WPF.Utilities; using WowUp.WPF.Extensions; +using Serilog; namespace WowUp.WPF.Services { @@ -106,6 +107,8 @@ namespace WowUp.WPF.Services public Task GetWowFolderPath() { var preference = GetWowLocationPreference(); + Log.Debug($"Wow Preference {preference?.Value}"); + return Task.FromResult(preference?.Value); } @@ -134,9 +137,12 @@ namespace WowUp.WPF.Services public async Task> ListAddons(WowClientType clientType) { var addonsPath = await GetAddonFolderPath(clientType); + Log.Debug($"AddonsPath {addonsPath}"); var addons = new List(); var addonDirectories = Directory.GetDirectories(addonsPath); + Log.Debug($"addonDirectories {addonDirectories.Length}"); + foreach (var directory in addonDirectories) { var directoryInfo = new DirectoryInfo(directory); @@ -152,14 +158,18 @@ namespace WowUp.WPF.Services return _preferenceRepository.FindByKey(WowLocationPreferenceKey); } - private bool ValidateWowFolder(string wowFolder) + public bool ValidateWowFolder(string wowFolder) { try { var directories = Directory.GetDirectories(wowFolder); - return directories.Any(dir => FolderNames.Any(fn => dir.Contains(fn))); + return directories.Any(dir => + { + var dirName = Path.GetFileName(dir); + return FolderNames.Any(fn => dirName.Contains(fn)); + }); } - catch(Exception ex) + catch(Exception) { return false; } diff --git a/WowUp.WPF/Services/WowUpService.cs b/WowUp.WPF/Services/WowUpService.cs index 3ead7a67..43bbf912 100644 --- a/WowUp.WPF/Services/WowUpService.cs +++ b/WowUp.WPF/Services/WowUpService.cs @@ -4,8 +4,10 @@ using Serilog; using System; using System.Linq; using System.Threading.Tasks; +using WowUp.WPF.Extensions; using WowUp.WPF.Models; using WowUp.WPF.Services.Contracts; +using WowUp.WPF.Utilities; namespace WowUp.WPF.Services { @@ -27,6 +29,11 @@ namespace WowUp.WPF.Services _cache = memoryCache; } + public void ShowLogsFolder() + { + FileUtilities.AppLogsPath.OpenUrlInBrowser(); + } + public async Task IsUpdateAvailable() { var latestVersionStr = await GetLatestVersion(); @@ -55,7 +62,6 @@ namespace WowUp.WPF.Services return string.Empty; } - return changeLogFile.ChangeLogs?.FirstOrDefault()?.Version ?? string.Empty; } diff --git a/WowUp.WPF/Utilities/FileUtilities.cs b/WowUp.WPF/Utilities/FileUtilities.cs index 1540d728..4a06be09 100644 --- a/WowUp.WPF/Utilities/FileUtilities.cs +++ b/WowUp.WPF/Utilities/FileUtilities.cs @@ -10,6 +10,7 @@ namespace WowUp.WPF.Utilities .GetFolderPath(Environment.SpecialFolder.LocalApplicationData); public static readonly string AppDataPath = Path.Combine(LocalAppDataPath, "WowUp"); + public static readonly string AppLogsPath = Path.Combine(AppDataPath, "Logs"); static FileUtilities() { diff --git a/WowUp.WPF/ViewModels/AddonsViewViewModel.cs b/WowUp.WPF/ViewModels/AddonsViewViewModel.cs index e7c32fa4..03910c5a 100644 --- a/WowUp.WPF/ViewModels/AddonsViewViewModel.cs +++ b/WowUp.WPF/ViewModels/AddonsViewViewModel.cs @@ -143,7 +143,6 @@ namespace WowUp.WPF.ViewModels catch (Exception ex) { Log.Error(ex, "LoadItems"); - Debug.WriteLine(ex); } finally { diff --git a/WowUp.WPF/ViewModels/MainWindowViewModel.cs b/WowUp.WPF/ViewModels/MainWindowViewModel.cs index a36bf360..aebdac57 100644 --- a/WowUp.WPF/ViewModels/MainWindowViewModel.cs +++ b/WowUp.WPF/ViewModels/MainWindowViewModel.cs @@ -19,6 +19,8 @@ namespace WowUp.WPF.ViewModels private readonly IWarcraftService _warcraftService; private readonly IWowUpService _wowUpService; + private System.Threading.Timer _timer; + public Command SelectWowCommand { get; set; } public Command DownloadLatestVersionCommand { get; set; } @@ -80,6 +82,8 @@ namespace WowUp.WPF.ViewModels TabItems = new ObservableCollection(); + _timer = new System.Threading.Timer(CheckVersion, null, TimeSpan.Zero, TimeSpan.FromMinutes(10)); + InitializeView(); } @@ -99,8 +103,6 @@ namespace WowUp.WPF.ViewModels private async void InitializeView() { - CheckVersion(); - var hasWowLocation = await HasWarcraftLocation(); ShowWowSelection = !hasWowLocation; @@ -112,7 +114,7 @@ namespace WowUp.WPF.ViewModels } } - private async void CheckVersion() + private async void CheckVersion(object state) { IsUpdateAvailable = await _wowUpService.IsUpdateAvailable(); } @@ -153,7 +155,7 @@ namespace WowUp.WPF.ViewModels private async Task HasWarcraftLocation() { var wowFolder = await _warcraftService.GetWowFolderPath(); - return !string.IsNullOrEmpty(wowFolder); + return _warcraftService.ValidateWowFolder(wowFolder) && !string.IsNullOrEmpty(wowFolder); } private void DownloadLatestVersion() diff --git a/WowUp.WPF/ViewModels/OptionsViewModel.cs b/WowUp.WPF/ViewModels/OptionsViewModel.cs index 6c88ed27..607d2f24 100644 --- a/WowUp.WPF/ViewModels/OptionsViewModel.cs +++ b/WowUp.WPF/ViewModels/OptionsViewModel.cs @@ -11,6 +11,7 @@ namespace WowUp.WPF.ViewModels public class OptionsViewModel : BaseViewModel { private readonly IWarcraftService _warcraftService; + private readonly IWowUpService _wowUpService; private string _wowLocation; public string WowLocation @@ -19,10 +20,16 @@ namespace WowUp.WPF.ViewModels set { SetProperty(ref _wowLocation, value); } } + public Command ShowLogsCommand { get; set; } + public OptionsViewModel( - IWarcraftService warcraftService) + IWarcraftService warcraftService, + IWowUpService wowUpService) { _warcraftService = warcraftService; + _wowUpService = wowUpService; + + ShowLogsCommand = new Command(() => ShowLogsFolder()); LoadOptions(); } @@ -32,6 +39,11 @@ namespace WowUp.WPF.ViewModels WowLocation = await _warcraftService.GetWowFolderPath(); } + private void ShowLogsFolder() + { + _wowUpService.ShowLogsFolder(); + } + public async void SetWowLocation() { var selectedPath = DialogUtilities.SelectFolder(); diff --git a/WowUp.WPF/Views/OptionsView.xaml b/WowUp.WPF/Views/OptionsView.xaml index afccbf4e..42db13e9 100644 --- a/WowUp.WPF/Views/OptionsView.xaml +++ b/WowUp.WPF/Views/OptionsView.xaml @@ -24,6 +24,8 @@ + + diff --git a/WowUp.WPF/Views/OptionsView.xaml.cs b/WowUp.WPF/Views/OptionsView.xaml.cs index d9e2d14f..30756aaa 100644 --- a/WowUp.WPF/Views/OptionsView.xaml.cs +++ b/WowUp.WPF/Views/OptionsView.xaml.cs @@ -21,5 +21,10 @@ namespace WowUp.WPF.Views { _viewModel.SetWowLocation(); } + + private void ShowLogsButton_Click(object sender, System.Windows.RoutedEventArgs e) + { + + } } } diff --git a/WowUp.WPF/WowUp.WPF.csproj b/WowUp.WPF/WowUp.WPF.csproj index 6a46c4de..1702cc80 100644 --- a/WowUp.WPF/WowUp.WPF.csproj +++ b/WowUp.WPF/WowUp.WPF.csproj @@ -10,7 +10,7 @@ WowUp Jliddev WowUp - 1.2.1 + 1.2.4 wowup_logo_512np_RRT_icon.ico