public string AddTeamMemberProfile(string TeamId, string ProfileId, string ProfileType, string Status) { try { if (!teammemberrepo.checkTeamMemberProfile(Guid.Parse(TeamId), ProfileId)) { teammember.Id = Guid.NewGuid(); teammember.TeamId = Guid.Parse(TeamId); teammember.ProfileId = ProfileId; teammember.ProfileType = ProfileType; teammember.Status = Convert.ToInt32(Status); teammember.StatusUpdateDate = DateTime.Now; teammemberrepo.addNewTeamMember(teammember); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return("Something Went Wrong"); } return(new JavaScriptSerializer().Serialize(teammember)); }
public string AddProfileToGroup(string profileid, string network, string groupid, string userid) { objGroupProfile = new Domain.Myfashion.Domain.GroupProfile(); objGroupProfile.Id = Guid.NewGuid(); objGroupProfile.GroupId = Guid.Parse(groupid); objGroupProfile.ProfileId = profileid; objGroupProfile.GroupOwnerId = Guid.Parse(userid); objGroupProfile.ProfileType = network; objGroupProfile.EntryDate = DateTime.Now; objGroupProfileRepository.AddGroupProfile(objGroupProfile); objTeam = new Domain.Myfashion.Domain.Team(); objTeam = objTeamRepository.GetAllTeam(Guid.Parse(groupid), Guid.Parse(userid)); objTeamMemberProfile = new Domain.Myfashion.Domain.TeamMemberProfile(); objTeamMemberProfile.Id = Guid.NewGuid(); objTeamMemberProfile.TeamId = objTeam.Id; objTeamMemberProfile.ProfileId = profileid; objTeamMemberProfile.ProfileType = network; objTeamMemberProfile.Status = 1; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); 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.Myfashion.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.Myfashion.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId)); Domain.Myfashion.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Myfashion.Domain.TeamMemberProfile(); objTeamMemberProfile.Id = Guid.NewGuid(); objTeamMemberProfile.TeamId = objTeam.Id; objTeamMemberProfile.Status = 1; objTeamMemberProfile.ProfileType = "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.Myfashion.Domain.SocialProfile objSocialProfile = new Domain.Myfashion.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); return(ret); }
public string AddLinkedinAccount(string oauth_token, string oauth_verifier, string reuqestTokenSecret, string consumerKey, string consumerSecret, string UserId, string GroupId) { try { logger.Error("AddLinkedinAccount()"); System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls; string ret = string.Empty; LinkedInProfile objProfile = new LinkedInProfile(); LinkedInProfile.UserProfile objUserProfile = new LinkedInProfile.UserProfile(); objSocialProfile = new Domain.Myfashion.Domain.SocialProfile(); oAuthLinkedIn _oauth = new oAuthLinkedIn(); objLinkedInAccount = new LinkedInAccount(); #region Get linkedin Profile data from Api try { _oauth.ConsumerKey = consumerKey; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.ConsumerSecret = consumerSecret; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.Token = oauth_token; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.TokenSecret = reuqestTokenSecret; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.Verifier = oauth_verifier; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.AccessTokenGet(oauth_token); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { objUserProfile = objProfile.GetUserProfile(_oauth); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } #endregion dynamic data = objUserProfile; try { #region LinkedInAccount objLinkedInAccount.UserId = Guid.Parse(UserId); objLinkedInAccount.LinkedinUserId = data.id.ToString(); try { objLinkedInAccount.EmailId = data.email.ToString(); } catch (Exception ex) { logger.Error(ex.StackTrace); } objLinkedInAccount.LinkedinUserName = data.first_name.ToString() + data.last_name.ToString(); objLinkedInAccount.OAuthToken = _oauth.Token; objLinkedInAccount.OAuthSecret = _oauth.TokenSecret; objLinkedInAccount.OAuthVerifier = _oauth.Verifier; try { objLinkedInAccount.ProfileImageUrl = data.picture_url.ToString(); } catch (Exception ex) { logger.Error(ex.StackTrace); } try { objLinkedInAccount.ProfileUrl = data.profile_url.ToString(); } catch (Exception ex) { logger.Error(ex.StackTrace); } #endregion #region SocialProfiles try { objLinkedInAccount.Connections = data.connections; objLinkedInAccount.IsActive = true; objSocialProfile.UserId = Guid.Parse(UserId); objSocialProfile.ProfileType = "linkedin"; objSocialProfile.ProfileId = data.id.ToString(); objSocialProfile.ProfileStatus = 1; objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.Id = Guid.NewGuid(); } catch (Exception ex) { logger.Error(ex.Message); } #endregion SocialProfiles #region Add TeamMemberProfile try { Domain.Myfashion.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId)); objTeamMemberProfile = new Domain.Myfashion.Domain.TeamMemberProfile(); objTeamMemberProfile.Id = Guid.NewGuid(); objTeamMemberProfile.TeamId = objTeam.Id; objTeamMemberProfile.Status = 1; objTeamMemberProfile.ProfileType = "linkedin"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = objLinkedInAccount.LinkedinUserId; objTeamMemberProfile.ProfileName = objLinkedInAccount.LinkedinUserName; objTeamMemberProfile.ProfilePicUrl = objLinkedInAccount.ProfileImageUrl; } catch (Exception ex) { logger.Error(ex.Message); } #endregion } catch (Exception ex) { logger.Error(ex.StackTrace); } try { if (!objLinkedInAccountRepository.checkLinkedinUserExists(objLinkedInAccount.LinkedinUserId, Guid.Parse(UserId))) { objLinkedInAccountRepository.addLinkedinUser(objLinkedInAccount); ret = "LinkedIn Account Added Successfully"; } else { ret = "LinkedIn Account Already Exist"; } if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeamMemberProfile.TeamId, objLinkedInAccount.LinkedinUserId)) { objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); } #region Add LinkedIn Feeds LinkedInNetwork objln = new LinkedInNetwork(); List <LinkedInNetwork.Network_Updates> userUPdate = objln.GetNetworkUpdates(_oauth, 20); foreach (var item in userUPdate) { try { objLinkedInFeed = new Domain.Myfashion.Domain.LinkedInFeed(); objLinkedInFeed.Feeds = item.Message; objLinkedInFeed.FromId = item.PersonId; objLinkedInFeed.FromName = item.PersonFirstName + " " + item.PersonLastName; objLinkedInFeed.FeedsDate = Convert.ToDateTime(item.DateTime); objLinkedInFeed.EntryDate = DateTime.Now; objLinkedInFeed.ProfileId = objLinkedInAccount.LinkedinUserId; objLinkedInFeed.Type = item.UpdateType; objLinkedInFeed.UserId = Guid.Parse(UserId); objLinkedInFeed.FromPicUrl = item.PictureUrl; objLinkedInFeed.ImageUrl = item.ImageUrl; objLinkedInFeed.FromUrl = item.url; } catch (Exception ex) { logger.Error(ex.StackTrace); } if (!objLinkedInFeedRepository.checkLinkedInFeedExists(objLinkedInFeed.FeedId, Guid.Parse(UserId))) { objLinkedInFeedRepository.addLinkedInFeed(objLinkedInFeed); } } #endregion #region Add LinkedIn UserUpdates GlobusLinkedinLib.App.Core.LinkedInUser l = new GlobusLinkedinLib.App.Core.LinkedInUser(); List <Domain.Myfashion.Domain.LinkedIn_Update_Messages> lst_Messages = l.GetUserUpdateNew(_oauth, objLinkedInAccount.LinkedinUserId, 10); foreach (var item_Messages in lst_Messages) { try { objLinkedInMessage = new Domain.Myfashion.Domain.LinkedInMessage(); objLinkedInMessage.Id = Guid.NewGuid(); objLinkedInMessage.Message = item_Messages.Message; objLinkedInMessage.ProfileId = item_Messages.ProfileId; objLinkedInMessage.ProfileName = item_Messages.ProfileName; objLinkedInMessage.CreatedDate = Convert.ToDateTime(item_Messages.CreatedDate); objLinkedInMessage.EntryDate = DateTime.Now; objLinkedInMessage.Type = item_Messages.Type; objLinkedInMessage.UserId = Guid.Parse(UserId); objLinkedInMessage.ImageUrl = item_Messages.ImageUrl; objLinkedInMessage.FeedId = item_Messages.FeedId; objLinkedInMessage.ProfileUrl = item_Messages.ProfileUrl; objLinkedInMessage.Comments = item_Messages.Comments; objLinkedInMessage.Likes = item_Messages.Likes; objLinkedInMessage.ProfileImageUrl = item_Messages.ProfileImageUrl; } catch (Exception ex) { logger.Error(ex.StackTrace); } if (!objLinkedInMessageRepository.checkLinkedInMessageExists(objLinkedInAccount.LinkedinUserId, objLinkedInMessage.FeedId, Guid.Parse(UserId))) { objLinkedInMessageRepository.addLinkedInMessage(objLinkedInMessage); } } #endregion } catch (Exception ex) { logger.Error(ex.StackTrace); } return(""); } catch (Exception ex) { logger.Error(ex.StackTrace); return(""); } }
private void AccessToken() { SocioBoard.Domain.User user = (User)Session["LoggedUser"]; oAuthTokenYoutube ObjoAuthTokenYoutube = new oAuthTokenYoutube(); oAuthToken objToken = new oAuthToken(); //GlobusGooglePlusLib.App.Core.PeopleController obj = new GlobusGooglePlusLib.App.Core.PeopleController(); logger.Error("Error1:oAuthToken"); string refreshToken = string.Empty; string access_token = string.Empty; try { string objRefresh = string.Empty; objRefresh = ObjoAuthTokenYoutube.GetRefreshToken(Request.QueryString["code"]); if (!objRefresh.StartsWith("[")) { objRefresh = "[" + objRefresh + "]"; } JArray objArray = JArray.Parse(objRefresh); logger.Error("Error1:GetRefreshToken"); if (!objRefresh.Contains("refresh_token")) { logger.Error("Error0:refresh_token"); access_token = objArray[0]["access_token"].ToString(); string abc = ObjoAuthTokenYoutube.RevokeToken(access_token); Response.Redirect("https://accounts.google.com/o/oauth2/auth?client_id=" + System.Configuration.ConfigurationManager.AppSettings["YtconsumerKey"] + "&redirect_uri=" + System.Configuration.ConfigurationManager.AppSettings["Ytredirect_uri"] + "&scope=https://www.googleapis.com/auth/youtube+https://www.googleapis.com/auth/youtube.readonly+https://www.googleapis.com/auth/youtubepartner+https://www.googleapis.com/auth/youtubepartner-channel-audit+https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/plus.me&response_type=code&access_type=offline"); logger.Error("Error1:refresh_token"); } foreach (var item in objArray) { logger.Error("Abhay Item :" + item); try { try { refreshToken = item["refresh_token"].ToString(); } catch (Exception ex) { logger.Error(ex.StackTrace); logger.Error(ex.Message); Console.WriteLine(ex.StackTrace); } access_token = item["access_token"].ToString(); break; } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } } //Get user Profile #region <<Get user Profile>> JArray objEmail = new JArray(); try { objEmail = objToken.GetUserInfo("me", access_token.ToString()); } catch (Exception ex) { logger.Error("Email : " + objEmail); logger.Error(ex.Message); } #endregion GlobusGooglePlusLib.Youtube.Core.Channels ObjChannel = new GlobusGooglePlusLib.Youtube.Core.Channels(); //Get the Channels of user JArray objarray = new JArray(); try { string part = (oAuthTokenYoutube.Parts.contentDetails.ToString() + "," + oAuthTokenYoutube.Parts.statistics.ToString()); string Value = ObjChannel.Get_Channel_List(access_token, part, 50, true); logger.Error("Successfully GetValus"); logger.Error("Value :" + Value); JObject UserChannels = JObject.Parse(@Value); logger.Error("Successfully Convert Jobj"); logger.Error("Successfully Convert Jobj"); objarray = (JArray)UserChannels["items"]; logger.Error("Successfully Convert JArr"); } catch (Exception ex) { logger.Error("UserChannels :" + ex.Message); } YoutubeAccount objYoutubeAccount = new YoutubeAccount(); YoutubeChannel objYoutubeChannel = new YoutubeChannel(); YoutubeChannelRepository objYoutubeChannelRepository = new YoutubeChannelRepository(); YoutubeAccountRepository objYoutubeAccountRepository = new YoutubeAccountRepository(); //put condition here to check is user already exise if exist then update else insert string ytuerid = ""; foreach (var itemEmail in objEmail) { logger.Error("itemEmail :" + itemEmail); try { objYoutubeAccount.Id = Guid.NewGuid(); ytuerid = itemEmail["id"].ToString(); objYoutubeAccount.Ytuserid = itemEmail["id"].ToString(); objYoutubeAccount.Emailid = itemEmail["email"].ToString(); objYoutubeAccount.Ytusername = itemEmail["given_name"].ToString(); objYoutubeAccount.Ytprofileimage = itemEmail["picture"].ToString(); objYoutubeAccount.Accesstoken = access_token; objYoutubeAccount.Refreshtoken = refreshToken; objYoutubeAccount.Isactive = 1; objYoutubeAccount.Entrydate = DateTime.Now; objYoutubeAccount.UserId = user.Id; } catch (Exception ex) { logger.Error("itemEmail1 :" + ex.Message); logger.Error("itemEmail1 :" + ex.StackTrace); Console.WriteLine(ex.StackTrace); } } foreach (var item in objarray) { try { objYoutubeChannel.Id = Guid.NewGuid(); objYoutubeChannel.Channelid = item["id"].ToString(); objYoutubeChannel.Likesid = item["contentDetails"]["relatedPlaylists"]["likes"].ToString(); objYoutubeChannel.Favoritesid = item["contentDetails"]["relatedPlaylists"]["favorites"].ToString(); objYoutubeChannel.Uploadsid = item["contentDetails"]["relatedPlaylists"]["uploads"].ToString(); objYoutubeChannel.Watchhistoryid = item["contentDetails"]["relatedPlaylists"]["watchHistory"].ToString(); objYoutubeChannel.Watchlaterid = item["contentDetails"]["relatedPlaylists"]["watchLater"].ToString(); objYoutubeChannel.Googleplususerid = ytuerid; try { string viewcnt = item["statistics"]["viewCount"].ToString(); objYoutubeChannel.ViewCount = Convert.ToInt32(viewcnt); string videocnt = item["statistics"]["videoCount"].ToString(); objYoutubeChannel.VideoCount = Convert.ToInt32(videocnt); string commentcnt = item["statistics"]["commentCount"].ToString(); objYoutubeChannel.CommentCount = Convert.ToInt32(commentcnt); string Subscribercnt = item["statistics"]["subscriberCount"].ToString(); objYoutubeChannel.SubscriberCount = Convert.ToInt32(Subscribercnt); try { string str = item["statistics"]["hiddenSubscriberCount"].ToString(); if (str == "false") { objYoutubeChannel.HiddenSubscriberCount = 0; } else { objYoutubeChannel.HiddenSubscriberCount = 1; } } catch (Exception ex) { logger.Error("aagaya1: " + ex); Console.WriteLine(ex.StackTrace); } } catch (Exception ex) { logger.Error("aagaya2: " + ex); Console.WriteLine(ex.StackTrace); } } catch (Exception ex) { logger.Error("aagaya3: " + ex); Console.WriteLine(ex.StackTrace); logger.Error(ex.StackTrace); logger.Error(ex.Message); } } //YoutubeChannelRepository.Add(objYoutubeChannel); SocialProfile objSocialProfile = new SocialProfile(); SocialProfilesRepository objSocialProfilesRepository = new SocialProfilesRepository(); objSocialProfile.Id = Guid.NewGuid(); objSocialProfile.UserId = user.Id; objSocialProfile.ProfileId = ytuerid; objSocialProfile.ProfileType = "youtube"; objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 1; logger.Error("aagaya"); if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); if (!objYoutubeAccountRepository.checkYoutubeUserExists(objYoutubeAccount)) { logger.Error("Abhay"); YoutubeAccountRepository.Add(objYoutubeAccount); logger.Error("Abhay account add ho gaya"); YoutubeChannelRepository.Add(objYoutubeChannel); logger.Error("Channel account add ho gaya"); GroupRepository objGroupRepository = new GroupRepository(); SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)HttpContext.Current.Session["GroupName"]; Groups lstDetails = objGroupRepository.getGroupName(team.GroupId); if (lstDetails.GroupName == "Socioboard") { TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository(); TeamMemberProfile teammemberprofile = new TeamMemberProfile(); teammemberprofile.Id = Guid.NewGuid(); teammemberprofile.TeamId = team.Id; teammemberprofile.ProfileId = objYoutubeAccount.Ytuserid; teammemberprofile.ProfileType = "youtube"; teammemberprofile.StatusUpdateDate = DateTime.Now; objTeamMemberProfileRepository.addNewTeamMember(teammemberprofile); } } } else { logger.Error("Suraj"); if (!objYoutubeAccountRepository.checkYoutubeUserExists(objYoutubeAccount)) { YoutubeAccountRepository.Add(objYoutubeAccount); YoutubeChannelRepository.Add(objYoutubeChannel); } else { Response.Redirect("Home.aspx"); } } Response.Redirect("Home.aspx"); } catch (Exception Err) { Console.Write(Err.Message.ToString()); logger.Error(Err.StackTrace); logger.Error(Err.Message); } }
public string AddGPlusAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string code) { string ret = string.Empty; string objRefresh = string.Empty; string refreshToken = string.Empty; string access_token = string.Empty; try { oAuthTokenGPlus ObjoAuthTokenGPlus = new oAuthTokenGPlus(); oAuthToken objToken = new oAuthToken(); objToken.ConsumerKey = client_id; objToken.ConsumerSecret = client_secret; try { objRefresh = ObjoAuthTokenGPlus.GetRefreshToken(code, client_id, client_secret, redirect_uri); logger.Error("vikash: ObjoAuthTokenGPlus()"); } catch (Exception ex) { } JObject objaccesstoken = JObject.Parse(objRefresh); try { refreshToken = objaccesstoken["refresh_token"].ToString(); } catch (Exception ex) { access_token = objaccesstoken["access_token"].ToString(); ObjoAuthTokenGPlus.RevokeToken(access_token); Console.WriteLine(ex.StackTrace); ret = "Refresh Token Not Found"; return(ret); } try { access_token = objaccesstoken["access_token"].ToString(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } JArray userinfo = new JArray(); try { userinfo = objToken.GetUserInfo("self", access_token.ToString()); } catch (Exception ex) { } Domain.Myfashion.Domain.GooglePlusAccount _GooglePlusAccount = new Domain.Myfashion.Domain.GooglePlusAccount(); foreach (var itemuserinfo in userinfo) { try { _GooglePlusAccount.Id = Guid.NewGuid(); _GooglePlusAccount.GpUserId = itemuserinfo["id"].ToString(); _GooglePlusAccount.GpUserName = itemuserinfo["name"].ToString(); _GooglePlusAccount.GpProfileImage = itemuserinfo["picture"].ToString(); _GooglePlusAccount.IsActive = 1; _GooglePlusAccount.ProfileType = "gplus"; _GooglePlusAccount.AccessToken = access_token; _GooglePlusAccount.RefreshToken = refreshToken; _GooglePlusAccount.EmailId = itemuserinfo["email"].ToString(); _GooglePlusAccount.UserId = Guid.Parse(UserId); _GooglePlusAccount.EntryDate = DateTime.Now; } catch (Exception ex) { logger.Error("AddGPlusAccount => GooglePlusAccount =>" + ex.Message); } } #region Get_InYourCircles try { string _InyourCircles = ObjoAuthTokenGPlus.APIWebRequestToGetUserInfo(Globals.strGetPeopleList.Replace("[userId]", _GooglePlusAccount.GpUserId).Replace("[collection]", "visible") + "?key=" + ConfigurationManager.AppSettings["Api_Key"].ToString(), access_token); JObject J_InyourCircles = JObject.Parse(_InyourCircles); _GooglePlusAccount.InYourCircles = Convert.ToInt32(J_InyourCircles["totalItems"].ToString()); } catch (Exception ex) { _GooglePlusAccount.InYourCircles = 0; } #endregion #region Get_HaveYouInCircles try { string _HaveYouInCircles = ObjoAuthTokenGPlus.APIWebRequestToGetUserInfo(Globals.strGetPeopleProfile + _GooglePlusAccount.GpUserId + "?key=" + ConfigurationManager.AppSettings["Api_Key"].ToString(), access_token); JObject J_HaveYouInCircles = JObject.Parse(_HaveYouInCircles); _GooglePlusAccount.HaveYouInCircles = Convert.ToInt32(J_HaveYouInCircles["circledByCount"].ToString()); } catch (Exception ex) { _GooglePlusAccount.HaveYouInCircles = 0; } #endregion #region Add GPlusAccount if (!objGooglePlusAccountRepository.checkGooglePlusUserExists(_GooglePlusAccount.GpUserId, _GooglePlusAccount.UserId)) { objGooglePlusAccountRepository.addGooglePlusUser(_GooglePlusAccount); #region Add TeamMemberProfile Domain.Myfashion.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId)); Domain.Myfashion.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Myfashion.Domain.TeamMemberProfile(); objTeamMemberProfile.Id = Guid.NewGuid(); objTeamMemberProfile.TeamId = objTeam.Id; objTeamMemberProfile.Status = 1; objTeamMemberProfile.ProfileType = "gplus"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = _GooglePlusAccount.GpUserId; objTeamMemberProfile.ProfilePicUrl = _GooglePlusAccount.GpProfileImage; objTeamMemberProfile.ProfileName = _GooglePlusAccount.GpUserName; objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); #endregion #region SocialProfile Domain.Myfashion.Domain.SocialProfile objSocialProfile = new Domain.Myfashion.Domain.SocialProfile(); objSocialProfile.Id = Guid.NewGuid(); objSocialProfile.ProfileType = "gplus"; objSocialProfile.ProfileId = _GooglePlusAccount.GpUserId; objSocialProfile.UserId = Guid.Parse(UserId); objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 1; if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } #endregion ret = "Account Added Successfully"; } else { ret = "Account already Exist !"; } #endregion GetUserActivities(UserId, _GooglePlusAccount.GpUserId, access_token); return(new JavaScriptSerializer().Serialize(_GooglePlusAccount)); } catch (Exception ex) { logger.Error(ex.Message); return(""); } }
/// <summary> /// /// </summary> private void getTwitterUserProfile() { var requestToken = (String)Request.QueryString["oauth_token"]; var requestSecret = (String)Session["requestSecret"]; var requestVerifier = (String)Request.QueryString["oauth_verifier"]; OAuth.AccessToken = requestToken; OAuth.AccessTokenSecret = requestVerifier; OAuth.AccessTokenGet(requestToken, requestVerifier); JArray profile = userinfo.Get_Users_LookUp_ByScreenName(OAuth, OAuth.TwitterScreenName); User user = (User)Session["LoggedUser"]; SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository(); SocialProfile socioprofile = new SocialProfile(); #region for managing referrals ManageReferrals(OAuth); #endregion foreach (var item in profile) { try { twitterAccount.FollowingCount = Convert.ToInt32(item["friends_count"].ToString()); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { twitterAccount.FollowersCount = Convert.ToInt32(item["followers_count"].ToString()); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } twitterAccount.Id = Guid.NewGuid(); twitterAccount.IsActive = true; twitterAccount.OAuthSecret = OAuth.AccessTokenSecret; twitterAccount.OAuthToken = OAuth.AccessToken; try { twitterAccount.ProfileImageUrl = item["profile_image_url"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { twitterAccount.ProfileUrl = string.Empty; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { twitterAccount.TwitterUserId = item["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception er) { try { twitterAccount.TwitterUserId = item["id"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception err) { Console.WriteLine(err.StackTrace); } Console.WriteLine(er.StackTrace); } try { twitterAccount.TwitterScreenName = item["screen_name"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } twitterAccount.UserId = user.Id; socioprofile.Id = Guid.NewGuid(); socioprofile.ProfileDate = DateTime.Now; socioprofile.ProfileId = twitterAccount.TwitterUserId; socioprofile.ProfileType = "twitter"; socioprofile.UserId = user.Id; if (HttpContext.Current.Session["login"] != null) { if (HttpContext.Current.Session["login"].ToString().Equals("twitter")) { User usr = new User(); UserRepository userrepo = new UserRepository(); Registration regObject = new Registration(); usr.AccountType = "free"; usr.CreateDate = DateTime.Now; usr.ExpiryDate = DateTime.Now.AddMonths(1); usr.Id = Guid.NewGuid(); usr.UserName = twitterAccount.TwitterName; usr.Password = regObject.MD5Hash(twitterAccount.TwitterName); usr.EmailId = ""; usr.UserStatus = 1; if (!userrepo.IsUserExist(usr.EmailId)) { UserRepository.Add(usr); } } } TwitterStatsRepository objTwtstats = new TwitterStatsRepository(); TwitterStats objStats = new TwitterStats(); Random rNum = new Random(); objStats.Id = Guid.NewGuid(); objStats.TwitterId = twitterAccount.TwitterUserId; objStats.UserId = user.Id; objStats.FollowingCount = twitterAccount.FollowingCount; objStats.FollowerCount = twitterAccount.FollowersCount; objStats.Age1820 = rNum.Next(twitterAccount.FollowersCount); objStats.Age2124 = rNum.Next(twitterAccount.FollowersCount); objStats.Age2534 = rNum.Next(twitterAccount.FollowersCount); objStats.Age3544 = rNum.Next(twitterAccount.FollowersCount); objStats.Age4554 = rNum.Next(twitterAccount.FollowersCount); objStats.Age5564 = rNum.Next(twitterAccount.FollowersCount); objStats.Age65 = rNum.Next(twitterAccount.FollowersCount); objStats.EntryDate = DateTime.Now; if (!objTwtstats.checkTwitterStatsExists(twitterAccount.TwitterUserId, user.Id)) { objTwtstats.addTwitterStats(objStats); } if (!twtrepo.checkTwitterUserExists(twitterAccount.TwitterUserId, user.Id)) { twtrepo.addTwitterkUser(twitterAccount); if (!socioprofilerepo.checkUserProfileExist(socioprofile)) { socioprofilerepo.addNewProfileForUser(socioprofile); GroupRepository objGroupRepository = new GroupRepository(); SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)HttpContext.Current.Session["GroupName"]; Groups lstDetails = objGroupRepository.getGroupName(team.GroupId); if (lstDetails.GroupName == "Socioboard") { TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository(); TeamMemberProfile teammemberprofile = new TeamMemberProfile(); teammemberprofile.Id = Guid.NewGuid(); teammemberprofile.TeamId = team.Id; teammemberprofile.ProfileId = twitterAccount.TwitterUserId; teammemberprofile.ProfileType = "twitter"; teammemberprofile.StatusUpdateDate = DateTime.Now; objTeamMemberProfileRepository.addNewTeamMember(teammemberprofile); } } else { socioprofilerepo.updateSocialProfile(socioprofile); } } else { HttpContext.Current.Session["alreadyexist"] = twitterAccount; twtrepo.updateTwitterUser(twitterAccount); TwitterMessageRepository twtmsgreponew = new TwitterMessageRepository(); twtmsgreponew.updateScreenName(twitterAccount.TwitterUserId, twitterAccount.TwitterScreenName); if (!socioprofilerepo.checkUserProfileExist(socioprofile)) { socioprofilerepo.addNewProfileForUser(socioprofile); } else { socioprofilerepo.updateSocialProfile(socioprofile); } } if (Session["UserAndGroupsForTwitter"] != null) { if (Session["UserAndGroupsForTwitter"].ToString() == "twitter") { try { if (Session["GroupName"] != null) { Groups group = (Groups)Session["GroupName"]; GroupProfile groupprofile = new GroupProfile(); GroupProfileRepository groupprofilerepo = new GroupProfileRepository(); groupprofile.Id = Guid.NewGuid(); groupprofile.ProfileId = socioprofile.ProfileId; groupprofile.ProfileType = "twitter"; groupprofile.GroupOwnerId = user.Id; groupprofile.EntryDate = DateTime.Now; groupprofile.GroupId = group.Id; if (!groupprofilerepo.checkGroupProfileExists(user.Id, group.Id, groupprofile.ProfileId)) { groupprofilerepo.AddGroupProfile(groupprofile); } } } catch (Exception e) { Console.WriteLine(e.StackTrace); } } } } }
public void getFacebookUserProfile(dynamic data, string accesstoken, long friends, Guid user) { SocialProfile socioprofile = new SocialProfile(); SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository(); FacebookAccount fbAccount = new FacebookAccount(); FacebookAccountRepository fbrepo = new FacebookAccountRepository(); try { try { fbAccount.AccessToken = accesstoken; } catch { } try { fbAccount.EmailId = data["email"].ToString(); } catch { } try { fbAccount.FbUserId = data["id"].ToString(); } catch { } try { fbAccount.ProfileUrl = data["link"].ToString(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { fbAccount.FbUserName = data["name"].ToString(); } catch { } try { fbAccount.Friends = Convert.ToInt32(friends); } catch { } try { fbAccount.Id = Guid.NewGuid(); } catch { } fbAccount.IsActive = 1; try { if (HttpContext.Current.Session["fbSocial"] != null) { if (HttpContext.Current.Session["fbSocial"] == "p") { //FacebookClient fbClient = new FacebookClient(accesstoken); //int fancountPage = 0; //dynamic fancount = fbClient.Get("fql", new { q = " SELECT fan_count FROM page WHERE page_id =" + fbAccount.FbUserId }); //foreach (var friend in fancount.data) //{ // fancountPage = friend.fan_count; //} //fbAccount.Friends = Convert.ToInt32(fancountPage); fbAccount.Type = "page"; } else { fbAccount.Type = "account"; } fbAccount.UserId = user; } if (HttpContext.Current.Session["UserAndGroupsForFacebook"] != null) { try { fbAccount.UserId = user; fbAccount.Type = "account"; } catch (Exception ex) { } } } catch { } #region unused //if (HttpContext.Current.Session["login"] != null) //{ // if (HttpContext.Current.Session["login"].ToString().Equals("facebook")) // { // User usr = new User(); // UserRepository userrepo = new UserRepository(); // Registration regObject = new Registration(); // usr.AccountType = "free"; // usr.CreateDate = DateTime.Now; // usr.ExpiryDate = DateTime.Now.AddMonths(1); // usr.Id = Guid.NewGuid(); // usr.UserName = data["name"].ToString(); // usr.Password = regObject.MD5Hash(data["name"].ToString()); // usr.EmailId = data["email"].ToString(); // usr.UserStatus = 1; // if (!userrepo.IsUserExist(data["email"].ToString())) // { // UserRepository.Add(usr); // } // } //} #endregion try { socioprofile.UserId = user; } catch { } try { socioprofile.ProfileType = "facebook"; } catch { } try { socioprofile.ProfileId = data["id"].ToString(); } catch { } try { socioprofile.ProfileStatus = 1; } catch { } try { socioprofile.ProfileDate = DateTime.Now; } catch { } try { socioprofile.Id = Guid.NewGuid(); } catch { } if (HttpContext.Current.Session["fbSocial"] != null) { if (HttpContext.Current.Session["fbSocial"] == "p") { HttpContext.Current.Session["fbpagedetail"] = fbAccount; } else { if (!fbrepo.checkFacebookUserExists(fbAccount.FbUserId, user)) { fbrepo.addFacebookUser(fbAccount); if (!socioprofilerepo.checkUserProfileExist(socioprofile)) { socioprofilerepo.addNewProfileForUser(socioprofile); GroupRepository objGroupRepository = new GroupRepository(); SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)HttpContext.Current.Session["GroupName"]; Groups lstDetails = objGroupRepository.getGroupName(team.GroupId); if (lstDetails.GroupName == "Socioboard") { TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository(); TeamMemberProfile teammemberprofile = new TeamMemberProfile(); teammemberprofile.Id = Guid.NewGuid(); teammemberprofile.TeamId = team.Id; teammemberprofile.ProfileId = fbAccount.FbUserId; teammemberprofile.ProfileType = "facebook"; teammemberprofile.StatusUpdateDate = DateTime.Now; objTeamMemberProfileRepository.addNewTeamMember(teammemberprofile); } } else { socioprofilerepo.updateSocialProfile(socioprofile); } } else { HttpContext.Current.Session["alreadyexist"] = fbAccount; fbrepo.updateFacebookUser(fbAccount); if (!socioprofilerepo.checkUserProfileExist(socioprofile)) { socioprofilerepo.addNewProfileForUser(socioprofile); } else { socioprofilerepo.updateSocialProfile(socioprofile); } } } } if (HttpContext.Current.Session["UserAndGroupsForFacebook"] != null) { if (HttpContext.Current.Session["UserAndGroupsForFacebook"].ToString() == "facebook") { try { if (!fbrepo.checkFacebookUserExists(fbAccount.FbUserId, user)) { fbrepo.addFacebookUser(fbAccount); if (!socioprofilerepo.checkUserProfileExist(socioprofile)) { socioprofilerepo.addNewProfileForUser(socioprofile); } else { socioprofilerepo.updateSocialProfile(socioprofile); } } else { fbrepo.updateFacebookUser(fbAccount); if (!socioprofilerepo.checkUserProfileExist(socioprofile)) { socioprofilerepo.addNewProfileForUser(socioprofile); } else { socioprofilerepo.updateSocialProfile(socioprofile); } } if (HttpContext.Current.Session["GroupName"] != null) { GroupProfile groupprofile = new GroupProfile(); GroupProfileRepository groupprofilerepo = new GroupProfileRepository(); Groups group = (Groups)HttpContext.Current.Session["GroupName"]; groupprofile.Id = Guid.NewGuid(); groupprofile.GroupOwnerId = user; groupprofile.ProfileId = socioprofile.ProfileId; groupprofile.ProfileType = "facebook"; groupprofile.GroupId = group.Id; groupprofile.EntryDate = DateTime.Now; if (!groupprofilerepo.checkGroupProfileExists(user, group.Id, groupprofile.ProfileId)) { groupprofilerepo.AddGroupProfile(groupprofile); } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }
public void ProcessRequest() { if (Request.QueryString["op"] == "login") { try { string email = Request.QueryString["username"]; string password = Request.QueryString["password"]; Registration regpage = new Registration(); password = regpage.MD5Hash(password); SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml"); UserRepository userrepo = new UserRepository(); LoginLogs objLoginLogs = new LoginLogs(); LoginLogsRepository objLoginLogsRepository = new LoginLogsRepository(); User user = userrepo.GetUserInfo(email, password); if (user == null) { Response.Write("Invalid Email or Password"); } else { if (user.UserStatus == 1) { Session["LoggedUser"] = user; // List<User> lstUser = new List<User>(); if (Session["LoggedUser"] != null) { //SocioBoard.Domain.User.lstUser.Add((User)Session["LoggedUser"]); //Application["OnlineUsers"] = SocioBoard.Domain.User.lstUser; //objLoginLogs.Id = new Guid(); //objLoginLogs.UserId = user.Id; //objLoginLogs.UserName = user.UserName; //objLoginLogs.LoginTime = DateTime.Now.AddHours(11.50); //objLoginLogsRepository.Add(objLoginLogs); Groups objGroups = new Groups(); GroupRepository objGroupRepository = new GroupRepository(); Team objteam = new Team(); TeamRepository objTeamRepository = new TeamRepository(); objGroups = objGroupRepository.getGroupDetail(user.Id); if (objGroups == null) { //================================================================================ //Insert into group try { objGroups = new Groups(); objGroups.Id = Guid.NewGuid(); objGroups.GroupName = ConfigurationManager.AppSettings["DefaultGroupName"]; objGroups.UserId = user.Id; objGroups.EntryDate = DateTime.Now; objGroupRepository.AddGroup(objGroups); objteam.Id = Guid.NewGuid(); objteam.GroupId = objGroups.Id; objteam.UserId = user.Id; objteam.EmailId = user.EmailId; // teams.FirstName = user.UserName; objTeamRepository.addNewTeam(objteam); SocialProfile objSocialProfile = new SocialProfile(); SocialProfilesRepository objSocialProfilesRepository = new SocialProfilesRepository(); List <SocialProfile> lstSocialProfile = objSocialProfilesRepository.getAllSocialProfilesOfUser(user.Id); if (lstSocialProfile != null) { if (lstSocialProfile.Count > 0) { foreach (SocialProfile item in lstSocialProfile) { try { TeamMemberProfile objTeamMemberProfile = new TeamMemberProfile(); TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository(); objTeamMemberProfile.Id = Guid.NewGuid(); objTeamMemberProfile.TeamId = objteam.Id; objTeamMemberProfile.ProfileId = item.ProfileId; objTeamMemberProfile.ProfileType = item.ProfileType; objTeamMemberProfile.Status = item.ProfileStatus; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } } } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error("Error : " + ex.Message); logger.Error("Error : " + ex.StackTrace); } //========================================================================================================== } BusinessSetting objBusinessSetting = new BusinessSetting(); BusinessSettingRepository objBusinessSettingRepository = new BusinessSettingRepository(); List <BusinessSetting> lstBusinessSetting = objBusinessSettingRepository.GetBusinessSettingByUserId(user.Id); if (lstBusinessSetting.Count == 0) { try { List <Groups> lstGroups = objGroupRepository.getAllGroups(user.Id); foreach (Groups item in lstGroups) { objBusinessSetting = new BusinessSetting(); objBusinessSetting.Id = Guid.NewGuid(); objBusinessSetting.BusinessName = item.GroupName; //objbsnssetting.GroupId = team.GroupId; objBusinessSetting.GroupId = item.Id; objBusinessSetting.AssigningTasks = false; objBusinessSetting.AssigningTasks = false; objBusinessSetting.TaskNotification = false; objBusinessSetting.TaskNotification = false; objBusinessSetting.FbPhotoUpload = 0; objBusinessSetting.UserId = user.Id; objBusinessSetting.EntryDate = DateTime.Now; objBusinessSettingRepository.AddBusinessSetting(objBusinessSetting); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } } Response.Write("user"); } else { Response.Write("You are Blocked by Admin Please contact Admin!"); } } } catch (Exception ex) { Response.Write("Error: " + ex.Message); Console.WriteLine(ex.StackTrace); logger.Error(ex.StackTrace); } } else if (Request.QueryString["op"] == "register") { User user = new User(); UserActivation objUserActivation = new UserActivation(); UserRepository userrepo = new UserRepository(); SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml"); Session["AjaxLogin"] = "******"; try { System.IO.StreamReader sr = new System.IO.StreamReader(Request.InputStream); string line = ""; line = sr.ReadToEnd(); JObject jo = JObject.Parse(line); user.PaymentStatus = "unpaid"; if (!string.IsNullOrEmpty(Request.QueryString["type"])) { user.AccountType = Request.QueryString["type"]; } else { user.AccountType = "deluxe"; } user.CreateDate = DateTime.Now; user.ExpiryDate = DateTime.Now.AddMonths(1); user.Id = Guid.NewGuid(); user.UserName = Server.UrlDecode((string)jo["firstname"]) + " " + Server.UrlDecode((string)jo["lastname"]); user.EmailId = Server.UrlDecode((string)jo["email"]); user.Password = Server.UrlDecode((string)jo["password"]); user.UserStatus = 1; if (!userrepo.IsUserExist(user.EmailId)) { UserRepository.Add(user); Session["LoggedUser"] = user; Response.Write("user"); objUserActivation.Id = Guid.NewGuid(); objUserActivation.UserId = user.Id; objUserActivation.ActivationStatus = "0"; UserActivationRepository.Add(objUserActivation); //add value in userpackage UserPackageRelation objUserPackageRelation = new UserPackageRelation(); UserPackageRelationRepository objUserPackageRelationRepository = new UserPackageRelationRepository(); PackageRepository objPackageRepository = new PackageRepository(); Package objPackage = objPackageRepository.getPackageDetails(user.AccountType); objUserPackageRelation.Id = new Guid(); objUserPackageRelation.PackageId = objPackage.Id; objUserPackageRelation.UserId = user.Id; objUserPackageRelation.PackageStatus = true; objUserPackageRelationRepository.AddUserPackageRelation(objUserPackageRelation); SocioBoard.Helper.MailSender.SendEMail(user.UserName, user.Password, user.EmailId, user.AccountType.ToString(), user.Id.ToString()); //MailSender.SendEMail(user.UserName, user.Password, user.EmailId); // lblerror.Text = "Registered Successfully !" + "<a href=\"login.aspx\">Login</a>"; } else { Response.Write("Email Already Exists !"); } } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } } else if (Request.QueryString["op"] == "facebooklogin") { SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml"); string redi = "http://www.facebook.com/dialog/oauth/?scope=publish_stream,read_stream,read_insights,manage_pages,user_checkins,user_photos,read_mailbox,manage_notifications,read_page_mailboxes,email,user_videos,offline_access&client_id=" + ConfigurationManager.AppSettings["ClientId"] + "&redirect_uri=" + ConfigurationManager.AppSettings["RedirectUrl"] + "&response_type=code"; Session["login"] = "******"; Response.Write(redi); } else if (Request.QueryString["op"] == "googlepluslogin") { Session["login"] = "******"; oAuthToken objToken = new oAuthToken(); Response.Write(objToken.GetAutherizationLink("https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/plus.me+https://www.googleapis.com/auth/plus.login")); } else if (Request.QueryString["op"] == "removeuser") { try { if (Session["LoggedUser"] != null) { SocioBoard.Domain.User.lstUser.Remove((User)Session["LoggedUser"]); } } catch (Exception Err) { logger.Error(Err.StackTrace); Response.Write(Err.StackTrace); } } }
protected void btnSendInvite_Click(object sender, EventArgs e) { try { int totalchkboxes = Convert.ToInt32(totalaccountscheck.InnerHtml.ToString()); string[] totalchkboxesArray = new string[totalchkboxes]; int jj = 0; for (int i = 0; i < totalchkboxes; i++) { if (Page.Request.Form["chkbox_" + i + ""] != null) { totalchkboxesArray[jj] = Page.Request.Form["chkbox_" + i + ""].ToString(); jj++; } } if (jj > 0) { if (!string.IsNullOrEmpty(txtEmail.Text) && !string.IsNullOrEmpty(txtFirstName.Text) && !string.IsNullOrEmpty(txtLastName.Text)) { if (txtEmail.Text != "Enter Email Address" && txtFirstName.Text != "First Name" && txtLastName.Text != "Last Name") { // if (rbAdmin.Checked || rbUser.Checked) // { //if (rbAdmin.Checked) //{ // AccessLevel = "admin"; //} //else if (rbUser.Checked) //{ // AccessLevel = "user"; //} // if (AccessLevel != string.Empty) // { TeamRepository teamrepo = new TeamRepository(); Team team = null; Guid gpId = (Guid)Session["GroupId"]; User user = (User)Session["LoggedUser"]; if (!teamrepo.checkTeamExists(txtEmail.Text, user.Id, gpId)) { team = new Team(); team.Id = Guid.NewGuid(); team.GroupId = (Guid)Session["GroupId"]; team.FirstName = txtFirstName.Text; team.LastName = txtLastName.Text; team.StatusUpdateDate = DateTime.Now; team.EmailId = txtEmail.Text; team.UserId = user.Id; team.InviteStatus = 1; team.InviteDate = DateTime.Now; // team.AccessLevel = AccessLevel; teamrepo.addNewTeam(team); } else { // team = teamrepo.getMemberByEmailId(user.Id, txtEmail.Text); Response.Write("<script>alert(\"Already invited in this group\");</script>"); } MailSender.SendInvitationEmail(team.FirstName + " " + team.LastName, user.UserName, team.EmailId, team.Id); if (totalchkboxesArray.Count() != 0) { TeamMemberProfileRepository teammemberprofilerepo = new TeamMemberProfileRepository(); foreach (var item in totalchkboxesArray) { try { if (!string.IsNullOrEmpty(item)) { string[] itemarray = item.Split('_'); TeamMemberProfile teammember = new TeamMemberProfile(); teammember.Id = Guid.NewGuid(); teammember.ProfileId = itemarray[1]; teammember.ProfileType = itemarray[0]; teammember.Status = 1; teammember.StatusUpdateDate = DateTime.Now; teammember.TeamId = team.Id; if (!teammemberprofilerepo.checkTeamMemberProfile(teammember.TeamId, teammember.ProfileId)) { teammemberprofilerepo.addNewTeamMember(teammember); } else { teammemberprofilerepo.updateTeamMember(teammember); } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } Response.Redirect("InviteMember.aspx"); } txtFirstName.Text = ""; txtLastName.Text = ""; txtEmail.Text = ""; // rbAdmin.Checked = false; // rbUser.Checked = false; Label1.Text = "Invitation Sends"; // } // } //else //{ // Response.Write("<script>alert(\"Please fill Group Name\");</script>"); //} } } } else { ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "MyFun1", "disp_confirm();", true); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }
public void getFacebookUserProfile(dynamic data, string accesstoken, long friends, Guid user) { SocialProfile socioprofile = new SocialProfile(); //SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository(); Api.SocialProfile.SocialProfile ApiObjSocialProfile = new Api.SocialProfile.SocialProfile(); FacebookAccount fbAccount = new FacebookAccount(); //FacebookAccountRepository fbrepo = new FacebookAccountRepository(); Api.FacebookFeed.FacebookFeed ApiObjFacebookFeed = new Api.FacebookFeed.FacebookFeed(); try { try { fbAccount.AccessToken = accesstoken; } catch { } try { fbAccount.EmailId = data["email"].ToString(); } catch { } try { fbAccount.FbUserId = data["id"].ToString(); } catch { } try { fbAccount.ProfileUrl = data["link"].ToString(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { fbAccount.FbUserName = data["name"].ToString(); } catch { } try { fbAccount.Friends = Convert.ToInt32(friends); } catch { } try { fbAccount.Id = Guid.NewGuid(); } catch { } fbAccount.IsActive = 1; try { if (HttpContext.Current.Session["fbSocial"] != null) { if (HttpContext.Current.Session["fbSocial"] == "p") { //FacebookClient fbClient = new FacebookClient(accesstoken); //int fancountPage = 0; //dynamic fancount = fbClient.Get("fql", new { q = " SELECT fan_count FROM page WHERE page_id =" + fbAccount.FbUserId }); //foreach (var friend in fancount.data) //{ // fancountPage = friend.fan_count; //} //fbAccount.Friends = Convert.ToInt32(fancountPage); fbAccount.Type = "page"; } else { fbAccount.Type = "account"; } fbAccount.UserId = user; } if (HttpContext.Current.Session["UserAndGroupsForFacebook"] != null) { try { fbAccount.UserId = user; fbAccount.Type = "account"; } catch (Exception ex) { } } } catch { } #region unused //if (HttpContext.Current.Session["login"] != null) //{ // if (HttpContext.Current.Session["login"].ToString().Equals("facebook")) // { // User usr = new User(); // UserRepository userrepo = new UserRepository(); // Registration regObject = new Registration(); // usr.AccountType = "free"; // usr.CreateDate = DateTime.Now; // usr.ExpiryDate = DateTime.Now.AddMonths(1); // usr.Id = Guid.NewGuid(); // usr.UserName = data["name"].ToString(); // usr.Password = regObject.MD5Hash(data["name"].ToString()); // usr.EmailId = data["email"].ToString(); // usr.UserStatus = 1; // if (!userrepo.IsUserExist(data["email"].ToString())) // { // UserRepository.Add(usr); // } // } //} #endregion try { socioprofile.UserId = user; } catch { } try { socioprofile.ProfileType = "facebook"; } catch { } try { socioprofile.ProfileId = data["id"].ToString(); } catch { } try { socioprofile.ProfileStatus = 1; } catch { } try { socioprofile.ProfileDate = DateTime.Now; } catch { } try { socioprofile.Id = Guid.NewGuid(); } catch { } if (HttpContext.Current.Session["fbSocial"] != null) { if (HttpContext.Current.Session["fbSocial"] == "p") { HttpContext.Current.Session["fbpagedetail"] = fbAccount; } else { if (!fbrepo.checkFacebookUserExists(fbAccount.FbUserId, user)) { fbrepo.addFacebookUser(fbAccount); if (!socioprofilerepo.checkUserProfileExist(socioprofile)) { socioprofilerepo.addNewProfileForUser(socioprofile); GroupRepository objGroupRepository = new GroupRepository(); SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)HttpContext.Current.Session["GroupName"]; Groups lstDetails = objGroupRepository.getGroupName(team.GroupId); if (lstDetails.GroupName == "Socioboard") { TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository(); TeamMemberProfile teammemberprofile = new TeamMemberProfile(); teammemberprofile.Id = Guid.NewGuid(); teammemberprofile.TeamId = team.Id; teammemberprofile.ProfileId = fbAccount.FbUserId; teammemberprofile.ProfileType = "facebook"; teammemberprofile.StatusUpdateDate = DateTime.Now; objTeamMemberProfileRepository.addNewTeamMember(teammemberprofile); } } else { socioprofilerepo.updateSocialProfile(socioprofile); } } else { HttpContext.Current.Session["alreadyexist"] = fbAccount; fbrepo.updateFacebookUser(fbAccount); if (!socioprofilerepo.checkUserProfileExist(socioprofile)) { socioprofilerepo.addNewProfileForUser(socioprofile); } else { socioprofilerepo.updateSocialProfile(socioprofile); } } } } if (HttpContext.Current.Session["UserAndGroupsForFacebook"] != null) { if (HttpContext.Current.Session["UserAndGroupsForFacebook"].ToString() == "facebook") { try { if (!fbrepo.checkFacebookUserExists(fbAccount.FbUserId, user)) { fbrepo.addFacebookUser(fbAccount); if (!socioprofilerepo.checkUserProfileExist(socioprofile)) { socioprofilerepo.addNewProfileForUser(socioprofile); } else { socioprofilerepo.updateSocialProfile(socioprofile); } } else { fbrepo.updateFacebookUser(fbAccount); if (!socioprofilerepo.checkUserProfileExist(socioprofile)) { socioprofilerepo.addNewProfileForUser(socioprofile); } else { socioprofilerepo.updateSocialProfile(socioprofile); } } if (HttpContext.Current.Session["GroupName"] != null) { GroupProfile groupprofile = new GroupProfile(); GroupProfileRepository groupprofilerepo = new GroupProfileRepository(); Groups group = (Groups)HttpContext.Current.Session["GroupName"]; groupprofile.Id = Guid.NewGuid(); groupprofile.GroupOwnerId = user; groupprofile.ProfileId = socioprofile.ProfileId; groupprofile.ProfileType = "facebook"; groupprofile.GroupId = group.Id; groupprofile.EntryDate = DateTime.Now; if (!groupprofilerepo.checkGroupProfileExists(user, group.Id, groupprofile.ProfileId)) { groupprofilerepo.AddGroupProfile(groupprofile); } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }
private void GetAccessToken() { try { User user = (User)Session["LoggedUser"]; if (user == null) { Response.Redirect("Default.aspx"); } oAuthTumbler requestHelper = new oAuthTumbler(); string code = Request.QueryString["oauth_verifier"]; string AccessTokenResponse = string.Empty; try { AccessTokenResponse = requestHelper.GetAccessToken(oAuthTumbler.TumblrToken, code); } catch (Exception ex) { logger.Error("AccessTokenResponse: " + ex.Message); logger.Error("AccessTokenResponse: " + ex.StackTrace); } string[] tokens = AccessTokenResponse.Split('&'); //extract access token & secret from response string accessToken = tokens[0].Split('=')[1]; string accessTokenSecret = tokens[1].Split('=')[1]; KeyValuePair <string, string> LoginDetails = new KeyValuePair <string, string>(accessToken, accessTokenSecret); string sstr = string.Empty; try { sstr = oAuthTumbler.OAuthData(Globals.UsersDashboardUrl, "GET", LoginDetails.Key, LoginDetails.Value, null); } catch (Exception ex) { logger.Error("sstr: " + ex.Message); logger.Error("sstr: " + ex.StackTrace); } JObject profile = new JObject(); try { profile = JObject.Parse(oAuthTumbler.OAuthData(Globals.UsersInfoUrl, "GET", LoginDetails.Key, LoginDetails.Value, null)); } catch (Exception ex) { logger.Error("profile: " + ex.Message); logger.Error("profile: " + ex.StackTrace); } JObject UserDashboard = JObject.Parse(oAuthTumbler.OAuthData(Globals.UsersDashboardUrl, "GET", LoginDetails.Key, LoginDetails.Value, null)); TumblrAccount objTumblrAccount = new TumblrAccount(); TumblrAccountRepository objTumblrAccountRepository = new TumblrAccountRepository(); SocialProfile objSocialProfile = new SocialProfile(); SocialProfilesRepository objSocialProfilesRepository = new SocialProfilesRepository(); objSocialProfile.Id = Guid.NewGuid(); objSocialProfile.UserId = user.Id; objSocialProfile.ProfileId = profile["response"]["user"]["name"].ToString(); objSocialProfile.ProfileType = "tumblr"; objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 1; objTumblrAccount.Id = Guid.NewGuid(); objTumblrAccount.tblrUserName = profile["response"]["user"]["name"].ToString(); objTumblrAccount.UserId = user.Id; objTumblrAccount.tblrAccessToken = accessToken; objTumblrAccount.tblrAccessTokenSecret = accessTokenSecret; objTumblrAccount.tblrProfilePicUrl = profile["response"]["user"]["name"].ToString(); objTumblrAccount.IsActive = 1; if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); if (!objTumblrAccountRepository.checkTubmlrUserExists(objTumblrAccount)) { TumblrAccountRepository.Add(objTumblrAccount); GroupRepository objGroupRepository = new GroupRepository(); SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)HttpContext.Current.Session["GroupName"]; Groups lstDetails = objGroupRepository.getGroupName(team.GroupId); if (lstDetails.GroupName == "Socioboard") { TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository(); TeamMemberProfile teammemberprofile = new TeamMemberProfile(); teammemberprofile.Id = Guid.NewGuid(); teammemberprofile.TeamId = team.Id; teammemberprofile.ProfileId = objTumblrAccount.tblrUserName; teammemberprofile.ProfileType = "tumblr"; teammemberprofile.StatusUpdateDate = DateTime.Now; objTeamMemberProfileRepository.addNewTeamMember(teammemberprofile); } } } else { if (!objTumblrAccountRepository.checkTubmlrUserExists(objTumblrAccount)) { TumblrAccountRepository.Add(objTumblrAccount); } else { Response.Redirect("Home.aspx"); } } JArray objJarray = (JArray)UserDashboard["response"]["posts"]; logger.Error("objJarray: " + objJarray); if (objJarray != null) { logger.Error("objJarray lenght : " + objJarray.Count); } else { logger.Error("objJarray is NULL"); } TumblrFeed objTumblrFeed = new TumblrFeed(); TumblrFeedRepository objTumblrFeedRepository = new TumblrFeedRepository(); foreach (var item in objJarray) { objTumblrFeed.Id = Guid.NewGuid(); objTumblrFeed.UserId = user.Id; try { objTumblrFeed.ProfileId = profile["response"]["user"]["name"].ToString(); logger.Error("objTumblrFeed.ProfileId : " + objTumblrFeed.ProfileId); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { objTumblrFeed.blogname = item["blog_name"].ToString(); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { objTumblrFeed.blogId = item["id"].ToString(); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { objTumblrFeed.blogposturl = item["post_url"].ToString(); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { String result = item["caption"].ToString(); objTumblrFeed.description = Regex.Replace(result, @"<[^>]*>", String.Empty); } catch (Exception ex) { objTumblrFeed.description = null; logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { objTumblrFeed.slug = item["slug"].ToString(); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { objTumblrFeed.type = item["type"].ToString(); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); 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) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { objTumblrFeed.reblogkey = item["reblog_key"].ToString(); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { string str = item["liked"].ToString(); if (str == "False") { objTumblrFeed.liked = 0; } else { objTumblrFeed.liked = 1; } } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); 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) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { objTumblrFeed.canreply = Convert.ToInt16(item["can_reply"]); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { objTumblrFeed.sourceurl = item["source_url"].ToString(); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { objTumblrFeed.sourcetitle = item["source_title"].ToString(); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); 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) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { objTumblrFeed.videourl = item["permalink_url"].ToString(); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { string str = item["note_count"].ToString(); objTumblrFeed.notes = Convert.ToInt16(str); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } objTumblrFeed.timestamp = DateTime.Now; if (!objTumblrFeedRepository.checkTumblrMessageExists(objTumblrFeed)) { try { logger.Error("objTumblrFeedRepository.checkTumblrMessageExists " + objTumblrAccount.Id); TumblrFeedRepository.Add(objTumblrFeed); } catch (Exception ex) { logger.Error("Exception : objTumblrFeedRepository.checkTumblrMessageExists " + objTumblrAccount.Id); logger.Error(ex.Message); logger.Error(ex.StackTrace); } } } Response.Redirect("Home.aspx"); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); } }
public void ProcessRequest() { TeamRepository objTeamRepository = new TeamRepository(); TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository(); FacebookAccountRepository fbaccountrepo = new FacebookAccountRepository(); TwitterAccountRepository twtaccountrepo = new TwitterAccountRepository(); LinkedInAccountRepository linkedaccrepo = new LinkedInAccountRepository(); InstagramAccountRepository instagramrepo = new InstagramAccountRepository(); GroupProfileRepository groupprofilerepo = new GroupProfileRepository(); BusinessSettingRepository objbsnsrepo = new BusinessSettingRepository(); TumblrAccountRepository tumblrrepo = new TumblrAccountRepository(); User user = (User)Session["LoggedUser"]; if (Request.QueryString["op"] != null) { if (Request.QueryString["op"] == "SaveGroupName") { string groupName = Request.QueryString["groupname"]; GroupRepository grouprepo = new GroupRepository(); Groups group = new Groups(); group.Id = Guid.NewGuid(); group.GroupName = groupName; group.UserId = user.Id; group.EntryDate = DateTime.Now; if (!grouprepo.checkGroupExists(user.Id, groupName)) { grouprepo.AddGroup(group); Groups grou = grouprepo.getGroupDetails(user.Id, groupName); Session["GroupName"] = grou; } else { Groups grou = grouprepo.getGroupDetails(user.Id, groupName); Session["GroupName"] = grou; } } else if (Request.QueryString["op"] == "bindGroupProfiles") { string bindprofiles = string.Empty; Guid groupid = Guid.Parse(Request.QueryString["groupId"]); Session["GroupId"] = groupid; GroupProfileRepository groupprofilesrepo = new GroupProfileRepository(); List <GroupProfile> lstgroupprofile = groupprofilesrepo.getAllGroupProfiles(user.Id, groupid); foreach (GroupProfile item in lstgroupprofile) { if (item.ProfileType == "facebook") { FacebookAccount account = fbaccountrepo.getFacebookAccountDetailsById(item.ProfileId, user.Id); if (account != null) { bindprofiles += "<div id=\"facebook_" + item.ProfileId + "\" class=\"ws_conct\"> <span class=\"img\"><img width=\"48\" height=\"48\" src=\"http://graph.facebook.com/" + item.ProfileId + "/picture?type=small\" alt=\"\"><i><img width=\"16\" height=\"16\" src=\"../Contents/img/fb_icon.png\" alt=\"\"></i></span><div class=\"fourfifth\">" + "<div class=\"location-container\">" + account.FbUserName + "</div><span onclick=\"AddProfileInInviteTeamMember('" + account.FbUserId + "','" + groupid + "','" + item.ProfileType + "')\" class=\"add remove\">+</span><span onclick=\"RemoveProfileFromGroup('" + item.ProfileId + "')\" class=\"add remove\">✖</span></div></div>"; } } else if (item.ProfileType == "twitter") { TwitterAccount twtaccount = twtaccountrepo.getUserInformation(user.Id, item.ProfileId); string profileimgurl = string.Empty; if (twtaccount != null) { if (twtaccount.ProfileImageUrl == string.Empty) { profileimgurl = "../../Contents/img/blank_img.png"; } else { profileimgurl = twtaccount.ProfileImageUrl; } bindprofiles += "<div id=\"twitter_" + item.ProfileId + "\" class=\"ws_conct active\"> <span class=\"img\"><img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"><i><img width=\"16\" height=\"16\" src=\"../Contents/img/twticon.png\" alt=\"\"></i></span><div class=\"fourfifth\">" + "<div class=\"location-container\">" + twtaccount.TwitterScreenName + "</div><span onclick=\"AddProfileInInviteTeamMember('" + twtaccount.TwitterUserId + "','" + groupid + "','" + item.ProfileType + "')\" class=\"add remove\">+</span><span onclick=\"RemoveProfileFromGroup('" + item.ProfileId + "')\" class=\"add remove\">✖</span></div></div>"; } } else if (item.ProfileType == "linkedin") { LinkedInAccount linkedaccount = linkedaccrepo.getUserInformation(user.Id, item.ProfileId); string profileimgurl = string.Empty; if (linkedaccount != null) { if (linkedaccount.ProfileUrl == string.Empty) { profileimgurl = "../../Contents/img/blank_img.png"; } else { profileimgurl = linkedaccount.ProfileImageUrl; } bindprofiles += "<div id=\"linkedin_" + item.ProfileId + "\" class=\"ws_conct active\"><span class=\"img\"><img width=\"48\" height=\"48\" alt=\"\" src=\"" + profileimgurl + "\" ><i>" + "<img width=\"16\" height=\"16\" alt=\"\" src=\"../Contents/img/link_icon.png\"></i></span>" + "<div class=\"fourfifth\"><div class=\"location-container\">" + linkedaccount.LinkedinUserName + "</div>" + "<span onclick=\"AddProfileInInviteTeamMember('" + linkedaccount.LinkedinUserId + "','" + groupid + "','" + item.ProfileType + "')\" class=\"add remove\">+</span><span onclick=\"RemoveProfileFromGroup('" + item.ProfileId + "')\" class=\"add remove\">✖</span></div></div>"; } } else if (item.ProfileType == "tumblr") { TumblrAccount tumblraccount = tumblrrepo.getTumblrAccountDetailsById(item.ProfileId, user.Id); string profileimgurl = string.Empty; if (tumblraccount != null) { if (tumblraccount.tblrProfilePicUrl == string.Empty) { profileimgurl = "../../Contents/img/blank_img.png"; } else { profileimgurl = "http://api.tumblr.com/v2/blog/" + tumblraccount.tblrUserName + ".tumblr.com/avatar"; } bindprofiles += "<div id=\"tumblr_" + item.ProfileId + "\" class=\"ws_conct active\"><span class=\"img\"><img width=\"48\" height=\"48\" alt=\"\" src=\"http://api.tumblr.com/v2/blog/" + tumblraccount.tblrUserName + ".tumblr.com/avatar\" ><i>" + "<img width=\"16\" height=\"16\" alt=\"\" src=\"../Contents/img/tumblr.png\"></i></span>" + "<div class=\"fourfifth\"><div class=\"location-container\">" + tumblraccount.tblrUserName + "</div>" + "<span onclick=\"AddProfileInInviteTeamMember('" + tumblraccount.tblrUserName + "','" + groupid + "','" + item.ProfileType + "')\" class=\"add remove\">+</span><span onclick=\"RemoveProfileFromGroup('" + item.ProfileId + "')\" class=\"add remove\">✖</span></div></div>"; } } else if (item.ProfileType == "instagram") { string profileimgurl = string.Empty; InstagramAccount instaaccount = instagramrepo.getInstagramAccountDetailsById(item.ProfileId, user.Id); if (instaaccount != null) { if (instaaccount.ProfileUrl == string.Empty) { profileimgurl = "../../Contents/img/blank_img.png"; } else { profileimgurl = instaaccount.ProfileUrl; } bindprofiles += "<div id=\"instagram_" + item.ProfileId + "\" class=\"ws_conct active\"><span class=\"img\"><img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"><i>" + "<img width=\"16\" height=\"16\" alt=\"\" src=\"../Contents/img/instagram_24X24.png\"></i></span><div class=\"fourfifth\"><div class=\"location-container\">" + instaaccount.InsUserName + "</div>" + "<span onclick=\"AddProfileInInviteTeamMember('" + instaaccount.InstagramId + "','" + groupid + "','" + item.ProfileType + "')\" class=\"add remove\">+</span><span onclick=\"RemoveProfileFromGroup('" + item.ProfileId + "')\" class=\"add remove\">✖</span></div></div>"; } } } Response.Write(bindprofiles); } else if (Request.QueryString["op"] == "deleteGroupName") { Guid groupid = Guid.Parse(Request.QueryString["groupId"]); GroupRepository grouprepo = new GroupRepository(); grouprepo.DeleteGroup(groupid); int count = groupprofilerepo.DeleteAllGroupProfile(groupid); int cnt = objbsnsrepo.DeleteBusinessSettingByUserid(groupid); List <Team> objTeamId = objTeamRepository.getAllDetailsUserEmail(groupid); foreach (Team item in objTeamId) { int deteleTeamMember = objTeamMemberProfileRepository.deleteTeamMember(item.Id); } int deleteTeam = objTeamRepository.deleteGroupRelatedTeam(groupid); } else if (Request.QueryString["op"] == "addProfilestoGroup") { string network = Request.QueryString["network"]; string id = Request.QueryString["profileid"]; Guid groupid = (Guid)Session["GroupId"]; GroupProfile groupprofile = new GroupProfile(); groupprofile.EntryDate = DateTime.Now; groupprofile.GroupId = groupid; groupprofile.Id = Guid.NewGuid(); groupprofile.ProfileId = id; groupprofile.ProfileType = network; groupprofile.GroupOwnerId = user.Id; GroupProfileRepository grouprepo = new GroupProfileRepository(); if (!grouprepo.checkGroupProfileExists(user.Id, groupid, id)) { grouprepo.AddGroupProfile(groupprofile); } Response.Write(groupid); } else if (Request.QueryString["op"] == "deleteGroupProfiles") { Guid groupid = (Guid)Session["GroupId"]; try { string profileid = Request.QueryString["profileid"]; GroupProfileRepository grouprepo = new GroupProfileRepository(); grouprepo.DeleteGroupProfile(user.Id, profileid, groupid); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } Response.Write(groupid); } if (Request.QueryString["op"] == "GetInviteMember") { string bindprofiles = string.Empty; string profileimgurl = string.Empty; try { string gp = Request.QueryString["groupId"]; Guid GroupId = Guid.Parse(gp); // TeamRepository objTeamRepository = new TeamRepository(); List <Team> objTeam = objTeamRepository.getAllDetailsUserEmail(GroupId); if (objTeam.Count != 0) { foreach (Team item in objTeam) { UserRepository objUserRepository = new UserRepository(); User ObjUserDetails = objUserRepository.getUserInfoByEmail(item.EmailId); if (ObjUserDetails != null) { if (string.IsNullOrEmpty(ObjUserDetails.ProfileUrl)) { profileimgurl = "../../Contents/img/blank_img.png"; } else { profileimgurl = ObjUserDetails.ProfileUrl; } bindprofiles += "<div style=\"float:left; margin-right:18%\"id=\"" + item.Id + "\">" + "<div style=\"float:left\"><span class=\"img\"><img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"></span>" + "</div><div style=\"float:left\" class=\"fourfifth\"><div style=\"font-size:small \">" + ObjUserDetails.UserName + "</div> </div><div style=\"float:left;margin-left:3px\" onclick=\"ShowInviteMemberProfileDetails('" + GroupId + "','" + ObjUserDetails.EmailId + "','" + user.Id + "')\"><input class=\"abc\" type=\"radio\" name=\"sex\" value=" + item.Id + "></div>" + "<span onclick=\"RemoveInviteMemberFromGroup('" + item.Id + "')\" style=\"margin-left:25px;font-size:small;cursor:pointer;position: absolute; margin-top: 28px;margin-left:10px\">x</span></div>"; //bindprofiles += "<div id=\"" + item.Id + "\" class=\"ws_conct active\"> <span class=\"img\"><img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"><i><img width=\"16\" height=\"16\" src=\"../Contents/img/twticon.png\" alt=\"\"></i></span><div class=\"fourfifth\">" + // "<div class=\"location-container\">" + ObjUserDetails.UserName + "</div><span class=\"add remove\" onclick=\"ShowInviteMemberProfileDetails('" + GroupId + "','" + ObjUserDetails.EmailId + "','" + user.Id + "')\"><input class=\"abc\" type=\"radio\" name=\"sex\" value=" + item.Id + "></span><span onclick=\"RemoveInviteMemberFromGroup('" + item.Id + "')\" class=\"add remove\">✖</span></div></div>"; } } } Response.Write(bindprofiles); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } if (Request.QueryString["op"] == "RemoveInviteMemberFromGroup") { if (!string.IsNullOrEmpty(Request.QueryString["Id"])) { try { string ide = Request.QueryString["Id"]; Guid id = Guid.Parse(ide); int deleteTeam = objTeamRepository.deleteinviteteamMember(id); int deleteProfiles = objTeamMemberProfileRepository.DeleteTeamMemberProfileByTeamId(id); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } } //modified by hozefa 4-7-2014 if (Request.QueryString["op"] == "ShowInviteMemberProfileDetails") { string bindprofiles = string.Empty; string gpId = Request.QueryString["groupId"]; Guid gpid = Guid.Parse(gpId); string emailId = Request.QueryString["emailid"]; string userId = Request.QueryString["userid"]; Team teamdata = objTeamRepository.getAllDetails(gpid, emailId); List <TeamMemberProfile> objTeamMemProfile = objTeamMemberProfileRepository.getAllTeamMemberProfilesOfTeam(teamdata.Id); try { foreach (TeamMemberProfile item in objTeamMemProfile) { if (item.ProfileType == "facebook") { FacebookAccount account = fbaccountrepo.getFacebookAccountDetailsById(item.ProfileId); if (account != null) { bindprofiles += "<div id=\"item\" style=\"float:left;width:170px;margin-top:6px\" id=\"facebook_" + item.ProfileId + "\"><div style=\"float:left\"<span class=\"img\">" + "<img width=\"48\" height=\"48\" src=\"http://graph.facebook.com/" + item.ProfileId + "/picture?type=small\" alt=\"\"></img><i><img style=\"margin-left:-18px\" width=\"16\" height=\"16\" src=\"../Contents/img/fb_icon.png\" alt=\"\"></img></i>" + "</span></div><div style=\"float:left\"><div style=\"font-size:small\">" + account.FbUserName + "</div></div>" + "<span onclick=\"RemoveInviteMemberProfileFromTeamMember('" + teamdata.Id + "','" + item.ProfileId + "','" + gpId + "','" + emailId + "','" + userId + "')\" style=\"margin-left:25px;font-size:small;cursor:pointer;position: absolute; margin-top: 28px;margin-left:10px\">x</span></div>"; } } else if (item.ProfileType == "twitter") { TwitterAccount twtaccount = twtaccountrepo.getUserInformation(item.ProfileId); string profileimgurl = string.Empty; if (twtaccount != null) { if (twtaccount.ProfileImageUrl == string.Empty) { profileimgurl = "../../Contents/img/blank_img.png"; } else { profileimgurl = twtaccount.ProfileImageUrl; } bindprofiles += "<div id=\"item\" style=\"float:left; width:170px;margin-top:6px\" id=\"twitter_" + item.ProfileId + "\"><div style=\"float:left\"<span class=\"img\">" + "<img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"></img><i><img style=\"margin-left:-18px\" width=\"16\" height=\"16\" src=\"../Contents/img/twticon.png\" alt=\"\"></img></i>" + "</span></div><div style=\"float:left\"><div style=\"font-size:small\">" + twtaccount.TwitterScreenName + "</div></div>" + "<span onclick=\"RemoveInviteMemberProfileFromTeamMember('" + teamdata.Id + "','" + item.ProfileId + "','" + gpId + "','" + emailId + "','" + userId + "')\" style=\"margin-left:25px;font-size:small;cursor:pointer;position: absolute; margin-top: 28px;margin-left:10px\">x</span></div>"; } } else if (item.ProfileType == "linkedin") { LinkedInAccount linkedaccount = linkedaccrepo.getUserInformation(item.ProfileId); string profileimgurl = string.Empty; if (linkedaccount != null) { if (linkedaccount.ProfileUrl == string.Empty) { profileimgurl = "../../Contents/img/blank_img.png"; } else { profileimgurl = linkedaccount.ProfileImageUrl; } bindprofiles += "<div id=\"item\" style=\"float:left;width:170px;margin-top:6px\" id=\"linkedin_" + item.ProfileId + "\"><div style=\"float:left\"<span class=\"img\">" + "<img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"></img><i><img style=\"margin-left:-18px\" width=\"16\" height=\"16\" src=\"../Contents/img/link_icon.png\" alt=\"\"></img></i>" + "</span></div><div style=\"float:left\"><div style=\"font-size:small\">" + linkedaccount.LinkedinUserName + "</div></div>" + "<span onclick=\"RemoveInviteMemberProfileFromTeamMember('" + teamdata.Id + "','" + item.ProfileId + "','" + gpId + "','" + emailId + "','" + userId + "')\" style=\"margin-left:25px;font-size:small;cursor:pointer;position: absolute; margin-top: 28px;margin-left:10px\">x</span></div>"; } } else if (item.ProfileType == "instagram") { string profileimgurl = string.Empty; InstagramAccount instaaccount = instagramrepo.getInstagramAccountDetailsById(item.ProfileId); if (instaaccount != null) { if (instaaccount.ProfileUrl == string.Empty) { profileimgurl = "../../Contents/img/blank_img.png"; } else { profileimgurl = instaaccount.ProfileUrl; } bindprofiles += "<div id=\"item\" style=\"float:left;width:170px; margin-top:6px\" id=\"instagram_" + item.ProfileId + "\"><div style=\"float:left\"<span class=\"img\">" + "<img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"></img><i><img style=\"margin-left:-18px\" width=\"16\" height=\"16\" src=\"../Contents/img/instagram_24X24.png\" alt=\"\"></img></i>" + "</span></div><div style=\"float:left\"><div style=\"font-size:small\">" + instaaccount.InsUserName + "</div></div>" + "<span onclick=\"RemoveInviteMemberProfileFromTeamMember('" + teamdata.Id + "','" + item.ProfileId + "','" + gpId + "','" + emailId + "','" + userId + "')\" style=\"margin-left:25px;font-size:small;cursor:pointer;position: absolute; margin-top: 28px;margin-left:10px\">x</span></div>"; } } else if (item.ProfileType == "tumblr") { string profileimgurl = string.Empty; TumblrAccount tumblraccount = tumblrrepo.getTumblrAccountDetailsById(item.ProfileId); if (tumblraccount != null) { if (tumblraccount.tblrProfilePicUrl == string.Empty) { profileimgurl = "../../Contents/img/blank_img.png"; } else { profileimgurl = "http://api.tumblr.com/v2/blog/" + tumblraccount.tblrUserName + ".tumblr.com/avatar"; } bindprofiles += "<div id=\"item\" style=\"float:left;width:170px; margin-top:6px\" id=\"tumblr_" + item.ProfileId + "\"><div style=\"float:left\"<span class=\"img\">" + "<img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"></img><i><img style=\"margin-left:-18px\" width=\"16\" height=\"16\" src=\"../Contents/img/tumblr.png\" alt=\"\"></img></i>" + "</span></div><div style=\"float:left\"><div style=\"font-size:small\">" + tumblraccount.tblrUserName + "</div></div>" + "<span onclick=\"RemoveInviteMemberProfileFromTeamMember('" + teamdata.Id + "','" + item.ProfileId + "','" + gpId + "','" + emailId + "','" + userId + "')\" style=\"margin-left:25px;font-size:small;cursor:pointer;position: absolute; margin-top: 28px;margin-left:10px\">x</span></div>"; } } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } Response.Write(bindprofiles); } if (Request.QueryString["op"] == "RemoveInviteMemberProfileFromTeamMember") { string profileId = Request.QueryString["ProfileId"]; Guid teamid = Guid.Parse(Request.QueryString["TeamId"]); try { int deleteTeamMembeProfile = objTeamMemberProfileRepository.DeleteTeamMemberProfileByTeamIdProfileId(profileId, teamid); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } if (Request.QueryString["op"] == "AddProfileInInviteTeamMember") { try { string EmailId = string.Empty; string Result = string.Empty; TeamMemberProfile objteam = new TeamMemberProfile(); objteam.ProfileId = Request.QueryString["Profileid"]; objteam.ProfileType = Request.QueryString["Profiletype"]; string GrpId = Request.QueryString["Groupid"]; Guid grpid = Guid.Parse(GrpId); TeamRepository objTeamrepo = new TeamRepository(); Team team = new Team(); Guid id = Guid.NewGuid(); objteam.Id = id; string teamid = Request.QueryString["Teamid"]; objteam.TeamId = Guid.Parse(teamid); objteam.StatusUpdateDate = DateTime.Now; objteam.Status = 0; team = objTeamrepo.getAllDetailsByTeamID(objteam.TeamId, grpid); EmailId = team.EmailId; try { if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objteam.TeamId, objteam.ProfileId)) { objTeamMemberProfileRepository.addNewTeamMember(objteam); Result = "Success"; } else { //ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('This Profile Already Added.');", true); Result = "Fail"; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } Response.Write(Result + "_" + EmailId); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } } }
public void getAccessToken() { GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"].ToString(), ConfigurationManager.AppSettings["InstagramClientSec"].ToString(), ConfigurationManager.AppSettings["InstagramCallBackURL"].ToString(), "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", ""); SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository(); SocialProfile socioprofile = new SocialProfile(); _api = oAuthInstagram.GetInstance(configi); AccessToken access = new AccessToken(); string code = Request.QueryString["code"].ToString(); SocioBoard.Domain.User user = (SocioBoard.Domain.User)Session["LoggedUser"]; access = _api.AuthGetAccessToken(code); UserController objusercontroller = new UserController(); InstagramResponse <GlobusInstagramLib.App.Core.User> objuser = objusercontroller.GetUserDetails(access.user.id, access.access_token); InstagramAccount objInsAccount = new InstagramAccount(); objInsAccount.AccessToken = access.access_token; //objInsAccount.FollowedBy=access.user. objInsAccount.InstagramId = access.user.id; objInsAccount.ProfileUrl = access.user.profile_picture; objInsAccount.InsUserName = access.user.username; objInsAccount.TotalImages = objuser.data.counts.media; objInsAccount.FollowedBy = objuser.data.counts.followed_by; objInsAccount.Followers = objuser.data.counts.follows; objInsAccount.UserId = user.Id; socioprofile.UserId = user.Id; socioprofile.ProfileType = "instagram"; socioprofile.ProfileId = access.user.id; socioprofile.ProfileStatus = 1; socioprofile.ProfileDate = DateTime.Now; socioprofile.Id = Guid.NewGuid(); if (objInsRepo.checkInstagramUserExists(access.user.id, user.Id)) { HttpContext.Current.Session["alreadyexist"] = objInsAccount; objInsRepo.updateInstagramUser(objInsAccount); if (!socioprofilerepo.checkUserProfileExist(socioprofile)) { socioprofilerepo.addNewProfileForUser(socioprofile); } } else { objInsRepo.addInstagramUser(objInsAccount); if (!socioprofilerepo.checkUserProfileExist(socioprofile)) { socioprofilerepo.addNewProfileForUser(socioprofile); GroupRepository objGroupRepository = new GroupRepository(); SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)HttpContext.Current.Session["GroupName"]; Groups lstDetails = objGroupRepository.getGroupName(team.GroupId); if (lstDetails.GroupName == "Socioboard") { TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository(); TeamMemberProfile teammemberprofile = new TeamMemberProfile(); teammemberprofile.Id = Guid.NewGuid(); teammemberprofile.TeamId = team.Id; teammemberprofile.ProfileId = socioprofile.ProfileId; teammemberprofile.ProfileType = "instagram"; teammemberprofile.StatusUpdateDate = DateTime.Now; objTeamMemberProfileRepository.addNewTeamMember(teammemberprofile); } } } string messages = getIntagramImages(objInsAccount); Response.Write(messages); }
public void GetLinkedInUserProfile(dynamic data, oAuthLinkedIn _oauth, Guid user, string LinkedinUserId) { SocialProfile socioprofile = new SocialProfile(); SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository(); LinkedInAccount objLinkedInAccount = new LinkedInAccount(); LinkedInAccountRepository objLiRepo = new LinkedInAccountRepository(); try { objLinkedInAccount.UserId = user; objLinkedInAccount.LinkedinUserId = data.id.ToString(); try { objLinkedInAccount.EmailId = data.email.ToString(); } catch { } objLinkedInAccount.LinkedinUserName = data.first_name.ToString() + data.last_name.ToString(); objLinkedInAccount.OAuthToken = _oauth.Token; objLinkedInAccount.OAuthSecret = _oauth.TokenSecret; objLinkedInAccount.OAuthVerifier = _oauth.Verifier; try { objLinkedInAccount.ProfileImageUrl = data.picture_url.ToString(); } catch { } try { objLinkedInAccount.ProfileUrl = data.profile_url.ToString(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } objLinkedInAccount.Connections = data.connections; objLinkedInAccount.IsActive = true; socioprofile.UserId = user; socioprofile.ProfileType = "linkedin"; socioprofile.ProfileId = LinkedinUserId; socioprofile.ProfileStatus = 1; socioprofile.ProfileDate = DateTime.Now; socioprofile.Id = Guid.NewGuid(); } catch { } try { if (!socioprofilerepo.checkUserProfileExist(socioprofile)) { socioprofilerepo.addNewProfileForUser(socioprofile); GroupRepository objGroupRepository = new GroupRepository(); SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)HttpContext.Current.Session["GroupName"]; Groups lstDetails = objGroupRepository.getGroupName(team.GroupId); if (lstDetails.GroupName == "Socioboard") { TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository(); TeamMemberProfile teammemberprofile = new TeamMemberProfile(); teammemberprofile.Id = Guid.NewGuid(); teammemberprofile.TeamId = team.Id; teammemberprofile.ProfileId = socioprofile.ProfileId; teammemberprofile.ProfileType = "linkedin"; teammemberprofile.StatusUpdateDate = DateTime.Now; objTeamMemberProfileRepository.addNewTeamMember(teammemberprofile); } } else { socioprofile.ProfileId = data.id.ToString(); socioprofilerepo.updateSocialProfile(socioprofile); } if (!objLiRepo.checkLinkedinUserExists(LinkedinUserId, user)) { objLiRepo.addLinkedinUser(objLinkedInAccount); } else { objLinkedInAccount.LinkedinUserId = LinkedinUserId; objLiRepo.updateLinkedinUser(objLinkedInAccount); } // GetLinkedInFeeds(_oauth, data.id, user.Id); } catch { } }
public string AddTumblrAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string code) { string ret = string.Empty; string AccessTokenResponse = string.Empty; try { oAuthTumbler requestHelper = new oAuthTumbler(); oAuthTumbler.TumblrConsumerKey = client_id; oAuthTumbler.TumblrConsumerSecret = client_secret; requestHelper.TumblrCallBackUrl = redirect_uri; AccessTokenResponse = requestHelper.GetAccessToken(oAuthTumbler.TumblrToken, code); logger.Error(AccessTokenResponse); string[] tokens = AccessTokenResponse.Split('&'); //extract access token & secret from response logger.Error(tokens); string accessToken = tokens[0].Split('=')[1]; logger.Error(accessToken); string accessTokenSecret = tokens[1].Split('=')[1]; logger.Error(accessTokenSecret); KeyValuePair <string, string> LoginDetails = new KeyValuePair <string, string>(accessToken, accessTokenSecret); JObject profile = new JObject(); try { profile = JObject.Parse(oAuthTumbler.OAuthData(Globals.UsersInfoUrl, "GET", LoginDetails.Key, LoginDetails.Value, null)); } catch (Exception ex) { } #region Add Tumblr Account objTumblrAccount = new Domain.Myfashion.Domain.TumblrAccount(); objTumblrAccount.Id = Guid.NewGuid(); objTumblrAccount.tblrUserName = profile["response"]["user"]["name"].ToString(); objTumblrAccount.UserId = Guid.Parse(UserId); objTumblrAccount.tblrAccessToken = accessToken; objTumblrAccount.tblrAccessTokenSecret = accessTokenSecret; objTumblrAccount.tblrProfilePicUrl = "http://api.tumblr.com/v2/blog/" + objTumblrAccount.tblrUserName + ".tumblr.com/avatar";//profile["response"]["user"]["name"].ToString(); objTumblrAccount.IsActive = 1; if (!objTumblrAccountRepository.checkTubmlrUserExists(objTumblrAccount)) { TumblrAccountRepository.Add(objTumblrAccount); #region Add Socialprofiles objSocialProfile = new Domain.Myfashion.Domain.SocialProfile(); objSocialProfile.Id = Guid.NewGuid(); objSocialProfile.UserId = Guid.Parse(UserId); objSocialProfile.ProfileId = profile["response"]["user"]["name"].ToString(); objSocialProfile.ProfileType = "tumblr"; objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 1; if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } #endregion #region Add TeamMemeberProfile Domain.Myfashion.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId)); Domain.Myfashion.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Myfashion.Domain.TeamMemberProfile(); objTeamMemberProfile.Id = Guid.NewGuid(); objTeamMemberProfile.TeamId = objTeam.Id; objTeamMemberProfile.Status = 1; objTeamMemberProfile.ProfileType = "tumblr"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = objTumblrAccount.tblrUserName; //Modified [13-02-15] objTeamMemberProfile.ProfilePicUrl = objTumblrAccount.tblrProfilePicUrl; objTeamMemberProfile.ProfileName = objTumblrAccount.tblrUserName; objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); #endregion } #endregion //if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeam.Id, objTumblrAccount.tblrUserName)) //{ // objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); //} #region Add Tumblr Feeds AddTunblrFeeds(UserId, LoginDetails, profile["response"]["user"]["name"].ToString()); #endregion } catch (Exception ex) { logger.Error("AddTumblrAccount => " + ex.StackTrace); } return(ret); }
public string AddYoutubeAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string code) { #region Local variables Inisitalisation string ret = string.Empty; string objRefresh = string.Empty; string refreshToken = string.Empty; string access_token = string.Empty; oAuthTokenYoutube ObjoAuthTokenYoutube = new oAuthTokenYoutube(); oAuthToken objToken = new oAuthToken(); Domain.Myfashion.Domain.YoutubeAccount objYoutubeAccount = new Domain.Myfashion.Domain.YoutubeAccount(); Domain.Myfashion.Domain.YoutubeChannel objYoutubeChannel; YoutubeChannelRepository objYoutubeChannelRepository = new YoutubeChannelRepository(); YoutubeAccountRepository objYoutubeAccountRepository = new YoutubeAccountRepository(); #endregion #region Get AccessToken and RefreshToken objToken.ConsumerKey = client_id; objToken.ConsumerSecret = client_secret; try { objRefresh = ObjoAuthTokenYoutube.GetRefreshToken(code, client_id, client_secret, redirect_uri); logger.Error("Abhay: ObjoAuthTokenYoutube()"); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); } JObject objaccesstoken = JObject.Parse(objRefresh); try { refreshToken = objaccesstoken["refresh_token"].ToString(); } catch (Exception ex) { access_token = objaccesstoken["access_token"].ToString(); ObjoAuthTokenYoutube.RevokeToken(access_token); Console.WriteLine(ex.StackTrace); return("Refresh Token Not Found"); } try { access_token = objaccesstoken["access_token"].ToString(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } #endregion #region Get user Profile and Add Youtube Account JArray userinfo = new JArray(); try { userinfo = objToken.GetUserInfo("me", access_token.ToString()); } catch (Exception ex) { } foreach (var itemEmail in userinfo) { try { objYoutubeAccount.Id = Guid.NewGuid(); objYoutubeAccount.Ytuserid = itemEmail["id"].ToString(); objYoutubeAccount.Emailid = itemEmail["email"].ToString(); try { objYoutubeAccount.Ytusername = itemEmail["given_name"].ToString(); } catch (Exception ex) { objYoutubeAccount.Ytusername = itemEmail["name"].ToString(); } objYoutubeAccount.Ytprofileimage = itemEmail["picture"].ToString(); objYoutubeAccount.Accesstoken = access_token; objYoutubeAccount.Refreshtoken = refreshToken; objYoutubeAccount.Isactive = 1; objYoutubeAccount.Entrydate = DateTime.Now; objYoutubeAccount.UserId = Guid.Parse(UserId); if (!objYoutubeAccountRepository.checkYoutubeUserExists(objYoutubeAccount)) { YoutubeAccountRepository.Add(objYoutubeAccount); ret = "Account Added Successfully"; } else { ret = "Account already Exist !"; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } #endregion #region Add Youtube Channels GlobusGooglePlusLib.Youtube.Core.Channels ObjChannel = new GlobusGooglePlusLib.Youtube.Core.Channels(); JArray objarray = new JArray(); try { string part = (oAuthTokenYoutube.Parts.contentDetails.ToString() + "," + oAuthTokenYoutube.Parts.statistics.ToString()); string Value = ObjChannel.Get_Channel_List(access_token, part, 50, true); JObject UserChannels = JObject.Parse(@Value); objarray = (JArray)UserChannels["items"]; } catch (Exception ex) { } foreach (var item in objarray) { objYoutubeChannel = new Domain.Myfashion.Domain.YoutubeChannel(); try { objYoutubeChannel.Id = Guid.NewGuid(); objYoutubeChannel.Channelid = item["id"].ToString(); objYoutubeChannel.Likesid = item["contentDetails"]["relatedPlaylists"]["likes"].ToString(); objYoutubeChannel.Favoritesid = item["contentDetails"]["relatedPlaylists"]["favorites"].ToString(); objYoutubeChannel.Uploadsid = item["contentDetails"]["relatedPlaylists"]["uploads"].ToString(); objYoutubeChannel.Watchhistoryid = item["contentDetails"]["relatedPlaylists"]["watchHistory"].ToString(); objYoutubeChannel.Watchlaterid = item["contentDetails"]["relatedPlaylists"]["watchLater"].ToString(); objYoutubeChannel.Googleplususerid = objYoutubeAccount.Ytuserid; objYoutubeChannel.UserId = Guid.Parse(UserId); try { string viewcnt = item["statistics"]["viewCount"].ToString(); objYoutubeChannel.ViewCount = Convert.ToInt32(viewcnt); string videocnt = item["statistics"]["videoCount"].ToString(); objYoutubeChannel.VideoCount = Convert.ToInt32(videocnt); string commentcnt = item["statistics"]["commentCount"].ToString(); objYoutubeChannel.CommentCount = Convert.ToInt32(commentcnt); string Subscribercnt = item["statistics"]["subscriberCount"].ToString(); objYoutubeChannel.SubscriberCount = Convert.ToInt32(Subscribercnt); try { string str = item["statistics"]["hiddenSubscriberCount"].ToString(); if (str == "false") { objYoutubeChannel.HiddenSubscriberCount = 0; } else { objYoutubeChannel.HiddenSubscriberCount = 1; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } if (!objYoutubeChannelRepository.checkYoutubeChannelExists(objYoutubeChannel.Channelid, Guid.Parse(UserId))) { YoutubeChannelRepository.Add(objYoutubeChannel); } } #endregion #region Add TeamMemberProfile Domain.Myfashion.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId)); Domain.Myfashion.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Myfashion.Domain.TeamMemberProfile(); objTeamMemberProfile.Id = Guid.NewGuid(); objTeamMemberProfile.TeamId = objTeam.Id; objTeamMemberProfile.Status = 1; objTeamMemberProfile.ProfileType = "youtube"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = objYoutubeAccount.Ytuserid; objTeamMemberProfile.ProfileName = objYoutubeAccount.Ytusername; objTeamMemberProfile.ProfilePicUrl = objYoutubeAccount.Ytprofileimage; if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeam.Id, objYoutubeAccount.Ytuserid)) { objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); } #endregion #region SocialProfile Domain.Myfashion.Domain.SocialProfile objSocialProfile = new Domain.Myfashion.Domain.SocialProfile(); objSocialProfile.Id = Guid.NewGuid(); objSocialProfile.ProfileType = "youtube"; objSocialProfile.ProfileId = objYoutubeAccount.Ytuserid; objSocialProfile.UserId = Guid.Parse(UserId); objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 1; if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } #endregion return(ret); }
public void GetPageProfile(dynamic data, oAuthLinkedIn _OAuth, string UserId, string CompanyPageId, string GroupId) { Domain.Socioboard.Domain.SocialProfile socioprofile = new Domain.Socioboard.Domain.SocialProfile(); Domain.Socioboard.Domain.GroupProfile grpProfile = new Domain.Socioboard.Domain.GroupProfile(); SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository(); Domain.Socioboard.Domain.LinkedinCompanyPage objLinkedincmpnypage = new Domain.Socioboard.Domain.LinkedinCompanyPage(); LinkedinCompanyPageRepository objLinkedCmpnyPgeRepo = new LinkedinCompanyPageRepository(); try { objLinkedincmpnypage.UserId = Guid.Parse(UserId); try { objLinkedincmpnypage.LinkedinPageId = data.Pageid.ToString(); } catch { } objLinkedincmpnypage.Id = Guid.NewGuid(); try { objLinkedincmpnypage.EmailDomains = data.EmailDomains.ToString(); } catch { } objLinkedincmpnypage.LinkedinPageName = data.name.ToString(); objLinkedincmpnypage.OAuthToken = _OAuth.Token; objLinkedincmpnypage.OAuthSecret = _OAuth.TokenSecret; objLinkedincmpnypage.OAuthVerifier = _OAuth.Verifier; try { objLinkedincmpnypage.Description = data.description.ToString(); } catch { } try { objLinkedincmpnypage.FoundedYear = data.founded_year.ToString(); } catch { } try { objLinkedincmpnypage.EndYear = data.end_year.ToString(); } catch { } try { objLinkedincmpnypage.Locations = data.locations.ToString(); } catch { } try { objLinkedincmpnypage.Specialties = data.Specialties.ToString(); } catch { } try { objLinkedincmpnypage.WebsiteUrl = data.website_url.ToString(); } catch { } try { objLinkedincmpnypage.Status = data.status.ToString(); } catch { } try { objLinkedincmpnypage.EmployeeCountRange = data.employee_count_range.ToString(); } catch { } try { objLinkedincmpnypage.Industries = data.industries.ToString(); } catch { } try { string NuberOfFollower = data.num_followers.ToString(); objLinkedincmpnypage.NumFollowers = Convert.ToInt16(NuberOfFollower); } catch { } try { objLinkedincmpnypage.CompanyType = data.company_type.ToString(); } catch { } try { objLinkedincmpnypage.LogoUrl = data.logo_url.ToString(); } catch { } try { objLinkedincmpnypage.SquareLogoUrl = data.square_logo_url.ToString(); } catch { } try { objLinkedincmpnypage.BlogRssUrl = data.blog_rss_url.ToString(); } catch { } try { objLinkedincmpnypage.UniversalName = data.universal_name.ToString(); } catch { } #region SocialProfiles socioprofile.UserId = Guid.Parse(UserId); socioprofile.ProfileType = "linkedincompanypage"; socioprofile.ProfileId = data.Pageid.ToString();; socioprofile.ProfileStatus = 1; socioprofile.ProfileDate = DateTime.Now; socioprofile.Id = Guid.NewGuid(); #endregion #region TeamMemberProfile //Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId)); //objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile(); //objTeamMemberProfile.Id = Guid.NewGuid(); //objTeamMemberProfile.TeamId = objTeam.Id; //objTeamMemberProfile.Status = 1; //objTeamMemberProfile.ProfileType = "linkedincompanypage"; //objTeamMemberProfile.StatusUpdateDate = DateTime.Now; //objTeamMemberProfile.ProfileId = socioprofile.ProfileId; grpProfile.Id = Guid.NewGuid(); grpProfile.GroupId = Guid.Parse(GroupId); grpProfile.GroupOwnerId = objLinkedincmpnypage.UserId; grpProfile.ProfileId = objLinkedincmpnypage.LinkedinPageId; grpProfile.ProfileType = "linkedincompanypage"; grpProfile.ProfileName = objLinkedincmpnypage.LinkedinPageName; grpProfile.EntryDate = DateTime.UtcNow; #endregion } catch { } try { if (!objSocialProfilesRepository.checkUserProfileExist(socioprofile)) { objSocialProfilesRepository.addNewProfileForUser(socioprofile); grpProfileRepo.AddGroupProfile(grpProfile); } if (!string.IsNullOrEmpty(GroupId)) { if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeamMemberProfile.TeamId, objLinkedincmpnypage.LinkedinPageId)) { objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); } } if (!objLinkedCmpnyPgeRepo.checkLinkedinPageExists(CompanyPageId, Guid.Parse(UserId))) { objLinkedCmpnyPgeRepo.addLinkenCompanyPage(objLinkedincmpnypage); } else { objLinkedincmpnypage.LinkedinPageId = CompanyPageId; objLinkedCmpnyPgeRepo.updateLinkedinPage(objLinkedincmpnypage); } } catch { } }
public string AddWordpressAccount(string code, string UserId, string GroupId) { WordpressAccountRepository objWPAccountRepo = new WordpressAccountRepository(); Domain.Myfashion.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Myfashion.Domain.TeamMemberProfile(); Domain.Myfashion.Domain.WordpressAccount objWordpressAccount = new Domain.Myfashion.Domain.WordpressAccount(); string client_id = ConfigurationManager.AppSettings["WordpessClientID"]; string redirect_uri = ConfigurationManager.AppSettings["WordpessCallBackURL"]; string client_secret = ConfigurationManager.AppSettings["WordpessClientSecret"]; oAuthWordpress _oAuth = new oAuthWordpress(); _oAuth.client_id = client_id; _oAuth.client_secret = client_secret; _oAuth.redirect_uri = redirect_uri; _oAuth.code = code; string postdata = _oAuth.PostDataToGetAccessToken(); try { string _token = _oAuth.APIWebRequest(Globals._TokenUrl, postdata); string access_token = JObject.Parse(_token)["access_token"].ToString(); _oAuth.access_token = access_token; //string postdata1 = _oAuth.PostDataToGetAccessToken(); //string _me = _oAuth.APIWebRequest(Globals._UserInfo, postdata1); string userinfo = _oAuth.APIWebRequestToGetUserInfo(Globals._UserInfo); JObject WP_User = JObject.Parse(userinfo); #region AddWPAccount objWordpressAccount.Id = Guid.NewGuid(); objWordpressAccount.WpUserId = WP_User["ID"].ToString(); objWordpressAccount.WpUserName = WP_User["username"].ToString(); objWordpressAccount.DisplayName = WP_User["display_name"].ToString(); objWordpressAccount.EmailId = WP_User["email"].ToString(); objWordpressAccount.PrimaryBlogId = WP_User["primary_blog"].ToString(); objWordpressAccount.TokenSiteId = WP_User["token_site_id"].ToString(); objWordpressAccount.UserAvtar = WP_User["avatar_URL"].ToString(); objWordpressAccount.ProfileUrl = WP_User["profile_URL"].ToString(); objWordpressAccount.SiteCount = Int32.Parse(WP_User["site_count"].ToString()); objWordpressAccount.UserId = Guid.Parse(UserId); objWordpressAccount.AccessToken = access_token; if (!objWPAccountRepo.IsProfileAllreadyExist(objWordpressAccount.UserId, objWordpressAccount.WpUserId)) { objWPAccountRepo.AddWordpressAccount(objWordpressAccount); } #endregion #region AddTeamMemberProfiles Domain.Myfashion.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId)); objTeamMemberProfile.Id = Guid.NewGuid(); objTeamMemberProfile.ProfileId = WP_User["ID"].ToString(); objTeamMemberProfile.TeamId = objTeam.Id; objTeamMemberProfile.ProfileType = "wordpress"; objTeamMemberProfile.Status = 1; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; if (!objTeamMemberProfileRepo.checkTeamMemberProfile(objTeam.Id, objTeamMemberProfile.ProfileId)) { objTeamMemberProfileRepo.addNewTeamMember(objTeamMemberProfile); } #endregion #region AddSocialProfile Domain.Myfashion.Domain.SocialProfile objSocialProfile = new Domain.Myfashion.Domain.SocialProfile(); objSocialProfile.Id = Guid.NewGuid(); objSocialProfile.UserId = Guid.Parse(UserId); objSocialProfile.ProfileType = "wordpress"; objSocialProfile.ProfileId = WP_User["ID"].ToString(); objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 1; if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } GetUserSites(UserId, objWordpressAccount.WpUserId); //GetUsersofblog(UserId,objWordpressAccount.WpUserId); #endregion } catch (Exception ex) { } return(""); }