Пример #1
0
        private void CheckUpdate(bool showResult)
        {
            var assem = Assembly.GetEntryAssembly();
            var assemName = assem.GetName();
            var ver = assemName.Version;
            var platform = "x86";
            if (Tools.Is64BitProcess)
                platform = "x64";
            Logger.Instance().Log("FrontView+", "Checking for updates. Current version : " + ver, true);
            _allowBeta = File.Exists(Helper.AppPath + "Yatse2.beta");

            var repo = new RemoteRepository();
            repo.SetDebug(_config.Debug);
            if (!repo.LoadRepository(Repository, platform, Helper.AppPath + "Updates"))
            {
                if (showResult)
                    ShowOkDialog(GetLocalizedString(114));
                return;
            }
                
            var result = repo.UpdateTranslations(Helper.LangPath);
            if (result)
            {
                if (showResult)
                    ShowOkDialog(GetLocalizedString(115));
                RefreshDictionaries();
            }
            var versions = repo.GetBuildList(_allowBeta);
            if (versions == null)
            {
                Logger.Instance().Log("FrontView+", "Build list empty !", true);
                if (showResult)
                    ShowOkDialog(GetLocalizedString(114));
            }
            else
            {
                if (versions.Version.Count < 1)
                {
                    Logger.Instance().Log("FrontView+", "Build list empty !", true);
                    if (showResult)
                        ShowOkDialog(GetLocalizedString(114));
                }
                else
                {
                    var lastBuild = versions.Version[versions.Version.Count - 1];

                    if (ver.Build >= lastBuild.Build)
                    {
                        Logger.Instance().Log("FrontView+", "Version is up2date!", true);
                        if (showResult)
                            ShowOkDialog(GetLocalizedString(113));
                    }
                    else
                    {
                        Logger.Instance().Log("FrontView+", "Update available : " + lastBuild.Build, true);
                        var res = ShowYesNoDialog(GetLocalizedString(109));
                        if (res)
                        {
                            Directory.CreateDirectory(Helper.AppPath + "Temp");
                            if (GetUpdater())
                            {
                                Process.Start(Helper.AppPath + @"Temp\Yatse2Setup.exe");
                                Close();
                            }
                            else
                            {
                                ShowOkDialog(GetLocalizedString(101));
                            }
                        }

                    }
                }
            }
            repo.CleanTemporary();
        }
Пример #2
0
        private void btn_GoUpdate_Click(object sender, RoutedEventArgs e)
        {
 
            var platform = "x86";
            if (Tools.IsFile64Bit(txb_SourceDirectory.Text + @"\Yatse2.exe") == true)
                platform = "x64";
            var repo = new RemoteRepository();

            repo.LoadRepository(Repository, platform, Helper.AppPath + "Updates");

            var versions = repo.GetBuildList(_allowBeta);
            if (versions == null)
            {
                MessageBox.Show(GetLocalizedString(10));
                repo.CleanTemporary();
                return;
            }
            if (versions.Version.Count < 1)
            {
                MessageBox.Show(GetLocalizedString(10));
                repo.CleanTemporary();
                return;
            }
            var lastBuild = versions.Version[versions.Version.Count - 1];

            brd_Update.Visibility = Visibility.Hidden;
            brd_BuildlInfos.Visibility = Visibility.Hidden;
            brd_InstallInfos.Visibility = Visibility.Visible;
            btn_Cancel.IsEnabled = false;
            txb_InstallInfos.Text = GetLocalizedString(6) + " " + lastBuild.Build + "\n\n" + GetLocalizedString(7);

            var updateInfo = new RepoInfo
                                 {
                                     Repo = Repository,
                                     Platform = platform,
                                     Source = txb_SourceDirectory.Text,
                                     Destination = txb_TargetDirectory.Text,
                                     Version = lastBuild
                                 };

            var backgroundWorker = new BackgroundWorker();
            backgroundWorker.DoWork += backgroundWorker_Update;
            backgroundWorker.RunWorkerCompleted += backgroundWorker_UpdateCompleted;

            backgroundWorker.RunWorkerAsync(updateInfo);

        }
Пример #3
0
        private void btn_Update_Click(object sender, RoutedEventArgs e)
        {
        	if (!File.Exists(txb_SourceDirectory.Text + @"\Yatse2.exe"))
        	{
        	    CheckIfUpdate();
                return;
        	}

            _allowBeta = File.Exists(txb_SourceDirectory.Text + @"\Yatse2.beta");
            var platform = "x86";
            if (Tools.IsFile64Bit(txb_SourceDirectory.Text + @"\Yatse2.exe") == true)
                platform = "x64";

            var repo = new RemoteRepository();
            repo.SetDebug(true);
            repo.LoadRepository(Repository, platform, Helper.AppPath + "Updates");

            var versions = repo.GetBuildList(_allowBeta);
            if (versions == null)
            {
                MessageBox.Show(GetLocalizedString(10));
                repo.CleanTemporary();
                return;
            }
            if (versions.Version.Count < 1)
            {
                MessageBox.Show(GetLocalizedString(10));
                repo.CleanTemporary();
                return;
            }
            var lastBuild = versions.Version[versions.Version.Count - 1];

            var version = Tools.GetFileRevision(txb_SourceDirectory.Text + @"\Yatse2.exe");
            if (version == lastBuild.Build)
            {
                MessageBox.Show(GetLocalizedString(12));
                repo.CleanTemporary();
                return;
            }

            var buildinfo = repo.GetVersionInfo(lastBuild);

            if (buildinfo == null)
            {
                MessageBox.Show(GetLocalizedString(14));
                repo.CleanTemporary();
            }
            else
            {
                txb_BuildInfos.Text = buildinfo.Description;
                brd_Update.Visibility = Visibility.Hidden;
                brd_BuildlInfos.Visibility = Visibility.Visible;
            }
        }
Пример #4
0
        private static void backgroundWorker_Update(object sender, DoWorkEventArgs e)
        {
            var updateInfo = (RepoInfo) e.Argument;

            var repo = new RemoteRepository();
            repo.LoadRepository(updateInfo.Repo, updateInfo.Platform, Helper.AppPath + "Updates");
            var result = repo.Update(updateInfo.Destination, updateInfo.Version);
            repo.CleanTemporary();
            e.Result = result;

        } 
Пример #5
0
        private void Install(string platform)
        {
            var repo = new RemoteRepository();
            repo.LoadRepository(Repository, platform, Helper.AppPath + "Updates");
            _allowBeta = File.Exists(txb_TargetDirectory.Text + @"\Yatse2.beta");
            var versions = repo.GetBuildList(_allowBeta);
            if (versions == null)
            {
                MessageBox.Show(GetLocalizedString(10));
                repo.CleanTemporary();
                return;
            }
            if (versions.Version.Count < 1)
            {
                MessageBox.Show(GetLocalizedString(10));
                repo.CleanTemporary();
                return;
            }
            var lastBuild = versions.Version[versions.Version.Count - 1];

            txb_InstallInfos.Text = GetLocalizedString(6) + " " + lastBuild.Build + " (" + platform + ")\n\n" + GetLocalizedString(7);
            brd_InstallInfos.Visibility = Visibility.Visible;
            brd_Install.Visibility = Visibility.Hidden;
            brd_BuildlInfos.Visibility = Visibility.Hidden;
            btn_Cancel.IsEnabled = false;


            var updateInfo = new RepoInfo
            {
                Repo = Repository,
                Platform = platform,
                Source = txb_SourceDirectory.Text,
                Destination = txb_TargetDirectory.Text,
                Version = lastBuild
            };

            var backgroundWorker = new BackgroundWorker();
            backgroundWorker.DoWork += backgroundWorker_Install;
            backgroundWorker.RunWorkerCompleted += backgroundWorker_InstallCompleted;

            backgroundWorker.RunWorkerAsync(updateInfo);

        }