コード例 #1
0
        public string SheduleFacebookGroupMessage(string FacebookId, string UserId, string sscheduledmsgguid)
        {
            string str = string.Empty;
            int facint = 0;
            try
            {
                objScheduledMessage = objScheduledMessageRepository.GetScheduledMessageDetails(Guid.Parse(sscheduledmsgguid));
                GroupScheduleMessageRepository grpschedulemessagerepo = new GroupScheduleMessageRepository();
                Domain.Socioboard.Domain.GroupScheduleMessage _GroupScheduleMessage = grpschedulemessagerepo.GetScheduleMessageId(objScheduledMessage.Id);
                if (objFacebookAccountRepository.checkFacebookUserExists(FacebookId, Guid.Parse(UserId)))
                {
                    objFacebookAccount = objFacebookAccountRepository.getFacebookAccountDetailsById(FacebookId, Guid.Parse(UserId));
                }
                else
                {
                    objFacebookAccount = objFacebookAccountRepository.getFacebookAccountDetailsById(FacebookId);
                }
                if (objFacebookAccount != null)
                {
                    FacebookClient fbclient = new FacebookClient(objFacebookAccount.AccessToken);
                    var args = new Dictionary<string, object>();
                    args["message"] = objScheduledMessage.ShareMessage;
                    string imagepath = objScheduledMessage.PicUrl;

                    var facebookpost = "";
                    try
                    {
                        if (!string.IsNullOrEmpty(imagepath))
                        {
                            var media = new FacebookMediaObject
                            {
                                FileName = "filename",
                                ContentType = "image/jpeg"
                            };
                            byte[] img = System.IO.File.ReadAllBytes(imagepath);
                            media.SetValue(img);
                            args["source"] = media;
                            facebookpost = fbclient.Post("v2.0/" + _GroupScheduleMessage.GroupId + "/photos", args).ToString();
                        }
                        else
                        {
                            facebookpost = fbclient.Post("v2.0/" + _GroupScheduleMessage.GroupId + "/feed", args).ToString();
                        }
                    }
                    catch (Exception ex)
                    {
                        objFacebookAccountRepository = new FacebookAccountRepository();
                        objFacebookAccount.IsActive = 2;
                        objFacebookAccountRepository.updateFacebookUserStatus(objFacebookAccount);
                        Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
                        SocialProfilesRepository objSocialProfilesRepository = new SocialProfilesRepository();
                        string errormsg = ex.Message;
                        if (errormsg.Contains("access token"))
                        {
                            objSocialProfile.UserId = objFacebookAccount.UserId;
                            objSocialProfile.ProfileId = objFacebookAccount.FbUserId;
                            objSocialProfile.ProfileStatus = 2;
                            objSocialProfilesRepository.updateSocialProfileStatus(objSocialProfile);
                        }
                        Console.WriteLine(ex.Message);
                        str = ex.Message;
                    }

                    if (!string.IsNullOrEmpty(facebookpost))
                    {
                        facint++;
                        str = "Message post on facebook for Id :" + objFacebookAccount.FbUserId + " and Message: " + objScheduledMessage.ShareMessage;
                        ScheduledMessage schmsg = new ScheduledMessage();
                        schmsg.UpdateScheduledMessageByMsgId(Guid.Parse(sscheduledmsgguid));
                        logger.Error("SheduleFacebookGroupMessageCount" + facint);
                    }
                }
                else
                {
                    str = "facebook account not found for id" + objScheduledMessage.ProfileId;
                }
            }
            catch (Exception ex)
            {
                str = ex.Message;
            }
            return str;
        }
コード例 #2
0
        private string PostTwitterMessage(String message, String profileid, string userid, string picurl, bool isScheduled, string sscheduledmsgguid = "")
        {
            bool rt = false;
            string ret = "";
            string str = "";

            Domain.Socioboard.Domain.TwitterAccount objTwitterAccount = objTwitterAccountRepository.GetUserInformation(Guid.Parse(userid), profileid);
            oAuthTwitter OAuthTwt = new oAuthTwitter();
            OAuthTwt.AccessToken = objTwitterAccount.OAuthToken;
            OAuthTwt.AccessTokenSecret = objTwitterAccount.OAuthSecret;
            OAuthTwt.TwitterScreenName = objTwitterAccount.TwitterScreenName;
            OAuthTwt.TwitterUserId = objTwitterAccount.TwitterUserId;
            this.SetCofigDetailsForTwitter(OAuthTwt);
            Tweet twt = new Tweet();
            if (!string.IsNullOrEmpty(picurl))
            {
                PhotoUpload ph = new PhotoUpload();
                //ph.Tweet(file, message, OAuthTwt);
                string res = string.Empty;
                rt = ph.NewTweet(picurl, message, OAuthTwt, ref res);
            }
            else
            {
                try
                {
                    JArray post = twt.Post_Statuses_Update(OAuthTwt, message);
                    ret = post[0]["id_str"].ToString();
                }
                catch { }
            }

            if (!string.IsNullOrEmpty(ret) || rt == true)
            {
                if (isScheduled)
                {
                    str = "Message post on twitter for Id :" + objTwitterAccount.TwitterUserId + " and Message: " + objScheduledMessage.ShareMessage;
                    ScheduledMessage schmsg = new ScheduledMessage();
                    schmsg.UpdateScheduledMessageByMsgId(Guid.Parse(sscheduledmsgguid));
                }
            }
            else
            {
                str = "Message not posted";
            }

            return str;
        }
コード例 #3
0
         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;
         }
コード例 #4
0
         public string ScheduleLinkedinGroupMessage(string scheduledmsgguid, string Userid, string profileid)
         {
             string str = string.Empty;
             try
             {
                 LinkedInAccount linkacc;
                 string authLink = string.Empty;
                 LinkedInAccountRepository linkedinAccRepo = new LinkedInAccountRepository();
                 objScheduledMessage = objScheduledMessageRepository.GetScheduledMessageDetails(Guid.Parse(scheduledmsgguid));
                 GroupScheduleMessageRepository grpschedulemessagerepo = new GroupScheduleMessageRepository();
                 Domain.Socioboard.Domain.GroupScheduleMessage _GroupScheduleMessage = grpschedulemessagerepo.GetScheduleMessageId(objScheduledMessage.Id);
                 if (linkedinAccRepo.checkLinkedinUserExists(profileid, Guid.Parse(Userid)))
                 {
                     linkacc = linkedinAccRepo.getUserInformation(Guid.Parse(Userid), profileid);
                 }
                 else
                 {
                     linkacc = linkedinAccRepo.getUserInformation(profileid);
                 }
                 oAuthLinkedIn oauthlin = new oAuthLinkedIn();
                 oauthlin.ConsumerKey = ConfigurationManager.AppSettings["LiApiKey"];
                 oauthlin.ConsumerSecret = ConfigurationManager.AppSettings["LiSecretKey"];
                 oauthlin.FirstName = linkacc.LinkedinUserName;
                 oauthlin.Id = linkacc.LinkedinUserId;
                 oauthlin.Token = linkacc.OAuthToken;
                 oauthlin.TokenSecret = linkacc.OAuthSecret;
                 oauthlin.Verifier = linkacc.OAuthVerifier;

                 string imgurl = objScheduledMessage.PicUrl;
                 string text = objScheduledMessage.ShareMessage;
                 string[] arrtext = null;
                 try
                 {
                     arrtext = System.Text.RegularExpressions.Regex.Split(text, "$%^_^%$");
                     if (arrtext.Count() == 1)
                     {
                         arrtext = null;
                         arrtext = text.Split(new string[] { "$%^_^%$" }, StringSplitOptions.None);
                     }
                 }
                 catch (Exception ex)
                 {
                     return "somthing went wrong";
                 }
                 string Title = arrtext[0];
                 string Message = arrtext[1];
                 string response = string.Empty;
                 if (linkacc != null)
                 {
                     try
                     {
                         if (string.IsNullOrEmpty(objScheduledMessage.ShareMessage) && string.IsNullOrEmpty(objScheduledMessage.PicUrl))
                         {
                             str = "There is no data in Share Message !";
                         }
                         else
                         {
                             SocialStream sociostream = new SocialStream();
                             if (!string.IsNullOrEmpty(imgurl))
                             {
                                 imgurl = ConfigurationManager.AppSettings["DomainName"].ToString() + Regex.Split(imgurl, "wwwroot")[1].Replace("\\", "/");
                                 response = sociostream.SetImagePostUpdate(oauthlin, _GroupScheduleMessage.GroupId, Message, Title, imgurl);
                             }
                             else
                             {
                                 response = sociostream.SetPostUpdate(oauthlin, _GroupScheduleMessage.GroupId, Message, Title);
                             }
                         }
                     }
                     catch (Exception ex)
                     {
                     }

                     str = "Message post on linkedingroup for Id :" + linkacc.LinkedinUserId + ", Title: " + Title + " and Message: " + Message;
                     ScheduledMessage schmsg = new ScheduledMessage();
                     schmsg.UpdateScheduledMessageByMsgId(Guid.Parse(scheduledmsgguid));

                 }
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.Message);
                 str = ex.Message;
             }
             return str;
         }
コード例 #5
0
 public string SheduleTumblrMessage(string TumblrId, string UserId, string sscheduledmsgguid)
 {
     string str = string.Empty;
     try
     {
         Guid userId = Guid.Parse(UserId);
         oAuthTumbler Obj_oAuthTumbler = new oAuthTumbler();
         oAuthTumbler.TumblrConsumerKey = ConfigurationManager.AppSettings["TumblrClientKey"];
         oAuthTumbler.TumblrConsumerSecret = ConfigurationManager.AppSettings["TumblrClientSec"];
         Obj_oAuthTumbler.TumblrCallBackUrl = ConfigurationManager.AppSettings["TumblrCallBackURL"];
         objScheduledMessage = objScheduledMessageRepository.GetScheduledMessageDetails(Guid.Parse(sscheduledmsgguid));
         Domain.Socioboard.Domain.TumblrAccount ObjTumblrAccount = objTumblrAccountRepository.getTumblrAccountDetailsById(TumblrId, Guid.Parse(UserId));
         oAuthTumbler.TumblrToken = ObjTumblrAccount.tblrAccessToken;
         oAuthTumbler.TumblrTokenSecret = ObjTumblrAccount.tblrAccessTokenSecret;
         PublishedPosts objPublishedPosts = new PublishedPosts();
         string picurl = objScheduledMessage.PicUrl;
         string message = objScheduledMessage.ShareMessage;
         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
         {
             try
             {
                 //objPublishedPosts.PostData(ObjTumblrAccount.tblrAccessToken, ObjTumblrAccount.tblrAccessTokenSecret, ObjTumblrAccount.tblrUserName, objScheduledMessage.ShareMessage, "", "Text");
                 if (!string.IsNullOrEmpty(picurl))
                 {
                     objPublishedPosts.PostData(ObjTumblrAccount.tblrAccessToken, ObjTumblrAccount.tblrAccessTokenSecret, objScheduledMessage.ProfileId, message, picurl, "photo");
                 }
                 else
                 {
                     objPublishedPosts.PostData(ObjTumblrAccount.tblrAccessToken, ObjTumblrAccount.tblrAccessTokenSecret, objScheduledMessage.ProfileId, message, "", "text");
                 }
                 str = "Message post on tumblr for Id :" + ObjTumblrAccount.tblrUserName + " and Message: " + objScheduledMessage.ShareMessage;
                 ScheduledMessage schmsg = new ScheduledMessage();
                 schmsg.UpdateScheduledMessageByMsgId(Guid.Parse(sscheduledmsgguid));
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 str = "Message is not posted";
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
         str = ex.Message;
     }
     return str;
 }
コード例 #6
0
        public string SheduleLinkedInMessage(string LinkedInId, string UserId, string sscheduledmsgguid)
        {
            string str = string.Empty;

            try
            {
                objScheduledMessage = objScheduledMessageRepository.GetScheduledMessageDetails(Guid.Parse(sscheduledmsgguid));
                objLinkedInAccount  = objLinkedInAccountRepository.getUserInformation(Guid.Parse(UserId), 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      = objLinkedInAccount.LinkedinUserName;
                Linkedin_oauth.Token          = objLinkedInAccount.OAuthToken;
                Linkedin_oauth.TokenSecret    = objLinkedInAccount.OAuthSecret;
                Linkedin_oauth.Verifier       = objLinkedInAccount.OAuthVerifier;
                if (objLinkedInAccount != null)
                {
                    try
                    {
                        GlobusLinkedinLib.App.Core.LinkedInUser linkeduser = new GlobusLinkedinLib.App.Core.LinkedInUser();

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

                        var response = string.Empty;;
                        try
                        {
                            response = linkeduser.SetStatusUpdate(Linkedin_oauth, objScheduledMessage.ShareMessage);
                            str      = "Message post on linkedin for Id :" + objLinkedInAccount.LinkedinUserId + " and Message: " + objScheduledMessage.ShareMessage;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }

                        if (string.IsNullOrEmpty(response))
                        {
                            ScheduledMessage schmsg = new ScheduledMessage();
                            schmsg.UpdateScheduledMessageByMsgId(Guid.Parse(sscheduledmsgguid));
                        }
                        else
                        {
                            str = "Message not posted";
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                }
                else
                {
                    str = "facebook account not found for id" + objScheduledMessage.ProfileId;
                }
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }

            return(str);
        }
コード例 #7
0
        public string SheduleFacebookMessage(string FacebookId, string UserId, string sscheduledmsgguid)
        {
            string str = string.Empty;
            try
            {
                objScheduledMessage = objScheduledMessageRepository.GetScheduledMessageDetails(Guid.Parse(sscheduledmsgguid));

                if (objFacebookAccountRepository.checkFacebookUserExists(FacebookId, Guid.Parse(UserId)))
                {
                    objFacebookAccount = objFacebookAccountRepository.getFacebookAccountDetailsById(FacebookId, Guid.Parse(UserId));
                }
                else
                {
                    objFacebookAccount = objFacebookAccountRepository.getFacebookAccountDetailsById(FacebookId);
                }
                if (objFacebookAccount != null)
                {
                    FacebookClient fbclient = new FacebookClient(objFacebookAccount.AccessToken);
                    var args = new Dictionary<string, object>();
                    args["message"] = objScheduledMessage.ShareMessage;
                    string imagepath = objScheduledMessage.PicUrl;

                    var facebookpost = "";
                    try
                    {


                        if (!string.IsNullOrEmpty(imagepath))
                        {
                            try
                            {
                                Uri u = new Uri(imagepath);
                                string filename = string.Empty;
                                string extension = string.Empty;
                                extension = Path.GetExtension(u.AbsolutePath).Replace(".", "");
                                var media = new FacebookMediaObject
                                {
                                    FileName = "filename",
                                    ContentType = "image/" + extension
                                };
                                //byte[] img = System.IO.File.ReadAllBytes(imagepath);
                                var webClient = new WebClient();
                                byte[] img = webClient.DownloadData(imagepath);
                                media.SetValue(img);
                                args["source"] = media;
                                facebookpost = fbclient.Post("v2.0/" + objFacebookAccount.FbUserId + "/photos", args).ToString();
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(imagepath + "not Found");
                                if (!string.IsNullOrEmpty(objScheduledMessage.Url))
                                {
                                    args["link"] = objScheduledMessage.Url;
                                }
                                facebookpost = fbclient.Post("v2.0/" + objFacebookAccount.FbUserId + "/feed", args).ToString();
                            }
                        }
                        else
                        {
                            facebookpost = fbclient.Post("v2.0/" + objFacebookAccount.FbUserId + "/feed", args).ToString();
                        }
                    }

                    catch (Exception ex)
                    {
                        //FacebookAccount ObjFacebookAccount = new FacebookAccount();
                        //objFacebookAccount = new Domain.Socioboard.Domain.FacebookAccount();
                        objFacebookAccountRepository = new FacebookAccountRepository();
                        //objFacebookAccount.IsActive = 2;
                        objFacebookAccountRepository.updateFacebookUserStatus(objFacebookAccount);
                        Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
                        SocialProfilesRepository objSocialProfilesRepository = new SocialProfilesRepository();
                        //logger.Error(ex.Message);
                        string errormsg = ex.Message;
                        if (errormsg.Contains("access token"))
                        {
                            objSocialProfile.UserId = objFacebookAccount.UserId;
                            objSocialProfile.ProfileId = objFacebookAccount.FbUserId;
                            objSocialProfile.ProfileStatus = 2;
                            objSocialProfilesRepository.updateSocialProfileStatus(objSocialProfile);
                        }
                        Console.WriteLine(ex.Message);
                        str = ex.Message;
                    }

                    if (!string.IsNullOrEmpty(facebookpost))
                    {
                        str = "Message post on facebook for Id :" + objFacebookAccount.FbUserId + " and Message: " + objScheduledMessage.ShareMessage;
                        ScheduledMessage schmsg = new ScheduledMessage();
                        schmsg.UpdateScheduledMessageByMsgId(Guid.Parse(sscheduledmsgguid));
                    }
                }
                else
                {
                    str = "facebook account not found for id" + objScheduledMessage.ProfileId;
                }
            }
            catch (Exception ex)
            {
                str = ex.Message;
            }
            return str;
        }
コード例 #8
0
        public string ScheduleLinkedinGroupMessage(string scheduledmsgguid, string Userid, string profileid)
        {
            string str = string.Empty;

            try
            {
                LinkedInAccount           linkacc;
                string                    authLink        = string.Empty;
                LinkedInAccountRepository linkedinAccRepo = new LinkedInAccountRepository();
                objScheduledMessage = objScheduledMessageRepository.GetScheduledMessageDetails(Guid.Parse(scheduledmsgguid));
                GroupScheduleMessageRepository grpschedulemessagerepo = new GroupScheduleMessageRepository();
                Domain.Socioboard.Domain.GroupScheduleMessage _GroupScheduleMessage = grpschedulemessagerepo.GetScheduleMessageId(objScheduledMessage.Id);
                if (linkedinAccRepo.checkLinkedinUserExists(profileid, Guid.Parse(Userid)))
                {
                    linkacc = linkedinAccRepo.getUserInformation(Guid.Parse(Userid), profileid);
                }
                else
                {
                    linkacc = linkedinAccRepo.getUserInformation(profileid);
                }
                oAuthLinkedIn oauthlin = new oAuthLinkedIn();
                oauthlin.ConsumerKey    = ConfigurationManager.AppSettings["LiApiKey"];
                oauthlin.ConsumerSecret = ConfigurationManager.AppSettings["LiSecretKey"];
                oauthlin.FirstName      = linkacc.LinkedinUserName;
                oauthlin.Id             = linkacc.LinkedinUserId;
                oauthlin.Token          = linkacc.OAuthToken;
                oauthlin.TokenSecret    = linkacc.OAuthSecret;
                oauthlin.Verifier       = linkacc.OAuthVerifier;

                string   imgurl  = objScheduledMessage.PicUrl;
                string   text    = objScheduledMessage.ShareMessage;
                string[] arrtext = null;
                try
                {
                    arrtext = System.Text.RegularExpressions.Regex.Split(text, "$%^_^%$");
                    if (arrtext.Count() == 1)
                    {
                        arrtext = null;
                        arrtext = text.Split(new string[] { "$%^_^%$" }, StringSplitOptions.None);
                    }
                }
                catch (Exception ex)
                {
                    return("somthing went wrong");
                }
                string Title    = arrtext[0];
                string Message  = arrtext[1];
                string response = string.Empty;
                if (linkacc != null)
                {
                    try
                    {
                        if (string.IsNullOrEmpty(objScheduledMessage.ShareMessage) && string.IsNullOrEmpty(objScheduledMessage.PicUrl))
                        {
                            str = "There is no data in Share Message !";
                        }
                        else
                        {
                            SocialStream sociostream = new SocialStream();
                            if (!string.IsNullOrEmpty(imgurl))
                            {
                                imgurl   = ConfigurationManager.AppSettings["DomainName"].ToString() + Regex.Split(imgurl, "wwwroot")[1].Replace("\\", "/");
                                response = sociostream.SetImagePostUpdate(oauthlin, _GroupScheduleMessage.GroupId, Message, Title, imgurl);
                            }
                            else
                            {
                                response = sociostream.SetPostUpdate(oauthlin, _GroupScheduleMessage.GroupId, Message, Title);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }

                    str = "Message post on linkedingroup for Id :" + linkacc.LinkedinUserId + ", Title: " + Title + " and Message: " + Message;
                    ScheduledMessage schmsg = new ScheduledMessage();
                    schmsg.UpdateScheduledMessageByMsgId(Guid.Parse(scheduledmsgguid));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                str = ex.Message;
            }
            return(str);
        }
コード例 #9
0
        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);
        }