protected override void Execute(CodeActivityContext context)
        {
            service = new TwitterService(ConsumerKey.Get(context),
                                         ConsumerSecret.Get(context),
                                         AccessToken.Get(context),
                                         AccessSecret.Get(context));
            service.TraceEnabled = true;

            using (var stream = new FileStream(MediaPath.Get(context), FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                TwitterChunkedMedia uploadedMedia = InitialiseMediaUpload(service, stream);

                UploadMediaChunks(service, stream, uploadedMedia);

                FinializeMediaAndWaitForProcessing(service, uploadedMedia);

                // Now send a tweet with the media attached
                var twitterStatus = service.SendTweet(new SendTweetOptions()
                {
                    Status   = Message.Get(context),
                    MediaIds = new string[] { uploadedMedia.MediaId.ToString() }
                });

                //AssertResultWas(service, HttpStatusCode.OK);
                //Assert.IsNotNull(twitterStatus);

                // Capture Posted Tweet Id
                TweetId.Set(context, twitterStatus.Id);
            }
        }
Ejemplo n.º 2
0
        //Settings

        public static void CreateSettings()
        {
            //Ok, Make new
            var     parser = new FileIniDataParser();
            IniData data   = new IniData();

            data["Satisfactory"]["DriveLetter"]    = DriveLetter;
            data["Satisfactory"]["FolderPath"]     = FolderPath;
            data["Satisfactory"]["ProgramName"]    = ProgramName;
            data["Satisfactory"]["SFSM_Installed"] = SFSM_Installed.ToString();
            data["Satisfactory"]["SFSM_Port"]      = SFSM_Port.ToString();
            data["Satisfactory"]["GameType"]       = GameType.ToString();

            data["Session"]["StartLoc"]      = StartLoc.ToString();
            data["Session"]["WorldName"]     = WorldName;
            data["Session"]["SaveName"]      = SaveName;
            data["Session"]["AdminPassword"] = AdminPassword;

            data["Network"]["MultiHome"] = MultiHome.ToString();
            data["Network"]["LanOnly"]   = LanOnly.ToString();

            data["Timers"]["EnableAutoRestart"]          = EnableAutoRestart.ToString();
            data["Timers"]["AutoRestartMinutesInterval"] = AutoRestartMinutesInterval.ToString();


            data["Web"]["WebListenIP"]  = WebListenIP.ToString();
            data["Web"]["WebPort"]      = WebPort.ToString();
            data["Web"]["AccessSecret"] = AccessSecret.ToString();

            parser.WriteFile("Configuration.ini", data);
        }
        protected override void Execute(CodeActivityContext context)
        {
            service = new TwitterService(ConsumerKey.Get(context),
                                         ConsumerSecret.Get(context),
                                         AccessToken.Get(context),
                                         AccessSecret.Get(context))
            {
                TraceEnabled = true
            };

            var tweetsSearch = service.Search(new SearchOptions
            {
                Q          = SearchKey.Get(context),
                Resulttype = TwitterSearchResultType.Recent,
                Count      = Count.Get(context)
            });

            List <TwitterStatus> resultList = new List <TwitterStatus>(tweetsSearch.Statuses);


            dtTweet.Columns.Add("Tweet Id");
            dtTweet.Columns.Add("User Name");
            dtTweet.Columns.Add("User Screen Name");
            dtTweet.Columns.Add("Text");
            dtTweet.Columns.Add("Created Date");
            dtTweet.Columns.Add("Retweet Count");
            dtTweet.Columns.Add("Favorite Count");
            dtTweet.Columns.Add("Profile Image URL");

            foreach (var tweet in tweetsSearch.Statuses)
            {
                //tweet.Id; //Id of the tweet
                //tweet.User.ScreenName;  //Screen Name of the user
                //tweet.User.Name;   //Name of the User
                //tweet.Text; // Trimmed Text of the tweet
                //tweet.FullText; // Full Text of the tweet
                //tweet.RetweetCount; //No of retweet on twitter
                //tweet.User.FavouritesCount; //No of Fav mark on twitter
                //tweet.User.ProfileImageUrl; //Profile Image of Tweet
                //tweet.CreatedDate; //For Tweet posted time
                //"https://twitter.com/intent/retweet?tweet_id=" + tweet.Id;  //For Retweet
                //"https://twitter.com/intent/tweet?in_reply_to=" + tweet.Id; //For Reply
                //"https://twitter.com/intent/favorite?tweet_id=" + tweet.Id; //For Favorite

                //Above are the things we can also get using TweetSharp.
                dtTweet.Rows.Add(
                    FetchUserDetails.Get(context) ? tweet.Id : 0L,
                    FetchUserDetails.Get(context) ? tweet.User.Name : "",
                    FetchUserDetails.Get(context) ? tweet.User.ScreenName : "",
                    FetchFullText.Get(context) ? tweet.FullText : tweet.Text,
                    tweet.CreatedDate,
                    tweet.RetweetCount,
                    tweet.FavoriteCount,
                    FetchUserDetails.Get(context) ? tweet.User.ProfileImageUrl : ""
                    );
            }
            OutputResult.Set(context, dtTweet);
        }
        protected override void Execute(CodeActivityContext context)
        {
            service = new TwitterService(ConsumerKey.Get(context),
                                         ConsumerSecret.Get(context),
                                         AccessToken.Get(context),
                                         AccessSecret.Get(context));

            service.Retweet(new RetweetOptions {
                Id = TweetID.Get(context)
            });
        }
Ejemplo n.º 5
0
        protected override void Execute(CodeActivityContext context)
        {
            try
            {
                service = new TwitterService(ConsumerKey.Get(context),
                                             ConsumerSecret.Get(context),
                                             AccessToken.Get(context),
                                             AccessSecret.Get(context));

                TwitterStatus status;
                if (ImagePath.Get(context) == null)
                {
                    // Send Tweet without Image
                    status = service.SendTweet(new SendTweetOptions {
                        Status = Message.Get(context)
                    });
                }
                else
                {
                    // Send Tweet with Image
                    MediaFile mf     = new MediaFile();
                    Stream    stream = new FileStream(ImagePath.Get(context), FileMode.Open);
                    mf.Content = stream;

                    var media = service.UploadMedia(new UploadMediaOptions {
                        Media = mf
                    });
                    var id = media.Media_Id;

                    List <string> ls = new List <string>();
                    ls.Add(id.ToString());

                    status = service.SendTweet(new SendTweetOptions
                    {
                        Status   = Message.Get(context),
                        MediaIds = ls,
                    });
                }

                // Capture Posted Tweet Id
                TweetId.Set(context, status.Id);
            }
            catch (Exception e)
            {
                TweetId.Set(context, e.Message);
            }
        }