IsUpdateRunning() публичный Метод

public IsUpdateRunning ( ) : bool
Результат bool
        private async void ManageLocal()
        {
            try
            {
                if (_running) return;

                GlobalObjects.ViewModel.LocalConfig = true;
                GlobalObjects.ViewModel.BlockNavigation = true;
                _running = true;
                var localXml = "";

                await Task.Run(async () => {
                    Dispatcher.Invoke(() =>
                    {
                        WaitManageLocal.Visibility = Visibility.Visible;
                        //ImgManageLocal.Visibility = Visibility.Collapsed;
                    });

                    GlobalObjects.ViewModel.ApplicationMode = ApplicationMode.ManageLocal;

                    var officeInstallManager = new OfficeLocalInstallManager();
                    localXml = await officeInstallManager.GenerateConfigXml();
                });

                GlobalObjects.ViewModel.ConfigXmlParser.LoadXml(localXml);
                GlobalObjects.ViewModel.ResetXml = true;
                GlobalObjects.ViewModel.ImportFile = null;

                GlobalObjects.ViewModel.ConfigXmlParser.ConfigurationXml.Add.Version = null;

                if (RestartWorkflow != null)
                {
                    this.RestartWorkflow(this, new EventArgs());
                }

                GlobalObjects.ViewModel.BlockNavigation = false;

                var installOffice = new InstallOffice();
                if (installOffice.IsUpdateRunning())
                {
                    this.TransitionTab(this, new TransitionTabEventArgs()
                    {
                        Direction = TransitionTabDirection.Forward,
                        Index = 6,
                        UseIndex = true
                    });
                }
                else
                {
                    this.TransitionTab(this, new TransitionTabEventArgs()
                    {
                        Direction = TransitionTabDirection.Forward,
                        Index = 0
                    });
                }

                LogAnaylytics("/StartView", "StartNew");
            }
            catch (Exception ex)
            {
                LogErrorMessage(ex);
            }
            finally
            {
                Dispatcher.Invoke(() =>
                {
                    WaitManageLocal.Visibility = Visibility.Collapsed;
                    //ImgManageLocal.Visibility = Visibility.Visible;
                });
                _running = false;
            }
        }
        public async Task RunUpdateOffice()
        {
            await Task.Run(async () =>
            {
                InstallOffice installOffice = null;
                try
                {
                    installOffice = new InstallOffice();
                    installOffice.UpdatingOfficeStatus += installOffice_UpdatingOfficeStatus;

                    Dispatcher.Invoke(() =>
                    {
                        UpdateStatus.Content = "Updating...";
                        ShowVersion.IsEnabled = false;
                        ChangeChannel.IsEnabled = false;
                    });

                    GlobalObjects.ViewModel.BlockNavigation = true;

                    SetItemState(LocalViewItem.Update, LocalViewState.Wait);

                    var currentChannel = LocalInstall.Channel;
                    if (!installOffice.IsUpdateRunning())
                    {
                        var ppDownloader = new ProPlusDownloader();
                        var baseUrl =
                            await ppDownloader.GetChannelBaseUrlAsync(currentChannel, OfficeEdition.Office32Bit);
                        if (string.IsNullOrEmpty(baseUrl))
                            throw (new Exception(string.Format("Cannot find BaseUrl for Channel: {0}", currentChannel)));

                        installOffice.ChangeUpdateSource(baseUrl);
                    }

                    SetSelectedVersion();

                    await installOffice.RunOfficeUpdateAsync(LocalInstall.LatestVersion);
                    
                    Dispatcher.Invoke(() =>
                    {
                        UpdateStatus.Content = "";
                    });

                    var installGenerator = new OfficeInstallManager(); 
                    LocalInstall = await installGenerator.CheckForOfficeInstallAsync();
                    if (LocalInstall.Installed)
                    {
                        Dispatcher.Invoke(() =>
                        {
                            VersionLabel.Content = LocalInstall.Version;
                            ChannelLabel.Content = LocalInstall.Channel;
                            ProductBranch.SelectedItem = LocalInstall.Channel;
                        });

                        if (LocalInstall.LatestVersionInstalled)
                        {
                            SetItemState(LocalViewItem.Update, LocalViewState.Success);
                        }
                        else
                        {
                            SetItemState(LocalViewItem.Update, LocalViewState.Action);
                            Dispatcher.Invoke(() =>
                            {
                                UpdateStatus.Content = "New version available  (" + LocalInstall.LatestVersion + ")";
                            });
                        }
                    }
                }
                catch (Exception ex)
                {
                    SetItemState(LocalViewItem.Update, LocalViewState.Fail);
                    Dispatcher.Invoke(() =>
                    {
                        UpdateStatus.Content = "The update failed";
                        ErrorText.Text = ex.Message;
                    });

                    LogErrorMessage(ex);
                }
                finally
                {
                    installOffice.ResetUpdateSource();
                    Dispatcher.Invoke(() =>
                    {
                        ShowVersion.IsEnabled = true;
                        ChangeChannel.IsEnabled = true;
                    });
                    GlobalObjects.ViewModel.BlockNavigation = false;
                }
            });
        }
Пример #3
0
        private async void ManageLocal()
        {
            try
            {
                if (_running)
                {
                    return;
                }

                GlobalObjects.ViewModel.LocalConfig     = true;
                GlobalObjects.ViewModel.BlockNavigation = true;
                _running = true;
                var localXml = "";

                await Task.Run(async() => {
                    Dispatcher.Invoke(() =>
                    {
                        WaitManageLocal.Visibility = Visibility.Visible;
                        //ImgManageLocal.Visibility = Visibility.Collapsed;
                    });

                    GlobalObjects.ViewModel.ApplicationMode = ApplicationMode.ManageLocal;

                    var officeInstallManager = new OfficeLocalInstallManager();
                    localXml = await officeInstallManager.GenerateConfigXml();
                });

                GlobalObjects.ViewModel.ConfigXmlParser.LoadXml(localXml);
                GlobalObjects.ViewModel.ResetXml   = true;
                GlobalObjects.ViewModel.ImportFile = null;

                GlobalObjects.ViewModel.ConfigXmlParser.ConfigurationXml.Add.Version = null;

                if (RestartWorkflow != null)
                {
                    this.RestartWorkflow(this, new EventArgs());
                }

                GlobalObjects.ViewModel.BlockNavigation = false;

                var installOffice = new InstallOffice();
                if (installOffice.IsUpdateRunning())
                {
                    this.TransitionTab(this, new TransitionTabEventArgs()
                    {
                        Direction = TransitionTabDirection.Forward,
                        Index     = 6,
                        UseIndex  = true
                    });
                }
                else
                {
                    this.TransitionTab(this, new TransitionTabEventArgs()
                    {
                        Direction = TransitionTabDirection.Forward,
                        Index     = 0
                    });
                }

                LogAnaylytics("/StartView", "StartNew");
            }
            catch (Exception ex)
            {
                LogErrorMessage(ex);
            }
            finally
            {
                Dispatcher.Invoke(() =>
                {
                    WaitManageLocal.Visibility = Visibility.Collapsed;
                    //ImgManageLocal.Visibility = Visibility.Visible;
                });
                _running = false;
            }
        }
        private async Task LoadViewState()
        {
            try
            {
                await Retry.BlockAsync(10, 1, async () => {
                    Dispatcher.Invoke(() =>
                    {
                       ErrorRow.Visibility = Visibility.Collapsed;
                    });

                    SetItemState(LocalViewItem.Install, LocalViewState.Default);

                    var installGenerator = new OfficeLocalInstallManager(); 
                    LocalInstall = await installGenerator.CheckForOfficeInstallAsync();

                    if (LocalInstall.Installed)
                    {
                        SetItemState(LocalViewItem.Install, LocalViewState.Success);
                        SetItemState(LocalViewItem.Uninstall, LocalViewState.Action);

                        Dispatcher.Invoke(() =>
                        {
                            VersionLabel.Content = "(" + LocalInstall.Version + ")";
                            ChannelLabel.Content = LocalInstall.Channel;

                           // ChannelLabel.Content = "First Release Deferred";

                            if (ChannelLabel.Content.ToString().Length < 10)
                            {
                                ChannelName.Width = new GridLength(100);
                            }
                            else if (ChannelLabel.Content.ToString().Length < 20)
                            {
                                ChannelName.Width = new GridLength(150);
                            }
                            else 
                            {
                                ChannelName.Width = new GridLength(200);
                            }

                            var selectIndex = 0;
                            if (LocalInstall.Channel != null)
                            {
                                for (var i = 0; i < ProductBranch.Items.Count; i++)
                                {
                                    var item = (OfficeBranch) ProductBranch.Items[i];
                                    if (item == null) continue;
                                    if (item.NewName.ToLower() != LocalInstall.Channel.ToLower()) continue;
                                    selectIndex = i;
                                    break;
                                }
                            }

                            BranchChanged(this, new BranchChangedEventArgs()
                            {
                                BranchName = LocalInstall.Channel
                            });

                            ProductBranch.SelectedIndex = selectIndex;
                        });

                        var installOffice = new InstallOffice();
                        if (installOffice.IsUpdateRunning())
                        {
                            await RunUpdateOffice();
                        }
                        else
                        {
                            if (LocalInstall.LatestVersionInstalled)
                            {
                                SetItemState(LocalViewItem.Update, LocalViewState.Success);
                            }
                            else
                            {
                                SetItemState(LocalViewItem.Update, LocalViewState.Action);
                                Dispatcher.Invoke(() =>
                                {
                                    UpdateStatus.Content = "New version available  (" + LocalInstall.LatestVersion + ")";
                                });
                            }
                        }

                        Dispatcher.Invoke(() =>
                        {
                            ChangeChannel.IsEnabled = false;
                        });
                    }
                    else
                    {
                        SetItemState(LocalViewItem.Install, LocalViewState.Action);
                    }
                });
            }
            catch (Exception ex)
            {
                SetItemState(LocalViewItem.Install, LocalViewState.Fail);
                Dispatcher.Invoke(() =>
                {
                    ErrorText.Text = ex.Message;
                });
                LogErrorMessage(ex);
            }
        }