Пример #1
0
    public void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            TransitAccountFeedItem tfi = GetAccountFeedItem();

            if (tfi == null)
            {
                Response.Redirect("AccountFeedItemsView.aspx");
                return;
            }

            licenseView.AccountId = tfi.AccountId;

            labelAccountName.Text = Renderer.Render(tfi.AccountName);
            imageAccount.Src      = string.Format("AccountPictureThumbnail.aspx?id={0}", tfi.AccountPictureId);

            this.Title = string.Format("{0}'s {1} in {2}",
                                       Renderer.Render(tfi.AccountName),
                                       Renderer.Render(tfi.Title),
                                       Renderer.Render(tfi.AccountFeedName));

            FeedTitle.Text            = Renderer.Render(tfi.AccountFeedName);
            FeedItemCreated.Text      = base.Adjust(tfi.Created).ToString();
            FeedItemTitle.NavigateUrl = tfi.Link;

            linkAccountView.HRef    = string.Format("AccountView.aspx?id={0}", tfi.AccountId);
            FeedTitle.NavigateUrl   = string.Format("AccountFeedView.aspx?id={0}", tfi.AccountFeedId);
            FeedXPosted.NavigateUrl = Render(tfi.Link);

            FeedItemTitle.Text = Renderer.Render(tfi.Title);

            Uri imgrewriteuri = new Uri(SessionManager.WebsiteUri, "AccountFeedItemPicture.aspx?src={url}");

            HtmlWriterOptions options = new HtmlWriterOptions();
            options.BaseHref         = Uri.IsWellFormedUriString(tfi.AccountFeedLinkUrl, UriKind.Absolute) ? new Uri(tfi.AccountFeedLinkUrl) : null;
            options.RewriteImgSrc    = imgrewriteuri;
            FeedItemDescription.Text = Renderer.CleanHtml(tfi.Description, options);

            FeedItemComments.DiscussionId = SessionManager.GetCount <TransitDiscussion, string, int>(
                typeof(AccountFeedItem).Name, RequestId, SessionManager.DiscussionService.GetOrCreateDiscussionId);

            GetDataFeature(sender, e);

            SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute();
            sitemapdata.Add(new SiteMapDataAttributeNode("Blogs", Request, "AccountFeedItemsView.aspx"));
            sitemapdata.Add(new SiteMapDataAttributeNode(tfi.AccountFeedName, Request, string.Format("AccountFeedView.aspx?id={0}", tfi.AccountFeedId)));
            sitemapdata.Add(new SiteMapDataAttributeNode(tfi.Title, Request.Url));
            StackSiteMap(sitemapdata);
        }
    }
Пример #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);
    }
Пример #3
0
    protected static TransitAccountFeedWithItems discoverRss(string url, string useragent)
    {
        try
        {
            RssFeed rssfeed = RssFeed.Read(GetFeedHttpRequest(url, useragent));

            foreach (RssChannel rsschannel in rssfeed.Channels)
            {
                TransitAccountFeedWithItems result = new TransitAccountFeedWithItems();
                result.Description = rsschannel.Description;
                result.FeedUrl = url;
                result.LinkUrl = rsschannel.Link.ToString();
                result.Name = rsschannel.Title;

                foreach(RssItem rssitem in rsschannel.Items)
                {
                    TransitAccountFeedItem item = new TransitAccountFeedItem();
                    item.AccountFeedLinkUrl = result.LinkUrl;
                    item.AccountFeedName = result.Name;
                    item.Created = rssitem.PubDate;
                    item.Description = rssitem.Description;
                    item.Link = rssitem.Link.ToString();
                    item.Title = rssitem.Title;
                    item.Updated = DateTime.UtcNow;
                    result.FeedItems.Add(item);
                }

                return result;
            }
        }
        catch
        {

        }

        return null;
    }
Пример #4
0
    protected static TransitAccountFeedWithItems discoverRss(string url, string useragent)
    {
        try
        {
            RssFeed rssfeed = RssFeed.Read(GetFeedHttpRequest(url, useragent));

            foreach (RssChannel rsschannel in rssfeed.Channels)
            {
                TransitAccountFeedWithItems result = new TransitAccountFeedWithItems();
                result.Description = rsschannel.Description;
                result.FeedUrl     = url;
                result.LinkUrl     = rsschannel.Link.ToString();
                result.Name        = rsschannel.Title;

                foreach (RssItem rssitem in rsschannel.Items)
                {
                    TransitAccountFeedItem item = new TransitAccountFeedItem();
                    item.AccountFeedLinkUrl = result.LinkUrl;
                    item.AccountFeedName    = result.Name;
                    item.Created            = rssitem.PubDate;
                    item.Description        = rssitem.Description;
                    item.Link    = rssitem.Link.ToString();
                    item.Title   = rssitem.Title;
                    item.Updated = DateTime.UtcNow;
                    result.FeedItems.Add(item);
                }

                return(result);
            }
        }
        catch
        {
        }

        return(null);
    }
Пример #5
0
    protected static TransitAccountFeedWithItems discoverAtom(string url, string useragent, Uri ns)
    {
        try
        {
            AtomFeed atomfeed = AtomFeed.Load(GetFeedStream(url, useragent), ns);

            TransitAccountFeedWithItems result = new TransitAccountFeedWithItems();

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

            result.FeedUrl = url;

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

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

            foreach (AtomEntry atomitem in atomfeed.Entries)
            {
                TransitAccountFeedItem item = new TransitAccountFeedItem();
                item.Description = string.Empty;
                foreach (AtomContent content in atomitem.Contents)
                {
                    if (!string.IsNullOrEmpty(item.Description))
                        item.Description += "\n";

                    switch (content.Type)
                    {
                        case MediaType.TextHtml:
                            item.Description += HttpUtility.HtmlDecode(content.Content);
                            break;
                        default:
                            item.Description += content.Content;
                            break;
                    }
                }

                if (string.IsNullOrEmpty(item.Description))
                {
                    item.Description = atomitem.Summary.Content;
                }

                item.Title = atomitem.Title.Content;

                if (atomitem.Links.Count > 0)
                {
                    foreach (AtomLink link in atomitem.Links)
                    {
                        if (link.Rel == Relationship.Alternate)
                        {
                            item.Link = link.HRef.ToString();
                        }
                    }
                }

                if (atomitem.Id != null && !string.IsNullOrEmpty(atomitem.Id.ToString())) item.Guid = atomitem.Id.ToString();
                if (atomitem.Created != null && atomitem.Created.DateTime.Ticks > 0) item.Created = atomitem.Created.DateTime.ToUniversalTime();
                result.FeedItems.Add(item);
            }

            return result;
        }
        catch
        {
            return null;
        }
    }
Пример #6
0
 public int CreateOrUpdateAccountFeedItem(string ticket, TransitAccountFeedItem item)
 {
     return(WebServiceImpl <TransitAccountFeedItem, ManagedAccountFeedItem, AccountFeedItem> .CreateOrUpdate(
                ticket, item));
 }
Пример #7
0
    protected static TransitAccountFeedWithItems discoverAtom(string url, string useragent, Uri ns)
    {
        try
        {
            AtomFeed atomfeed = AtomFeed.Load(GetFeedStream(url, useragent), ns);

            TransitAccountFeedWithItems result = new TransitAccountFeedWithItems();

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

            result.FeedUrl = url;

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

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

            foreach (AtomEntry atomitem in atomfeed.Entries)
            {
                TransitAccountFeedItem item = new TransitAccountFeedItem();
                item.Description = string.Empty;
                foreach (AtomContent content in atomitem.Contents)
                {
                    if (!string.IsNullOrEmpty(item.Description))
                    {
                        item.Description += "\n";
                    }

                    switch (content.Type)
                    {
                    case MediaType.TextHtml:
                        item.Description += HttpUtility.HtmlDecode(content.Content);
                        break;

                    default:
                        item.Description += content.Content;
                        break;
                    }
                }

                if (string.IsNullOrEmpty(item.Description))
                {
                    item.Description = atomitem.Summary.Content;
                }

                item.Title = atomitem.Title.Content;

                if (atomitem.Links.Count > 0)
                {
                    foreach (AtomLink link in atomitem.Links)
                    {
                        if (link.Rel == Relationship.Alternate)
                        {
                            item.Link = link.HRef.ToString();
                        }
                    }
                }

                if (atomitem.Id != null && !string.IsNullOrEmpty(atomitem.Id.ToString()))
                {
                    item.Guid = atomitem.Id.ToString();
                }
                if (atomitem.Created != null && atomitem.Created.DateTime.Ticks > 0)
                {
                    item.Created = atomitem.Created.DateTime.ToUniversalTime();
                }
                result.FeedItems.Add(item);
            }

            return(result);
        }
        catch
        {
            return(null);
        }
    }
Пример #8
0
 public int CreateOrUpdateAccountFeedItem(string ticket, TransitAccountFeedItem item)
 {
     return WebServiceImpl<TransitAccountFeedItem, ManagedAccountFeedItem, AccountFeedItem>.CreateOrUpdate(
         ticket, item);
 }