示例#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);
            }
        }
示例#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());
            }
        }
示例#3
0
        public virtual void DetectSettings(IBlogSettingsDetectionContext context, BlogSettingsDetector detector)
        {
            if (detector.IncludeOptionOverrides)
            {
                if (detector.IncludeCategoryScheme)
                {
                    Debug.Assert(!detector.UseManifestCache,
                                 "This code will not run correctly under the manifest cache, due to option overrides not being set");

                    IDictionary optionOverrides = context.OptionOverrides;
                    if (optionOverrides == null)
                    {
                        optionOverrides = new Hashtable();
                    }

                    bool hasNewCategories = optionOverrides.Contains(BlogClientOptions.SUPPORTS_NEW_CATEGORIES);
                    bool hasScheme        = optionOverrides.Contains(BlogClientOptions.CATEGORY_SCHEME);
                    if (!hasNewCategories || !hasScheme)
                    {
                        string scheme;
                        bool   supportsNewCategories;
                        GetCategoryInfo(context.HostBlogId,
                                        optionOverrides[BlogClientOptions.CATEGORY_SCHEME] as string, // may be null
                                        out scheme,
                                        out supportsNewCategories);

                        if (scheme == null)
                        {
                            // no supported scheme was found or provided
                            optionOverrides[BlogClientOptions.SUPPORTS_CATEGORIES] = false.ToString();
                        }
                        else
                        {
                            if (!optionOverrides.Contains(BlogClientOptions.SUPPORTS_NEW_CATEGORIES))
                            {
                                optionOverrides.Add(BlogClientOptions.SUPPORTS_NEW_CATEGORIES, supportsNewCategories.ToString());
                            }
                            if (!optionOverrides.Contains(BlogClientOptions.CATEGORY_SCHEME))
                            {
                                optionOverrides.Add(BlogClientOptions.CATEGORY_SCHEME, scheme);
                            }
                        }

                        context.OptionOverrides = optionOverrides;
                    }
                }

                // GetFeaturesXml(context.HostBlogId);
            }
        }