Ejemplo n.º 1
0
        public override void PostScheduleMessage(dynamic data)
        {
            try
            {
                oAuthTwitter             OAuthTwt   = new oAuthTwitter();
                TwitterAccountRepository fbaccrepo  = new TwitterAccountRepository();
                TwitterAccount           twtaccount = fbaccrepo.getUserInformation(data.UserId, data.ProfileId);


                OAuthTwt.CallBackUrl       = System.Configuration.ConfigurationSettings.AppSettings["callbackurl"];
                OAuthTwt.ConsumerKey       = System.Configuration.ConfigurationSettings.AppSettings["consumerKey"];
                OAuthTwt.ConsumerKeySecret = System.Configuration.ConfigurationSettings.AppSettings["consumerSecret"];
                OAuthTwt.AccessToken       = twtaccount.OAuthToken;
                OAuthTwt.AccessTokenSecret = twtaccount.OAuthSecret;
                OAuthTwt.TwitterScreenName = twtaccount.TwitterScreenName;
                OAuthTwt.TwitterUserId     = twtaccount.TwitterUserId;


                #region For Testing
                // For Testing

                //OAuthTwt.ConsumerKey = "udiFfPxtCcwXWl05wTgx6w";
                //OAuthTwt.ConsumerKeySecret = "jutnq6N32Rb7cgbDSgfsrUVgRQKMbUB34yuvAfCqTI";
                //OAuthTwt.AccessToken = "1904022338-Ao9chvPouIU8ejE1HMG4yJsP3hOgEoXJoNRYUF7";
                //OAuthTwt.AccessTokenSecret = "Wj93a8csVFfaFS1MnHjbmbPD3V6DJbhEIf4lgSAefORZ5";
                //OAuthTwt.TwitterScreenName = "";
                //OAuthTwt.TwitterUserId = "";
                #endregion

                TwitterUser twtuser = new TwitterUser();

                if (string.IsNullOrEmpty(data.ShareMessage))
                {
                    data.ShareMessage = "There is no data in Share Message !";
                }

                JArray post = twtuser.Post_Status_Update(OAuthTwt, data.ShareMessage);



                Console.WriteLine("Message post on twitter for Id :" + twtaccount.TwitterUserId + " and Message: " + data.ShareMessage);
                ScheduledMessageRepository schrepo = new ScheduledMessageRepository();
                schrepo.updateMessage(data.Id);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                Log log = new Log();
                log.CreatedDate = DateTime.Now;
                log.Exception   = ex.Message;
                log.Id          = Guid.NewGuid();
                log.ModuleName  = "TwitterScheduler";
                log.ProfileId   = data.ProfileId;
                log.Status      = false;
                LogRepository logRepo = new LogRepository();
                logRepo.AddLog(log);
            }
        }
Ejemplo n.º 2
0
        public override void PostScheduleMessage(dynamic data)
        {
            try
            {
                LinkedInAccountRepository linkedinrepo = new LinkedInAccountRepository();

                LinkedInAccount linkedinaccount = linkedinrepo.getLinkedinAccountDetailsById(data.ProfileId);

                Console.WriteLine("=========================================================================");

                //   IEnumerable<LinkedInAccount> lstlinkedinaccount = linkedinrepo.getLinkedinAccountDetailsById(data.ProfileId);

                //foreach (LinkedInAccount item in lstlinkedinaccount)
                //{
                //    linkedinaccount = item;
                //    break;

                //}

                oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn();
                Linkedin_oauth.ConsumerKey    = System.Configuration.ConfigurationSettings.AppSettings["LiApiKey"].ToString();
                Linkedin_oauth.ConsumerSecret = System.Configuration.ConfigurationSettings.AppSettings["LiSecretKey"].ToString();
                Linkedin_oauth.FirstName      = linkedinaccount.LinkedinUserName;
                Linkedin_oauth.Token          = linkedinaccount.OAuthToken;
                Linkedin_oauth.TokenSecret    = linkedinaccount.OAuthSecret;
                Linkedin_oauth.Verifier       = linkedinaccount.OAuthVerifier;
                LinkedInUser linkeduser = new LinkedInUser();
                var          response   = linkeduser.SetStatusUpdate(Linkedin_oauth, data.ShareMessage);
                Console.WriteLine("Message post on linkedin for Id :" + linkedinaccount.LinkedinUserId + " and Message: " + data.ShareMessage);
                Console.WriteLine("=============================================================");
                ScheduledMessageRepository schrepo = new ScheduledMessageRepository();
                ScheduledMessage           schmsg  = new ScheduledMessage();
                schmsg.Id           = data.Id;
                schmsg.ProfileId    = data.ProfileId;
                schmsg.ProfileType  = "linkedin";
                schmsg.Status       = true;
                schmsg.UserId       = data.UserId;
                schmsg.ShareMessage = data.ShareMessage;
                schmsg.ScheduleTime = data.ScheduleTime;
                schmsg.ClientTime   = data.ClientTime;
                schmsg.CreateTime   = data.CreateTime;
                schmsg.PicUrl       = data.PicUrl;

                schrepo.updateMessage(data.Id);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }
Ejemplo n.º 3
0
        public override void PostScheduleMessage(dynamic data)
        {
            try
            {
                FacebookAccountRepository fbaccrepo = new FacebookAccountRepository();
                //IEnumerable<FacebookAccount> lstfbaccount = fbaccrepo.getUserDetails(data.ProfileId);
                FacebookAccount fbaccount = fbaccrepo.getUserDetails(data.ProfileId);
                if (fbaccount != null)
                {
                    //FacebookAccount fbaccount = null;
                    //foreach (FacebookAccount item in lstfbaccount)
                    //{
                    //    fbaccount = item;
                    //    break;
                    //}

                    FacebookClient fbclient = new FacebookClient(fbaccount.AccessToken);
                    var            args     = new Dictionary <string, object>();
                    args["message"] = data.ShareMessage;

                    //var facebookpost = fbclient.Post("/me/feed", args);
                    var facebookpost = "";
                    try
                    {
                        if (fbaccount.Type == "account")
                        {
                            facebookpost = fbclient.Post("/me/feed", args).ToString();
                        }
                        else
                        {
                            facebookpost = fbclient.Post("/" + fbaccount.FbUserId + "/feed", args).ToString();
                        }
                    }
                    catch (Exception ex)
                    {
                        FacebookAccount           objFacebookAccount           = new FacebookAccount();
                        FacebookAccountRepository objFacebookAccountRepository = new FacebookAccountRepository();
                        objFacebookAccount.FbUserId = data.ProfileId;
                        objFacebookAccount.UserId   = fbaccount.UserId;
                        objFacebookAccount.IsActive = 2;
                        objFacebookAccountRepository.updateFacebookUserStatus(objFacebookAccount);
                        SocialProfile            objSocialProfile            = new SocialProfile();
                        SocialProfilesRepository objSocialProfilesRepository = new SocialProfilesRepository();
                        //logger.Error(ex.Message);
                        string errormsg = ex.Message;
                        if (errormsg.Contains("access token"))
                        {
                            objSocialProfile.UserId        = fbaccount.UserId;
                            objSocialProfile.ProfileId     = data.ProfileId;
                            objSocialProfile.ProfileStatus = 2;
                            objSocialProfilesRepository.updateSocialProfileStatus(objSocialProfile);
                        }
                        Console.WriteLine(ex.Message);
                    }

                    Console.WriteLine("Message post on facebook for Id :" + fbaccount.FbUserId + " and Message: " + data.ShareMessage);

                    ScheduledMessageRepository schrepo = new ScheduledMessageRepository();
                    ScheduledMessage           schmsg  = new ScheduledMessage();
                    schmsg.Id           = data.Id;
                    schmsg.ProfileId    = data.ProfileId;
                    schmsg.ProfileType  = "";
                    schmsg.Status       = true;
                    schmsg.UserId       = data.UserId;
                    schmsg.ShareMessage = data.ShareMessage;
                    schmsg.ScheduleTime = data.ScheduleTime;
                    schmsg.ClientTime   = data.ClientTime;
                    schmsg.CreateTime   = data.CreateTime;
                    schmsg.PicUrl       = data.PicUrl;

                    schrepo.updateMessage(data.Id);
                }
                else
                {
                    Console.WriteLine("facebook account not found for id" + data.ProfileId);
                }
            }
            catch (FacebookApiLimitException ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }