Beispiel #1
0
    protected void discoverRel(string url, ArrayList feeds)
    {
        HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);

        request.UserAgent = SessionManager.GetCachedConfiguration("SnCore.Web.UserAgent", "SnCore/1.0");
        request.Accept    = "*/*";
        WebResponse response = request.GetResponse();
        string      content;

        using (StreamReader sr = new StreamReader(response.GetResponseStream()))
        {
            content = sr.ReadToEnd();
            sr.Close();
        }

        List <HtmlLinkControl> links = HtmlLinkExtractor.Extract(content, new Uri(url));

        foreach (HtmlLinkControl link in links)
        {
            switch (link.Type.ToLower())
            {
            case "application/rss+xml":
            case "application/atom+xml":
                TransitAccountFeed feed = new TransitAccountFeed();
                feed.FeedUrl     = link.Href;
                feed.LinkUrl     = inputLinkUrl.Text;
                feed.Description = string.Empty;
                feed.Name        = link.Title;
                feeds.Add(feed);
                break;
            }
        }
    }
Beispiel #2
0
    public string GetDataObjectName()
    {
        switch (Feature.DataObjectName)
        {
        case "AccountFeed":
        {
            TransitAccountFeed t_instance = SessionManager.GetInstance <TransitAccountFeed, int>(
                Feature.DataRowId, SessionManager.SyndicationService.GetAccountFeedById);
            return(t_instance.Name);
        }

        case "AccountFeedItem":
        {
            TransitAccountFeedItem t_instance = SessionManager.GetInstance <TransitAccountFeedItem, int>(
                Feature.DataRowId, SessionManager.SyndicationService.GetAccountFeedItemById);
            return(t_instance.Title);
        }

        case "Account":
        {
            TransitAccount t_instance = SessionManager.GetInstance <TransitAccount, int>(
                Feature.DataRowId, SessionManager.AccountService.GetAccountById);
            return(t_instance.Name);
        }

        case "AccountEvent":
        {
            TransitAccountEvent t_instance = SessionManager.GetInstance <TransitAccountEvent, int, long>(
                Feature.DataRowId, 0, SessionManager.EventService.GetAccountEventById);
            return(t_instance.Name);
        }

        case "AccountGroup":
        {
            TransitAccountGroup t_instance = SessionManager.GetInstance <TransitAccountGroup, int>(
                Feature.DataRowId, SessionManager.GroupService.GetAccountGroupById);
            return(t_instance.Name);
        }

        case "Place":
        {
            TransitPlace t_instance = SessionManager.GetInstance <TransitPlace, int>(
                Feature.DataRowId, SessionManager.PlaceService.GetPlaceById);
            return(t_instance.Name);
        }
        }

        return(string.Empty);
    }
Beispiel #3
0
        public int CreateOrUpdateAccountFeed(string ticket, TransitAccountFeed feed)
        {
            int id = WebServiceImpl <TransitAccountFeed, ManagedAccountFeed, AccountFeed> .CreateOrUpdate(
                ticket, feed);

            try
            {
                UpdateAccountFeedItems(ticket, id);
            }
            catch
            {
            }

            return(id);
        }
    public void Page_Load(object sender, EventArgs e)
    {
        gridManage.OnGetDataSource += new EventHandler(gridManage_OnGetDataSource);
        if (!IsPostBack)
        {
            TransitAccountFeed f = AccountFeed;
            labelFeed.Text            = Renderer.Render(f.Name);
            labelFeed.NavigateUrl     = f.LinkUrl;
            labelFeedDescription.Text = Renderer.Render(f.Description);

            licenseView.AccountId = f.AccountId;

            GetDataPublish(sender, e);

            TransitFeedType t = SessionManager.GetInstance <TransitFeedType, string>(
                f.FeedType, SessionManager.SyndicationService.GetFeedTypeByName);

            gridManage.RepeatColumns = t.SpanColumns;
            gridManage.RepeatRows    = t.SpanRows;

            TransitAccount a = SessionManager.GetInstance <TransitAccount, int>(
                f.AccountId, SessionManager.AccountService.GetAccountById);

            labelAccountName.Text = Renderer.Render(a.Name);
            linkAccount.HRef      = string.Format("AccountView.aspx?id={0}", a.Id);
            imageAccount.Src      = string.Format("AccountPictureThumbnail.aspx?id={0}", a.PictureId);

            this.Title = string.Format("{0}'s {1}", Renderer.Render(a.Name), Renderer.Render(f.Name));

            gridManage.VirtualItemCount = SessionManager.GetCount <TransitAccountFeedItem, int>(
                RequestId, SessionManager.SyndicationService.GetAccountFeedItemsCount);
            gridManage_OnGetDataSource(sender, e);
            gridManage.DataBind();

            GetDataFeature(sender, e);

            redirect.AccountId     = f.AccountId;
            redirect.TargetUri     = string.Format("AccountFeedView.aspx?id={0}", f.Id);
            linkRelRss.NavigateUrl = string.Format("AccountFeedRss.aspx?id={0}", f.Id);

            SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute();
            sitemapdata.Add(new SiteMapDataAttributeNode("Blogs", Request, "AccountFeedItemsView.aspx"));
            sitemapdata.Add(new SiteMapDataAttributeNode(f.Name, Request.Url));
            StackSiteMap(sitemapdata);
        }
    }
Beispiel #5
0
    protected void discoverAtom(string url, ArrayList feeds, Uri ns)
    {
        try
        {
            AtomFeed atomfeed = AtomFeed.Load(GetFeedStream(url), ns);

            TransitAccountFeed feed = new TransitAccountFeed();

            if (atomfeed.SubTitle != null)
            {
                feed.Description = atomfeed.SubTitle.Content;
            }
            else if (atomfeed.Tagline != null)
            {
                feed.Description = atomfeed.Tagline.Content;
            }

            feed.FeedUrl = url;

            if (atomfeed.Links != null)
            {
                foreach (AtomLink link in atomfeed.Links)
                {
                    if (link.Rel == Relationship.Alternate)
                    {
                        feed.LinkUrl = link.HRef.ToString();
                        break;
                    }
                }
            }

            if (atomfeed.Title != null)
            {
                feed.Name = atomfeed.Title.Content;
            }

            feeds.Add(feed);
        }
        catch
        {
        }
    }
Beispiel #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        gridManage.OnGetDataSource += new EventHandler(gridManage_OnGetDataSource);
        if (!IsPostBack)
        {
            if (FeedId > 0)
            {
                TransitAccountFeed f = Feed;

                TransitFeedType t = SessionManager.GetInstance <TransitFeedType, string>(
                    f.FeedType, SessionManager.SyndicationService.GetFeedTypeByName);
                gridManage.RepeatColumns    = t.SpanColumnsPreview;
                gridManage.RepeatRows       = t.SpanRowsPreview;
                gridManage.VirtualItemCount = SessionManager.GetCount <TransitAccountFeedItem, int>(
                    FeedId, SessionManager.SyndicationService.GetAccountFeedItemsCount);
                gridManage_OnGetDataSource(this, null);
                gridManage.DataBind();
            }
        }
    }
Beispiel #7
0
    protected void discoverRss(string url, ArrayList feeds)
    {
        try
        {
            RssFeed rssfeed = RssFeed.Read(GetFeedHttpRequest(url));

            foreach (RssChannel rsschannel in rssfeed.Channels)
            {
                TransitAccountFeed feed = new TransitAccountFeed();
                feed.Description = rsschannel.Description;
                feed.FeedUrl     = url;
                feed.LinkUrl     = rsschannel.Link.ToString();
                feed.Name        = rsschannel.Title;
                feeds.Add(feed);
                break;
            }
        }
        catch
        {
        }
    }
    public void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute();
            sitemapdata.Add(new SiteMapDataAttributeNode("Me Me", Request, "AccountManage.aspx"));
            sitemapdata.Add(new SiteMapDataAttributeNode("Syndication", Request, "AccountFeedsManage.aspx"));

            DomainClass cs = SessionManager.GetDomainClass("AccountFeed");
            inputName.MaxLength     = cs["Name"].MaxLengthInChars;
            inputFeedUrl.MaxLength  = cs["FeedUrl"].MaxLengthInChars;
            inputUsername.MaxLength = cs["Username"].MaxLengthInChars;
            inputPassword.MaxLength = cs["Password"].MaxLengthInChars;
            inputLinkUrl.MaxLength  = cs["LinkUrl"].MaxLengthInChars;

            GetFeedTypes(sender, e);

            string feedtype = Request.Params["type"];
            ListItemManager.TrySelect(selectType, feedtype);

            if (RequestId > 0)
            {
                TransitAccountFeed tf = SessionManager.SyndicationService.GetAccountFeedById(
                    SessionManager.Ticket, RequestId);

                inputName.Text                    = tf.Name;
                inputDescription.Text             = tf.Description;
                inputLinkUrl.Text                 = tf.LinkUrl;
                inputFeedUrl.Text                 = tf.FeedUrl;
                inputUsername.Text                = tf.Username;
                inputShown.Checked                = !tf.Hidden;
                inputPublish.Checked              = tf.Publish;
                inputPublishImgs.Checked          = tf.PublishImgs;
                inputPublishMedia.Checked         = tf.PublishMedia;
                inputPassword.Attributes["value"] = tf.Password;

                if (tf.UpdateFrequency > 0)
                {
                    ListItemManager.SelectAdd(
                        inputUpdateFrequency,
                        string.Format("Every {0} Hours", tf.UpdateFrequency),
                        tf.UpdateFrequency);
                }

                ListItemManager.TrySelect(selectType, tf.FeedType);
                sitemapdata.Add(new SiteMapDataAttributeNode(tf.Name, Request.Url));
                feedredirect.TargetUri = string.Format("AccountFeedView.aspx?id={0}", tf.Id);
            }
            else
            {
                if (Request.Params["name"] != null)
                {
                    inputName.Text               = Request.Params["name"];
                    inputUsername.Enabled        = false;
                    inputPassword.Enabled        = false;
                    inputUpdateFrequency.Enabled = false;
                }

                if (Request.Params["feed"] != null)
                {
                    inputFeedUrl.Text    = Request.Params["feed"];
                    inputFeedUrl.Enabled = false;
                }

                if (Request.Params["link"] != null)
                {
                    inputLinkUrl.Text    = Request.Params["link"];
                    inputLinkUrl.Enabled = false;
                }

                if (Request.Params["description"] != null)
                {
                    inputDescription.Text = Request.Params["description"];
                }

                string type = Request.Params["type"];
                ListItemManager.TrySelect(selectType, type);
                sitemapdata.Add(new SiteMapDataAttributeNode("New Feed", Request.Url));
                feedredirect.Visible = false;
            }

            StackSiteMap(sitemapdata);
        }

        SetDefaultButton(linkSave);
    }
    public void save(object sender, EventArgs e)
    {
        TransitAccountFeed s = new TransitAccountFeed();

        s.Id              = RequestId;
        s.Name            = inputName.Text;
        s.Description     = inputDescription.Text;
        s.AccountId       = SessionManager.Account.Id;
        s.FeedType        = selectType.SelectedValue;
        s.UpdateFrequency = int.Parse(inputUpdateFrequency.SelectedValue);

        if (!string.IsNullOrEmpty(inputFeedUrl.Text) && !Uri.IsWellFormedUriString(inputFeedUrl.Text, UriKind.Absolute))
        {
            inputFeedUrl.Text = "http://" + inputFeedUrl.Text;
        }

        if (!string.IsNullOrEmpty(inputLinkUrl.Text) && !Uri.IsWellFormedUriString(inputLinkUrl.Text, UriKind.Absolute))
        {
            inputLinkUrl.Text = "http://" + inputLinkUrl.Text;
        }

        s.FeedUrl      = inputFeedUrl.Text;
        s.LinkUrl      = inputLinkUrl.Text;
        s.Publish      = inputPublish.Checked;
        s.Hidden       = !inputShown.Checked;
        s.PublishImgs  = inputPublishImgs.Checked;
        s.PublishMedia = inputPublishMedia.Checked;

        if (s.Id == 0)
        {
            TransitAccountFeedQueryOptions qopt = new TransitAccountFeedQueryOptions();
            qopt.AccountId         = SessionManager.AccountId;
            qopt.PublishedOnly     = false;
            qopt.PicturesOnly      = false;
            qopt.WithFeedItemsOnly = false;
            List <TransitAccountFeed> feeds = SessionManager.SyndicationService.GetAccountFeeds(
                SessionManager.Ticket, qopt, null);

            foreach (TransitAccountFeed feed in feeds)
            {
                if (feed.Name.Trim().ToLower() == s.Name.Trim().ToLower())
                {
                    throw new Exception(string.Format("A syndicated feed with the same name '{0}' already exists. " +
                                                      "Click <a href='AccountFeedEdit.aspx?id={1}'>here</a> to modify it.",
                                                      Renderer.Render(feed.Name), feed.Id));
                }

                if (feed.FeedUrl.Trim().ToLower() == s.FeedUrl.Trim().ToLower())
                {
                    throw new Exception(string.Format("A syndicated feed with the same feed address already exists. " +
                                                      "The feed name is '{0}' and the address is '{1}'. " +
                                                      "Click <a href='AccountFeedEdit.aspx?id={2}'>here</a> to modify it.",
                                                      Renderer.Render(feed.Name), Renderer.Render(feed.FeedUrl), feed.Id));
                }
            }
        }

        SessionManager.CreateOrUpdate <TransitAccountFeed>(
            s, SessionManager.SyndicationService.CreateOrUpdateAccountFeed);
        Redirect("AccountFeedsManage.aspx");
    }
Beispiel #10
0
    public void save(object sender, EventArgs e)
    {
        TransitAccountFeed s = new TransitAccountFeed();
        s.Id = RequestId;
        s.Name = inputName.Text;
        s.Description = inputDescription.Text;
        s.AccountId = SessionManager.Account.Id;
        s.FeedType = selectType.SelectedValue;
        s.UpdateFrequency = int.Parse(inputUpdateFrequency.SelectedValue);

        if (!string.IsNullOrEmpty(inputFeedUrl.Text) && !Uri.IsWellFormedUriString(inputFeedUrl.Text, UriKind.Absolute))
            inputFeedUrl.Text = "http://" + inputFeedUrl.Text;

        if (!string.IsNullOrEmpty(inputLinkUrl.Text) && !Uri.IsWellFormedUriString(inputLinkUrl.Text, UriKind.Absolute))
            inputLinkUrl.Text = "http://" + inputLinkUrl.Text;

        s.FeedUrl = inputFeedUrl.Text;
        s.LinkUrl = inputLinkUrl.Text;
        s.Publish = inputPublish.Checked;
        s.Hidden = ! inputShown.Checked;
        s.PublishImgs = inputPublishImgs.Checked;
        s.PublishMedia = inputPublishMedia.Checked;

        if (s.Id == 0)
        {
            TransitAccountFeedQueryOptions qopt = new TransitAccountFeedQueryOptions();
            qopt.AccountId = SessionManager.AccountId;
            qopt.PublishedOnly = false;
            qopt.PicturesOnly = false;
            qopt.WithFeedItemsOnly = false;
            List<TransitAccountFeed> feeds = SessionManager.SyndicationService.GetAccountFeeds(
                SessionManager.Ticket, qopt, null);

            foreach (TransitAccountFeed feed in feeds)
            {
                if (feed.Name.Trim().ToLower() == s.Name.Trim().ToLower())
                {
                    throw new Exception(string.Format("A syndicated feed with the same name '{0}' already exists. " +
                        "Click <a href='AccountFeedEdit.aspx?id={1}'>here</a> to modify it.", 
                        Renderer.Render(feed.Name), feed.Id));
                }

                if (feed.FeedUrl.Trim().ToLower() == s.FeedUrl.Trim().ToLower())
                {
                    throw new Exception(string.Format("A syndicated feed with the same feed address already exists. " +
                        "The feed name is '{0}' and the address is '{1}'. " +
                        "Click <a href='AccountFeedEdit.aspx?id={2}'>here</a> to modify it.", 
                        Renderer.Render(feed.Name), Renderer.Render(feed.FeedUrl), feed.Id));
                }
            }
        }

        SessionManager.CreateOrUpdate<TransitAccountFeed>(
            s, SessionManager.SyndicationService.CreateOrUpdateAccountFeed);
        Redirect("AccountFeedsManage.aspx");
    }
Beispiel #11
0
    protected void discoverAtom(string url, ArrayList feeds, Uri ns)
    {
        try
        {
            AtomFeed atomfeed = AtomFeed.Load(GetFeedStream(url), ns);

            TransitAccountFeed feed = new TransitAccountFeed();

            if (atomfeed.SubTitle != null)
            {
                feed.Description = atomfeed.SubTitle.Content;
            }
            else if (atomfeed.Tagline != null)
            {
                feed.Description = atomfeed.Tagline.Content;
            }

            feed.FeedUrl = url;

            if (atomfeed.Links != null)
            {
                foreach (AtomLink link in atomfeed.Links)
                {
                    if (link.Rel == Relationship.Alternate)
                    {
                        feed.LinkUrl = link.HRef.ToString();
                        break;
                    }
                }
            }

            if (atomfeed.Title != null)
            {
                feed.Name = atomfeed.Title.Content;
            }

            feeds.Add(feed);
        }
        catch
        {
        }
    }
Beispiel #12
0
    protected void discoverRss(string url, ArrayList feeds)
    {
        try
        {
            RssFeed rssfeed = RssFeed.Read(GetFeedHttpRequest(url));

            foreach (RssChannel rsschannel in rssfeed.Channels)
            {
                TransitAccountFeed feed = new TransitAccountFeed();
                feed.Description = rsschannel.Description;
                feed.FeedUrl = url;
                feed.LinkUrl = rsschannel.Link.ToString();
                feed.Name = rsschannel.Title;
                feeds.Add(feed);
                break;
            }
        }
        catch
        {
        }
    }
Beispiel #13
0
    protected void discoverRel(string url, ArrayList feeds)
    {
        HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
        request.UserAgent = SessionManager.GetCachedConfiguration("SnCore.Web.UserAgent", "SnCore/1.0");
        request.Accept = "*/*";
        WebResponse response = request.GetResponse();
        string content;
        using (StreamReader sr = new StreamReader(response.GetResponseStream()))
        {
            content = sr.ReadToEnd();
            sr.Close();
        }

        List<HtmlLinkControl> links = HtmlLinkExtractor.Extract(content, new Uri(url));
        foreach (HtmlLinkControl link in links)
        {
            switch (link.Type.ToLower())
            {
                case "application/rss+xml":
                case "application/atom+xml":
                    TransitAccountFeed feed = new TransitAccountFeed();
                    feed.FeedUrl = link.Href;
                    feed.LinkUrl = inputLinkUrl.Text;
                    feed.Description = string.Empty;
                    feed.Name = link.Title;
                    feeds.Add(feed);
                    break;
            }
        }
    }
Beispiel #14
0
        public int CreateOrUpdateAccountFeed(string ticket, TransitAccountFeed feed)
        {
            int id = WebServiceImpl<TransitAccountFeed, ManagedAccountFeed, AccountFeed>.CreateOrUpdate(
                ticket, feed);

            try
            {
                UpdateAccountFeedItems(ticket, id);
            }
            catch
            {

            }

            return id;
        }