コード例 #1
0
        /// <summary>
        /// Use a typical RssItem as data source.
        /// </summary>
        public RssNewsItem(RssNewsSource source, RssItem item) : base(source)
        {
            // If created from an rss item this means this is a new item, not known to the DB yet.
            this.IsRead = false;

            Author      = item.Author;
            Comments    = item.Comments;
            Description = item.Description;
            if (item.Guid != null)
            {
                Guid = item.Guid.Name;
            }
            Link     = item.Link;
            DateTime = item.PubDate;
            Title    = item.Title.Trim();
        }
コード例 #2
0
        /// <summary>
        /// Use a typical RssItem as data source.
        /// </summary>
        public RssNewsItem(RssNewsSource source, RssItem item)
            : base(source)
        {
            // If created from an rss item this means this is a new item, not known to the DB yet.
            this.IsRead = false;

            Author = item.Author;
            Comments = item.Comments;
            Description = item.Description;
            if (item.Guid != null)
            {
                Guid = item.Guid.Name;
            }
            Link = item.Link;
            DateTime = item.PubDate;
            Title = item.Title.Trim();
        }
コード例 #3
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBoxAdd.Text))
            {
                return;
            }

            RssNewsSource source = new RssNewsSource(this.textBoxAdd.Text);
            source.Update();
            if (source.OperationalState != OperationalStateEnum.Operational)
            {
                MessageBox.Show("Failed to find source.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                _control.Manager.AddSource(source);
                textBoxAdd.Text = "";
                UpdateUI();
            }
        }
コード例 #4
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBoxAdd.Text))
            {
                return;
            }

            RssNewsSource source = new RssNewsSource(this.textBoxAdd.Text);

            source.Update();
            if (source.OperationalState != OperationalStateEnum.Operational)
            {
                MessageBox.Show("Failed to find source.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                _control.Manager.AddSource(source);
                textBoxAdd.Text = "";
                UpdateUI();
            }
        }
コード例 #5
0
        /// <summary>
        /// 
        /// </summary>
        public void Initialize(Platform platform)
        {
            SystemMonitor.CheckWarning(NewsSourcesUnsafe.Count == 0, "Manager already has assigned sources.");

            _platform = platform;

            _persistenceHelper = CreatePersistenceHelper(platform.Settings);
            if (_persistenceHelper == null)
            {
                SystemMonitor.Error("Failed to initialize the persistence helper for Platform News Manager.");
                return;
            }

            // Make sure this load is before the accept events, so that they do not cause adding failure.
            List<EventSource> sources = _persistenceHelper.SelectDynamicType<EventSource>(null, null);

            base.SourceAddedEvent += new NewsSourceUpdateDelegate(PlatformNewsManager_SourceAddedEvent);
            base.SourceRemovedEvent += new NewsSourceUpdateDelegate(PlatformNewsManager_SourceRemovedEvent);

            if (sources != null)
            {
                foreach (EventSource source in sources)
                {// Add the source to subscribe to it, than load items.
                    base.AddSource(source);

                    if (source.Enabled)
                    {
                        LoadSourceItemsFromPersistence(source);
                    }
                }
            }

            if (platform != null)
            {// Load the default sources.
                foreach (string feedAddress in platform.Settings.DefaultRSSFeeds)
                {
                    if (GetSourceByAddress(feedAddress) == null)
                    {
                        RssNewsSource newSource = new RssNewsSource();
                        newSource.Initialize(feedAddress);

                        AddSource(newSource);
                    }
                }
            }

            GeneralHelper.FireAndForget(UpdateFeeds);
        }