Пример #1
0
    public void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int pagenumber = int.Parse(Request["PageNumber"]);
            int pagecount  = int.Parse(Request["PageCount"]);
            int pagesize   = int.Parse(Request["PageSize"]);

            ServiceQueryOptions serviceoptions = new ServiceQueryOptions();
            serviceoptions.PageSize   = pagesize;
            serviceoptions.PageNumber = pagenumber;

            TransitAccountFeedQueryOptions options = new TransitAccountFeedQueryOptions();
            gridManage.DataSource = SessionManager.SyndicationService.GetAccountFeeds(
                SessionManager.Ticket, options, serviceoptions);
            gridManage.DataBind();

            if (pagenumber > 0)
            {
                linkPrev.HRef = string.Format("AccountFeedsViewList.aspx?PageNumber={0}&PageSize={1}&PageCount={2}",
                                              pagenumber - 1, pagesize, pagecount);
            }

            if (pagenumber < pagecount - 1)
            {
                linkNext.HRef = string.Format("AccountFeedsViewList.aspx?PageNumber={0}&PageSize={1}&PageCount={2}",
                                              pagenumber + 1, pagesize, pagecount);
            }
        }
    }
Пример #2
0
 TransitAccountFeedQueryOptions GetOptions()
 {
     TransitAccountFeedQueryOptions qopt = new TransitAccountFeedQueryOptions();
     qopt.AccountId = AccountId;
     qopt.Hidden = false;
     return qopt;
 }
Пример #3
0
    private void GetData(object sender, EventArgs e)
    {
        TransitAccountFeedQueryOptions options = GetQueryOptions();

        gridManage.CurrentPageIndex = 0;
        gridManage.VirtualItemCount = SessionManager.GetCount <TransitAccountFeed, TransitAccountFeedQueryOptions>(
            options, SessionManager.SyndicationService.GetAccountFeedsCount);

        TransitAccountFeedItemQueryOptions feeditem_options = new TransitAccountFeedItemQueryOptions();

        feeditem_options.City            = options.City;
        feeditem_options.Country         = options.Country;
        feeditem_options.PublishedOnly   = options.PublishedOnly;
        feeditem_options.State           = options.State;
        feeditem_options.AccountFeedName = options.Name;
        feeditem_options.AccountFeedName = inputName.Text;

        int feedItemsCount = SessionManager.GetCount <TransitAccountFeedItem, TransitAccountFeedItemQueryOptions>(
            feeditem_options, SessionManager.SyndicationService.GetAllAccountFeedItemsCount);

        string feeds_queryargs = string.Format("city={0}&country={1}&state={2}",
                                               Renderer.UrlEncode(options.City),
                                               Renderer.UrlEncode(options.Country),
                                               Renderer.UrlEncode(options.State));

        labelCount.Text = string.Format("{0} blog{1} with <a href='AccountFeedItemsView.aspx?{4}'>{2} {3}</a>",
                                        gridManage.VirtualItemCount, gridManage.VirtualItemCount == 1 ? string.Empty : "s",
                                        feedItemsCount, feedItemsCount == 1 ? "post" : "posts",
                                        feeds_queryargs);

        gridManage_OnGetDataSource(this, null);
        gridManage.DataBind();
    }
Пример #4
0
    public void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int pagenumber = int.Parse(Request["PageNumber"]);
            int pagecount = int.Parse(Request["PageCount"]);
            int pagesize = int.Parse(Request["PageSize"]);

            ServiceQueryOptions serviceoptions = new ServiceQueryOptions();
            serviceoptions.PageSize = pagesize;
            serviceoptions.PageNumber = pagenumber;

            TransitAccountFeedQueryOptions options = new TransitAccountFeedQueryOptions();
            gridManage.DataSource = SessionManager.SyndicationService.GetAccountFeeds(
                SessionManager.Ticket, options, serviceoptions);
            gridManage.DataBind();

            if (pagenumber > 0)
                linkPrev.HRef = string.Format("AccountFeedsViewList.aspx?PageNumber={0}&PageSize={1}&PageCount={2}",
                    pagenumber - 1, pagesize, pagecount);

            if (pagenumber < pagecount - 1)
                linkNext.HRef = string.Format("AccountFeedsViewList.aspx?PageNumber={0}&PageSize={1}&PageCount={2}",
                    pagenumber + 1, pagesize, pagecount);
        }
    }
Пример #5
0
    TransitAccountFeedQueryOptions GetOptions()
    {
        TransitAccountFeedQueryOptions qopt = new TransitAccountFeedQueryOptions();

        qopt.AccountId = AccountId;
        qopt.Hidden    = false;
        return(qopt);
    }
Пример #6
0
 TransitAccountFeedQueryOptions GetOptions()
 {
     TransitAccountFeedQueryOptions qopt = new TransitAccountFeedQueryOptions();
     qopt.AccountId = SessionManager.AccountId;
     qopt.Hidden = true;
     qopt.PicturesOnly = false;
     qopt.PublishedOnly = false;
     qopt.Hidden = true;
     qopt.WithFeedItemsOnly = false;
     return qopt;
 }
Пример #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            linkSuggestFeature.HRef =
                string.Format("BugEdit.aspx?pid={0}&type=Suggestion",
                              SessionManager.GetCachedConfiguration(
                                  "SnCore.NewFeature.ProjectId", "0"));

            linkReportBug.HRef =
                string.Format("BugEdit.aspx?pid={0}&type=Bug",
                              SessionManager.GetCachedConfiguration(
                                  "SnCore.Bug.ProjectId", "0"));

            linkSiteDiscussion.HRef =
                string.Format("DiscussionView.aspx?id={0}",
                              SessionManager.GetCachedConfiguration(
                                  "SnCore.Site.DiscussionId", "0"));

            linkBlog.HRef =
                string.Format("AccountBlogView.aspx?id={0}",
                              SessionManager.GetCachedConfiguration(
                                  "SnCore.Blog.Id", "0"));

            AccountActivityQueryOptions aaqo = new AccountActivityQueryOptions();
            listAccounts.DataSource = GetPagedList(SessionManager.SocialService.GetAccountActivityCount(SessionManager.Ticket, aaqo));
            listAccounts.DataBind();

            TransitAccountFeedQueryOptions fqo = new TransitAccountFeedQueryOptions();
            listFeeds.DataSource = GetPagedList(SessionManager.SyndicationService.GetAccountFeedsCount(SessionManager.Ticket, fqo));
            listFeeds.DataBind();

            TransitPlaceQueryOptions pqo = new TransitPlaceQueryOptions();
            listPlaces.DataSource = GetPagedList(SessionManager.PlaceService.GetPlacesCount(SessionManager.Ticket, pqo));
            listPlaces.DataBind();

            TransitAccountEventQueryOptions aeqo = new TransitAccountEventQueryOptions();
            listAccountEvents.DataSource = GetPagedList(SessionManager.EventService.GetAccountEventsCount(SessionManager.Ticket, aeqo));
            listAccountEvents.DataBind();

            listAccountGroups.DataSource = GetPagedList(SessionManager.GroupService.GetAccountGroupsCount(SessionManager.Ticket));
            listAccountGroups.DataBind();

            listStories.DataSource = GetPagedList(SessionManager.StoryService.GetAllAccountStoriesCount(SessionManager.Ticket));
            listStories.DataBind();

            listDiscussions.DataSource = SessionManager.DiscussionService.GetDiscussions(SessionManager.Ticket, null);
            listDiscussions.DataBind();

            listSurveys.DataSource = SessionManager.ObjectService.GetSurveys(SessionManager.Ticket, null);
            listSurveys.DataBind();
        }
    }
Пример #8
0
    TransitAccountFeedQueryOptions GetOptions()
    {
        TransitAccountFeedQueryOptions qopt = new TransitAccountFeedQueryOptions();

        qopt.AccountId         = SessionManager.AccountId;
        qopt.Hidden            = true;
        qopt.PicturesOnly      = false;
        qopt.PublishedOnly     = false;
        qopt.Hidden            = true;
        qopt.WithFeedItemsOnly = false;
        return(qopt);
    }
Пример #9
0
    private TransitAccountFeedQueryOptions GetQueryOptions()
    {
        TransitAccountFeedQueryOptions options = new TransitAccountFeedQueryOptions();

        options.PicturesOnly      = checkboxPicturesOnly.Checked;
        options.PublishedOnly     = true;
        options.WithFeedItemsOnly = true;
        options.City    = inputCity.Text;
        options.Country = inputCountry.SelectedValue;
        options.State   = inputState.SelectedValue;
        options.Name    = inputName.Text;
        return(options);
    }
Пример #10
0
    void gridManage_OnGetDataSource(object sender, EventArgs e)
    {
        TransitAccountFeedQueryOptions options = GetQueryOptions();

        string queryargs = string.Format("order={0}&asc={1}&city={2}&country={3}&state={4}&name={5}&pictures={6}&page={7}",
                                         Renderer.UrlEncode(options.SortOrder),
                                         Renderer.UrlEncode(options.SortAscending),
                                         Renderer.UrlEncode(options.City),
                                         Renderer.UrlEncode(options.Country),
                                         Renderer.UrlEncode(options.State),
                                         Renderer.UrlEncode(options.Name),
                                         Renderer.UrlEncode(options.PicturesOnly),
                                         gridManage.CurrentPageIndex);

        Title = titleBlogs.Text = (string.IsNullOrEmpty(options.City)
            ? titleBlogs.DefaultText
            : string.Format("{0}: {1}", titleBlogs.DefaultText, options.City));

        if (IsPostBack)
        {
            Title = string.Format("{0} - {1}", SessionManager.GetCachedConfiguration(
                                      "SnCore.Title", "SnCore"), titleBlogs.Text);
        }

        linkRelRss.NavigateUrl    = string.Format("AccountFeedsRss.aspx?{0}", queryargs);
        linkPermalink.NavigateUrl = string.Format("AccountFeedsView.aspx?{0}", queryargs);

        ServiceQueryOptions serviceoptions = new ServiceQueryOptions();

        serviceoptions.PageSize   = gridManage.PageSize;
        serviceoptions.PageNumber = gridManage.CurrentPageIndex;
        gridManage.DataSource     = SessionManager.GetCollection <TransitAccountFeed, TransitAccountFeedQueryOptions>(
            options, serviceoptions, SessionManager.SyndicationService.GetAccountFeeds);

        if (((SnCoreMasterPage)Master).ScriptManager.IsInAsyncPostBack &&
            !((SnCoreMasterPage)Master).ScriptManager.IsNavigating)
        {
            NameValueCollection history = new NameValueCollection();
            history.Add("city", options.City);
            history.Add("country", options.Country);
            history.Add("state", options.State);
            history.Add("name", options.Name);
            history.Add("sortorder", options.SortOrder);
            history.Add("sortascending", options.SortAscending.ToString());
            history.Add("page", gridManage.CurrentPageIndex.ToString());
            ((SnCoreMasterPage)Master).ScriptManager.AddHistoryPoint(history, Page.Title);
        }

        panelLinks.Update();
    }
Пример #11
0
    private void GetData(object sender, EventArgs e)
    {
        TransitAccountFeedItemQueryOptions options = GetQueryOptions();

        gridManage.CurrentPageIndex = 0;

        gridManage.VirtualItemCount = SessionManager.GetCount <TransitAccountFeedItem, TransitAccountFeedItemQueryOptions>(
            options, SessionManager.SyndicationService.GetAllAccountFeedItemsCount);

        Title = titleBlogPosts.Text = (string.IsNullOrEmpty(options.City)
            ? titleBlogPosts.DefaultText
            : string.Format("{0}: {1}", titleBlogPosts.DefaultText, options.City));

        if (IsPostBack)
        {
            Title = string.Format("{0} - {1}", SessionManager.GetCachedConfiguration(
                                      "SnCore.Title", "SnCore"), titleBlogPosts.Text);
        }

        TransitAccountFeedQueryOptions feed_options = new TransitAccountFeedQueryOptions();

        feed_options.PublishedOnly     = true;
        feed_options.PicturesOnly      = false;
        feed_options.City              = options.City;
        feed_options.State             = options.State;
        feed_options.Country           = options.Country;
        feed_options.WithFeedItemsOnly = true;
        int feedsCount = SessionManager.GetCount <TransitAccountFeed, TransitAccountFeedQueryOptions>(
            feed_options, SessionManager.SyndicationService.GetAccountFeedsCount);

        string feeds_queryargs = string.Format("city={0}&country={1}&state={2}",
                                               Renderer.UrlEncode(options.City),
                                               Renderer.UrlEncode(options.Country),
                                               Renderer.UrlEncode(options.State));

        labelCount.Text = string.Format("{0} post{1} from <a href='AccountFeedsView.aspx?{4}'>{2} blog{3}</a>",
                                        gridManage.VirtualItemCount, gridManage.VirtualItemCount == 1 ? string.Empty : "s",
                                        feedsCount, feedsCount == 1 ? string.Empty : "s",
                                        feeds_queryargs);

        gridManage_OnGetDataSource(this, null);
        gridManage.DataBind();
    }
    private void GetData()
    {
        gridManage.CurrentPageIndex = 0;
        gridManage.VirtualItemCount = SessionManager.GetCount <TransitAccountFeedItemImg, TransitAccountFeedItemImgQueryOptions>(
            QueryOptions, SessionManager.SyndicationService.GetAccountFeedItemImgsCount);
        gridManage_OnGetDataSource(this, null);
        gridManage.DataBind();

        TransitAccountFeedQueryOptions options = new TransitAccountFeedQueryOptions();

        options.PublishedOnly = false;
        options.PicturesOnly  = false;
        int feedsCount = SessionManager.GetCount <TransitAccountFeed, TransitAccountFeedQueryOptions>(
            options, SessionManager.SyndicationService.GetAccountFeedsCount);

        labelCount.Text = string.Format("{0} picture{1} from <a href='AccountFeedsView.aspx'>{2} blog{3}</a>",
                                        gridManage.VirtualItemCount, gridManage.VirtualItemCount == 1 ? string.Empty : "s",
                                        feedsCount, feedsCount == 1 ? string.Empty : "s");
    }
Пример #13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            TransitAccountFeedQueryOptions options = new TransitAccountFeedQueryOptions();
            options.SortAscending = Ascending;
            options.SortOrder     = SortOrder;
            options.City          = City;
            options.Country       = Country;
            options.State         = State;
            options.Name          = Name;

            ServiceQueryOptions queryoptions = new ServiceQueryOptions();
            queryoptions.PageNumber = 0;
            queryoptions.PageSize   = 10;

            rssRepeater.DataSource = SessionManager.SyndicationService.GetAccountFeeds(
                SessionManager.Ticket, options, queryoptions);
            rssRepeater.DataBind();
        }
    }
Пример #14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            TransitAccountFeedQueryOptions options = new TransitAccountFeedQueryOptions();
            options.SortAscending = Ascending;
            options.SortOrder = SortOrder;
            options.City = City;
            options.Country = Country;
            options.State = State;
            options.Name = Name;

            ServiceQueryOptions queryoptions = new ServiceQueryOptions();
            queryoptions.PageNumber = 0;
            queryoptions.PageSize = 10;

            rssRepeater.DataSource = SessionManager.SyndicationService.GetAccountFeeds(
                SessionManager.Ticket, options, queryoptions);
            rssRepeater.DataBind();
        }
    }
Пример #15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            linkSuggestFeature.HRef =
                string.Format("BugEdit.aspx?pid={0}&type=Suggestion",
                       SessionManager.GetCachedConfiguration(
                        "SnCore.NewFeature.ProjectId", "0"));

            linkReportBug.HRef =
                string.Format("BugEdit.aspx?pid={0}&type=Bug",
                       SessionManager.GetCachedConfiguration(
                        "SnCore.Bug.ProjectId", "0"));

            linkSiteDiscussion.HRef =
                string.Format("DiscussionView.aspx?id={0}",
                       SessionManager.GetCachedConfiguration(
                        "SnCore.Site.DiscussionId", "0"));

            linkBlog.HRef = 
                string.Format("AccountBlogView.aspx?id={0}",
                       SessionManager.GetCachedConfiguration(
                        "SnCore.Blog.Id", "0"));

            AccountActivityQueryOptions aaqo = new AccountActivityQueryOptions();
            listAccounts.DataSource = GetPagedList(SessionManager.SocialService.GetAccountActivityCount(SessionManager.Ticket, aaqo));
            listAccounts.DataBind();

            TransitAccountFeedQueryOptions fqo = new TransitAccountFeedQueryOptions();
            listFeeds.DataSource = GetPagedList(SessionManager.SyndicationService.GetAccountFeedsCount(SessionManager.Ticket, fqo));
            listFeeds.DataBind();

            TransitPlaceQueryOptions pqo = new TransitPlaceQueryOptions();
            listPlaces.DataSource = GetPagedList(SessionManager.PlaceService.GetPlacesCount(SessionManager.Ticket, pqo));
            listPlaces.DataBind();

            TransitAccountEventQueryOptions aeqo = new TransitAccountEventQueryOptions();
            listAccountEvents.DataSource = GetPagedList(SessionManager.EventService.GetAccountEventsCount(SessionManager.Ticket, aeqo));
            listAccountEvents.DataBind();

            listAccountGroups.DataSource = GetPagedList(SessionManager.GroupService.GetAccountGroupsCount(SessionManager.Ticket));
            listAccountGroups.DataBind();

            listStories.DataSource = GetPagedList(SessionManager.StoryService.GetAllAccountStoriesCount(SessionManager.Ticket));
            listStories.DataBind();

            listDiscussions.DataSource = SessionManager.DiscussionService.GetDiscussions(SessionManager.Ticket, null);
            listDiscussions.DataBind();

            listSurveys.DataSource = SessionManager.ObjectService.GetSurveys(SessionManager.Ticket, null);
            listSurveys.DataBind();
        }
    }
Пример #16
0
 public int GetAccountFeedsCount(string ticket, TransitAccountFeedQueryOptions qopt)
 {
     return WebServiceImpl<TransitAccountFeed, ManagedAccountFeed, AccountFeed>.GetCount(
         ticket, qopt.CreateCountQuery());
 }
Пример #17
0
 public List<TransitAccountFeed> GetAccountFeeds(string ticket, TransitAccountFeedQueryOptions qopt, ServiceQueryOptions options)
 {
     return WebServiceImpl<TransitAccountFeed, ManagedAccountFeed, AccountFeed>.GetList(
         ticket, options, qopt.CreateQuery());
 }
Пример #18
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");
    }
Пример #19
0
    private void GetData(object sender, EventArgs e)
    {
        TransitAccountFeedItemQueryOptions options = GetQueryOptions();

        gridManage.CurrentPageIndex = 0;

        gridManage.VirtualItemCount = SessionManager.GetCount<TransitAccountFeedItem, TransitAccountFeedItemQueryOptions>(
                options, SessionManager.SyndicationService.GetAllAccountFeedItemsCount);

        Title = titleBlogPosts.Text = (string.IsNullOrEmpty(options.City)
            ? titleBlogPosts.DefaultText
            : string.Format("{0}: {1}", titleBlogPosts.DefaultText, options.City));

        if (IsPostBack)
        {
            Title = string.Format("{0} - {1}", SessionManager.GetCachedConfiguration(
                "SnCore.Title", "SnCore"), titleBlogPosts.Text);
        }

        TransitAccountFeedQueryOptions feed_options = new TransitAccountFeedQueryOptions();
        feed_options.PublishedOnly = true;
        feed_options.PicturesOnly = false;
        feed_options.City = options.City;
        feed_options.State = options.State;
        feed_options.Country = options.Country;
        feed_options.WithFeedItemsOnly = true;
        int feedsCount = SessionManager.GetCount<TransitAccountFeed, TransitAccountFeedQueryOptions>(
            feed_options, SessionManager.SyndicationService.GetAccountFeedsCount);

        string feeds_queryargs = string.Format("city={0}&country={1}&state={2}",
            Renderer.UrlEncode(options.City),
            Renderer.UrlEncode(options.Country),
            Renderer.UrlEncode(options.State));

        labelCount.Text = string.Format("{0} post{1} from <a href='AccountFeedsView.aspx?{4}'>{2} blog{3}</a>",
            gridManage.VirtualItemCount, gridManage.VirtualItemCount == 1 ? string.Empty : "s",
            feedsCount, feedsCount == 1 ? string.Empty : "s",
            feeds_queryargs);

        gridManage_OnGetDataSource(this, null);
        gridManage.DataBind();
    }
Пример #20
0
 public int GetAccountFeedsCount(string ticket, TransitAccountFeedQueryOptions qopt)
 {
     return(WebServiceImpl <TransitAccountFeed, ManagedAccountFeed, AccountFeed> .GetCount(
                ticket, qopt.CreateCountQuery()));
 }
Пример #21
0
 public List <TransitAccountFeed> GetAccountFeeds(string ticket, TransitAccountFeedQueryOptions qopt, ServiceQueryOptions options)
 {
     return(WebServiceImpl <TransitAccountFeed, ManagedAccountFeed, AccountFeed> .GetList(
                ticket, options, qopt.CreateQuery()));
 }
Пример #22
0
 private TransitAccountFeedQueryOptions GetQueryOptions()
 {
     TransitAccountFeedQueryOptions options = new TransitAccountFeedQueryOptions();
     options.PicturesOnly = checkboxPicturesOnly.Checked;
     options.PublishedOnly = true;
     options.WithFeedItemsOnly = true;
     options.City = inputCity.Text;
     options.Country = inputCountry.SelectedValue;
     options.State = inputState.SelectedValue;
     options.Name = inputName.Text;
     return options;
 }
Пример #23
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");
    }
    private void GetData()
    {
        gridManage.CurrentPageIndex = 0;
        gridManage.VirtualItemCount = SessionManager.GetCount<TransitAccountFeedItemMedia, TransitAccountFeedItemMediaQueryOptions>(
            QueryOptions, SessionManager.SyndicationService.GetAccountFeedItemMediasCount);
        gridManage_OnGetDataSource(this, null);
        gridManage.DataBind();

        TransitAccountFeedQueryOptions options = new TransitAccountFeedQueryOptions();
        options.PublishedOnly = false;
        options.PicturesOnly = false;
        int feedsCount = SessionManager.GetCount<TransitAccountFeed, TransitAccountFeedQueryOptions>(
            options, SessionManager.SyndicationService.GetAccountFeedsCount);

        labelCount.Text = string.Format("{0} media item{1} from <a href='AccountFeedsView.aspx'>{2} blog{3}</a>",
            gridManage.VirtualItemCount, gridManage.VirtualItemCount == 1 ? string.Empty : "s",
            feedsCount, feedsCount == 1 ? string.Empty : "s");
    }