示例#1
0
        public static string ComposeTwitterMessage(string message, string profileid, long userid, string picurl, bool isScheduled, DatabaseRepository dbr, Domain.Socioboard.Models.TwitterAccount TwitterAccount, Domain.Socioboard.Models.ScheduledMessage schmessage)
        {
            bool   rt  = false;
            string ret = "";
            string str = "Message posted";

            if (message.Length > 140)
            {
                message = message.Substring(0, 135);
            }
            Domain.Socioboard.Models.TwitterAccount objTwitterAccount = TwitterAccount;
            // oAuthTwitter OAuthTwt = new oAuthTwitter("MbOQl85ZcvRGvp3kkOOJBlbFS", "GF0UIXnTAX28hFhN1ISNf3tURHARZdKWlZrsY4PlHm9A4llYjZ", "http://serv1.socioboard.com/TwitterManager/Twitter");
            oAuthTwitter OAuthTwt = new oAuthTwitter("h4FT0oJ46KBBMwbcifqZMw", "yfowGI2g21E2mQHjtHjUvGqkfbI7x26WDCvjiSZOjas", "https://www.socioboard.com/TwitterManager/Twitter");

            OAuthTwt.AccessToken       = objTwitterAccount.oAuthToken;
            OAuthTwt.AccessTokenSecret = objTwitterAccount.oAuthSecret;
            OAuthTwt.TwitterScreenName = objTwitterAccount.twitterScreenName;
            OAuthTwt.TwitterUserId     = objTwitterAccount.twitterUserId;

            Tweet twt = new Tweet();

            if (!string.IsNullOrEmpty(picurl))
            {
                try
                {
                    PhotoUpload ph  = new PhotoUpload();
                    string      res = string.Empty;
                    rt = ph.NewTweet(picurl, message, OAuthTwt, ref res);
                }
                catch (Exception ex)
                {
                    apiHitsCount = MaxapiHitsCount;
                }
            }
            else
            {
                try
                {
                    JArray post = twt.Post_Statuses_Update(OAuthTwt, message);
                    ret = post[0]["id_str"].ToString();
                }
                catch (Exception ex)
                {
                    apiHitsCount = MaxapiHitsCount;
                }
            }

            if (!string.IsNullOrEmpty(ret) || rt == true)
            {
                schmessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated;
                schmessage.url    = ret;
                dbr.Update <ScheduledMessage>(schmessage);
            }
            else
            {
                str = "Message not posted";
            }

            return(str);
        }
        public static string ComposeTwitterMessage(string message, string profileid, long userid, string picurl, bool isScheduled, DatabaseRepository dbr, Domain.Socioboard.Models.TwitterAccount TwitterAccount, Domain.Socioboard.Models.ScheduledMessage schmessage)
        {
            bool   rt  = false;
            string ret = "";
            string str = "Message posted";

            if (message.Length > 140)
            {
                message = message.Substring(0, 135);
            }
            Domain.Socioboard.Models.TwitterAccount objTwitterAccount = TwitterAccount;
            oAuthTwitter OAuthTwt = new oAuthTwitter(Helper.AppSettings.twitterConsumerKey, Helper.AppSettings.twitterConsumerScreatKey, Helper.AppSettings.twitterRedirectionUrl);

            OAuthTwt.AccessToken       = objTwitterAccount.oAuthToken;
            OAuthTwt.AccessTokenSecret = objTwitterAccount.oAuthSecret;
            OAuthTwt.TwitterScreenName = objTwitterAccount.twitterScreenName;
            OAuthTwt.TwitterUserId     = objTwitterAccount.twitterUserId;

            Tweet twt = new Tweet();

            if (!string.IsNullOrEmpty(picurl))
            {
                try
                {
                    PhotoUpload ph  = new PhotoUpload();
                    string      res = string.Empty;
                    rt = ph.NewTweet(picurl, message, OAuthTwt, ref res);
                }
                catch (Exception ex)
                {
                    apiHitsCount = MaxapiHitsCount;
                }
            }
            else
            {
                try
                {
                    JArray post = twt.Post_Statuses_Update(OAuthTwt, message);
                    ret = post[0]["id_str"].ToString();
                }
                catch (Exception ex)
                {
                    apiHitsCount = MaxapiHitsCount;
                }
            }

            if (!string.IsNullOrEmpty(ret) || rt == true)
            {
                schmessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated;
                schmessage.url    = ret;
                dbr.Update <ScheduledMessage>(schmessage);
            }
            else
            {
                str = "Message not posted";
            }

            return(str);
        }
        public static string ComposeTwitterMessage(string message, string profileid, long userid, string picurl, bool isScheduled, DatabaseRepository dbr, Domain.Socioboard.Models.TwitterAccount TwitterAccount, Domain.Socioboard.Models.ScheduledMessage schmessage, Domain.Socioboard.Models.User _user)
        {
            bool   rt  = false;
            string ret = "";
            string str = "Message posted";

            if (message.Length > 140)
            {
                message = message.Substring(0, 135);
            }
            Domain.Socioboard.Models.TwitterAccount objTwitterAccount = TwitterAccount;
            oAuthTwitter OAuthTwt = new oAuthTwitter(AppSettings.twitterConsumerKey, AppSettings.twitterConsumerScreatKey, AppSettings.twitterRedirectionUrl);

            OAuthTwt.AccessToken       = objTwitterAccount.oAuthToken;
            OAuthTwt.AccessTokenSecret = objTwitterAccount.oAuthSecret;
            OAuthTwt.TwitterScreenName = objTwitterAccount.twitterScreenName;
            OAuthTwt.TwitterUserId     = objTwitterAccount.twitterUserId;

            Tweet twt = new Tweet();

            if (!string.IsNullOrEmpty(picurl))
            {
                try
                {
                    PhotoUpload ph  = new PhotoUpload();
                    string      res = string.Empty;
                    rt = ph.NewTweet(picurl, message, OAuthTwt, ref res);
                }
                catch (Exception ex)
                {
                    apiHitsCount = MaxapiHitsCount;
                }
            }
            else
            {
                try
                {
                    JArray post = twt.Post_Statuses_Update(OAuthTwt, message);
                    ret = post[0]["id_str"].ToString();
                }
                catch (Exception ex)
                {
                    apiHitsCount = MaxapiHitsCount;
                }
            }

            if (!string.IsNullOrEmpty(ret) || rt == true)
            {
                schmessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated;
                //schmessage.url = ret;
                dbr.Update <ScheduledMessage>(schmessage);
                Domain.Socioboard.Models.Notifications notify = new Notifications();
                Notifications lstnotifications = dbr.Single <Notifications>(t => t.MsgId == schmessage.id);
                if (lstnotifications == null)
                {
                    notify.MsgId            = schmessage.id;
                    notify.MsgStatus        = "Scheduled";
                    notify.notificationtime = schmessage.localscheduletime;
                    notify.NotificationType = "Schedule Successfully";
                    notify.ReadOrUnread     = "Unread";
                    notify.UserId           = userid;
                    dbr.Add <Notifications>(notify);
                    if (_user.scheduleSuccessUpdates)
                    {
                        string sucResponse = SendMailbySendGrid(AppSettings.from_mail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, true, AppSettings.sendGridUserName, AppSettings.sendGridPassword);
                    }
                }
                else
                {
                    //if (_user.scheduleSuccessUpdates)
                    //{
                    //    string sucResponse = SendMailbySendGrid(AppSettings.from_mail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, true, AppSettings.sendGridUserName, AppSettings.sendGridPassword);
                    //}
                }
            }
            else
            {
                str = "Message not posted";
                Domain.Socioboard.Models.Notifications notify = new Notifications();
                Notifications lstnotifications = dbr.Single <Notifications>(t => t.MsgId == schmessage.id);
                if (lstnotifications == null)
                {
                    notify.MsgId            = schmessage.id;
                    notify.MsgStatus        = "Failed";
                    notify.notificationtime = schmessage.localscheduletime;
                    notify.NotificationType = "Schedule Failed";
                    notify.ReadOrUnread     = "Unread";
                    notify.UserId           = userid;
                    dbr.Add <Notifications>(notify);
                    if (_user.scheduleFailureUpdates)
                    {
                        string falResponse = SendMailbySendGrid(AppSettings.from_mail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, false, AppSettings.sendGridUserName, AppSettings.sendGridPassword);
                    }
                }
                else
                {
                    //if (_user.scheduleFailureUpdates)
                    //{
                    //    string falResponse = SendMailbySendGrid(AppSettings.from_mail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, false, AppSettings.sendGridUserName, AppSettings.sendGridPassword);
                    //}
                }
            }

            return(str);
        }
示例#4
0
        public static string PostTwitterMessage(AppSettings _AppSettings, Cache _redisCache, string message, string profileid, long userid, string url, bool isScheduled, DatabaseRepository dbr, ILogger _logger, string sscheduledmsgguid = "")
        {
            bool   rt    = false;
            string ret   = "";
            string str   = "";
            int    Twtsc = 0;

            Domain.Socioboard.Models.TwitterAccount objTwitterAccount = Api.Socioboard.Repositories.TwitterRepository.getTwitterAccount(profileid, _redisCache, dbr);
            oAuthTwitter OAuthTwt = new oAuthTwitter(_AppSettings.twitterConsumerKey, _AppSettings.twitterConsumerScreatKey, _AppSettings.twitterRedirectionUrl);

            OAuthTwt.AccessToken       = objTwitterAccount.oAuthToken;
            OAuthTwt.AccessTokenSecret = objTwitterAccount.oAuthSecret;
            OAuthTwt.TwitterScreenName = objTwitterAccount.twitterScreenName;
            OAuthTwt.TwitterUserId     = objTwitterAccount.twitterUserId;

            Tweet twt = new Tweet();

            if (!string.IsNullOrEmpty(url))
            {
                try
                {
                    PhotoUpload ph  = new PhotoUpload();
                    string      res = string.Empty;
                    rt = ph.NewTweet(url, message, OAuthTwt, ref res);
                }
                catch (Exception ex)
                {
                    _logger.LogError("PostTwitterMessageWithImage" + ex.StackTrace);
                    _logger.LogError("PostTwitterMessageWithImage" + ex.Message);
                }
            }
            else
            {
                try
                {
                    JArray post = twt.Post_Statuses_Update(OAuthTwt, message);
                    ret = post[0]["id_str"].ToString();
                }
                catch (Exception ex)
                {
                    _logger.LogError("PostTwitterMessage" + ex.StackTrace);
                    _logger.LogError("PostTwitterMessage" + ex.Message);
                }
            }

            if (!string.IsNullOrEmpty(ret) || rt == true)
            {
                ScheduledMessage scheduledMessage = new ScheduledMessage();
                scheduledMessage.createTime        = DateTime.UtcNow;
                scheduledMessage.picUrl            = objTwitterAccount.profileImageUrl;
                scheduledMessage.profileId         = profileid;
                scheduledMessage.profileType       = Domain.Socioboard.Enum.SocialProfileType.Twitter;
                scheduledMessage.scheduleTime      = DateTime.UtcNow;
                scheduledMessage.shareMessage      = message;
                scheduledMessage.socialprofileName = objTwitterAccount.twitterScreenName;
                scheduledMessage.userId            = userid;
                scheduledMessage.status            = Domain.Socioboard.Enum.ScheduleStatus.Compleated;
                scheduledMessage.url = url;
                dbr.Add <ScheduledMessage>(scheduledMessage);
            }
            else
            {
                str = "Message not posted";
            }

            return(str);
        }