/// <summary>
 /// OnAction for Twitter post object type.
 /// </summary>
 /// <param name="actionName"></param>
 /// <param name="actionArgument">Integer ID as a string.</param>
 private void OnAction_Twitter(string actionName, object actionArgument)
 {
     switch (actionName)
     {
     case "delete":
         try
         {
             TwitterPostInfoProvider.DeleteTwitterPostInfo(ValidationHelper.GetInteger(actionArgument, 0));
         }
         catch (Exception ex)
         {
             EventLogProvider.LogWarning("Social marketing - Twitter post", "DELETEPOST", ex, SiteContext.CurrentSiteID, "Twitter post could not be deleted.");
             Control.ShowError(Control.GetString("sm.twitter.posts.msg.deleteerror"));
         }
         break;
     }
 }
    /// <summary>
    /// Form OnBeforeDataRetrieval.
    /// </summary>
    private void Form_OnBeforeDataRetrieval(object sender, EventArgs eventArgs)
    {
        if (!HasUserModifyPermission)
        {
            return;
        }

        if (chkPostToTwitter.Checked)
        {
            if ((TweetInfo == null) || TweetInfo.IsEditable)
            {
                // Post does not exist or can be modified
                TweetInfo = SetControlDataIntoPost(TweetInfo);
                TwitterPostInfoProvider.SetTwitterPostInfo(TweetInfo);
            }
            else if (!FormDataEqualsPostInfo(TweetInfo))
            {
                mPublishedWhileEditing = true;
            }
        }
        else
        {
            // Checkbox post to Twitter is not checked
            if (TweetInfo != null)
            {
                if (TweetInfo.IsEditable)
                {
                    // Existing post has to be deleted
                    TwitterPostInfoProvider.DeleteTwitterPostInfo(TweetInfo);
                    TweetInfo = null;
                    InitializeControls();
                }
                else
                {
                    mPublishedWhileEditing = true;
                }
            }
            else if (mBackCompatibilityValue.HasValue)
            {
                // Form has to be cleaned up from old value
                mBackCompatibilityValue = null;
                InitializeControls();
            }
        }
    }
Пример #3
0
    /// <summary>
    /// Deletes all tweets tied to channel 'MyNewTwitterChannel'.
    /// </summary>
    private bool DeleteTwitterPosts()
    {
        // Get the channel the tweet is tied to
        TwitterAccountInfo channel = TwitterAccountInfoProvider.GetTwitterAccountInfo("MyNewTwitterChannel", SiteContext.CurrentSiteID);

        if (channel == null)
        {
            throw new Exception("[ApiExamples.DeleteTwitterPosts]: Account 'MyNewTwitterChannel' has not been found.");
        }

        // Get all posts tied to the account
        ObjectQuery <TwitterPostInfo> tweets = TwitterPostInfoProvider.GetTwitterPostInfoByAccountId(channel.TwitterAccountID);

        // Delete these posts from CMS and from Twitter
        foreach (TwitterPostInfo tweet in tweets)
        {
            TwitterPostInfoProvider.DeleteTwitterPostInfo(tweet);
        }

        return(tweets.Count != 0);
    }