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 }
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) { } } } }