Example #1
0
        private async Task UpdateRootManifest(bool setNewAsCurrent = false)
        {
            SetUIProgressState(true);
            SetUIState(false);

Retry:

            try
            {
                await repository.RefreshManifest(setNewAsCurrent);
            }
            catch (Exception err)
            {
                if (err is WebException)
                {
                    // WebException wex = (WebException) err;

                    MessageBox.Show("Não foi possível ler o manifesto online: " + err.Message +
                                    ". Mudando para modo Offline.");
                    repository.AlwaysAssumeCurrent = true;
                    goto Retry;
                }
                else if (err is ValidationException)
                {
                    MessageBox.Show("Existem problemas no manifesto " +
                                    "(Isso provavelmente não é sua culpa, já que precisa arrumar no servidor!):" +
                                    "\n\n" + err.Message);
                }
                else
                {
                    MessageBox.Show("Houve algum problema em baixar e ler o manifesto:\n\n" +
                                    err.ToString());
                }

                Application.Current.Shutdown();
                return;
            }

            RefreshBackgroundImage();

            SetGlobalStatus(true);
            SetUIProgressState(false);

            var revText = string.Format("{0} -> {1}",
                                        repository.CurrentManifest != null && repository.CurrentManifest.revision != null ? repository.CurrentManifest.revision.ToString() : "?",
                                        repository.LatestManifest != null && repository.LatestManifest.revision != null ? repository.LatestManifest.revision.ToString() : "?"
                                        );

            Log("Revision: " + revText);

            /*if (repository.Status.current)
             *  btnDownload.Content = "verify";
             * else
             *  btnDownload.Content = "sync";*/

            btnCancel.Visibility = System.Windows.Visibility.Hidden;

            /* Verify if we need to restart ourselves. */
            if (repository.RequireRestart)
            {
                await this.ShowMessageAsync("Reinício necessário", "O chimera necessita reiniciar.");

                System.Diagnostics.Process.Start(Application.ResourceAssembly.Location);
                Application.Current.Shutdown();
            }

            if (!IgnoreRepositoryLock && repository.LatestManifest.locked != "")
            {
                await this.ShowMessageAsync("Repositório travado", repository.LatestManifest.locked);

                Application.Current.Shutdown();
            }

            this.BorderThickness = new Thickness(repository.LatestManifest.border ? 1 : 0);

            var effect = repository.LatestManifest.dropShadows ? new DropShadowEffect()
            {
                // Color = (Color) ColorConverter.ConvertFromString(repository.LatestManifest.textColor),
                Opacity    = 0.5,
                BlurRadius = 10
            } : null;

            btnRun.Effect              = effect;
            labelDLSize.Effect         = effect;
            labelDownloadStatus.Effect = effect;

            SetUIState(true);
        }