示例#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.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
        }
示例#2
0
        public bool checkTumblrMessageExists(Domain.Socioboard.Domain.TumblrFeed tumblrFeed)
        {
            //Creates a database connection and opens up a session
            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                //Begin session trasaction and opens up.
                using (NHibernate.ITransaction transaction = session.BeginTransaction())
                {
                    try
                    {
                        //Proceed action, to get all data of facebook feed by user feed id and User id(Guid).
                        NHibernate.IQuery query = session.CreateQuery("from TumblrFeed where UserId = :userid and blogId = :msgid");
                        query.SetParameter("userid", tumblrFeed.UserId);
                        query.SetParameter("msgid", tumblrFeed.blogId);
                        var resutl = query.UniqueResult();

                        if (resutl == null)
                        {
                            return(false);
                        }
                        else
                        {
                            return(true);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        return(true);
                    }
                } //End Transaction
            }     //End session
        }
示例#3
0
        public void UpdateTumblrFeed(Domain.Socioboard.Domain.TumblrFeed tumblrFeed)
        {
            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                using (NHibernate.ITransaction transaction = session.BeginTransaction())
                {
                    try
                    {
                    }

                    catch (Exception)
                    {
                        throw;
                    }
                }
            }
        }
示例#4
0
 public static void Add(Domain.Socioboard.Domain.TumblrFeed tumblrFeed)
 {
     //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.
             try
             {
                 session.Save(tumblrFeed);
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 logger.Error("Add mien prob hai :" + ex.Message);
             }
         } //End Using trasaction
     }     //End Using session
 }
示例#5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="UserId">Tumblr User id</param>
        public string GetData(object UserId,string TumblrId)
        {
            string ret = string.Empty;
            Guid userId = (Guid)UserId;

            TumblrFeed objTumblrFeed = new TumblrFeed();
            Api.TumblrFeed.TumblrFeed ApiObjTumblrFeed = new Api.TumblrFeed.TumblrFeed();
            Api.TumblrAccount.TumblrAccount ApiObjTumblrAccount = new Api.TumblrAccount.TumblrAccount();
            //List<TumblrAccount> lstTumblrAccount = new List<TumblrAccount>();

            List<Domain.Socioboard.Domain.TumblrAccount> lstTumblrAccount = (List<Domain.Socioboard.Domain.TumblrAccount>)(new JavaScriptSerializer().Deserialize(ApiObjTumblrAccount.GetAllTumblrAccountsOfUser(userId.ToString()), typeof(List<Domain.Socioboard.Domain.TumblrAccount>)));


            foreach (TumblrAccount lstItem in lstTumblrAccount)
            {
                Api.Tumblr.Tumblr ApiObjTumblr = new Api.Tumblr.Tumblr();
                ret = ApiObjTumblr.getTumblrData(lstItem.UserId.ToString(), lstItem.tblrUserName);
                             
            }
            return ret;
        }
示例#6
0
 public Domain.Socioboard.Domain.TumblrFeed getFeedOfProfilebyIdProfileId(string profileid, Guid id)
 {
     Domain.Socioboard.Domain.TumblrFeed result = new Domain.Socioboard.Domain.TumblrFeed();
     //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.TumblrFeed> objlstfb = session.CreateQuery("from TumblrFeed where  ProfileId = :profid and Id=:id ")
                                                                   .SetParameter("profid", profileid)
                                                                   .SetParameter("id", id)
                                                                   .List <Domain.Socioboard.Domain.TumblrFeed>().ToList <Domain.Socioboard.Domain.TumblrFeed>();
             if (objlstfb.Count > 0)
             {
                 result = objlstfb[0];
             }
             return(result);
         } //End Transaction
     }     //End session
 }
示例#7
0
        private void AddTunblrFeeds(string UserId, KeyValuePair <string, string> LoginDetails, string username)
        {
            JObject UserDashboard = JObject.Parse(oAuthTumbler.OAuthData(Globals.UsersDashboardUrl, "GET", LoginDetails.Key, LoginDetails.Value, null));
            JArray  objJarray     = (JArray)UserDashboard["response"]["posts"];

            foreach (var item in objJarray)
            {
                objTumblrFeed        = new Domain.Socioboard.Domain.TumblrFeed();
                objTumblrFeed.Id     = Guid.NewGuid();
                objTumblrFeed.UserId = Guid.Parse(UserId);
                try
                {
                    objTumblrFeed.ProfileId = username;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    objTumblrFeed.blogname = item["blog_name"].ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    objTumblrFeed.blogId = item["id"].ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    objTumblrFeed.blogposturl = item["post_url"].ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    String result = item["caption"].ToString();
                    objTumblrFeed.description = Regex.Replace(result, @"<[^>]*>", String.Empty);
                }
                catch (Exception ex)
                {
                    objTumblrFeed.description = null;
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    objTumblrFeed.slug = item["slug"].ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    objTumblrFeed.type = item["type"].ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    string   test = item["date"].ToString();
                    DateTime dt;
                    if (test.Contains("GMT"))
                    {
                        test = test.Replace("GMT", "").Trim().ToString();
                        dt   = Convert.ToDateTime(test);
                    }
                    else
                    {
                        test = test.Replace("GMT", "").Trim().ToString();
                        dt   = Convert.ToDateTime(test);
                    }
                    objTumblrFeed.date = dt;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    objTumblrFeed.reblogkey = item["reblog_key"].ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    string str = item["liked"].ToString();
                    if (str == "False")
                    {
                        objTumblrFeed.liked = 0;
                    }
                    else
                    {
                        objTumblrFeed.liked = 1;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    string str = item["followed"].ToString();
                    if (str == "false")
                    {
                        objTumblrFeed.followed = 0;
                    }
                    else
                    {
                        objTumblrFeed.followed = 1;
                    }
                    // objTumblrDashboard.followed = Convert.ToInt16(item["followed"]);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    objTumblrFeed.canreply = Convert.ToInt16(item["can_reply"]);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    objTumblrFeed.sourceurl = item["source_url"].ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    objTumblrFeed.sourcetitle = item["source_title"].ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    JArray asdasd12 = (JArray)item["photos"];
                    foreach (var item1 in asdasd12)
                    {
                        objTumblrFeed.imageurl = item1["original_size"]["url"].ToString();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    objTumblrFeed.videourl = item["permalink_url"].ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                try
                {
                    string str = item["note_count"].ToString();
                    objTumblrFeed.notes = Convert.ToInt16(str);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                objTumblrFeed.timestamp = DateTime.Now;
                if (!objTumblrFeedRepository.checkTumblrMessageExists(objTumblrFeed))
                {
                    try
                    {
                        TumblrFeedRepository.Add(objTumblrFeed);
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
        }
示例#8
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

        }
示例#9
0
        private void AddTunblrFeeds(string UserId, KeyValuePair<string, string> LoginDetails, string username)
        {
            JObject UserDashboard = JObject.Parse(oAuthTumbler.OAuthData(Globals.UsersDashboardUrl, "GET", LoginDetails.Key, LoginDetails.Value, null));
            JArray objJarray = (JArray)UserDashboard["response"]["posts"];
            foreach (var item in objJarray)
            {
                objTumblrFeed = new Domain.Socioboard.Domain.TumblrFeed();
                objTumblrFeed.Id = Guid.NewGuid();
                objTumblrFeed.UserId = Guid.Parse(UserId);
                try
                {
                    objTumblrFeed.ProfileId = username;

                }
                catch (Exception ex)
                {

                    Console.WriteLine(ex.Message);
                }
                try
                {
                    objTumblrFeed.blogname = item["blog_name"].ToString();
                }
                catch (Exception ex)
                {

                    Console.WriteLine(ex.Message);
                }
                try
                {
                    objTumblrFeed.blogId = item["id"].ToString();
                }
                catch (Exception ex)
                {

                    Console.WriteLine(ex.Message);
                }
                try
                {
                    objTumblrFeed.blogposturl = item["post_url"].ToString();
                }
                catch (Exception ex)
                {

                    Console.WriteLine(ex.Message);
                }
                try
                {
                    String result = item["caption"].ToString();
                    objTumblrFeed.description = Regex.Replace(result, @"<[^>]*>", String.Empty);
                }
                catch (Exception ex)
                {
                    objTumblrFeed.description = null;
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    objTumblrFeed.slug = item["slug"].ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    objTumblrFeed.type = item["type"].ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    string test = item["date"].ToString();
                    DateTime dt;
                    if (test.Contains("GMT"))
                    {
                        test = test.Replace("GMT", "").Trim().ToString();
                        dt = Convert.ToDateTime(test);
                    }
                    else
                    {
                        test = test.Replace("GMT", "").Trim().ToString();
                        dt = Convert.ToDateTime(test);
                    }
                    objTumblrFeed.date = dt;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    objTumblrFeed.reblogkey = item["reblog_key"].ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    string str = item["liked"].ToString();
                    if (str == "False")
                    {
                        objTumblrFeed.liked = 0;
                    }
                    else { objTumblrFeed.liked = 1; }

                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    string str = item["followed"].ToString();
                    if (str == "false")
                    {
                        objTumblrFeed.followed = 0;
                    }
                    else { objTumblrFeed.followed = 1; }
                    // objTumblrDashboard.followed = Convert.ToInt16(item["followed"]);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    objTumblrFeed.canreply = Convert.ToInt16(item["can_reply"]);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    objTumblrFeed.sourceurl = item["source_url"].ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    objTumblrFeed.sourcetitle = item["source_title"].ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    JArray asdasd12 = (JArray)item["photos"];
                    foreach (var item1 in asdasd12)
                    {
                        objTumblrFeed.imageurl = item1["original_size"]["url"].ToString();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                try
                {
                    objTumblrFeed.videourl = item["permalink_url"].ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                try
                {
                    string str = item["note_count"].ToString();
                    objTumblrFeed.notes = Convert.ToInt16(str);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                objTumblrFeed.timestamp = DateTime.Now;
                if (!objTumblrFeedRepository.checkTumblrMessageExists(objTumblrFeed))
                {
                    try
                    {
                        TumblrFeedRepository.Add(objTumblrFeed);
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }

        }
        public Domain.Socioboard.Domain.TumblrFeed getFeedOfProfilebyIdProfileId(string profileid, Guid id)
        {

            Domain.Socioboard.Domain.TumblrFeed result = new Domain.Socioboard.Domain.TumblrFeed();
            //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.TumblrFeed> objlstfb = session.CreateQuery("from TumblrFeed where  ProfileId = :profid and Id=:id ")
                           .SetParameter("profid", profileid)
                        .SetParameter("id", id)
                       .List<Domain.Socioboard.Domain.TumblrFeed>().ToList<Domain.Socioboard.Domain.TumblrFeed>();
                    if (objlstfb.Count > 0)
                    {
                        result = objlstfb[0];
                    }
                    return result;
                }//End Transaction
            }//End session
        }