Пример #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            RssFeed feed = new RssFeed(ModuleId, ItemId);

            if (feed.ModuleId != ModuleId)
            {
                SiteUtils.RedirectToAccessDeniedPage(this);
                return;
            }

            RssFeed.DeleteEntriesByFeed(ItemId);
            RssFeed.DeleteFeed(ItemId);
            CurrentPage.UpdateLastModifiedTime();

            if (hdnReturnUrl.Value.Length > 0)
            {
                WebUtils.SetupRedirect(this, hdnReturnUrl.Value);
                return;
            }

            WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
        }
Пример #2
0
        private void PopulateControls()
        {
            RssFeed feed = new RssFeed(ModuleId, ItemId);

            if (feed.ModuleId != ModuleId)
            {
                SiteUtils.RedirectToAccessDeniedPage(this);
                return;
            }

            txtAuthor.Text = feed.Author;
            txtWebSite.Text = feed.Url;
            txtRssUrl.Text = feed.RssUrl;
            txtImageUrl.Text = feed.ImageUrl;
            txtSortRank.Text = feed.SortRank.ToInvariantString();
            //FeedType.SetValue(feed.FeedType);
            chkPublishByDefault.Checked = feed.PublishByDefault;
        }
 private void BindSelectedFeed()
 {
     RssFeed feed = new RssFeed(ModuleId, ItemID);
     this.lblFeedHeading.Visible = true;
     this.lblFeedHeading.Text = "<h2>" + feed.Author + "</h2>";
 }
Пример #4
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            Page.Validate("feeds");
            if (!Page.IsValid) { return; }

            RssFeed feed = new RssFeed(ModuleId, ItemId);

            if (feed.ModuleId != ModuleId)
            {
                SiteUtils.RedirectToAccessDeniedPage(this);
                return;
            }

            feed.ModuleId = ModuleId;
            feed.Author = txtAuthor.Text;
            feed.Url = txtWebSite.Text;
            feed.RssUrl = txtRssUrl.Text;
            feed.ImageUrl = txtImageUrl.Text;
            int sortRank = 500;
            int.TryParse(txtSortRank.Text, out sortRank);
            feed.SortRank = sortRank;

            SiteUser siteUser = SiteUtils.GetCurrentSiteUser();
            if (siteUser == null) return;

            Module module = new Module(ModuleId);
            feed.ModuleGuid = module.ModuleGuid;
            feed.UserId = siteUser.UserId;
            feed.UserGuid = siteUser.UserGuid;
            feed.LastModUserGuid = siteUser.UserGuid;
            feed.PublishByDefault = chkPublishByDefault.Checked;

            if (feed.Save())
            {
                CurrentPage.UpdateLastModifiedTime();

                FeedCache.RefreshFeed(
                    feed,
                    ModuleId,
                    module.ModuleGuid,
                    config.MaxDaysOld,
                    config.MaxEntriesPerFeed,
                    config.EnableSelectivePublishing);

                String rssFriendlyUrl = "aggregator" + ModuleId.ToInvariantString() + "rss.aspx";
                if (!FriendlyUrl.Exists(siteSettings.SiteId, rssFriendlyUrl))
                {
                    FriendlyUrl friendlyUrl = new FriendlyUrl();
                    friendlyUrl.SiteId = siteSettings.SiteId;
                    friendlyUrl.SiteGuid = siteSettings.SiteGuid;
                    friendlyUrl.Url = rssFriendlyUrl;
                    friendlyUrl.RealUrl = "~/FeedManager/FeedAggregate.aspx?pageid=" + PageId.ToInvariantString() + "&mid=" + ModuleId.ToInvariantString();
                    friendlyUrl.Save();
                }

                if (hdnReturnUrl.Value.Length > 0)
                {
                    WebUtils.SetupRedirect(this, hdnReturnUrl.Value);
                    return;
                }

                WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
            }
        }
        public void InstallContent(Module module, string configInfo)
        {
            if (string.IsNullOrEmpty(configInfo)) { return; }

            SiteSettings siteSettings = new SiteSettings(module.SiteId);
            SiteUser admin = SiteUser.GetNewestUser(siteSettings);

            XmlDocument xml = new XmlDocument();

            using (StreamReader stream = File.OpenText(HostingEnvironment.MapPath(configInfo)))
            {
                xml.LoadXml(stream.ReadToEnd());
            }

            foreach (XmlNode node in xml.DocumentElement.ChildNodes)
            {
                if (node.Name == "feed")
                {
                    XmlAttributeCollection feedAttributes = node.Attributes;

                    RssFeed feed = new RssFeed(module.ModuleId);

                    feed.ModuleId = module.ModuleId;
                    feed.ModuleGuid = module.ModuleGuid;

                    if (admin != null)
                    {
                        feed.UserId = admin.UserId;
                        feed.UserGuid = admin.UserGuid;
                        feed.LastModUserGuid = admin.UserGuid;
                    }

                    if (feedAttributes["feedName"] != null)
                    {
                        feed.Author = feedAttributes["feedName"].Value;
                    }

                    if (feedAttributes["webUrl"] != null)
                    {
                        feed.Url = feedAttributes["webUrl"].Value;
                    }

                    if (feedAttributes["feedUrl"] != null)
                    {
                        feed.RssUrl = feedAttributes["feedUrl"].Value;
                    }

                    if (feedAttributes["sortRank"] != null)
                    {
                        int sort = 500;
                        if (int.TryParse(feedAttributes["sortRank"].Value,
                            out sort))
                        {
                            feed.SortRank = sort;
                        }
                    }

                    feed.Save();
                }

                if (node.Name == "moduleSetting")
                {
                    XmlAttributeCollection settingAttributes = node.Attributes;

                    if ((settingAttributes["settingKey"] != null)&&(settingAttributes["settingKey"].Value.Length > 0))
                    {
                        string key = settingAttributes["settingKey"].Value;
                        string val = string.Empty;
                        if (settingAttributes["settingValue"] != null)
                        {
                            val = settingAttributes["settingValue"].Value;
                        }

                        ModuleSettings.UpdateModuleSetting(module.ModuleGuid, module.ModuleId, key, val);

                    }

                }

            }
        }