Example #1
0
        private object DetectWeblogSettings(IProgressHost progressHost)
        {
            using (BlogClientUIContextScope uiContextScope = new BlogClientUIContextScope(_uiContext))
            {
                try
                {
                    BlogSettingsDetector blogSettingsDetector = new BlogSettingsDetector(_temporarySettings);
                    blogSettingsDetector.DetectSettings(progressHost);
                }
                catch (OperationCancelledException)
                {
                    // WasCancelled == true
                }
                catch (BlogClientOperationCancelledException)
                {
                    _hostOperation.Cancel();
                    // WasCancelled == true
                }
                catch (Exception ex)
                {
                    Trace.Fail("Error occurred while downloading weblog posts and  categories: " + ex.ToString());
                }

                return(this);
            }
        }
Example #2
0
        private void Main()
        {
            try
            {
                // delay the check for updates
                Thread.Sleep(1000);

                // only run one service-update at a time process wide
                lock (_serviceUpdateLock)
                {
                    // establish settings detection context
                    ServiceUpdateSettingsDetectionContext settingsDetectionContext = new ServiceUpdateSettingsDetectionContext(_blogId);

                    // fire-up a blog settings detector to query for changes
                    BlogSettingsDetector settingsDetector = new BlogSettingsDetector(settingsDetectionContext);
                    settingsDetector.SilentMode = true;
                    using (RegistryKey key = Registry.CurrentUser.OpenSubKey(ApplicationEnvironment.SettingsRootKeyName + @"\Weblogs\" + _blogId + @"\HomepageOptions"))
                    {
                        if (key != null)
                        {
                            settingsDetector.IncludeFavIcon            = false;
                            settingsDetector.IncludeCategories         = settingsDetectionContext.BlogSupportsCategories;
                            settingsDetector.UseManifestCache          = true;
                            settingsDetector.IncludeHomePageSettings   = false;
                            settingsDetector.IncludeCategoryScheme     = false;
                            settingsDetector.IncludeInsecureOperations = false;
                        }
                    }
                    settingsDetector.IncludeImageEndpoints = false;
                    settingsDetector.DetectSettings(SilentProgressHost.Instance);

                    // write the settings
                    using (ProcessKeepalive.Open())
                    {
                        using (BlogSettings settings = BlogSettings.ForBlogId(_blogId))
                            settings.ApplyUpdates(settingsDetectionContext);
                    }

                    // if changes were made then fire an event to notify the UI
                    if (settingsDetectionContext.HasUpdates)
                    {
                        _settingsChangedHandler(_blogId, false);
                    }
                }
            }
            catch (ManualKeepaliveOperationException)
            {
            }
            catch (Exception ex)
            {
                Trace.Fail("Unexpected exception during ServiceUpdateChecker.Main: " + ex.ToString());
            }
        }