Пример #1
0
        public void TestCheckForUpdateEqualToCurrentVersionAvailable()
        {
            FileSystem.Current.GetDirectory("c:\\program files\\MGDF\\game").Create();
            FileSystem.Current.GetFile("c:\\program files\\MGDF\\game\\game.json").WriteText(ReadTextFile("console.json"));

            MockFile gamesManagerFile = (MockFile)FileSystem.Current.GetFile("C:\\program files\\MGDF\\GamesManager.exe");

            gamesManagerFile.WriteText("EXECUTABLE");
            gamesManagerFile.AssemblyVersion = new Version(1, 0, 0, 0);

            var newFrameworkData = GenerateDataBlock(65536);
            var frameworkMd5     = GenerateMd5Hash(newFrameworkData);

            ((MockHttpRequestManager)HttpRequestManager.Current).ExpectResponse("http://www.matchstickframework.org/downloads/1/MGDF.zip", newFrameworkData);
            ((MockHttpRequestManager)HttpRequestManager.Current).ExpectResponse("http://games.junkship.org/gamesource.asmx/downloads/1/Console/latest.json", @"{""framework"":{
""version"":""1.0.0.0"",
""url"":""http://www.matchstickframework.org/downloads/1/MGDF.zip"",
""md5"":""" + frameworkMd5 + @"""
}}");

            Game             game   = new Game("c:\\program files\\MGDF\\game\\game.json");
            AvailableUpdates update = UpdateChecker.CheckForUpdate(game);

            Assert.IsNotNull(update);
            Assert.IsNull(update.Framework);
        }
Пример #2
0
        public void TestCheckForUpdateInapplicablePartialUpdatesAvailable()
        {
            //lets pretend that this game is already installed.
            FileSystem.Current.GetDirectory("c:\\program files\\MGDF\\game").Create();
            FileSystem.Current.GetFile("c:\\program files\\MGDF\\game\\game.json").WriteText(ReadTextFile("console.json"));

            var newGameData = GenerateDataBlock(65536);
            var gameMd5     = GenerateMd5Hash(newGameData);

            ((MockHttpRequestManager)HttpRequestManager.Current).ExpectResponse("http://games.junkship.org/gamesource.asmx", @"{ 
""latest"":{
""version"":""1.1.2.4"",
""url"":""http://www.junkship.net/downloads/console.zip"",
""md5"":""" + gameMd5 + @"""
},
""updateOlderVersions"":[
    {
        ""url"":""http://www.junkship.net/downloads/console-update1.zip"",
        ""md5"":""" + gameMd5 + @""",
        ""fromVersion"":""0.1.1.1""
    }
]
}");

            Game game   = new Game("c:\\program files\\MGDF\\game\\game.json");
            var  update = UpdateChecker.CheckForUpdate(game);

            Assert.IsNotNull(update);
            Assert.IsNotNull(update.Game);
            Assert.AreEqual("http://www.junkship.net/downloads/console.zip", update.Game.Url);
            Assert.AreEqual(gameMd5, update.Game.MD5);
            Assert.AreEqual("1.1.2.4", update.Game.Version);
        }
        public async void CheckForUpdate_given_multiple_releases_returns_new_update()
        {
            var currentVersion   = "v5.5.5";
            var returnVersionNew = "v6.6.6";
            var returnVersionOld = "v4.4.4";

            var mock      = new Mock <ISource <GithubReleases> >();
            var returnVal = new GithubReleases {
                Releases = new List <GithubRelease> {
                    new GithubRelease {
                        Tag_name = returnVersionOld
                    }, new GithubRelease {
                        Tag_name = returnVersionNew
                    }
                }
            };

            mock.Setup(m => m.GetContent(null)).ReturnsAsync(returnVal);
            var logic = new UpdateChecker(mock.Object);

            logic.Settings = CreateSettings(currentVersion);

            var result = await logic.CheckForUpdate();

            Assert.True(result.Item1);
            Assert.Equal(returnVersionNew, result.Item2);
        }
Пример #4
0
        /// <summary>
        /// Checks for version and shows message
        /// </summary>
        /// <param name="showIfCurrent">show message or not if current version</param>
        private void CheckForUpdate(bool showIfCurrent)
        {
            UpdateChecker     updater     = new UpdateChecker(this);
            UpdateCheckResult checkResult = updater.CheckForUpdate(true);

            switch (checkResult)
            {
            case UpdateCheckResult.CheckError:
                // nothing to do as updater displayed error
                break;

            case UpdateCheckResult.CurrentVersion:
                if (showIfCurrent)
                {
                    MessageBox.Show(this,
                                    Resources.FormGUI_checkForUpdateToolStripMenuItem_Click_The_version_is_most_current,
                                    Resources.FormGUI_checkForUpdateToolStripMenuItem_Click_Version_check, MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
                break;

            case UpdateCheckResult.UpdatePresent:
                // if new version found - display the "new version found" dialog
                ShowUpdateMessage(updater.CurrentVersion, updater.UpdateVersion, updater.UpdatePath);
                break;
            }
        }
Пример #5
0
 private void CheckForUpdateCommandExecuted(object parameter)
 {
     this._isUpdateAvailable = UpdateChecker.CheckForUpdate(true);
     if (this._isUpdateAvailable == true)
     {
         Locator.Get <IDialogService>().ShowDialog(new UpdateWindowViewModel());
     }
 }
        private async void CheckForUpdate(UpdateChecker updateChecker)
        {
            var result = await updateChecker.CheckForUpdate();

            VersionNumber = result.Item1
                ? $"Current version: {Settings.GetVersionNumber()}\nUpdate available: {result.Item2}"
                : Settings.GetVersionNumber();
        }
        public Task ExecuteAsync(CancellationToken cancellationToken)
        {
            if (AppConfigs.Configuration.UpdateMode == UpdateMode.Never)
            {
                return(Task.CompletedTask);
            }

            return(_updateChecker.CheckForUpdate(cancellationToken));
        }
Пример #8
0
        public void TestCheckForUpdateAndDownloadUpdateWithAuthInvalidCachedCredentials()
        {
            Resources.InitUserDirectory("Console", false);

            //lets pretend that this game is already installed.
            FileSystem.Current.GetDirectory("c:\\program files\\MGDF\\game").Create();
            FileSystem.Current.GetFile("c:\\program files\\MGDF\\game\\game.json").WriteText(ReadTextFile("console.json"));

            var newGameData = GenerateDataBlock(65536);
            var gameMd5     = GenerateMd5Hash(newGameData);

            SettingsManager.Instance.Settings          = new GameSettings();
            SettingsManager.Instance.Settings.GameUid  = "Console";
            SettingsManager.Instance.Settings.UserName = "******";
            SettingsManager.Instance.Settings.Password = "******";
            SettingsManager.Instance.Save();

            ((MockHttpRequestManager)HttpRequestManager.Current).SetCredentials("http://www.junkship.net/downloads/console.zip", "user", "password1");
            ((MockHttpRequestManager)HttpRequestManager.Current).ExpectResponse("http://www.junkship.net/downloads/console.zip", newGameData);
            ((MockHttpRequestManager)HttpRequestManager.Current).ExpectResponse("http://games.junkship.org/gamesource.asmx", @"{ 
""latest"":{
""version"":""1.1.2.4"",
""url"":""http://www.junkship.net/downloads/console.zip"",
""md5"":""" + gameMd5 + @"""
}
}");

            Game game   = new Game("c:\\program files\\MGDF\\game\\game.json");
            var  update = UpdateChecker.CheckForUpdate(game);

            Assert.IsNotNull(update);
            Assert.IsNotNull(update.Game);
            Assert.AreEqual("http://www.junkship.net/downloads/console.zip", update.Game.Url);
            Assert.AreEqual(gameMd5, update.Game.MD5);
            Assert.AreEqual("1.1.2.4", update.Game.Version);

            Assert.IsFalse(FileSystem.Current.GetFile("c:\\temp.zip").Exists);

            //now download the actual update.
            GameDownloader downloader = new GameDownloader(game, "http://www.junkship.net/downloads/console.zip", "c:\\temp.zip", gameMd5, args =>
            {
                args.UserName = "******";
                args.Password = "******";
                return(true);
            });

            downloader.Start();


            Assert.AreEqual(SettingsManager.Instance.Settings.GameUid, "Console");
            Assert.AreEqual(SettingsManager.Instance.Settings.UserName, "user");
            Assert.AreEqual(SettingsManager.Instance.Settings.Password, "password1");

            Assert.IsTrue(FileSystem.Current.GetFile("c:\\temp.zip").Exists);
            Assert.AreEqual(65536, FileSystem.Current.GetFile("c:\\temp.zip").Length);
        }
Пример #9
0
        public void TestCheckForUpdateNoUpdatesAvailable()
        {
            //lets pretend that this game is already installed.
            FileSystem.Current.GetDirectory("c:\\program files\\MGDF\\game").Create();
            FileSystem.Current.GetFile("c:\\program files\\MGDF\\game\\game.json").WriteText(ReadTextFile("console.json"));


            Game game   = new Game("c:\\program files\\MGDF\\game\\game.json");
            var  update = UpdateChecker.CheckForUpdate(game);

            Assert.IsNotNull(update);
            Assert.IsNull(update.Game);
        }
Пример #10
0
        /// <summary>
        /// When the window is loaded, the update checker is run and DiscordRPC is set
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
#if DEBUG
            Console.WriteLine("Updater disabled because this is a debug build.");
#else
            new Thread(() =>
            {
                ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                Thread.CurrentThread.IsBackground    = true;
                try
                {
                    string contents;
                    using (var wc = new WebClient())
                        contents = wc.DownloadString("https://teknoparrot.com/api/version");
                    if (!UpdateChecker.CheckForUpdate(GameVersion.CurrentVersion, contents))
                    {
                        return;
                    }
                    if (MessageBox.Show(
                            $"There is a new version available: {contents} (currently using {GameVersion.CurrentVersion}). Would you like to download it?",
                            "New update!", MessageBoxButton.YesNo, MessageBoxImage.Information) !=
                        MessageBoxResult.Yes)
                    {
                        return;
                    }
                    Thread.CurrentThread.IsBackground = false;
                    Process.Start("https://teknoparrot.com");
                    //Application.Current.Dispatcher.Invoke((Action)delegate {
                    //    var update = new DownloadWindow("https://teknoparrot.com/files/TeknoParrot_" + contents + ".zip", Environment.GetEnvironmentVariable("TEMP") + "\\teknoparrot.zip", true);
                    //    update.ShowDialog();
                    //});
                }
                catch (Exception)
                {
                    // Ignored
                }
            }).Start();
#endif

            if (ParrotData.UseDiscordRPC)
            {
                DiscordRPC.UpdatePresence(new DiscordRPC.RichPresence
                {
                    details       = "Main Menu",
                    largeImageKey = "teknoparrot",
                });
            }
        }
Пример #11
0
        private void DoWork()
        {
            try
            {
                if (_checkForUpdates)
                {
                    Logger.Current.Write(LogInfoLevel.Info, "Checking for updates...");
                    View.Invoke(() =>
                    {
                        View.Title   = "Checking for updates...";
                        View.Details = "Checking for updates...";
                    });

                    AvailableUpdates availableUpdates = UpdateChecker.CheckForUpdate(Game.Current);

                    if ((availableUpdates.Framework != null || availableUpdates.Game != null) && GetUpdatePermission())
                    {
                        Logger.Current.Write(LogInfoLevel.Info, "Updates found, restarting elevated...");

                        if (!UACControl.IsVistaOrHigher() && !UACControl.IsAdmin())
                        {
                            //pre vista you can't elevate, so we have to bail out with an error here.
                            ViewFactory.Current.CreateView <IMessage>().Show("Updating requires administrator access", "Administrator accesss required");
                            _workerThread = null;
                            View.Invoke(CloseView);
                            return;
                        }

                        UACControl.RestartElevated(Resources.GamesManagerBootArguments(
                                                       availableUpdates.Game != null ? availableUpdates.Game.Url : string.Empty,
                                                       availableUpdates.Game != null ? availableUpdates.Game.MD5 : string.Empty,
                                                       availableUpdates.Framework != null ? availableUpdates.Framework.Url : string.Empty,
                                                       availableUpdates.Framework != null ? availableUpdates.Framework.MD5 : string.Empty));
                        return;
                    }
                }

                Launch();
            }
            catch (ThreadAbortException)
            {
            }
            catch (Exception ex)
            {
                _workerThread = null;
                View.Invoke(() => Program.ShowUnhandledError(ex));
            }
        }
Пример #12
0
        public void TestCheckForUpdateNoUpdateAvailable()
        {
            FileSystem.Current.GetDirectory("c:\\program files\\MGDF\\game").Create();
            FileSystem.Current.GetFile("c:\\program files\\MGDF\\game\\game.json").WriteText(ReadTextFile("console.json"));

            MockFile gamesManagerFile = (MockFile)FileSystem.Current.GetFile("C:\\program files\\MGDF\\GamesManager.exe");

            gamesManagerFile.WriteText("EXECUTABLE");
            gamesManagerFile.AssemblyVersion = new Version(1, 0, 0, 0);

            Game             game   = new Game("c:\\program files\\MGDF\\game\\game.json");
            AvailableUpdates update = UpdateChecker.CheckForUpdate(game);

            Assert.IsNotNull(update);
            Assert.IsNull(update.Framework);
        }
Пример #13
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            LoadParrotData();
            //CreateConfigValue();

            foreach (var gameProfile in GameProfileLoader.GameProfiles)
            {
                ComboBoxItem item = new ComboBoxItem
                {
                    Content = gameProfile.GameName,
                    Tag     = gameProfile
                };

                GameListComboBox.Items.Add(item);

                if (_parrotData.SaveLastPlayed && gameProfile.GameName == _parrotData.LastPlayed)
                {
                    GameListComboBox.SelectedItem = item;
                }
            }

            new Thread(() =>
            {
                ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                Thread.CurrentThread.IsBackground    = true;
                try
                {
                    string contents;
                    using (var wc = new WebClient())
                        contents = wc.DownloadString("https://teknoparrot.com/api/version");
                    if (UpdateChecker.CheckForUpdate(GameVersion.CurrentVersion, contents))
                    {
                        if (MessageBox.Show(
                                $"There is a new version available: {contents}. Would like to visit teknoparrot.com to download it?",
                                "New update!", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
                        {
                            Process.Start("https://teknoparrot.com");
                        }
                    }
                }
                catch (Exception ex)
                {
                    // Ignored
                }
            }).Start();
        }
Пример #14
0
        private async Task <bool> CheckIfUpdateAvailable(bool forceCheck)
        {
            var result = await UpdateChecker.CheckForUpdate(forceCheck);

            if (!result.Item1)
            {
                return(false);
            }

            var win = new UpdateAvailableWindow(result.Item2)
            {
                Owner = this,
                WindowStartupLocation = WindowStartupLocation.CenterOwner
            };

            win.Show();
            return(true);
        }
        public async void CheckForUpdate_given_no_releases_returns_no_update()
        {
            var currentVersion = "v5.5.5";

            var mock      = new Mock <ISource <GithubReleases> >();
            var returnVal = new GithubReleases {
                Releases = new List <GithubRelease>()
            };

            mock.Setup(m => m.GetContent(null)).ReturnsAsync(returnVal);
            var logic = new UpdateChecker(mock.Object);

            logic.Settings = CreateSettings(currentVersion);

            var result = await logic.CheckForUpdate();

            Assert.False(result.Item1);
        }
Пример #16
0
        public void UpdateChecker_CheckForUpdate_Test()
        {
            var checker = new UpdateChecker();
             ApplicationUpdate update = checker.CheckForUpdate("uniqueId", Path.Combine(Environment.CurrentDirectory, "ApplicationUpdate.xml"));

             Assert.AreEqual("0.4.10.156", update.Version);
             Assert.AreEqual(new DateTime(2010, 3, 18), update.UpdateDate);
             Assert.AreEqual(2, update.UpdateFiles.Count);
             Assert.AreEqual("Windows Installer", update.UpdateFiles[0].Description);
             Assert.AreEqual("http://hfm-net.googlecode.com/files/HFM Release 0.4.10.156.msi", update.UpdateFiles[0].HttpAddress);
             Assert.AreEqual(1569792, update.UpdateFiles[0].Size);
             Assert.AreEqual("30847cc654974d969f8f5a3f2423040d", update.UpdateFiles[0].MD5);
             Assert.AreEqual("b38dd073546647dcf37d89d62cb63823934c8fce", update.UpdateFiles[0].SHA1);
             Assert.AreEqual(0, update.UpdateFiles[0].UpdateType);
             Assert.AreEqual("Zip Archive", update.UpdateFiles[1].Description);
             Assert.AreEqual("http://hfm-net.googlecode.com/files/HFM Release 0.4.10.156.zip", update.UpdateFiles[1].HttpAddress);
             Assert.AreEqual(584621, update.UpdateFiles[1].Size);
             Assert.AreEqual("d1ea4151b2165c6a7ef3ec519b479464", update.UpdateFiles[1].MD5);
             Assert.AreEqual("4103946141f90105510827a0baf13cb38cb00256", update.UpdateFiles[1].SHA1);
             Assert.AreEqual(1, update.UpdateFiles[1].UpdateType);
        }
Пример #17
0
        public void TestCheckForUpdateAndDownloadUpdate()
        {
            FileSystem.Current.GetDirectory("c:\\program files\\MGDF\\game").Create();
            FileSystem.Current.GetFile("c:\\program files\\MGDF\\game\\game.json").WriteText(ReadTextFile("console.json"));

            MockFile gamesManagerFile = (MockFile)FileSystem.Current.GetFile("C:\\program files\\MGDF\\GamesManager.exe");

            gamesManagerFile.WriteText("EXECUTABLE");
            gamesManagerFile.AssemblyVersion = new Version(1, 0, 0, 0);

            var newFrameworkData = GenerateDataBlock(65536);
            var frameworkMd5     = GenerateMd5Hash(newFrameworkData);

            ((MockHttpRequestManager)HttpRequestManager.Current).ExpectResponse("http://www.matchstickframework.org/downloads/1/MGDF.zip", newFrameworkData);
            ((MockHttpRequestManager)HttpRequestManager.Current).ExpectResponse("http://games.junkship.org/gamesource.asmx", @"{""framework"":{
""version"":""1.1.2.4"",
""url"":""http://www.matchstickframework.org/downloads/1/MGDF.zip"",
""md5"":""" + frameworkMd5 + @"""
}}");

            Game             game   = new Game("c:\\program files\\MGDF\\game\\game.json");
            AvailableUpdates update = UpdateChecker.CheckForUpdate(game);

            Assert.IsNotNull(update);
            Assert.IsNotNull(update.Framework);
            Assert.AreEqual("http://www.matchstickframework.org/downloads/1/MGDF.zip", update.Framework.Url);
            Assert.AreEqual(frameworkMd5, update.Framework.MD5);
            Assert.AreEqual("1.1.2.4", update.Framework.Version);

            Assert.IsFalse(FileSystem.Current.GetFile("c:\\temp.zip").Exists);

            //now download the actual update.
            FileDownloader downloader = new FileDownloader("http://www.matchstickframework.org/downloads/1/MGDF.zip", "c:\\temp.zip", frameworkMd5, null);

            downloader.Start();

            Assert.IsTrue(FileSystem.Current.GetFile("c:\\temp.zip").Exists);
            Assert.AreEqual(65536, FileSystem.Current.GetFile("c:\\temp.zip").Length);
        }
Пример #18
0
        void CheckForUpdatesLabelClick(object sender, EventArgs e)
        {
            string newVersion;
            string changes;

            try
            {
                if (UpdateChecker.CheckForUpdate(out newVersion, out changes))
                {
                    Messages.ShowInformationBox(string.Format(Translation.Current[531], newVersion, changes));
                    SupportManager.DoSupport(SupportRequest.OpenDownloadPage);
                }
                else
                {
                    Messages.ShowInformationBox(Translation.Current[532]);
                }
            }
            catch (InvalidOperationException exc)
            {
                Messages.ShowErrorBox(exc.Message);
            }
        }
Пример #19
0
        private void UpdateCheckMenuItem_Click(object sender, EventArgs e)
        {
            var candidate = new DownloadCandidate("https://raw.githubusercontent.com/yuma140902/UpdateJSON_Forge/master/OreUnifyGeneratorWin/versions.json");
            var checker   = new UpdateChecker(candidate);
            var version   = checker.CheckForUpdate();

            if (checker.HasError)
            {
                MessageBox.Show($"{candidate.Enumerate().FirstOrDefault()} を取得できません。\nアップデートの確認に失敗しました。",
                                "アップデート確認失敗", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else if (version == null)
            {
                MessageBox.Show($"最新のバージョンを使っています: {Program.Version}");
                return;
            }

            var sb = new StringBuilder();

            sb.AppendLine($"新しいバージョン {version.Version} が利用可能です。");
            if (!string.IsNullOrEmpty(version.Description))
            {
                sb.AppendLine($"説明: {version.Description}");
            }
            sb.AppendLine($"URL: {version.Url}");
            sb.AppendLine("ダウンロードしますか?");

            var result = MessageBox.Show(sb.ToString(), "", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (result == DialogResult.Yes)
            {
                if (version.Url.StartsWith("http"))
                {
                    Process.Start(version.Url);
                }
            }
        }
Пример #20
0
        private async Task RunUpdateCheck()
        {
            try {
                var result = await UpdateChecker.CheckForUpdate(_cancellationSource.Token);

                if (!(result is UpdateInfo update)) // No update found
                {
                    return;
                }

                if (Properties.Settings.Default.IgnoreUpdate == update.UpdateVersion.ToString())
                {
                    return;
                }

                await Dispatcher.InvokeAsync(() => {
                    var decision = ShowUpdateFoundWindow(update);
                    switch (decision)
                    {
                    case UpdateDecision.Accept:
                        Logger.LogInfo($"AutoUpdate: Accepted update to {update.UpdateVersion}");
                        ShowDownloadWindow(update);
                        break;

                    case UpdateDecision.NotNow:
                        Logger.LogInfo($"AutoUpdate: Delayed update to {update.UpdateVersion}");
                        break;

                    case UpdateDecision.IgnoreUpdate:
                        Logger.LogInfo($"AutoUpdate: Ignored update to {update.UpdateVersion}");
                        Properties.Settings.Default.IgnoreUpdate = update.UpdateVersion.ToString();
                        break;
                    }
                }, _cancellationSource.Token);
            } catch (Exception e) {
                Logger.LogException("Auto update failed", e);
            }
        }
Пример #21
0
        public void TestCheckForUpdateAndDownloadUpdateNoAuth()
        {
            //lets pretend that this game is already installed.
            FileSystem.Current.GetDirectory("c:\\program files\\MGDF\\game").Create();
            FileSystem.Current.GetFile("c:\\program files\\MGDF\\game\\game.json").WriteText(ReadTextFile("console.json"));

            var newGameData = GenerateDataBlock(65536);
            var gameMd5     = GenerateMd5Hash(newGameData);

            ((MockHttpRequestManager)HttpRequestManager.Current).ExpectResponse("http://www.junkship.net/downloads/console.zip", newGameData);
            ((MockHttpRequestManager)HttpRequestManager.Current).ExpectResponse("http://games.junkship.org/gamesource.asmx", @"{ 
""latest"":{
""version"":""1.1.2.4"",
""url"":""http://www.junkship.net/downloads/console.zip"",
""md5"":""" + gameMd5 + @"""
}
}");

            Game game   = new Game("c:\\program files\\MGDF\\game\\game.json");
            var  update = UpdateChecker.CheckForUpdate(game);

            Assert.IsNotNull(update);
            Assert.IsNotNull(update.Game);
            Assert.AreEqual("http://www.junkship.net/downloads/console.zip", update.Game.Url);
            Assert.AreEqual(gameMd5, update.Game.MD5);
            Assert.AreEqual("1.1.2.4", update.Game.Version);

            Assert.IsFalse(FileSystem.Current.GetFile("c:\\temp.zip").Exists);

            //now download the actual update.
            GameDownloader downloader = new GameDownloader(game, "http://www.junkship.net/downloads/console.zip", "c:\\temp.zip", gameMd5, null);

            downloader.Start();

            Assert.IsTrue(FileSystem.Current.GetFile("c:\\temp.zip").Exists);
            Assert.AreEqual(65536, FileSystem.Current.GetFile("c:\\temp.zip").Length);
        }
Пример #22
0
        public void TestAutoUpdateChecker(string currentVersion, string newVersion, bool expectedResult)
        {
            var result = UpdateChecker.CheckForUpdate(currentVersion, newVersion);

            Assert.Equal(expectedResult, result);
        }
Пример #23
0
 public Task ExecuteAsync(CancellationToken cancellationToken)
 {
     return(_updateChecker.CheckForUpdate(cancellationToken));
 }
Пример #24
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            LoadParrotData();
            //CreateConfigValue();

            foreach (var gameProfile in GameProfileLoader.GameProfiles)
            {
                ComboBoxItem item = new ComboBoxItem
                {
                    Content = gameProfile.GameName,
                    Tag     = gameProfile
                };

                GameListComboBox.Items.Add(item);

                if (_parrotData.SaveLastPlayed && gameProfile.GameName == _parrotData.LastPlayed)
                {
                    GameListComboBox.SelectedItem = item;
                }
            }

            new Thread(() =>
            {
                ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                Thread.CurrentThread.IsBackground    = true;
                try
                {
                    string contents;
                    using (var wc = new WebClient())
                        contents = wc.DownloadString("https://teknoparrot.com/api/version");
                    if (UpdateChecker.CheckForUpdate(GameVersion.CurrentVersion, contents))
                    {
                        if (MessageBox.Show(
                                $"There is a new version available: {contents} (currently using {GameVersion.CurrentVersion}). Would you like to download it?",
                                "New update!", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
                        {
                            Thread.CurrentThread.IsBackground = false;
                            //Process.Start("https://teknoparrot.com");

                            Application.Current.Dispatcher.Invoke((Action) delegate {
                                Views.DownloadWindow update = new Views.DownloadWindow();
                                update.ShowDialog();
                            });
                        }
                    }
                }
                catch (Exception)
                {
                    // Ignored
                }
            }).Start();

            if (_parrotData.UseDiscordRPC)
            {
                DiscordRPC.UpdatePresence(new DiscordRPC.RichPresence
                {
                    details       = "Main Menu",
                    largeImageKey = "teknoparrot",
                });
            }

            Title = "TeknoParrot UI " + GameVersion.CurrentVersion;
        }
 public UpdatePresenterTests()
 {
     var checker = new UpdateChecker();
      _update = checker.CheckForUpdate("uniqueId", Path.Combine(Environment.CurrentDirectory, "ApplicationUpdateLocal.xml"));
 }
Пример #26
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     UpdateChecker.CheckForUpdate();
 }
Пример #27
0
        internal static bool CheckForUpdateCore()
        {
            UpdateChecker updateChecker = new UpdateChecker(new Uri(Properties.Settings.Default.UpdateURL), typeof(Program).Assembly.GetName().Version);

            return(updateChecker.CheckForUpdate(Properties.Settings.Default.UpdateCheckIncludePrerelease));
        }