示例#1
0
        public string TumblrComposeMessage(String message, String profileid, string userid, string currentdatetime, string picurl)
        {
            string ret = "";

            Domain.Socioboard.Domain.TumblrAccount objTumblrAccount = objTumblrAccountRepository.getTumblrAccountDetailsById(profileid, Guid.Parse(userid));
            oAuthTumbler Obj_oAuthTumbler = new oAuthTumbler();

            oAuthTumbler.TumblrToken       = objTumblrAccount.tblrAccessToken;
            oAuthTumbler.TumblrTokenSecret = objTumblrAccount.tblrAccessTokenSecret;
            PublishedPosts objPublishedPosts = new PublishedPosts();

            try
            {
                if (!string.IsNullOrEmpty(picurl))
                {
                    objPublishedPosts.PostData(objTumblrAccount.tblrAccessToken, objTumblrAccount.tblrAccessTokenSecret, profileid, message, picurl, "photo");
                }
                else
                {
                    objPublishedPosts.PostData(objTumblrAccount.tblrAccessToken, objTumblrAccount.tblrAccessTokenSecret, profileid, message, "", "text");
                }
                ret = "success";
            }
            catch (Exception ex)
            {
                ret = "failuer";
            }
            return(ret);
        }
示例#2
0
        public string getTumblrData(string UserId, string Tumblrid)
        {
            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"];
            TumblrAccountRepository objTumblrAccountRepository = new TumblrAccountRepository();

            Domain.Socioboard.Domain.TumblrAccount ObjTumblrAccount = objTumblrAccountRepository.getTumblrAccountDetailsById(Tumblrid, userId);
            #region UpdateTeammemberprofile
            Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
            objTeamMemberProfile.ProfileName   = ObjTumblrAccount.tblrUserName;
            objTeamMemberProfile.ProfilePicUrl = ObjTumblrAccount.tblrProfilePicUrl;
            objTeamMemberProfile.ProfileId     = ObjTumblrAccount.tblrUserName;
            objTeamMemberProfileRepository.updateTeamMemberbyprofileid(objTeamMemberProfile);
            #endregion
            oAuthTumbler.TumblrToken       = ObjTumblrAccount.tblrAccessToken;
            oAuthTumbler.TumblrTokenSecret = ObjTumblrAccount.tblrAccessTokenSecret;
            KeyValuePair <string, string> LoginDetails = new KeyValuePair <string, string>(ObjTumblrAccount.tblrAccessToken, ObjTumblrAccount.tblrAccessTokenSecret);
            AddTunblrFeeds(UserId, LoginDetails, ObjTumblrAccount.tblrUserName);
            Domain.Socioboard.Domain.TumblrFeed tumblrTumblrFeed = new Domain.Socioboard.Domain.TumblrFeed();
            TumblrFeedRepository.Add(tumblrTumblrFeed);
            return("Tumblr info is updated successfully");
            //Obj_oAuthTumbler.TumblrOAuthVerifier=ObjTumblrAccount.tbl
        }
        public Domain.Socioboard.Domain.TumblrAccount getTumblrAccountDetailsById(string tumblruserid)
        {

            Domain.Socioboard.Domain.TumblrAccount result = new Domain.Socioboard.Domain.TumblrAccount();
            //Creates a database connection and opens up a session
            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                //After Session creation, start Transaction.
                using (NHibernate.ITransaction transaction = session.BeginTransaction())
                {

                    // proceed action, to get all Facebook Account of User by UserId(Guid) and FbUserId(string).
                    List<Domain.Socioboard.Domain.TumblrAccount> objlsttumb = session.CreateQuery("from TumblrAccount where tblrUserName = :tblruname")
                            .SetParameter("tblruname", tumblruserid)
                       .List<Domain.Socioboard.Domain.TumblrAccount>().ToList<Domain.Socioboard.Domain.TumblrAccount>();
                    if (objlsttumb.Count > 0)
                    {
                        result = objlsttumb[0];
                    }
                    return result;
                }//End Transaction
            }//End s


        }
        public bool checkTubmlrUserExists(Domain.Socioboard.Domain.TumblrAccount objTumblrAccount)
        {
            //Creates a database connection and opens up a session
            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                //After Session creation, start Transaction.
                using (NHibernate.ITransaction transaction = session.BeginTransaction())
                {
                    try
                    {
                        //Proceed action, to Check if FacebookUser is Exist in database or not by UserId and FbuserId.
                        // And Set the reuired paremeters to find the specific values.
                        NHibernate.IQuery query = session.CreateQuery("from TumblrAccount where UserId = :uidd and tblrUserName = :tbuname");
                        query.SetParameter("uidd", objTumblrAccount.UserId);
                        query.SetParameter("tbuname", objTumblrAccount.tblrUserName);
                        var result = query.UniqueResult();

                        if (result == null)
                        {
                            return(false);
                        }
                        else
                        {
                            return(true);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        return(true);
                    }
                } //End Transaction
            }     //End session
        }
 public void updateTumblrUser(Domain.Socioboard.Domain.TumblrAccount tumblrAccount)
 {
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 session.CreateQuery("Update tumblraccount set tblrAccessToken =:TumblrAccessToken,tblrAccessTokenSecret=:TumblrAccessTokenSecret,tblrProfilePicUrl=:TumblrProfilePicUrl where tblrUserName =:TumblrUserName and UserId = :UserId")
                 .SetParameter("TumblrUserName", tumblrAccount.tblrUserName)
                 .SetParameter("TumblrAccessToken", tumblrAccount.tblrAccessToken)
                 .SetParameter("TumblrAccessTokenSecret", tumblrAccount.tblrAccessTokenSecret)
                 .SetParameter("TumblrProfilePicUrl", tumblrAccount.tblrProfilePicUrl)
                 .SetParameter("UserId", tumblrAccount.UserId)
                 .SetParameter("IsActive", "1")
                 .ExecuteUpdate();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 // return 0;
             }
         }
     }
 }
示例#6
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);
        }
示例#7
0
 public string UpdateTumblrAccountByAdmin(string ObjTumblr)
 {
     Domain.Socioboard.Domain.TumblrAccount ObjTumblrAccount = (Domain.Socioboard.Domain.TumblrAccount)(new JavaScriptSerializer().Deserialize(ObjTumblr, typeof(Domain.Socioboard.Domain.TumblrAccount)));
     try
     {
         objTumblrAccountRepository.updateTumblrUser(ObjTumblrAccount);
         return(new JavaScriptSerializer().Serialize("Update Successfully"));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
         return(new JavaScriptSerializer().Serialize("Something went Wrong"));
     }
 }
示例#8
0
        public string getTumblrData(string UserId, string Tumblrid)
        {
            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"];
                TumblrAccountRepository objTumblrAccountRepository      = new TumblrAccountRepository();
                Domain.Socioboard.Domain.TumblrAccount ObjTumblrAccount = objTumblrAccountRepository.getTumblrAccountDetailsById(Tumblrid, userId);

                oAuthTumbler.TumblrToken       = ObjTumblrAccount.tblrAccessToken;
                oAuthTumbler.TumblrTokenSecret = ObjTumblrAccount.tblrAccessTokenSecret;
                KeyValuePair <string, string> LoginDetails = new KeyValuePair <string, string>(ObjTumblrAccount.tblrAccessToken, ObjTumblrAccount.tblrAccessTokenSecret);
                JObject profile = new JObject();
                try
                {
                    profile = JObject.Parse(oAuthTumbler.OAuthData(Globals.UsersInfoUrl, "GET", LoginDetails.Key, LoginDetails.Value, null));
                }
                catch (Exception ex)
                {
                }

                #region UpdateTumblrAccount
                string tumblrnameold = ObjTumblrAccount.tblrUserName;
                ObjTumblrAccount.tblrUserName      = profile["response"]["user"]["name"].ToString();
                ObjTumblrAccount.tblrProfilePicUrl = "http://api.tumblr.com/v2/blog/" + objTumblrAccount.tblrUserName + ".tumblr.com/avatar";
                objTumblrAccountRepository.UpdateTumblrAccount(ObjTumblrAccount, tumblrnameold);
                #endregion

                #region UpdateTeammemberprofile
                Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                objTeamMemberProfile.ProfileName   = ObjTumblrAccount.tblrUserName;
                objTeamMemberProfile.ProfilePicUrl = ObjTumblrAccount.tblrProfilePicUrl;
                objTeamMemberProfile.ProfileId     = ObjTumblrAccount.tblrUserName;
                objTeamMemberProfileRepository.updateTeamMemberbyprofileid(objTeamMemberProfile);
                #endregion

                AddTunblrFeeds(UserId, LoginDetails, ObjTumblrAccount.tblrUserName);
            }
            catch (Exception ex)
            {
                logger.Error("GetTumblrData => " + ex.Message);
            }
            //Domain.Socioboard.Domain.TumblrFeed tumblrTumblrFeed = new Domain.Socioboard.Domain.TumblrFeed();
            //TumblrFeedRepository.Add(tumblrTumblrFeed);
            return("Tumblr info is updated successfully");
            //Obj_oAuthTumbler.TumblrOAuthVerifier=ObjTumblrAccount.tbl
        }
 public static void Add(Domain.Socioboard.Domain.TumblrAccount tumbler)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //After Session creation, start and open Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             //Proceed action to save data.
             session.Save(tumbler);
             transaction.Commit();
         } //End Using trasaction
     }     //End Using session
 }
 public Domain.Socioboard.Domain.TumblrAccount getTumblrAccountDetailsById(string tumblruserid, Guid userId)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //After Session creation, start Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             // proceed action, to get all Facebook Account of User by UserId(Guid) and FbUserId(string).
             NHibernate.IQuery query = session.CreateQuery("from TumblrAccount where tblrUserName = :tblruname and UserId=:userId");
             query.SetParameter("tblruname", tumblruserid);
             query.SetParameter("userId", userId);
             Domain.Socioboard.Domain.TumblrAccount result = (Domain.Socioboard.Domain.TumblrAccount)query.UniqueResult();
             return(result);
         } //End Transaction
     }     //End session
 }
 public Domain.Socioboard.Domain.TumblrAccount getTumblrAccountDetailsById(string tumblruserid)
 {
     Domain.Socioboard.Domain.TumblrAccount result = new Domain.Socioboard.Domain.TumblrAccount();
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //After Session creation, start Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             // proceed action, to get all Facebook Account of User by UserId(Guid) and FbUserId(string).
             List <Domain.Socioboard.Domain.TumblrAccount> objlsttumb = session.CreateQuery("from TumblrAccount where tblrUserName = :tblruname")
                                                                        .SetParameter("tblruname", tumblruserid)
                                                                        .List <Domain.Socioboard.Domain.TumblrAccount>().ToList <Domain.Socioboard.Domain.TumblrAccount>();
             if (objlsttumb.Count > 0)
             {
                 result = objlsttumb[0];
             }
             return(result);
         } //End Transaction
     }     //End s
 }
 public int UpdateTumblrAccount(Domain.Socioboard.Domain.TumblrAccount _TumblrAccount, string tumblrUserName)
 {
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 int i = session.CreateQuery("Update tumblraccount set tblrProfilePicUrl=:TumblrProfilePicUrl, tblrUserName =:TumblrUserName where tblrUserName =:TumblrUserNameold")
                         .SetParameter("TumblrUserName", _TumblrAccount.tblrUserName)
                         .SetParameter("TumblrProfilePicUrl", _TumblrAccount.tblrProfilePicUrl)
                         .SetParameter("TumblrUserNameold", tumblrUserName)
                         .ExecuteUpdate();
                 transaction.Commit();
                 return(i);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 return(0);
             }
         }
     }
 }
示例#13
0
        public string AddTumblrAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string code)
        {
            string ret = string.Empty;
            string AccessTokenResponse = string.Empty;

            try
            {
                oAuthTumbler requestHelper = new oAuthTumbler();
                oAuthTumbler.TumblrConsumerKey    = client_id;
                oAuthTumbler.TumblrConsumerSecret = client_secret;
                requestHelper.TumblrCallBackUrl   = redirect_uri;
                AccessTokenResponse = requestHelper.GetAccessToken(oAuthTumbler.TumblrToken, code);
                logger.Error(AccessTokenResponse);

                string[] tokens = AccessTokenResponse.Split('&'); //extract access token & secret from response
                logger.Error(tokens);
                string accessToken = tokens[0].Split('=')[1];
                logger.Error(accessToken);
                string accessTokenSecret = tokens[1].Split('=')[1];
                logger.Error(accessTokenSecret);

                KeyValuePair <string, string> LoginDetails = new KeyValuePair <string, string>(accessToken, accessTokenSecret);

                JObject profile = new JObject();
                try
                {
                    profile = JObject.Parse(oAuthTumbler.OAuthData(Globals.UsersInfoUrl, "GET", LoginDetails.Key, LoginDetails.Value, null));
                }
                catch (Exception ex)
                {
                }


                #region Add Tumblr Account
                objTumblrAccount                       = new Domain.Socioboard.Domain.TumblrAccount();
                objTumblrAccount.Id                    = Guid.NewGuid();
                objTumblrAccount.tblrUserName          = profile["response"]["user"]["name"].ToString();
                objTumblrAccount.UserId                = Guid.Parse(UserId);
                objTumblrAccount.tblrAccessToken       = accessToken;
                objTumblrAccount.tblrAccessTokenSecret = accessTokenSecret;
                objTumblrAccount.tblrProfilePicUrl     = "http://api.tumblr.com/v2/blog/" + objTumblrAccount.tblrUserName + ".tumblr.com/avatar";//profile["response"]["user"]["name"].ToString();
                objTumblrAccount.IsActive              = 1;
                if (!objTumblrAccountRepository.checkTubmlrUserExists(objTumblrAccount))
                {
                    TumblrAccountRepository.Add(objTumblrAccount);

                    #region Add Socialprofiles
                    objSocialProfile               = new Domain.Socioboard.Domain.SocialProfile();
                    objSocialProfile.Id            = Guid.NewGuid();
                    objSocialProfile.UserId        = Guid.Parse(UserId);
                    objSocialProfile.ProfileId     = profile["response"]["user"]["name"].ToString();
                    objSocialProfile.ProfileType   = "tumblr";
                    objSocialProfile.ProfileDate   = DateTime.Now;
                    objSocialProfile.ProfileStatus = 1;
                    if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                    {
                        objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
                    }
                    #endregion

                    #region Add TeamMemeberProfile
                    Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                    Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                    objTeamMemberProfile.Id               = Guid.NewGuid();
                    objTeamMemberProfile.TeamId           = objTeam.Id;
                    objTeamMemberProfile.Status           = 1;
                    objTeamMemberProfile.ProfileType      = "tumblr";
                    objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                    objTeamMemberProfile.ProfileId        = objTumblrAccount.tblrUserName;

                    //Modified [13-02-15]
                    objTeamMemberProfile.ProfilePicUrl = objTumblrAccount.tblrProfilePicUrl;
                    objTeamMemberProfile.ProfileName   = objTumblrAccount.tblrUserName;

                    objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                    #endregion
                }
                #endregion


                //if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeam.Id, objTumblrAccount.tblrUserName))
                //{
                //    objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                //}

                #region Add Tumblr Feeds
                AddTunblrFeeds(UserId, LoginDetails, profile["response"]["user"]["name"].ToString());
                #endregion
            }
            catch (Exception ex)
            {
                logger.Error("AddTumblrAccount => " + ex.StackTrace);
            }
            return(ret);
        }
示例#14
0
 public string ProfilesConnected(string UserId)
 {
     try
     {
         Guid userid = Guid.Parse(UserId);
         SocialProfilesRepository socialRepo = new SocialProfilesRepository();
         List <Domain.Socioboard.Domain.SocialProfile> lstsocioprofile = socialRepo.getAllSocialProfilesOfUser(userid);
         List <profileConnected> lstProfile = new List <profileConnected>();
         foreach (Domain.Socioboard.Domain.SocialProfile sp in lstsocioprofile)
         {
             profileConnected pc = new profileConnected();
             pc.Id            = sp.Id;
             pc.ProfileDate   = sp.ProfileDate;
             pc.ProfileId     = sp.ProfileId;
             pc.ProfileStatus = sp.ProfileStatus;
             pc.ProfileType   = sp.ProfileType;
             pc.UserId        = sp.UserId;
             if (sp.ProfileType == "facebook")
             {
                 try
                 {
                     FacebookAccountRepository objFbAccRepo            = new FacebookAccountRepository();
                     Domain.Socioboard.Domain.FacebookAccount objFbAcc = objFbAccRepo.getUserDetails(sp.ProfileId);
                     pc.ProfileName   = objFbAcc.FbUserName;
                     pc.ProfileImgUrl = "http://graph.facebook.com/" + sp.ProfileId + "/picture?type=small";
                 }
                 catch (Exception ex)
                 {
                     Console.WriteLine(ex.StackTrace);
                 }
             }
             else if (sp.ProfileType == "twitter")
             {
                 try
                 {
                     TwitterAccountRepository objTwtAccRepo            = new TwitterAccountRepository();
                     Domain.Socioboard.Domain.TwitterAccount objTwtAcc = objTwtAccRepo.getUserInfo(sp.ProfileId);
                     pc.ProfileName   = objTwtAcc.TwitterScreenName;
                     pc.ProfileImgUrl = objTwtAcc.ProfileImageUrl;
                 }
                 catch (Exception ex)
                 {
                     Console.WriteLine(ex.StackTrace);
                 }
             }
             else if (sp.ProfileType == "instagram")
             {
                 try
                 {
                     InstagramAccountRepository objInsAccRepo            = new InstagramAccountRepository();
                     Domain.Socioboard.Domain.InstagramAccount objInsAcc = objInsAccRepo.getInstagramAccountById(sp.ProfileId);
                     pc.ProfileName   = objInsAcc.InsUserName;
                     pc.ProfileImgUrl = objInsAcc.ProfileUrl;
                 }
                 catch (Exception ex)
                 {
                     Console.WriteLine(ex.StackTrace);
                 }
             }
             else if (sp.ProfileType == "linkedin")
             {
                 try
                 {
                     LinkedInAccountRepository objLiAccRepo            = new LinkedInAccountRepository();
                     Domain.Socioboard.Domain.LinkedInAccount objLiAcc = objLiAccRepo.getLinkedinAccountDetailsById(sp.ProfileId);
                     pc.ProfileName   = objLiAcc.LinkedinUserName;
                     pc.ProfileImgUrl = objLiAcc.ProfileImageUrl;
                 }
                 catch (Exception ex)
                 {
                     Console.WriteLine(ex.StackTrace);
                 }
             }
             else if (sp.ProfileType == "googleplus")
             {
                 try
                 {
                     GooglePlusAccountRepository objGpAccRepo            = new GooglePlusAccountRepository();
                     Domain.Socioboard.Domain.GooglePlusAccount objGpAcc = objGpAccRepo.getUserDetails(sp.ProfileId);
                     pc.ProfileName   = objGpAcc.GpUserName;
                     pc.ProfileImgUrl = objGpAcc.GpProfileImage;
                 }
                 catch (Exception ex)
                 {
                     Console.WriteLine(ex.StackTrace);
                 }
             }
             else if (sp.ProfileType == "tumblr")
             {
                 try
                 {
                     TumblrAccountRepository objTumblrAccountRepository      = new TumblrAccountRepository();
                     Domain.Socioboard.Domain.TumblrAccount objTumblrAccount = objTumblrAccountRepository.getTumblrAccountDetailsById(sp.ProfileId);
                     pc.ProfileName   = objTumblrAccount.tblrUserName;
                     pc.ProfileImgUrl = objTumblrAccount.tblrProfilePicUrl;
                 }
                 catch (Exception ex)
                 {
                     Console.WriteLine(ex.StackTrace);
                 }
             }
             else if (sp.ProfileType == "youtube")
             {
                 try
                 {
                     YoutubeAccountRepository objYoutubeAccountRepository      = new YoutubeAccountRepository();
                     Domain.Socioboard.Domain.YoutubeAccount objYoutubeAccount = objYoutubeAccountRepository.getYoutubeAccountDetailsById(sp.ProfileId);
                     pc.ProfileName   = objYoutubeAccount.Ytusername;
                     pc.ProfileImgUrl = objYoutubeAccount.Ytprofileimage;
                 }
                 catch (Exception ex)
                 {
                     Console.WriteLine(ex.StackTrace);
                 }
             }
             lstProfile.Add(pc);
         }
         return(new JavaScriptSerializer().Serialize(lstProfile));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
         return(new JavaScriptSerializer().Serialize("Please Try Again"));
     }
 }
示例#15
0
        public string AddTumblrAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string code)
        {
            string ret = string.Empty;
            string AccessTokenResponse = string.Empty;
            try
            {
                oAuthTumbler requestHelper = new oAuthTumbler();
                oAuthTumbler.TumblrConsumerKey = client_id;
                oAuthTumbler.TumblrConsumerSecret = client_secret;
                requestHelper.TumblrCallBackUrl = redirect_uri;
                AccessTokenResponse = requestHelper.GetAccessToken(oAuthTumbler.TumblrToken, code);
                logger.Error(AccessTokenResponse);

                string[] tokens = AccessTokenResponse.Split('&'); //extract access token & secret from response
                logger.Error(tokens);
                string accessToken = tokens[0].Split('=')[1];
                logger.Error(accessToken);
                string accessTokenSecret = tokens[1].Split('=')[1];
                logger.Error(accessTokenSecret);

                KeyValuePair<string, string> LoginDetails = new KeyValuePair<string, string>(accessToken, accessTokenSecret);

                JObject profile = new JObject();
                try
                {
                    profile = JObject.Parse(oAuthTumbler.OAuthData(Globals.UsersInfoUrl, "GET", LoginDetails.Key, LoginDetails.Value, null));
                }
                catch (Exception ex)
                {
                }


                #region Add Tumblr Account
                objTumblrAccount = new Domain.Socioboard.Domain.TumblrAccount();
                objTumblrAccount.Id = Guid.NewGuid();
                objTumblrAccount.tblrUserName = profile["response"]["user"]["name"].ToString();
                objTumblrAccount.UserId = Guid.Parse(UserId);
                objTumblrAccount.tblrAccessToken = accessToken;
                objTumblrAccount.tblrAccessTokenSecret = accessTokenSecret;
                objTumblrAccount.tblrProfilePicUrl = "http://api.tumblr.com/v2/blog/" + objTumblrAccount.tblrUserName + ".tumblr.com/avatar";//profile["response"]["user"]["name"].ToString();
                objTumblrAccount.IsActive = 1;
                if (!objTumblrAccountRepository.checkTubmlrUserExists(objTumblrAccount))
                {
                    TumblrAccountRepository.Add(objTumblrAccount);

                    #region Add Socialprofiles
                    objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
                    objSocialProfile.Id = Guid.NewGuid();
                    objSocialProfile.UserId = Guid.Parse(UserId);
                    objSocialProfile.ProfileId = profile["response"]["user"]["name"].ToString();
                    objSocialProfile.ProfileType = "tumblr";
                    objSocialProfile.ProfileDate = DateTime.Now;
                    objSocialProfile.ProfileStatus = 1;
                    if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                    {
                        objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
                    }
                    #endregion

                    #region Add TeamMemeberProfile
                    Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                    Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                    objTeamMemberProfile.Id = Guid.NewGuid();
                    objTeamMemberProfile.TeamId = objTeam.Id;
                    objTeamMemberProfile.Status = 1;
                    objTeamMemberProfile.ProfileType = "tumblr";
                    objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                    objTeamMemberProfile.ProfileId = objTumblrAccount.tblrUserName;

                    //Modified [13-02-15]
                    objTeamMemberProfile.ProfilePicUrl = objTumblrAccount.tblrProfilePicUrl;
                    objTeamMemberProfile.ProfileName = objTumblrAccount.tblrUserName;

                    objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                    #endregion
                }
                #endregion

              
                //if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeam.Id, objTumblrAccount.tblrUserName))
                //{
                //    objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                //}

                #region Add Tumblr Feeds
                AddTunblrFeeds(UserId, LoginDetails, profile["response"]["user"]["name"].ToString());
                #endregion

            }
            catch (Exception ex)
            {
                logger.Error("AddTumblrAccount => "+ex.StackTrace);
            }
            return ret;
        }
示例#16
0
        private static async Task<ISocialSiteAccount> GetSocialAccountFromGroupProfile(Guid objUserid, Domain.Socioboard.Domain.GroupProfile objGroupProfile)
        {
            ISocialSiteAccount objSocialSiteAccount = null;
            string accesstoken = string.Empty;
             try {
                accesstoken = System.Web.HttpContext.Current.Session["access_token"].ToString();
            }
            catch { }

            if (objGroupProfile.ProfileType == "facebook" || objGroupProfile.ProfileType == "facebook_page")
            {
                //using (Api.FacebookAccount.FacebookAccount ApiobjFacebookAccount = new Api.FacebookAccount.FacebookAccount())
                //{
                //    ApiobjFacebookAccount.Timeout = 300000;
                //    objSocialSiteAccount = (FacebookAccount)(new JavaScriptSerializer().Deserialize(ApiobjFacebookAccount.getFacebookAccountDetailsById(objUserid.ToString(), objGroupProfile.ProfileId.ToString()), typeof(FacebookAccount)));
                //}
                FacebookAccount fbaccount = new FacebookAccount();
                HttpResponseMessage fbresponse = await WebApiReq.GetReq("api/ApiFacebookAccount/GetFacebookAcoount?ProfileId=" + objGroupProfile.ProfileId, "Bearer", accesstoken);
                if (fbresponse.IsSuccessStatusCode)
                {
                    fbaccount = await fbresponse.Content.ReadAsAsync<Domain.Socioboard.Domain.FacebookAccount>();
                    objSocialSiteAccount = fbaccount;
                }
            }
            else if (objGroupProfile.ProfileType == "twitter")
            {
                //using (Api.TwitterAccount.TwitterAccount ApiobjTwitterAccount = new Api.TwitterAccount.TwitterAccount())
                //{

                //    ApiobjTwitterAccount.Timeout = 300000;
                //    objSocialSiteAccount = (TwitterAccount)(new JavaScriptSerializer().Deserialize(ApiobjTwitterAccount.GetTwitterAccountDetailsById(objUserid.ToString(), objGroupProfile.ProfileId.ToString()), typeof(TwitterAccount)));

                //}
                TwitterAccount twitterAcc = new TwitterAccount();
                HttpResponseMessage twitterresponse = await WebApiReq.GetReq("api/ApiTwitterAccount/GetTwitterAccountDetailsById?ProfileId=" + objGroupProfile.ProfileId, "Bearer", accesstoken);
                if (twitterresponse.IsSuccessStatusCode)
                {
                    twitterAcc = await twitterresponse.Content.ReadAsAsync<Domain.Socioboard.Domain.TwitterAccount>();
                    objSocialSiteAccount = twitterAcc;
                }
            }
            else if (objGroupProfile.ProfileType == "linkedin")
            {
                //using (Api.LinkedinAccount.LinkedinAccount ApiobjLinkedinAccount = new Api.LinkedinAccount.LinkedinAccount())
                //{

                //    ApiobjLinkedinAccount.Timeout = 300000;
                //    objSocialSiteAccount = (LinkedInAccount)(new JavaScriptSerializer().Deserialize(ApiobjLinkedinAccount.GetLinkedinAccountDetailsById(objUserid.ToString(), objGroupProfile.ProfileId.ToString()), typeof(LinkedInAccount)));

                //}
                LinkedInAccount LinkedinAcc = new LinkedInAccount();
                HttpResponseMessage Linkedinresponse = await WebApiReq.GetReq("api/ApiLinkedinAccount/GetLinkedinAccountDetailsById?ProfileId=" + objGroupProfile.ProfileId, "Bearer", accesstoken);
                if (Linkedinresponse.IsSuccessStatusCode)
                {
                    LinkedinAcc = await Linkedinresponse.Content.ReadAsAsync<Domain.Socioboard.Domain.LinkedInAccount>();
                    objSocialSiteAccount = LinkedinAcc;
                }

            }
            else if (objGroupProfile.ProfileType == "instagram")
            {
                //using (Api.InstagramAccount.InstagramAccount ApiobjInstagramAccount = new Api.InstagramAccount.InstagramAccount())
                //{
                //    objSocialSiteAccount = (InstagramAccount)(new JavaScriptSerializer().Deserialize(ApiobjInstagramAccount.UserInformation(objUserid.ToString(), objGroupProfile.ProfileId.ToString()), typeof(InstagramAccount)));

                //}
                InstagramAccount instAcc = new InstagramAccount();
                HttpResponseMessage response = await WebApiReq.GetReq("api/ApiInstagramAccount/GetInstagramAccount?ProfileId=" + objGroupProfile.ProfileId, "Bearer", accesstoken);
                if (response.IsSuccessStatusCode)
                {
                    instAcc = await response.Content.ReadAsAsync<Domain.Socioboard.Domain.InstagramAccount>();
                    objSocialSiteAccount = instAcc;
                }
            }
            else if (objGroupProfile.ProfileType == "youtube")
            {
                //using (Api.YoutubeAccount.YoutubeAccount ApiobjYoutubeAccount = new Api.YoutubeAccount.YoutubeAccount())
                //{

                //    ApiobjYoutubeAccount.Timeout = 300000;
                //    objSocialSiteAccount = (YoutubeAccount)(new JavaScriptSerializer().Deserialize(ApiobjYoutubeAccount.GetYoutubeAccountDetailsById(objUserid.ToString(), objGroupProfile.ProfileId.ToString()), typeof(YoutubeAccount)));

                //}

                YoutubeAccount ytAcc = new YoutubeAccount();
                HttpResponseMessage response = await WebApiReq.GetReq("api/ApiYoutubeAccount/GetYoutubeAccount?ProfileId=" + objGroupProfile.ProfileId, "Bearer", accesstoken);
                if (response.IsSuccessStatusCode)
                {
                    ytAcc = await response.Content.ReadAsAsync<Domain.Socioboard.Domain.YoutubeAccount>();
                    objSocialSiteAccount = ytAcc;
                }
            }
            else if (objGroupProfile.ProfileType == "tumblr")
            {
                //using (Api.TumblrAccount.TumblrAccount ApiobjTumblrAccount = new Api.TumblrAccount.TumblrAccount())
                //{

                //    ApiobjTumblrAccount.Timeout = 300000;
                //    objSocialSiteAccount = (TumblrAccount)(new JavaScriptSerializer().Deserialize(ApiobjTumblrAccount.GetTumblrAccountDetailsById(objUserid.ToString(), objGroupProfile.ProfileId.ToString()), typeof(TumblrAccount)));

                //}
                TumblrAccount ytAcc = new TumblrAccount();
                HttpResponseMessage response = await WebApiReq.GetReq("api/ApiTumblrAccount/GetTumblrAccountDetailsById?ProfileId=" + objGroupProfile.ProfileId, "Bearer", accesstoken);
                if (response.IsSuccessStatusCode)
                {
                    ytAcc = await response.Content.ReadAsAsync<Domain.Socioboard.Domain.TumblrAccount>();
                    objSocialSiteAccount = ytAcc;
                }

            }
            else if (objGroupProfile.ProfileType == "linkedincompanypage")
            {
                //using (Api.LinkedinCompanyPage.LinkedinCompanyPage objLinkedinCompanyPage = new Api.LinkedinCompanyPage.LinkedinCompanyPage())
                //{

                //    objLinkedinCompanyPage.Timeout = 300000;
                //    objSocialSiteAccount = (LinkedinCompanyPage)(new JavaScriptSerializer().Deserialize(objLinkedinCompanyPage.GetLinkedinCompanyPageDetailsByUserIdAndPageId(objUserid.ToString(), objGroupProfile.ProfileId.ToString()), typeof(LinkedinCompanyPage)));
                //}

                LinkedinCompanyPage licompanypage = new LinkedinCompanyPage();
                HttpResponseMessage response = await WebApiReq.GetReq("api/ApiLinkedinCompanyPage/GetLinkedinCompanyPageDetailsByUserIdAndPageId?ProfileId=" + objGroupProfile.ProfileId, "Bearer", accesstoken);
                if (response.IsSuccessStatusCode)
                {
                    licompanypage = await response.Content.ReadAsAsync<Domain.Socioboard.Domain.LinkedinCompanyPage>();
                    objSocialSiteAccount = licompanypage;
                }


            }
            else if (objGroupProfile.ProfileType == "gplus")
            {
                //using (Api.GooglePlusAccount.GooglePlusAccount ApiobjGooglePlusAccount = new Api.GooglePlusAccount.GooglePlusAccount())
                //{

                //    ApiobjGooglePlusAccount.Timeout = 300000;
                //    objSocialSiteAccount = (GooglePlusAccount)(new JavaScriptSerializer().Deserialize(ApiobjGooglePlusAccount.GetGooglePlusAccountDetailsById(objUserid.ToString(), objGroupProfile.ProfileId), typeof(GooglePlusAccount)));

                //}
                GooglePlusAccount googlePlusAccount = new GooglePlusAccount();
                HttpResponseMessage response = await WebApiReq.GetReq("api/ApiGooglePlusAccount/GetGooglePlusAccount?ProfileId=" + objGroupProfile.ProfileId, "Bearer", accesstoken);
                if (response.IsSuccessStatusCode)
                {
                    googlePlusAccount = await response.Content.ReadAsAsync<Domain.Socioboard.Domain.GooglePlusAccount>();
                    objSocialSiteAccount = googlePlusAccount;
                }
            }
            else if (objGroupProfile.ProfileType == "googleanalytics")
            {
                //using (Api.GoogleAnalyticsAccount.GoogleAnalyticsAccount ApiobjGoogleAnalyticsAccount = new Api.GoogleAnalyticsAccount.GoogleAnalyticsAccount())
                //{

                //    ApiobjGoogleAnalyticsAccount.Timeout = 300000;
                //    objSocialSiteAccount = (GoogleAnalyticsAccount)(new JavaScriptSerializer().Deserialize(ApiobjGoogleAnalyticsAccount.GetGooglePlusAccountDetailsById(objUserid.ToString(), objGroupProfile.ProfileId), typeof(GoogleAnalyticsAccount)));

                //}
                GoogleAnalyticsAccount googlePlusAccount = new GoogleAnalyticsAccount();
                HttpResponseMessage response = await WebApiReq.GetReq("api/ApiGoogleAnalyticsAccount/GetGooglePlusAccountDetailsById?ProfileId=" + objGroupProfile.ProfileId + "&UserId=" + objUserid.ToString(), "Bearer", accesstoken);
                if (response.IsSuccessStatusCode)
                {
                    googlePlusAccount = await response.Content.ReadAsAsync<Domain.Socioboard.Domain.GoogleAnalyticsAccount>();
                    objSocialSiteAccount = googlePlusAccount;
                }
            }


            return objSocialSiteAccount;
        }