Exemple #1
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);
        }
Exemple #2
0
        public string ADDScheduledMessage(string typeandid, string ShareMessage, DateTime ClientTime, DateTime ScheduleTime, bool Status, string UserId, string PicUrl, DateTime CreateTime)
        {
            try
            {
                Guid          userid    = Guid.Parse(UserId);
                List <string> type      = new List <string>();
                List <string> profileid = new List <string>();
                string[]      TypeandId = typeandid.Split(',');
                for (int i = 0; i < TypeandId.Length; i = i + 2)
                {
                    type.Add(TypeandId[i]);
                    profileid.Add(TypeandId[i + 1]);
                }
                objScheduledMessage = new Domain.Socioboard.Domain.ScheduledMessage();

                try
                {
                    for (int i = 0; i < type.Count; i++)
                    {
                        objScheduledMessage.Id           = Guid.NewGuid();
                        objScheduledMessage.ShareMessage = ShareMessage;
                        objScheduledMessage.ClientTime   = ClientTime;
                        objScheduledMessage.ScheduleTime = ScheduleTime;
                        objScheduledMessage.CreateTime   = CreateTime;
                        objScheduledMessage.Status       = Status;
                        objScheduledMessage.UserId       = userid;
                        objScheduledMessage.ProfileType  = type[i];
                        objScheduledMessage.PicUrl       = PicUrl;
                        objScheduledMessage.ProfileId    = profileid[i];
                        objScheduledMessageRepository.addNewMessage(objScheduledMessage);
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message);
                    Console.WriteLine(ex.StackTrace);
                }
                ScheduledMessage objScheduledMessages = new ScheduledMessage();
                return(new JavaScriptSerializer().Serialize(typeandid));
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                Console.WriteLine(ex.StackTrace);
                return(new JavaScriptSerializer().Serialize("Please try Again"));
            }
        }
Exemple #3
0
        public string UpdateScheduledMessage(string typeidandmsgid, string ShareMessage, DateTime scheduledTime, string picurl)
        {
            try
            {
                //Guid msgid = Guid.Parse(MsgId);
                List <string> type      = new List <string>();
                List <string> profileid = new List <string>();
                List <string> msgid     = new List <string>();
                string[]      TypeandId = typeidandmsgid.Split(',');
                for (int i = 0; i < TypeandId.Length; i = i + 3)
                {
                    type.Add(TypeandId[i]);
                    profileid.Add(TypeandId[i + 1]);
                    msgid.Add(TypeandId[i + 2]);
                }
                ScheduledMessageRepository objScheduledMessageRepository = new ScheduledMessageRepository();
                ScheduledMessage           objScheduledMessage           = new ScheduledMessage();

                try
                {
                    for (int i = 0; i < type.Count; i++)
                    {
                        objScheduledMessageRepository.UpdateProfileScheduleMessage(Guid.Parse(msgid[i]), profileid[i], ShareMessage, type[i], scheduledTime, picurl);
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message);
                    Console.WriteLine(ex.StackTrace);
                }
                ScheduledMessage objScheduledMessages = new ScheduledMessage();
                return(new JavaScriptSerializer().Serialize(typeidandmsgid));
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                Console.WriteLine(ex.StackTrace);
                return(new JavaScriptSerializer().Serialize("Please try Again"));
            }
        }
Exemple #4
0
        public string GetTeamMembeDetailsForGroupReport(string TeamId, string userid, string days)
        {
            string FacebookprofileId         = string.Empty;
            string TwitterprofileId          = string.Empty;
            string FacebookFanPageId         = string.Empty;
            string profid                    = string.Empty;
            string FacebookInboxMessagecount = string.Empty;
            string TwitterInboxMessagecount  = string.Empty;

            Domain.Socioboard.Domain.GroupStatDetails _GroupStatDetails = new Domain.Socioboard.Domain.GroupStatDetails();

            Guid UserId = Guid.Parse(userid);

            try
            {
                List <FacebookAccount> _facebookAccount = new List <FacebookAccount>();
                List <Domain.Socioboard.Domain.TeamMemberProfile> lstTeamMember = teammemberrepo.getAllTeamMemberProfilesOfTeam(Guid.Parse(TeamId));


                foreach (Domain.Socioboard.Domain.TeamMemberProfile TeamMemberProfile in lstTeamMember)
                {
                    #region MyRegion
                    try
                    {
                        if (TeamMemberProfile.ProfileType == "facebook" || TeamMemberProfile.ProfileType == "twitter")
                        {
                            profid += TeamMemberProfile.ProfileId + ',';
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        if (TeamMemberProfile.ProfileType == "facebook")
                        {
                            FacebookprofileId += TeamMemberProfile.ProfileId + ',';
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        if (TeamMemberProfile.ProfileType == "twitter")
                        {
                            TwitterprofileId += TeamMemberProfile.ProfileId + ',';
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        if (TeamMemberProfile.ProfileType == "facebook_page")
                        {
                            FacebookFanPageId += TeamMemberProfile.ProfileId + ',';
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    #endregion
                }

                #region MyRegion
                try
                {
                    profid = profid.Substring(0, profid.Length - 1);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                try
                {
                    FacebookFanPageId = FacebookFanPageId.Substring(0, FacebookFanPageId.Length - 1);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                    FacebookFanPageId = null;
                }
                try
                {
                    TwitterprofileId = TwitterprofileId.Substring(0, TwitterprofileId.Length - 1);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                    TwitterprofileId = null;
                }
                try
                {
                    FacebookprofileId = FacebookprofileId.Substring(0, FacebookprofileId.Length - 1);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                    FacebookprofileId = null;
                }
                #endregion

                #region Inboxmessagecount
                if (!string.IsNullOrEmpty(FacebookprofileId))
                {
                    try
                    {
                        FacebookMessage _FacebookMessage = new FacebookMessage();
                        FacebookInboxMessagecount = _FacebookMessage.GetAllInboxMessage(userid, FacebookprofileId, days);
                    }
                    catch (Exception ex)
                    {
                        FacebookInboxMessagecount = (0).ToString();
                        Console.WriteLine(ex.StackTrace);
                    }
                }
                else
                {
                    FacebookInboxMessagecount = (0).ToString();
                }

                if (!string.IsNullOrEmpty(TwitterprofileId))
                {
                    try
                    {
                        TwitterFeed _TwitterFeed = new TwitterFeed();
                        TwitterInboxMessagecount = _TwitterFeed.TwitterInboxMessagecount(userid, TwitterprofileId, days);
                    }
                    catch (Exception ex)
                    {
                        TwitterInboxMessagecount = (0).ToString();
                        Console.WriteLine(ex.StackTrace);
                    }
                }

                else
                {
                    TwitterInboxMessagecount = (0).ToString();
                }

                _GroupStatDetails.IncommingMessage = (Convert.ToInt32(FacebookInboxMessagecount) + Convert.ToInt32(TwitterInboxMessagecount));
                #endregion

                #region sentmessage
                if (!string.IsNullOrEmpty(profid))
                {
                    try
                    {
                        ScheduledMessage _ScheduledMessage = new ScheduledMessage();
                        _GroupStatDetails.SentMessage = _ScheduledMessage.GetAllScheduledMessage(userid, profid, days);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        _GroupStatDetails.SentMessage = 0;
                    }
                }
                #endregion

                #region twitterfolllower
                try
                {
                    TwitterAccountFollowers _TwitterAccountFollowers = new TwitterAccountFollowers();
                    _GroupStatDetails.TwitterFollower = _TwitterAccountFollowers.FollowerCount(userid, TwitterprofileId, days);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                    _GroupStatDetails.TwitterFollower = 0;
                }

                #endregion

                #region fancount
                try
                {
                    FacebookFanPage _FacebookFanPage = new FacebookFanPage();
                    _GroupStatDetails.FacebookFan = _FacebookFanPage.FacebookFans(userid, FacebookFanPageId, days);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                    _GroupStatDetails.FacebookFan = 0;
                }

                #endregion


                #region MentionRetweetDetails
                try
                {
                    TwitterMessage _TwitterMessage = new TwitterMessage();
                    _GroupStatDetails.MentionGraph = string.Empty;
                    string graphdetails = _TwitterMessage.GetAllRetweetMentionBydays(userid, TwitterprofileId, days);

                    string[] data = graphdetails.Split('@');
                    foreach (var item in data)
                    {
                        if (item.Contains("usrtwet^"))
                        {
                            _GroupStatDetails.UserTweetGraph = item.Replace("usrtwet^", "");
                        }
                        else if (item.Contains("mention^"))
                        {
                            _GroupStatDetails.MentionGraph = item.Replace("mention^", "");
                        }
                        else if (item.Contains("retwet^"))
                        {
                            _GroupStatDetails.RetweetGraph = item.Replace("retwet^", "");
                        }
                        else if (item.Contains("metion"))
                        {
                            _GroupStatDetails.Mention = Convert.ToInt32(item.Replace("metion", ""));
                        }
                        else if (item.Contains("retwet"))
                        {
                            _GroupStatDetails.Retweet = Convert.ToInt32(item.Replace("retwet", ""));
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                #endregion

                try
                {
                    ScheduledMessage _ScheduledMessage = new ScheduledMessage();

                    string   details = _ScheduledMessage.GetAllScheduleMsgDetailsForReport(userid, TwitterprofileId, days);
                    string[] data    = details.Split('@');
                    foreach (var item in data)
                    {
                        if (item.Contains("plaintext_"))
                        {
                            _GroupStatDetails.PlainText = Convert.ToInt32(item.Replace("plaintext_", ""));
                        }

                        else
                        {
                            _GroupStatDetails.PhotoLink = Convert.ToInt32(item);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return("Something Went Wrong");
            }

            return(new JavaScriptSerializer().Serialize(_GroupStatDetails));
        }
Exemple #5
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);
        }
Exemple #6
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);
        }
Exemple #7
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);
        }