public string GetGPusData(string UserId, string ProfileId) { Domain.Socioboard.Domain.GooglePlusAccount _GooglePlusAccount = objGooglePlusAccountRepository.GetGooglePlusAccount(Guid.Parse(UserId), ProfileId); GetGoogleplusCircles(UserId, ProfileId); GetUserActivities(_GooglePlusAccount.UserId.ToString(), _GooglePlusAccount.GpUserId, _GooglePlusAccount.AccessToken); return("Gplus Account Updated Successfully"); }
public string GetGooglePlusAccountDetailsById(string UserId, string ProfileId) { try { Domain.Socioboard.Domain.GooglePlusAccount objGpAccount = ObjGooglePlusAccountsRepo.getGooglePlusAccountDetailsById(ProfileId, Guid.Parse(UserId)); return(new JavaScriptSerializer().Serialize(objGpAccount)); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return("Something Went Wrong"); } }
public IHttpActionResult GetGooglePlusAccount(string ProfileId) { try { Domain.Socioboard.Domain.GooglePlusAccount objGpAccount = ObjGooglePlusAccountsRepo.getUserDetails(ProfileId); return(Ok(objGpAccount)); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(BadRequest("Something Went Wrong")); } }
public string UpdateGooglePlusAccountByAdmin(string ObjGooglePlus) { Domain.Socioboard.Domain.GooglePlusAccount ObjGooglePlusAccount = (Domain.Socioboard.Domain.GooglePlusAccount)(new JavaScriptSerializer().Deserialize(ObjGooglePlus, typeof(Domain.Socioboard.Domain.GooglePlusAccount))); try { ObjGooglePlusAccountsRepo.updateGooglePlusUser(ObjGooglePlusAccount); return(new JavaScriptSerializer().Serialize("Update Successfully")); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(new JavaScriptSerializer().Serialize("Something went Wrong")); } }
public void GetGoogleplusCircles(string UserId, string ProfileId) { try { Domain.Socioboard.Domain.GooglePlusAccount _GooglePlusAccount = objGooglePlusAccountRepository.GetGooglePlusAccount(Guid.Parse(UserId), ProfileId); oAuthTokenGPlus ObjoAuthTokenGPlus = new oAuthTokenGPlus(); oAuthToken objToken = new oAuthToken(); #region Get_InYourCircles try { string _InyourCircles = ObjoAuthTokenGPlus.APIWebRequestToGetUserInfo(Globals.strGetPeopleList.Replace("[userId]", _GooglePlusAccount.GpUserId).Replace("[collection]", "visible") + "?key=" + ConfigurationManager.AppSettings["Api_Key"].ToString(), _GooglePlusAccount.AccessToken); 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(), _GooglePlusAccount.AccessToken); JObject J_HaveYouInCircles = JObject.Parse(_HaveYouInCircles); _GooglePlusAccount.HaveYouInCircles = Convert.ToInt32(J_HaveYouInCircles["circledByCount"].ToString()); } catch (Exception ex) { _GooglePlusAccount.HaveYouInCircles = 0; } #endregion objGooglePlusAccountRepository.UpdateGooglePlusAccount(_GooglePlusAccount); } catch (Exception ex) { logger.Error(ex.Message); } }
public string GetGPusData(string UserId, string ProfileId) { Domain.Socioboard.Domain.GooglePlusAccount _GooglePlusAccount = objGooglePlusAccountRepository.GetGooglePlusAccount(Guid.Parse(UserId), ProfileId); //oAuthToken objToken = new oAuthToken(); oAuthTokenGPlus objToken = new oAuthTokenGPlus(); string finalToken = string.Empty; string finaltoken = objToken.GetAccessToken(_GooglePlusAccount.RefreshToken); try { JObject objArray = JObject.Parse(finaltoken); finalToken = objArray["access_token"].ToString(); GetGoogleplusCircles(UserId, ProfileId, finalToken); GetUserActivities(_GooglePlusAccount.UserId.ToString(), _GooglePlusAccount.GpUserId, finalToken, 0); // break; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } return("Gplus Account Updated Successfully"); }
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.Socioboard.Domain.GooglePlusAccount _GooglePlusAccount = new Domain.Socioboard.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.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId)); Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile(); objTeamMemberProfile.Id = Guid.NewGuid(); objTeamMemberProfile.TeamId = objTeam.Id; objTeamMemberProfile.Status = 1; objTeamMemberProfile.ProfileType = "gplus"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = _GooglePlusAccount.GpUserId; objTeamMemberProfile.ProfilePicUrl = _GooglePlusAccount.GpProfileImage; objTeamMemberProfile.ProfileName = _GooglePlusAccount.GpUserName; objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); #endregion #region SocialProfile Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.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 ""; } }
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.Socioboard.Domain.GooglePlusAccount _GooglePlusAccount = new Domain.Socioboard.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.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId)); Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile(); objTeamMemberProfile.Id = Guid.NewGuid(); objTeamMemberProfile.TeamId = objTeam.Id; objTeamMemberProfile.Status = 1; objTeamMemberProfile.ProfileType = "gplus"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = _GooglePlusAccount.GpUserId; objTeamMemberProfile.ProfilePicUrl = _GooglePlusAccount.GpProfileImage; objTeamMemberProfile.ProfileName = _GooglePlusAccount.GpUserName; objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); #endregion #region SocialProfile Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.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(""); } }