コード例 #1
0
        public bool checkTumblrMessageExists(Domain.Myfashion.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
        }
コード例 #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.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
        }
コード例 #3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="UserId">Tumblr User id</param>
 public string GetData(object UserId,string TumblrId)
 {
     string ret = string.Empty;
     try
     {
         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<Domain.Myfashion.Domain.TumblrAccount> lstTumblrAccount = (List<Domain.Myfashion.Domain.TumblrAccount>)(new JavaScriptSerializer().Deserialize(ApiObjTumblrAccount.GetAllTumblrAccountsOfUser(userId.ToString()), typeof(List<Domain.Myfashion.Domain.TumblrAccount>)));
         foreach (TumblrAccount lstItem in lstTumblrAccount)
         {
             try
             {
                 Api.Tumblr.Tumblr ApiObjTumblr = new Api.Tumblr.Tumblr();
                 ret = ApiObjTumblr.getTumblrData(lstItem.UserId.ToString(), lstItem.tblrUserName);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.Message);
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     return ret;
 }
コード例 #4
0
        public void UpdateTumblrFeed(Domain.Myfashion.Domain.TumblrFeed tumblrFeed)
        {
            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                using (NHibernate.ITransaction transaction = session.BeginTransaction())
                {
                    try
                    {
                    }

                    catch (Exception)
                    {
                        throw;
                    }
                }
            }
        }
コード例 #5
0
 public static void Add(Domain.Myfashion.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
 }
コード例 #6
0
 public Domain.Myfashion.Domain.TumblrFeed getFeedOfProfilebyIdProfileId(string profileid, Guid id)
 {
     Domain.Myfashion.Domain.TumblrFeed result = new Domain.Myfashion.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.Myfashion.Domain.TumblrFeed> objlstfb = session.CreateQuery("from TumblrFeed where  ProfileId = :profid and Id=:id ")
                                                                  .SetParameter("profid", profileid)
                                                                  .SetParameter("id", id)
                                                                  .List <Domain.Myfashion.Domain.TumblrFeed>().ToList <Domain.Myfashion.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)
        {
            int     I             = 0;
            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.Myfashion.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))
                {
                    I++;
                    try
                    {
                        TumblrFeedRepository.Add(objTumblrFeed);
                        logger.Error("objTumblrFeedCount>>>" + I);
                    }
                    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.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

        }
コード例 #9
0
        private void AddTunblrFeeds(string UserId, KeyValuePair<string, string> LoginDetails, string username)
        {
            int I = 0;
            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.Myfashion.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))
                {
                    I++;
                    try
                    {
                        
                        TumblrFeedRepository.Add(objTumblrFeed);
                        logger.Error("objTumblrFeedCount>>>"+I);
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }

        }
コード例 #10
0
        public Domain.Myfashion.Domain.TumblrFeed getFeedOfProfilebyIdProfileId(string profileid, Guid id)
        {

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