Esempio n. 1
0
        public string LinkedinComposeMessage(String message, String profileid, string userid, string currentdatetime, string picurl)
        {
            string ret = "";

            Domain.Socioboard.Domain.LinkedInAccount LinkedAccount = objLinkedInAccountRepository.getUserInformation(Guid.Parse(userid), profileid);
            oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn();

            Linkedin_oauth.Verifier    = LinkedAccount.OAuthVerifier;
            Linkedin_oauth.TokenSecret = LinkedAccount.OAuthSecret;
            Linkedin_oauth.Token       = LinkedAccount.OAuthToken;
            Linkedin_oauth.Id          = LinkedAccount.LinkedinUserId;
            Linkedin_oauth.FirstName   = LinkedAccount.LinkedinUserName;
            SocialStream sociostream = new SocialStream();

            if (!string.IsNullOrEmpty(picurl))
            {
                string res = sociostream.SetImageStatusUpdate(Linkedin_oauth, message, picurl);
            }
            else
            {
                string res = sociostream.SetStatusUpdate(Linkedin_oauth, message);
            }

            //string res = sociostream.SetStatusUpdate(Linkedin_oauth, message);
            return(ret);
        }
        public string LinkedinComposeMessage(String message, String profileid, string userid, string currentdatetime, string picurl)
        {
            string                    ret = "";
            LinkedInAccount           LinkedAccount;
            string                    authLink        = string.Empty;
            LinkedInAccountRepository linkedinAccRepo = new LinkedInAccountRepository();

            if (linkedinAccRepo.checkLinkedinUserExists(profileid, Guid.Parse(userid)))
            {
                LinkedAccount = linkedinAccRepo.getUserInformation(Guid.Parse(userid), profileid);
            }
            else
            {
                LinkedAccount = linkedinAccRepo.getUserInformation(profileid);
            }
            oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn();

            Linkedin_oauth.Verifier    = LinkedAccount.OAuthVerifier;
            Linkedin_oauth.TokenSecret = LinkedAccount.OAuthSecret;
            Linkedin_oauth.Token       = LinkedAccount.OAuthToken;
            Linkedin_oauth.Id          = LinkedAccount.LinkedinUserId;
            Linkedin_oauth.FirstName   = LinkedAccount.LinkedinUserName;
            SocialStream sociostream = new SocialStream();

            if (!string.IsNullOrEmpty(picurl))
            {
                picurl = ConfigurationManager.AppSettings["DomainName"].ToString() + Regex.Split(picurl, "wwwroot")[1].Replace("\\", "/");
                string res = sociostream.SetImageStatusUpdate(Linkedin_oauth, message, picurl);
            }
            else
            {
                string res = sociostream.SetStatusUpdate(Linkedin_oauth, message);
            }

            //string res = sociostream.SetStatusUpdate(Linkedin_oauth, message);
            return(ret);
        }
        public string SheduleLinkedInMessage(string LinkedInId, string UserId, string sscheduledmsgguid)
        {
            string                    str = string.Empty;
            LinkedInAccount           LinkedAccount;
            string                    authLink        = string.Empty;
            LinkedInAccountRepository linkedinAccRepo = new LinkedInAccountRepository();

            try
            {
                objScheduledMessage = objScheduledMessageRepository.GetScheduledMessageDetails(Guid.Parse(sscheduledmsgguid));
                if (linkedinAccRepo.checkLinkedinUserExists(LinkedInId, Guid.Parse(UserId)))
                {
                    LinkedAccount = linkedinAccRepo.getUserInformation(Guid.Parse(UserId), LinkedInId);
                }
                else
                {
                    LinkedAccount = linkedinAccRepo.getUserInformation(LinkedInId);
                }
                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      = LinkedAccount.LinkedinUserName;
                Linkedin_oauth.Token          = LinkedAccount.OAuthToken;
                Linkedin_oauth.TokenSecret    = LinkedAccount.OAuthSecret;
                Linkedin_oauth.Verifier       = LinkedAccount.OAuthVerifier;
                string message = objScheduledMessage.ShareMessage;
                string picurl  = objScheduledMessage.PicUrl;
                if (LinkedAccount != null)
                {
                    try
                    {
                        //GlobusLinkedinLib.App.Core.LinkedInUser linkeduser = new GlobusLinkedinLib.App.Core.LinkedInUser();
                        if (string.IsNullOrEmpty(objScheduledMessage.ShareMessage) && string.IsNullOrEmpty(objScheduledMessage.PicUrl))
                        {
                            //objScheduledMessage.ShareMessage = "There is no data in Share Message !";
                            str = "There is no data in Share Message !";
                        }
                        else
                        {
                            var response = string.Empty;;
                            try
                            {
                                //response = linkeduser.SetStatusUpdate(Linkedin_oauth, objScheduledMessage.ShareMessage);
                                SocialStream sociostream = new SocialStream();
                                if (!string.IsNullOrEmpty(picurl))
                                {
                                    picurl   = ConfigurationManager.AppSettings["DomainName"].ToString() + Regex.Split(picurl, "wwwroot")[1].Replace("\\", "/");
                                    response = sociostream.SetImageStatusUpdate(Linkedin_oauth, message, picurl);
                                }
                                else
                                {
                                    response = sociostream.SetStatusUpdate(Linkedin_oauth, message);
                                }
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.StackTrace);
                                str = ex.Message;
                            }

                            if (!string.IsNullOrEmpty(response))
                            {
                                str = "Message post on linkedin for Id :" + LinkedAccount.LinkedinUserId + " and Message: " + objScheduledMessage.ShareMessage;
                                ScheduledMessage schmsg = new ScheduledMessage();
                                schmsg.UpdateScheduledMessageByMsgId(Guid.Parse(sscheduledmsgguid));
                            }
                            else
                            {
                                str = "Message not posted";
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        str = ex.Message;
                    }
                }
                else
                {
                    str = "Linkedin account not found for id" + objScheduledMessage.ProfileId;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                str = ex.Message;
            }
            return(str);
        }