Exemple #1
0
        // Upgrade site to the current version
        private void SiteUpgrade_Click(object sender, RoutedEventArgs e)
        {
            // Give the user feedback
            startProgressIndicator(Strings.UpgradingApplication);

            // Get the button that was clicked
            FrameworkElement element = (FrameworkElement)sender;

            // Get the site to be upgraded
            Site site = element.DataContext as Site;

            // Hook to the upgrade completed event
            ApplicationBuilderClient client = WCFProxyFactory.CreateApplicationBuilderProxy();

            client.UpgradeSiteCompleted += (o, args) =>
            {
                if (args.Error != null)
                {
                    ESRIControls.MessageBoxDialog.Show(args.Error.Message);
                }
                else
                {
                    // update the product version on the current site object
                    site.ProductVersion = args.Site.ProductVersion;

                    // Since the Site object is not a dependency object,
                    Grid parent = element.FindAncestorOfType <Grid>();
                    if (parent != null)
                    {
                        parent.DataContext = null;
                        parent.DataContext = site;
                    }
                }

                // Hide progress indicator
                stopProgressIndicator();
            };

            // Get ID of current template
            string templateID = null;

            if (BuilderApplication.Instance != null && BuilderApplication.Instance.Templates != null)
            {
                templateID = BuilderApplication.Instance.Templates.FirstOrDefault(t => t.IsDefault).ID;
            }

            if (templateID == null)
            {
                templateID = "Default";
            }

            // Do upgrade
            client.UpgradeSiteAsync(site.ID, templateID);
        }