Exemplo n.º 1
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.Myfashion.Domain.TumblrAccount ObjTumblrAccount = objTumblrAccountRepository.getTumblrAccountDetailsById(Tumblrid, userId);
            #region UpdateTeammemberprofile
            Domain.Myfashion.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Myfashion.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.Myfashion.Domain.TumblrFeed tumblrTumblrFeed = new Domain.Myfashion.Domain.TumblrFeed();
            TumblrFeedRepository.Add(tumblrTumblrFeed);
            return("Tumblr info is updated successfully");
            //Obj_oAuthTumbler.TumblrOAuthVerifier=ObjTumblrAccount.tbl
        }
        public Domain.Myfashion.Domain.TumblrAccount getTumblrAccountDetailsById(string tumblruserid)
        {

            Domain.Myfashion.Domain.TumblrAccount result = new Domain.Myfashion.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.Myfashion.Domain.TumblrAccount> objlsttumb = session.CreateQuery("from TumblrAccount where tblrUserName = :tblruname")
                            .SetParameter("tblruname", tumblruserid)
                       .List<Domain.Myfashion.Domain.TumblrAccount>().ToList<Domain.Myfashion.Domain.TumblrAccount>();
                    if (objlsttumb.Count > 0)
                    {
                        result = objlsttumb[0];
                    }
                    return result;
                }//End Transaction
            }//End s


        }
        public bool checkTubmlrUserExists(Domain.Myfashion.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.Myfashion.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;
             }
         }
     }
 }
Exemplo n.º 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.Myfashion.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);
        }
Exemplo n.º 6
0
 public string UpdateTumblrAccountByAdmin(string ObjTumblr)
 {
     Domain.Myfashion.Domain.TumblrAccount ObjTumblrAccount = (Domain.Myfashion.Domain.TumblrAccount)(new JavaScriptSerializer().Deserialize(ObjTumblr, typeof(Domain.Myfashion.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"));
     }
 }
 public static void Add(Domain.Myfashion.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.Myfashion.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.Myfashion.Domain.TumblrAccount result = (Domain.Myfashion.Domain.TumblrAccount)query.UniqueResult();
             return(result);
         } //End Transaction
     }     //End session
 }
Exemplo n.º 9
0
        public string TumblrComposeMessage(String message, String profileid, string userid, string currentdatetime, string picurl)
        {
            string ret = "";

            Domain.Myfashion.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();

            if (!string.IsNullOrEmpty(picurl))
            {
                objPublishedPosts.PostData(objTumblrAccount.tblrAccessToken, objTumblrAccount.tblrAccessTokenSecret, profileid, message, picurl, "photo");
            }
            else
            {
                objPublishedPosts.PostData(objTumblrAccount.tblrAccessToken, objTumblrAccount.tblrAccessTokenSecret, profileid, message, "", "text");
            }
            return(ret);
        }
 public Domain.Myfashion.Domain.TumblrAccount getTumblrAccountDetailsById(string tumblruserid)
 {
     Domain.Myfashion.Domain.TumblrAccount result = new Domain.Myfashion.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.Myfashion.Domain.TumblrAccount> objlsttumb = session.CreateQuery("from TumblrAccount where tblrUserName = :tblruname")
                                                                       .SetParameter("tblruname", tumblruserid)
                                                                       .List <Domain.Myfashion.Domain.TumblrAccount>().ToList <Domain.Myfashion.Domain.TumblrAccount>();
             if (objlsttumb.Count > 0)
             {
                 result = objlsttumb[0];
             }
             return(result);
         } //End Transaction
     }     //End s
 }
Exemplo n.º 11
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.Myfashion.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.Myfashion.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.Myfashion.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                    Domain.Myfashion.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Myfashion.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);
        }
        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.Myfashion.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.Myfashion.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.Myfashion.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                    Domain.Myfashion.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Myfashion.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;
        }