/// <summary>
    /// Gets localized message describing post state.
    /// </summary>
    /// <param name="postId">Post id.</param>
    private object GetPostState(int postId)
    {
        switch (Control.ObjectType)
        {
        // Facebook post
        case FacebookPostInfo.OBJECT_TYPE:
            FacebookPostInfo facebookPost = FacebookPostInfoProvider.GetFacebookPostInfo(postId);
            return(FacebookPostInfoProvider.GetPostPublishStateMessage(facebookPost, MembershipContext.AuthenticatedUser, SiteContext.CurrentSite, true));

        // Twitter post
        case TwitterPostInfo.OBJECT_TYPE:
            TwitterPostInfo twitterPost = TwitterPostInfoProvider.GetTwitterPostInfo(postId);
            return(TwitterPostInfoProvider.GetPostPublishStateMessage(twitterPost, MembershipContext.AuthenticatedUser, SiteContext.CurrentSite, true));
        }

        return(String.Empty);
    }
    /// <summary>
    /// OnAfterDataLoad event
    /// </summary>
    private void ControlOnAfterDataLoad(object sender, EventArgs eventArgs)
    {
        FacebookPostInfo facebookPost = Control.EditedObject as FacebookPostInfo;

        if ((facebookPost != null) && (facebookPost.FacebookPostID > 0))
        {
            string message = FacebookPostInfoProvider.GetPostPublishStateMessage(facebookPost, MembershipContext.AuthenticatedUser, SiteContext.CurrentSite);
            if (facebookPost.IsFaulty)
            {
                Control.ShowError(message);
            }
            else
            {
                Control.ShowInformation(message);
            }

            // Disable control if post has already been published or is faulty
            Control.Enabled = !(facebookPost.IsPublished || facebookPost.IsFaulty);
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Shows given Facebook post's publish state.
    /// </summary>
    /// <param name="post">Facebook post.</param>
    private void ShowPostPublishState(FacebookPostInfo post)
    {
        string message = FacebookPostInfoProvider.GetPostPublishStateMessage(post, MembershipContext.AuthenticatedUser, CurrentSite);

        if (String.IsNullOrEmpty(message))
        {
            return;
        }

        if (post.IsFaulty)
        {
            ShowPostStateError(message);
            ShowError(String.Format("<strong>{0}</strong>: {1}", GetString("sm.facebook.autopost"), message));
        }
        else if (post.IsPublished)
        {
            ShowPostStateSuccess(message);
        }
        else
        {
            ShowPostStateInformation(message, MessageTypeEnum.Information);
        }
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Shows given Facebook post's publish state.
    /// </summary>
    /// <param name="post">Facebook post.</param>
    private void ShowPostPublishState(FacebookPostInfo post)
    {
        string message = FacebookPostInfoProvider.GetPostPublishStateMessage(post, MembershipContext.AuthenticatedUser, CurrentSite);

        if (String.IsNullOrEmpty(message))
        {
            return;
        }

        if (post.IsFaulty)
        {
            var errorMessage = FormatErrorMessage(message);
            ShowError(errorMessage);
        }
        else if (post.IsPublished)
        {
            ShowConfirmation(message, true);
        }
        else
        {
            ShowInformation(message);
        }
    }
Ejemplo n.º 5
0
    /// <summary>
    /// Loads data from post info object into the dialog.
    /// </summary>
    /// <param name="post">Facebook post info object.</param>
    private void LoadPostIntoDialog(FacebookPostInfo post)
    {
        if ((post == null) || (post.FacebookPostSiteID != SiteContext.CurrentSiteID))
        {
            pnlPostDetail.Visible = false;
            ShowError(GetString("sm.facebook.posts.msg.postnotexist"));
            return;
        }

        lblPostStatus.Text         = FacebookPostInfoProvider.GetPostPublishStateMessage(post, MembershipContext.AuthenticatedUser, SiteContext.CurrentSite, true);
        lblPeopleReachedValue.Text = ValidationHelper.GetString(post.FacebookPostInsightPeopleReached, String.Empty);
        if (post.FacebookPostCampaignID.HasValue)
        {
            CampaignInfo campaign = CampaignInfo.Provider.Get(post.FacebookPostCampaignID.Value);
            if (campaign != null)
            {
                lblCampaign.Text = HTMLHelper.HTMLEncode(campaign.CampaignDisplayName);
            }
        }
        else
        {
            pnlCampaign.Visible = false;
        }

        lblPostText.Text          = GetPostTextHTML(post.FacebookPostText);
        lblPostLikesValue.Text    = ValidationHelper.GetString(post.FacebookPostInsightLikesFromPage, String.Empty);
        lblPostCommentsValue.Text = ValidationHelper.GetString(post.FacebookPostInsightCommentsFromPage, String.Empty);
        lblPostSharesValue.Text   = ValidationHelper.GetString(post.FacebookPostInsightSharesFromPage, String.Empty);

        lblTotalLikesValue.Text    = ValidationHelper.GetString(post.FacebookPostInsightLikesTotal, String.Empty);
        lblTotalCommentsValue.Text = ValidationHelper.GetString(post.FacebookPostInsightCommentsTotal, String.Empty);

        lblHidePostValue.Text     = ValidationHelper.GetString(post.FacebookPostInsightNegativeHidePost, String.Empty);
        lblHideAllPostsValue.Text = ValidationHelper.GetString(post.FacebookPostInsightNegativeHideAllPosts, String.Empty);
        lblReportSpamValue.Text   = ValidationHelper.GetString(post.FacebookPostInsightNegativeReportSpam, String.Empty);
        lblUnlikePageValue.Text   = ValidationHelper.GetString(post.FacebookPostInsightNegativeUnlikePage, String.Empty);
    }