From 00f2be216b240e1c69ce50ad777f5e7f2a05181a Mon Sep 17 00:00:00 2001 From: "alishahb@users.noreply.github.com" <34hh0sdifsd> Date: Sun, 18 Sep 2016 09:28:20 +0300 Subject: [PATCH] Revert build --- UpdateWatcher/App.xaml.cs | 16 ++++++++-------- UpdateWatcher/MainWindow.xaml.cs | 6 ++++++ UpdateWatcher/Managers/BuildsManager.cs | 4 ++-- UpdateWatcher/Properties/AssemblyInfo.cs | 4 ++-- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/UpdateWatcher/App.xaml.cs b/UpdateWatcher/App.xaml.cs index 88ead08..1509ddb 100644 --- a/UpdateWatcher/App.xaml.cs +++ b/UpdateWatcher/App.xaml.cs @@ -18,6 +18,7 @@ namespace UpdateWatcher /// public partial class App : Application { + public event EventHandler OnWorkStarted; public event EventHandler OnWorkCompleted; public event EventHandler OnTick; @@ -63,11 +64,6 @@ private void Initialize(object sender, StartupEventArgs startupEventArgs) BuildsManager.UpdateInfo(Settings.DownloadFolder); - if (BuildsManager.LastBuild()?.FullPath != Settings.LastFileData?.FullPath) - Settings.LastFileData = null; - - RevertBuild(); - Config.Save(); DownloadManager = new DownloadManager(Config.Data.DownloadFolder); @@ -85,6 +81,10 @@ private void Initialize(object sender, StartupEventArgs startupEventArgs) MainWindow = new MainWindow(); MainWindow.Show(); + OnWorkStarted?.Invoke(this, null); + RevertBuild(); + Config.Save(); + OnWorkCompleted?.Invoke(this, null); } @@ -186,10 +186,10 @@ private void OnDownloadDataCompleted(FileInfo info) private void CheckIgnore(FileInfo info) { - if (BuildsManager.IsIgnored(info.FullName)) + if (BuildsManager.IsIgnored(info.Name)) Logger.Debug($"CheckIgnore Manager :: This build marked as ignored {info.Name}, Size: {info.Length}, skipping"); - if (!BuildsManager.IsIgnored(info.FullName) && Settings.LastFileData?.FullPath != info.FullName) + if (!BuildsManager.IsIgnored(info.Name) && Settings.LastFileData?.FullPath != info.FullName) { Settings.LastFileData = new FileData(info); @@ -344,7 +344,7 @@ public void Save() private void RevertBuild() { if (Settings.LastFileData == null) return; - if (BuildsManager.IsIgnored(Settings.LastFileData.FullPath)) + if (BuildsManager.IsIgnored(Settings.LastFileData.FileName)) { Logger.Debug($"RevertBuild Manager :: Current build [{Settings.LastFileData.FileName}] marked as ignored, will try revert previous if have one"); diff --git a/UpdateWatcher/MainWindow.xaml.cs b/UpdateWatcher/MainWindow.xaml.cs index 884aecf..3835f36 100644 --- a/UpdateWatcher/MainWindow.xaml.cs +++ b/UpdateWatcher/MainWindow.xaml.cs @@ -93,6 +93,7 @@ public MainWindow() Application.Current.Exit += Current_Exit; ((App)App.Current).OnWorkCompleted += OnWorkCompleted; + ((App)App.Current).OnWorkStarted += OnWorkStarted; ((App)App.Current).OnTick += OnTick; ((App)App.Current).OnTick += OnTick; @@ -160,6 +161,11 @@ private void BtnStart_OnClick(object sender, RoutedEventArgs e) ((App)App.Current).Download(); } + private void OnWorkStarted(object sender, EventArgs e) + { + OnStarted(); + } + private void OnStarted() { diff --git a/UpdateWatcher/Managers/BuildsManager.cs b/UpdateWatcher/Managers/BuildsManager.cs index ada215f..2f989a5 100644 --- a/UpdateWatcher/Managers/BuildsManager.cs +++ b/UpdateWatcher/Managers/BuildsManager.cs @@ -99,8 +99,8 @@ public void UpdateInfo(string buildsFolder) } - public bool IsIgnored(string fullPath) => Builds.Any(b => b.Ignore && b.FullPath == fullPath); - public IBuildData LastBuild() => Builds.OrderByDescending(b => + public bool IsIgnored(string fileName) => Builds.Any(b => b.Ignore && b.FileName == fileName); + public IBuildData LastBuild() => Builds.Where(b=> !b.Ignore).OrderByDescending(b => { var version = VersionParser.Parse(new FileInfo(b.FullPath).Name); if (string.IsNullOrWhiteSpace(version)) version = "0.0"; diff --git a/UpdateWatcher/Properties/AssemblyInfo.cs b/UpdateWatcher/Properties/AssemblyInfo.cs index 80afe7f..4b200b1 100644 --- a/UpdateWatcher/Properties/AssemblyInfo.cs +++ b/UpdateWatcher/Properties/AssemblyInfo.cs @@ -34,5 +34,5 @@ // // Можно задать все значения или принять номер построения и номер редакции по умолчанию, // используя "*", как показано ниже: -[assembly: AssemblyVersion("1.1.42.0906")] -[assembly: AssemblyInformationalVersion("Build date: 2016-09-18 09:06:53; Revision date: 2016-09-18 09:06:50; Revision(s) in working copy: 8:42.")] \ No newline at end of file +[assembly: AssemblyVersion("1.1.43.0928")] +[assembly: AssemblyInformationalVersion("Build date: 2016-09-18 09:28:13; Revision date: 2016-09-18 09:28:11; Revision(s) in working copy: 8:43.")] \ No newline at end of file