public string InstagramLikeUnLike(string LikeCount, string IsLike, string FeedId, string InstagramId, string UserId) { string str = string.Empty; try { objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId, Guid.Parse(UserId)); LikesController objlikes = new LikesController(); int islike = Convert.ToInt32(IsLike); int LikeCounts = Convert.ToInt32(LikeCount); if (islike == 0) { islike = 1; bool dd = objlikes.PostUserLike(FeedId, objInstagramAccount.AccessToken); LikeCounts++; objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts); str = "unlike"; } else { islike = 0; bool i = objlikes.DeleteLike(FeedId, objInstagramAccount.AccessToken); LikeCounts = LikeCounts - 1; objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts); str = "like"; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } return(str); }
/// <updateInstagramUser> /// update InstagramUser account. /// </summary> /// <param name="insaccount">Set Values in a InstagramAccount Class Property and Pass the same Object of InstagramAccount Class.(Domain.InstagramAccount)</param> public void updateInstagramUser(Domain.Socioboard.Domain.InstagramAccount insaccount) { //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 Update InstagrameAccount // And Set the reuired paremeters to find the specific values. try { session.CreateQuery("Update InstagramAccount set InsUserName =:InsUserName,ProfileUrl=:ProfileUrl,AccessToken =:AccessToken,Followers =:Followers,FollowedBy=:FollowedBy,TotalImages=:TotalImages where InstagramId = :InstagramId and UserId = :userid") .SetParameter("InsUserName", insaccount.InsUserName) .SetParameter("ProfileUrl", insaccount.ProfileUrl) .SetParameter("AccessToken", insaccount.AccessToken) .SetParameter("Followers", insaccount.Followers) .SetParameter("FollowedBy", insaccount.FollowedBy) .SetParameter("TotalImages", insaccount.TotalImages) .SetParameter("InstagramId", insaccount.InstagramId) .SetParameter("userid", insaccount.UserId) .ExecuteUpdate(); transaction.Commit(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); // return 0; } } //End Transaction } //End session }
/// <getInstagramAccountById> /// Get Instagram account from database by InsId(String) /// </summary> /// <param name="InsId"> InsId InstagramAccount(String)</param> /// <returns>Return object of InstagramAccount Class with value of each member.</returns> public Domain.Socioboard.Domain.InstagramAccount getInstagramAccountById(string InsId) { //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 get Instagram account from database. NHibernate.IQuery query = session.CreateQuery("from InstagramAccount where InstagramId = :InstagramId"); query.SetParameter("InstagramId", InsId); Domain.Socioboard.Domain.InstagramAccount insAccount = new Domain.Socioboard.Domain.InstagramAccount(); foreach (Domain.Socioboard.Domain.InstagramAccount item in query.Enumerable <Domain.Socioboard.Domain.InstagramAccount>()) { insAccount = item; break; } return(insAccount); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(null); } } //End Transaction } //End session }
public string AddComment(string UserId, string FeedId, string Text, string InstagramId) { GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"], ConfigurationManager.AppSettings["InstagramClientSec"], ConfigurationManager.AppSettings["RedirectUrl"], "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", ""); oAuthInstagram _api = new oAuthInstagram(); _api = oAuthInstagram.GetInstance(configi); objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId, Guid.Parse(UserId)); CommentController objComment = new CommentController(); bool ret = objComment.PostCommentAdd(FeedId, Text, objInstagramAccount.AccessToken); return(""); }
/// <addInstagramUser> /// add a new account of Instagram for user. /// </summary> /// <param name="insaccount">Set Values in a InstagramAccount Class Property and Pass the same Object of InstagramAccount Class.(Domain.InstagramAccount)</param> public void addInstagramUser(Domain.Socioboard.Domain.InstagramAccount insaccount) { //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 Save data. session.Save(insaccount); transaction.Commit(); } //End Transaction } //End session }
public string UpdateInstagramAccountByAdmin(string ObjInstagram) { Domain.Socioboard.Domain.InstagramAccount ObjInstagramAccount = (Domain.Socioboard.Domain.InstagramAccount)(new JavaScriptSerializer().Deserialize(ObjInstagram, typeof(Domain.Socioboard.Domain.InstagramAccount))); try { objInstagramAccountRepository.updateInstagramUser(ObjInstagramAccount); return(new JavaScriptSerializer().Serialize("Update Successfully")); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(new JavaScriptSerializer().Serialize("Something went Wrong")); } }
public string getInstagramData(string UserId, string InstagramId) { Guid userId = Guid.Parse(UserId); InstagramAccountRepository objInstagramAccountRepository = new InstagramAccountRepository(); //LinkedInAccountRepository objLinkedInAccountRepository = new LinkedInAccountRepository(); Domain.Socioboard.Domain.InstagramAccount objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId, userId); GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"], ConfigurationManager.AppSettings["InstagramClientSec"], ConfigurationManager.AppSettings["RedirectUrl"], "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", ""); oAuthInstagram _api = new oAuthInstagram(); _api = oAuthInstagram.GetInstance(configi); GetIntagramImages(objInstagramAccount); return("Instagram Info is Updated successfully"); }
/// <getInstagramAccountDetailsById> /// Get Instagram Account Details by Insuserid(string) userId(Guid). /// </summary> /// <param name="Insuserid">Insuserid InstagramAccount(String)</param> /// <param name="userId">Insuserid InstagramAccount(Guid)</param> /// <returns>Return a object of FacebookMessage Class with value of each member.</returns> public Domain.Socioboard.Domain.InstagramAccount getInstagramAccountDetailsById(string Insuserid, 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 Instagram Account Details. NHibernate.IQuery query = session.CreateQuery("from InstagramAccount where InstagramId = :InstagramId and UserId = :UserId") .SetParameter("InstagramId", Insuserid) .SetParameter("UserId", userId); Domain.Socioboard.Domain.InstagramAccount result = (Domain.Socioboard.Domain.InstagramAccount)query.UniqueResult(); return(result); } //End Transaction } //End session }
public string SheduleInstagramMessage(string InstagramId, string UserId, string sscheduledmsgguid) { string str = string.Empty; try { objScheduledMessage = objScheduledMessageRepository.GetScheduledMessageDetails(Guid.Parse(sscheduledmsgguid)); objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId, Guid.Parse(UserId)); // oAuthInstagram Instagram_oauth = new oAuthInstagram(); // Instagram_oauth.ConsumerKey = System.Configuration.ConfigurationSettings.AppSettings["LiApiKey"].ToString(); //Instagram_oauth. } catch (Exception ex) { throw; } return(str); }
public string SheduleInstagramMessage(string InstagramId, string UserId, string sscheduledmsgguid) { string str = string.Empty; try { objScheduledMessage = objScheduledMessageRepository.GetScheduledMessageDetails(Guid.Parse(sscheduledmsgguid)); objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId, Guid.Parse(UserId)); // oAuthInstagram Instagram_oauth = new oAuthInstagram(); // Instagram_oauth.ConsumerKey = System.Configuration.ConfigurationSettings.AppSettings["LiApiKey"].ToString(); //Instagram_oauth. } catch (Exception ex) { throw; } return str; }
public Domain.Socioboard.Domain.InstagramAccount getInstagramAccountDetailsById(string Insuserid) { //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 Instagram Account Details. List <Domain.Socioboard.Domain.InstagramAccount> objlst = session.CreateQuery("from InstagramAccount where InstagramId = :InstagramId ") .SetParameter("InstagramId", Insuserid) .List <Domain.Socioboard.Domain.InstagramAccount>().ToList <Domain.Socioboard.Domain.InstagramAccount>(); Domain.Socioboard.Domain.InstagramAccount result = new Domain.Socioboard.Domain.InstagramAccount(); if (objlst.Count > 0) { result = objlst[0]; } return(result); } //End Transaction } //End session }
public string InstagramLikeUnLike(string LikeCount, string IsLike, string FeedId, string InstagramId, string UserId) { string str = string.Empty; GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"], ConfigurationManager.AppSettings["InstagramClientSec"], ConfigurationManager.AppSettings["RedirectUrl"], "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", ""); oAuthInstagram _api = new oAuthInstagram(); _api = oAuthInstagram.GetInstance(configi); try { objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId, Guid.Parse(UserId)); LikesController objlikes = new LikesController(); int islike = Convert.ToInt32(IsLike); int LikeCounts = Convert.ToInt32(LikeCount); if (islike == 0) { islike = 1; bool dd = objlikes.PostUserLike(FeedId, objInstagramAccount.AccessToken); LikeCounts++; objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts); str = "unlike"; } else { islike = 0; bool i = objlikes.DeleteLike(FeedId, objInstagramAccount.AccessToken); LikeCounts = LikeCounts - 1; objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts); str = "like"; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } return(str); }
public string getInstagramData(string UserId, string InstagramId) { Guid userId = Guid.Parse(UserId); InstagramAccountRepository objInstagramAccountRepository = new InstagramAccountRepository(); //LinkedInAccountRepository objLinkedInAccountRepository = new LinkedInAccountRepository(); Domain.Socioboard.Domain.InstagramAccount objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId, userId); GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"], ConfigurationManager.AppSettings["InstagramClientSec"], ConfigurationManager.AppSettings["RedirectUrl"], "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", ""); oAuthInstagram _api = new oAuthInstagram(); _api = oAuthInstagram.GetInstance(configi); GetIntagramImages(objInstagramAccount); #region UpdateTeammemberprofile Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile(); objTeamMemberProfile.ProfileName = objInstagramAccount.InsUserName; objTeamMemberProfile.ProfilePicUrl = objInstagramAccount.ProfileUrl; objTeamMemberProfile.ProfileId = objInstagramAccount.InstagramId; objTeamMemberProfileRepository.updateTeamMemberbyprofileid(objTeamMemberProfile); #endregion return("Instagram Info is Updated successfully"); }
public string AddComment(string UserId, string FeedId, string Text, string InstagramId) { GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"], ConfigurationManager.AppSettings["InstagramClientSec"], ConfigurationManager.AppSettings["RedirectUrl"], "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", ""); oAuthInstagram _api = new oAuthInstagram(); _api = oAuthInstagram.GetInstance(configi); objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId, Guid.Parse(UserId)); CommentController objComment = new CommentController(); bool ret = objComment.PostCommentAdd(FeedId, Text, objInstagramAccount.AccessToken); return ""; }
public string AddInstagramAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string code) { string ret = string.Empty; oAuthInstagram objInsta = new oAuthInstagram(); GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", client_id, client_secret, redirect_uri, "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", ""); oAuthInstagram _api=new oAuthInstagram (); _api = oAuthInstagram.GetInstance(configi); AccessToken access = new AccessToken(); access = _api.AuthGetAccessToken(code); #region InstagramAccount UserController objusercontroller = new UserController(); InstagramResponse<GlobusInstagramLib.App.Core.User> objuser = objusercontroller.GetUserDetails(access.user.id, access.access_token); objInstagramAccount = new Domain.Socioboard.Domain.InstagramAccount(); objInstagramAccount.AccessToken = access.access_token; objInstagramAccount.InstagramId = access.user.id; objInstagramAccount.ProfileUrl = access.user.profile_picture; objInstagramAccount.InsUserName = access.user.username; objInstagramAccount.TotalImages = objuser.data.counts.media; objInstagramAccount.FollowedBy = objuser.data.counts.followed_by; objInstagramAccount.Followers = objuser.data.counts.follows; objInstagramAccount.UserId = Guid.Parse(UserId); #endregion if (!objInstagramAccountRepository.checkInstagramUserExists(objInstagramAccount.InstagramId,Guid.Parse(UserId))) { objInstagramAccountRepository.addInstagramUser(objInstagramAccount); #region Add TeamMemberProfile 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 = "instagram"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = objInstagramAccount.InstagramId; //Modified [13-02-15] objTeamMemberProfile.ProfilePicUrl = objInstagramAccount.ProfileUrl; objTeamMemberProfile.ProfileName = objInstagramAccount.InsUserName; objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); #endregion #region SocialProfile Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile(); objSocialProfile.Id = Guid.NewGuid(); objSocialProfile.ProfileType = "instagram"; objSocialProfile.ProfileId = objInstagramAccount.InstagramId; objSocialProfile.UserId = Guid.Parse(UserId); objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 1; #endregion #region Add SocialProfile if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } #endregion ret = "Account Added Successfully"; } else { ret = "Account already Exist !"; } GetIntagramImages(objInstagramAccount); return ret; }
public string InstagramLikeUnLike(string LikeCount, string IsLike, string FeedId, string InstagramId, string UserId) { string str = string.Empty; try { objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId, Guid.Parse(UserId)); LikesController objlikes = new LikesController(); int islike = Convert.ToInt32(IsLike); int LikeCounts = Convert.ToInt32(LikeCount); if (islike == 0) { islike = 1; bool dd = objlikes.PostUserLike(FeedId,objInstagramAccount.AccessToken); LikeCounts++; objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts); str = "unlike"; } else { islike = 0; bool i = objlikes.DeleteLike(FeedId, objInstagramAccount.AccessToken); LikeCounts = LikeCounts - 1; objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts); str = "like"; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } return str; }
public ActionResult UpdateProfileDetails(string Network, string ProfileName) { if (Session["User"] != null) { Domain.Socioboard.Domain.User _User = (Domain.Socioboard.Domain.User)Session["User"]; if (_User.UserType != "SuperAdmin") { return(RedirectToAction("Index", "Index")); } } else { return(RedirectToAction("Index", "Index")); } string ReturnMessage = string.Empty; bool Status = false; if (Network == "Facebook") { Domain.Socioboard.Domain.FacebookAccount objfb = (FacebookAccount)Session["UpdateProfileData"]; objfb.IsActive = 1; objfb.FbUserName = ProfileName; string objFacebook = new JavaScriptSerializer().Serialize(objfb); Api.Facebook.Facebook ApiObjfb = new Api.Facebook.Facebook(); string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateFacebookAccountByAdmin(objFacebook), typeof(string))); ReturnMessage = FbMessage; } if (Network == "Twitter") { Status = true; Domain.Socioboard.Domain.TwitterAccount objfb = (TwitterAccount)Session["UpdateProfileData"]; objfb.IsActive = Status; objfb.TwitterScreenName = ProfileName; string objFacebook = new JavaScriptSerializer().Serialize(objfb); Api.Twitter.Twitter ApiObjfb = new Api.Twitter.Twitter(); string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateTwitterAccountByAdmin(objFacebook), typeof(string))); ReturnMessage = FbMessage; } if (Network == "Linkedin") { Status = true; Domain.Socioboard.Domain.LinkedInAccount objfb = (LinkedInAccount)Session["UpdateProfileData"]; objfb.IsActive = Status; objfb.LinkedinUserName = ProfileName; string objFacebook = new JavaScriptSerializer().Serialize(objfb); Api.Twitter.Twitter ApiObjfb = new Api.Twitter.Twitter(); string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateTwitterAccountByAdmin(objFacebook), typeof(string))); ReturnMessage = FbMessage; } if (Network == "Instagram") { Status = true; Domain.Socioboard.Domain.InstagramAccount objfb = (InstagramAccount)Session["UpdateProfileData"]; objfb.IsActive = Status; objfb.InsUserName = ProfileName; string objFacebook = new JavaScriptSerializer().Serialize(objfb); Api.Instagram.Instagram ApiObjfb = new Api.Instagram.Instagram(); string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateInstagramAccountByAdmin(objFacebook), typeof(string))); ReturnMessage = FbMessage; } //if (Network == "Tumblr") //{ // Status = true; // Domain.Socioboard.Domain.TwitterAccount objfb = (TwitterAccount)Session["UpdateProfileData"]; // objfb.IsActive = Status; // objfb.TwitterScreenName = ProfileName; // string objFacebook = new JavaScriptSerializer().Serialize(objfb); // Api.Twitter.Twitter ApiObjfb = new Api.Twitter.Twitter(); // string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateTwitterAccountByAdmin(objFacebook), typeof(string))); // ReturnMessage = FbMessage; //} if (Network == "Youtube") { Status = true; Domain.Socioboard.Domain.YoutubeAccount objfb = (YoutubeAccount)Session["UpdateProfileData"]; objfb.Isactive = 1; objfb.Ytusername = ProfileName; string objFacebook = new JavaScriptSerializer().Serialize(objfb); Api.Youtube.Youtube ApiObjfb = new Api.Youtube.Youtube(); string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateYouTubeAccountByAdmin(objFacebook), typeof(string))); ReturnMessage = FbMessage; } if (Network == "GooglePlus") { Status = true; Domain.Socioboard.Domain.GooglePlusAccount objfb = (GooglePlusAccount)Session["UpdateProfileData"]; objfb.IsActive = 1; objfb.GpUserName = ProfileName; string objFacebook = new JavaScriptSerializer().Serialize(objfb); Api.Twitter.Twitter ApiObjfb = new Api.Twitter.Twitter(); string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateTwitterAccountByAdmin(objFacebook), typeof(string))); ReturnMessage = FbMessage; } return(Content(ReturnMessage)); }
public string PostBlock(string FollowingId, string InstagramId) { Relationship _Relationship = new Relationship(); objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId); string ret = _Relationship.BlockUserPost(FollowingId, objInstagramAccount.AccessToken); return ""; }
public void GetInstagramFeeds(Domain.Socioboard.Domain.InstagramAccount objInsAccount) { try { GlobusInstagramLib.Instagram.Core.UsersMethods.Users userInstagram = new GlobusInstagramLib.Instagram.Core.UsersMethods.Users(); InstagramResponse <InstagramMedia[]> userinf2 = userInstagram.CurrentUserFeed("", "", "20", objInsAccount.AccessToken); InstagramResponse <Comment[]> usercmts = new InstagramResponse <Comment[]>(); objInstagramComment = new Domain.Socioboard.Domain.InstagramComment(); objInstagramFeed = new Domain.Socioboard.Domain.InstagramFeed(); CommentController objComment = new CommentController(); LikesController objLikes = new LikesController(); if (userinf2 != null) { for (int j = 0; j < userinf2.data.Count(); j++) { try { objInstagramFeed.EntryDate = DateTime.Now; try { objInstagramFeed.FeedDate = userinf2.data[j].created_time.ToString(); } catch { } try { objInstagramFeed.FeedId = userinf2.data[j].id; } catch { } try { objInstagramFeed.FeedImageUrl = userinf2.data[j].images.low_resolution.url.ToString(); } catch { } try { objInstagramFeed.InstagramId = objInsAccount.InstagramId; } catch { } try { objInstagramFeed.LikeCount = userinf2.data[j].likes.count; } catch { } try { objInstagramFeed.CommentCount = userinf2.data[j].comments.count; } catch { } try { string str = userinf2.data[j].user_has_liked.ToString(); if (str == "False") { objInstagramFeed.IsLike = 0; } else { objInstagramFeed.IsLike = 1; } } catch { } try { objInstagramFeed.AdminUser = userinf2.data[j].caption.from.username; } catch { } try { objInstagramFeed.Feed = userinf2.data[j].caption.text; } catch { } try { objInstagramFeed.ImageUrl = userinf2.data[j].caption.from.profile_picture; } catch { } try { objInstagramFeed.FromId = userinf2.data[j].caption.from.id; } catch { } try { objInstagramFeed.FeedUrl = userinf2.data[j].link; } catch { } try { objInstagramFeed.UserId = objInsAccount.UserId; } catch { } if (!objInstagramFeedRepository.checkInstagramFeedExists(userinf2.data[j].id, objInsAccount.UserId)) { objInstagramFeedRepository.addInstagramFeed(objInstagramFeed); } usercmts = objComment.GetComment(userinf2.data[j].id, objInsAccount.AccessToken); for (int cmt = 0; cmt < usercmts.data.Count(); cmt++) { try { try { objInstagramComment.Comment = usercmts.data[cmt].text; } catch { } try { objInstagramComment.CommentDate = usercmts.data[cmt].created_time.ToString(); } catch { } try { objInstagramComment.CommentId = usercmts.data[cmt].id; } catch { } try { objInstagramComment.EntryDate = DateTime.Now; } catch { } try { objInstagramComment.FeedId = userinf2.data[j].id; } catch { } try { objInstagramComment.Id = Guid.NewGuid(); } catch { } try { objInstagramComment.InstagramId = objInsAccount.InstagramId; } catch { } try { objInstagramComment.UserId = objInsAccount.UserId; } catch { } try { objInstagramComment.FromName = usercmts.data[cmt].from.username; } catch { } try { objInstagramComment.FromProfilePic = usercmts.data[cmt].from.profile_picture; } catch { } if (!objInstagramCommentRepository.checkInstagramCommentExists(usercmts.data[cmt].id, objInsAccount.UserId)) { objInstagramCommentRepository.addInstagramComment(objInstagramComment); } } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } } } catch (Exception ex) { logger.Error(ex.Message); } } } } catch (Exception ex) { logger.Error(ex.Message); } }
public string InstagramLikeUnLike(string LikeCount, string IsLike, string FeedId, string InstagramId, string UserId) { MongoRepository instagramFeedRepo = new MongoRepository("InstagramFeed"); string str = string.Empty; //GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"], ConfigurationManager.AppSettings["InstagramClientSec"], ConfigurationManager.AppSettings["RedirectUrl"], "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", ""); //oAuthInstagram _api = new oAuthInstagram(); //_api = oAuthInstagram.GetInstance(configi); try { objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId); LikesController objlikes = new LikesController(); int islike = Convert.ToInt32(IsLike); int LikeCounts = Convert.ToInt32(LikeCount); if (islike == 0) { islike = 1; bool dd = objlikes.PostUserLike(FeedId, objInstagramAccount.AccessToken); LikeCounts++; //objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts); str = "unlike"; } else { islike = 0; bool i = objlikes.DeleteLike(FeedId, objInstagramAccount.AccessToken); LikeCounts = LikeCounts - 1; //objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts); str = "like"; } FilterDefinition<BsonDocument> filter = new BsonDocument("FeedId", FeedId); var update = Builders<BsonDocument>.Update.Set("IsLike", islike).Set("LikeCount", LikeCounts); instagramFeedRepo.Update<Domain.Socioboard.MongoDomain.InstagramFeed>(update, filter); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } return str; }
public string AddComment(string UserId, string FeedId, string Text, string InstagramId) { MongoRepository instagarmCommentRepo = new MongoRepository("InstagramComment"); Domain.Socioboard.MongoDomain.InstagramComment _InstagramComment = new Domain.Socioboard.MongoDomain.InstagramComment(); //GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"], ConfigurationManager.AppSettings["InstagramClientSec"], ConfigurationManager.AppSettings["RedirectUrl"], "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", ""); //oAuthInstagram _api = new oAuthInstagram(); //_api = oAuthInstagram.GetInstance(configi); objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId); CommentController objComment = new CommentController(); string ret = objComment.PostCommentAdd(FeedId, Text, objInstagramAccount.AccessToken); if (!string.IsNullOrEmpty(ret)) { try { JObject JData = JObject.Parse(ret); string commentid = JData["data"]["id"].ToString(); string time = JData["data"]["created_time"].ToString(); string profilepic = JData["data"]["from"]["profile_picture"].ToString(); string username = JData["data"]["from"]["username"].ToString(); _InstagramComment.Id = ObjectId.GenerateNewId(); _InstagramComment.strId = ObjectId.GenerateNewId().ToString(); _InstagramComment.FeedId = FeedId; _InstagramComment.InstagramId = InstagramId; _InstagramComment.FromProfilePic = profilepic; _InstagramComment.FromName = username; _InstagramComment.CommentDate = time; _InstagramComment.Comment = Text; _InstagramComment.CommentId = commentid; //objInstagramCommentRepository.addInstagramComment(_InstagramComment); instagarmCommentRepo.Add(_InstagramComment); } catch (Exception ex) { logger.Error(ex.Message); return null; } } else { return null; } return new JavaScriptSerializer().Serialize(_InstagramComment); }
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")); } }
public string AddInstagramAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string code) { string ret = string.Empty; oAuthInstagram objInsta = new oAuthInstagram(); GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", client_id, client_secret, redirect_uri, "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", ""); oAuthInstagram _api = new oAuthInstagram(); _api = oAuthInstagram.GetInstance(configi); AccessToken access = new AccessToken(); access = _api.AuthGetAccessToken(code); UserController objusercontroller = new UserController(); try { logger.Error("AddInstagramAccount == >>" + access.access_token); #region InstagramAccount InstagramResponse<GlobusInstagramLib.App.Core.User> objuser = objusercontroller.GetUserDetails(access.user.id, access.access_token); objInstagramAccount = new Domain.Socioboard.Domain.InstagramAccount(); objInstagramAccount.AccessToken = access.access_token; objInstagramAccount.InstagramId = access.user.id; try { objInstagramAccount.ProfileUrl = access.user.profile_picture; } catch (Exception ex) { logger.Error("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace); } try { objInstagramAccount.InsUserName = access.user.username; } catch (Exception ex) { logger.Error("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace); } try { objInstagramAccount.TotalImages = objuser.data.counts.media; } catch (Exception ex) { logger.Error("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace); } try { objInstagramAccount.FollowedBy = objuser.data.counts.followed_by; } catch (Exception ex) { logger.Error("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace); } try { objInstagramAccount.Followers = objuser.data.counts.follows; } catch (Exception ex) { logger.Error("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace); } objInstagramAccount.UserId = Guid.Parse(UserId); #endregion if (!objInstagramAccountRepository.checkInstagramUserExists(objInstagramAccount.InstagramId, Guid.Parse(UserId))) { objInstagramAccountRepository.addInstagramUser(objInstagramAccount); #region Add TeamMemberProfile //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 = "instagram"; //objTeamMemberProfile.StatusUpdateDate = DateTime.Now; //objTeamMemberProfile.ProfileId = objInstagramAccount.InstagramId; ////Modified [13-02-15] //objTeamMemberProfile.ProfilePicUrl = objInstagramAccount.ProfileUrl; //objTeamMemberProfile.ProfileName = objInstagramAccount.InsUserName; //objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); Domain.Socioboard.Domain.GroupProfile grpProfile = new Domain.Socioboard.Domain.GroupProfile(); grpProfile.Id = Guid.NewGuid(); grpProfile.EntryDate = DateTime.UtcNow; grpProfile.GroupId = Guid.Parse(GroupId); grpProfile.GroupOwnerId = Guid.Parse(UserId); grpProfile.ProfileId = objInstagramAccount.InstagramId; grpProfile.ProfileType = "instagram"; grpProfile.ProfileName = objInstagramAccount.InsUserName; grpProfile.ProfilePic = objInstagramAccount.ProfileUrl; grpProfileRepo.AddGroupProfile(grpProfile); #endregion #region SocialProfile Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile(); objSocialProfile.Id = Guid.NewGuid(); objSocialProfile.ProfileType = "instagram"; objSocialProfile.ProfileId = objInstagramAccount.InstagramId; objSocialProfile.UserId = Guid.Parse(UserId); objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 1; #endregion #region Add SocialProfile if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } #endregion ret = "Account Added Successfully"; } else { ret = "Account already Exist !"; } //GetIntagramImages(objInstagramAccount); GetInstagramFeeds(objInstagramAccount); GetInstagramUserDetails(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken); GetInstagramFollowing(objInstagramAccount.UserId.ToString(), objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1); GetInstagramFollower(objInstagramAccount.UserId.ToString(), objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1); GetInstagramPostLikes(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1); GetInstagramPostComments(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken); //GetInstagramUserPosts(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken); } catch (Exception ex) { logger.Error(ex.Message); } return ret; }
public static List<Domain.Socioboard.Domain.InstagramAccount> GetUserTeamMemberInstaProfiles() { User objUser = (User)System.Web.HttpContext.Current.Session["User"]; string groupid = System.Web.HttpContext.Current.Session["group"].ToString(); Api.InstagramAccount.InstagramAccount ApiInstaAccount = new Api.InstagramAccount.InstagramAccount(); List<Domain.Socioboard.Domain.TeamMemberProfile> lstTeamMemberProfile = new List<Domain.Socioboard.Domain.TeamMemberProfile>(); List<Domain.Socioboard.Domain.InstagramAccount> ret_InstaProfile = new List<Domain.Socioboard.Domain.InstagramAccount>(); Domain.Socioboard.Domain.InstagramAccount _InstaAccount = new Domain.Socioboard.Domain.InstagramAccount(); Api.Team.Team objApiTeam = new Api.Team.Team(); objApiTeam.Timeout = 300000; JObject team = JObject.Parse(objApiTeam.GetTeamByGroupId(System.Web.HttpContext.Current.Session["group"].ToString())); Api.TeamMemberProfile.TeamMemberProfile objApiTeamMemberProfile = new Api.TeamMemberProfile.TeamMemberProfile(); objApiTeamMemberProfile.Timeout = 300000; lstTeamMemberProfile = (List<Domain.Socioboard.Domain.TeamMemberProfile>)new JavaScriptSerializer().Deserialize(objApiTeamMemberProfile.GetTeamMemberProfilesByTeamId(Convert.ToString(team["Id"])), typeof(List<Domain.Socioboard.Domain.TeamMemberProfile>)); foreach (Domain.Socioboard.Domain.TeamMemberProfile team_member in lstTeamMemberProfile) { _InstaAccount = (Domain.Socioboard.Domain.InstagramAccount)new JavaScriptSerializer().Deserialize(ApiInstaAccount.UserInformation(objUser.Id.ToString(), team_member.ProfileId), typeof(Domain.Socioboard.Domain.InstagramAccount)); if (team_member.ProfileType == "instagram" && !string.IsNullOrEmpty(_InstaAccount.AccessToken)) { ret_InstaProfile.Add(_InstaAccount); } } return ret_InstaProfile; }
public string AddInstagramAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string code) { string ret = string.Empty; oAuthInstagram objInsta = new oAuthInstagram(); GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", client_id, client_secret, redirect_uri, "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", ""); oAuthInstagram _api = new oAuthInstagram(); _api = oAuthInstagram.GetInstance(configi); AccessToken access = new AccessToken(); access = _api.AuthGetAccessToken(code); #region InstagramAccount UserController objusercontroller = new UserController(); InstagramResponse <GlobusInstagramLib.App.Core.User> objuser = objusercontroller.GetUserDetails(access.user.id, access.access_token); objInstagramAccount = new Domain.Socioboard.Domain.InstagramAccount(); objInstagramAccount.AccessToken = access.access_token; objInstagramAccount.InstagramId = access.user.id; objInstagramAccount.ProfileUrl = access.user.profile_picture; objInstagramAccount.InsUserName = access.user.username; objInstagramAccount.TotalImages = objuser.data.counts.media; objInstagramAccount.FollowedBy = objuser.data.counts.followed_by; objInstagramAccount.Followers = objuser.data.counts.follows; objInstagramAccount.UserId = Guid.Parse(UserId); #endregion if (!objInstagramAccountRepository.checkInstagramUserExists(objInstagramAccount.InstagramId, Guid.Parse(UserId))) { objInstagramAccountRepository.addInstagramUser(objInstagramAccount); #region Add TeamMemberProfile 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 = "instagram"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = objInstagramAccount.InstagramId; //Modified [13-02-15] objTeamMemberProfile.ProfilePicUrl = objInstagramAccount.ProfileUrl; objTeamMemberProfile.ProfileName = objInstagramAccount.InsUserName; objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); #endregion #region SocialProfile Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile(); objSocialProfile.Id = Guid.NewGuid(); objSocialProfile.ProfileType = "instagram"; objSocialProfile.ProfileId = objInstagramAccount.InstagramId; objSocialProfile.UserId = Guid.Parse(UserId); objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 1; #endregion #region Add SocialProfile if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } #endregion ret = "Account Added Successfully"; } else { ret = "Account already Exist !"; } GetIntagramImages(objInstagramAccount); return(ret); }
public string InstagramLikeUnLike(string LikeCount, string IsLike, string FeedId, string InstagramId, string UserId) { string str = string.Empty; GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"], ConfigurationManager.AppSettings["InstagramClientSec"], ConfigurationManager.AppSettings["RedirectUrl"], "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", ""); oAuthInstagram _api = new oAuthInstagram(); _api = oAuthInstagram.GetInstance(configi); try { objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId, Guid.Parse(UserId)); LikesController objlikes = new LikesController(); int islike = Convert.ToInt32(IsLike); int LikeCounts = Convert.ToInt32(LikeCount); if (islike == 0) { islike = 1; bool dd = objlikes.PostUserLike(FeedId, objInstagramAccount.AccessToken); LikeCounts++; objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts); str = "unlike"; } else { islike = 0; bool i = objlikes.DeleteLike(FeedId, objInstagramAccount.AccessToken); LikeCounts = LikeCounts - 1; objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts); str = "like"; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } return str; }
public Domain.Socioboard.Domain.InstagramAccount getInstagramAccountDetailsById(string Insuserid) { //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 Instagram Account Details. List<Domain.Socioboard.Domain.InstagramAccount> objlst = session.CreateQuery("from InstagramAccount where InstagramId = :InstagramId ") .SetParameter("InstagramId", Insuserid) .List<Domain.Socioboard.Domain.InstagramAccount>().ToList<Domain.Socioboard.Domain.InstagramAccount>(); Domain.Socioboard.Domain.InstagramAccount result = new Domain.Socioboard.Domain.InstagramAccount(); if (objlst.Count > 0) { result = objlst[0]; } return result; }//End Transaction }//End session }
public string GetIntagramImages(Domain.Socioboard.Domain.InstagramAccount objInsAccount) { { InstagramResponse <GlobusInstagramLib.App.Core.User[]> userinf = new InstagramResponse <GlobusInstagramLib.App.Core.User[]>(); InstagramResponse <GlobusInstagramLib.App.Core.User[]> userinf1 = new InstagramResponse <GlobusInstagramLib.App.Core.User[]>(); InstagramResponse <InstagramMedia[]> userinf2 = new InstagramResponse <InstagramMedia[]>(); InstagramResponse <Comment[]> usercmts = new InstagramResponse <Comment[]>(); MediaController objMedia = new MediaController(); CommentController objComment = new CommentController(); LikesController objLikes = new LikesController(); objInstagramComment = new Domain.Socioboard.Domain.InstagramComment(); objInstagramFeed = new Domain.Socioboard.Domain.InstagramFeed(); string html = string.Empty; int i = 0; string[] allhtmls = new string[0]; int countofimages = 0; GlobusInstagramLib.Instagram.Core.UsersMethods.Users userInstagram = new GlobusInstagramLib.Instagram.Core.UsersMethods.Users(); try { userinf2 = userInstagram.UserRecentMedia(objInsAccount.InstagramId, string.Empty, string.Empty, "20", string.Empty, string.Empty, objInsAccount.AccessToken); } catch (Exception ex) { logger.Error(ex.StackTrace); } if (userinf2 != null) { for (int j = 0; j < userinf2.data.Count(); j++) { try { usercmts = objComment.GetComment(userinf2.data[j].id, objInsAccount.AccessToken); bool liked = false; try { //liked = objLikes.LikeToggle(userinf2.data[j].id, objInsAccount.InstagramId, objInsAccount.AccessToken); } catch (Exception ex) { logger.Error(ex.StackTrace); } int n = usercmts.data.Count(); for (int cmt = 0; cmt < usercmts.data.Count(); cmt++) { try { objInstagramComment.Comment = Uri.EscapeDataString(usercmts.data[cmt].text); objInstagramComment.CommentDate = usercmts.data[cmt].created_time.ToString(); objInstagramComment.CommentId = usercmts.data[cmt].id; objInstagramComment.EntryDate = DateTime.Now.ToString(); objInstagramComment.FeedId = userinf2.data[j].id; objInstagramComment.Id = Guid.NewGuid(); objInstagramComment.InstagramId = objInsAccount.InstagramId; objInstagramComment.UserId = objInsAccount.UserId; objInstagramComment.FromName = usercmts.data[cmt].from.full_name; objInstagramComment.FromProfilePic = usercmts.data[cmt].from.profile_picture; if (!objInstagramCommentRepository.checkInstagramCommentExists(usercmts.data[cmt].id, objInsAccount.UserId)) { objInstagramCommentRepository.addInstagramComment(objInstagramComment); } } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } } objInstagramFeed.EntryDate = DateTime.Now; try { objInstagramFeed.FeedDate = userinf2.data[j].created_time.ToString(); } catch (Exception ex) { logger.Error(ex.StackTrace); } try { objInstagramFeed.FeedId = userinf2.data[j].id; } catch (Exception ex) { logger.Error(ex.StackTrace); } try { objInstagramFeed.FeedImageUrl = userinf2.data[j].images.low_resolution.url.ToString(); } catch (Exception ex) { logger.Error(ex.StackTrace); } try { objInstagramFeed.InstagramId = objInsAccount.InstagramId; } catch (Exception ex) { logger.Error(ex.StackTrace); } try { objInstagramFeed.LikeCount = userinf2.data[j].likes.count; } catch (Exception ex) { logger.Error(ex.StackTrace); } try { objInstagramFeed.UserId = objInsAccount.UserId; } catch (Exception ex) { logger.Error(ex.StackTrace); } try { objInstagramFeed.CommentCount = userinf2.data[j].comments.count; } catch (Exception ex) { logger.Error(ex.StackTrace); } try { string str = userinf2.data[j].user_has_liked.ToString(); if (str == "False") { objInstagramFeed.IsLike = 0; } else { objInstagramFeed.IsLike = 1; } } catch (Exception ex) { logger.Error(ex.StackTrace); } try { objInstagramFeed.AdminUser = userinf2.data[j].caption.from.username; } catch (Exception ex) { logger.Error(ex.StackTrace); } if (!objInstagramFeedRepository.checkInstagramFeedExists(userinf2.data[j].id, objInsAccount.UserId)) { objInstagramFeedRepository.addInstagramFeed(objInstagramFeed); } } catch (Exception ex) { logger.Error(ex.StackTrace); } i++; } } try { userinf2 = userInstagram.CurrentUserFeed(string.Empty, string.Empty, "20", objInsAccount.AccessToken); } catch (Exception ex) { logger.Error(ex.StackTrace); } if (userinf2 != null) { for (int j = 0; j < userinf2.data.Count(); j++) { try { usercmts = objComment.GetComment(userinf2.data[j].id, objInsAccount.AccessToken); bool liked = false; try { // liked = objLikes.LikeToggle(userinf2.data[j].id, objInsAccount.InstagramId, objInsAccount.AccessToken); } catch (Exception ex) { logger.Error(ex.StackTrace); } int n = usercmts.data.Count(); for (int cmt = 0; cmt < usercmts.data.Count(); cmt++) { try { objInstagramComment.Comment = Uri.EscapeDataString(usercmts.data[cmt].text); objInstagramComment.CommentDate = usercmts.data[cmt].created_time.ToString(); objInstagramComment.CommentId = usercmts.data[cmt].id; objInstagramComment.EntryDate = DateTime.Now.ToString(); objInstagramComment.FeedId = userinf2.data[j].id; objInstagramComment.Id = Guid.NewGuid(); objInstagramComment.InstagramId = objInsAccount.InstagramId; objInstagramComment.UserId = objInsAccount.UserId; objInstagramComment.FromName = usercmts.data[cmt].from.full_name; objInstagramComment.FromProfilePic = usercmts.data[cmt].from.profile_picture; if (!objInstagramCommentRepository.checkInstagramCommentExists(usercmts.data[cmt].id, objInsAccount.UserId)) { objInstagramCommentRepository.addInstagramComment(objInstagramComment); } } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } } objInstagramFeed.EntryDate = DateTime.Now; objInstagramFeed.FeedDate = userinf2.data[j].created_time.ToString(); objInstagramFeed.FeedId = userinf2.data[j].id; objInstagramFeed.FeedImageUrl = userinf2.data[j].images.low_resolution.url.ToString(); objInstagramFeed.InstagramId = objInsAccount.InstagramId; objInstagramFeed.LikeCount = userinf2.data[j].likes.count; objInstagramFeed.CommentCount = userinf2.data[j].comments.count; string str = userinf2.data[j].user_has_liked.ToString(); if (str == "False") { objInstagramFeed.IsLike = 0; } else { objInstagramFeed.IsLike = 1; } objInstagramFeed.AdminUser = userinf2.data[j].caption.from.username + "-" + userinf2.data[j].caption.from.full_name; objInstagramFeed.UserId = objInsAccount.UserId; if (!objInstagramFeedRepository.checkInstagramFeedExists(userinf2.data[j].id, objInsAccount.UserId)) { objInstagramFeedRepository.addInstagramFeed(objInstagramFeed); } } catch (Exception ex) { logger.Error(ex.StackTrace); } i++; } } i++; string totalhtml = string.Empty; try { for (int k = 0; k < countofimages; k++) { totalhtml = totalhtml + allhtmls[k]; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } // Session["AllHtmls"] = allhtmls; return(totalhtml); } }
/// <getInstagramAccountById> /// Get Instagram account from database by InsId(String) /// </summary> /// <param name="InsId"> InsId InstagramAccount(String)</param> /// <returns>Return object of InstagramAccount Class with value of each member.</returns> public Domain.Socioboard.Domain.InstagramAccount getInstagramAccountById(string InsId) { //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 get Instagram account from database. NHibernate.IQuery query = session.CreateQuery("from InstagramAccount where InstagramId = :InstagramId"); query.SetParameter("InstagramId", InsId); Domain.Socioboard.Domain.InstagramAccount insAccount = new Domain.Socioboard.Domain.InstagramAccount(); foreach (Domain.Socioboard.Domain.InstagramAccount item in query.Enumerable<Domain.Socioboard.Domain.InstagramAccount>()) { insAccount = item; break; } return insAccount; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return null; } }//End Transaction }//End session }
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; }