/// <updateGooglePlusUser> /// Update google pluse user account details. /// </summary> /// <param name="gpaccount">Set Values in a GooglePlusAccount Class Property and Pass the same Object of GooglePlusAccount Class.(Domain.GooglePlusAccount)</param> public void updateGooglePlusUser(GooglePlusAccount gpaccount) { //Creates a database connection and opens up a session using (NHibernate.ISession session = SessionFactory.GetNewSession()) { //After Session creation, start Transaction. using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { //Proceed action, to update google pluse account details session.CreateQuery("Update GooglePlusAccount set GpUserName =:gpusername,AccessToken =:access,RefreshToken=:refreshtoken,GpProfileImage =:gpprofileimage,RefreshToken=:refreshtoken,EmailId=:emailid where GpUserId = :gpuserid and UserId = :userid") .SetParameter("gpusername", gpaccount.GpUserName) .SetParameter("access", gpaccount.AccessToken) .SetParameter("refreshtoken",gpaccount.RefreshToken) .SetParameter("gpprofileimage", gpaccount.GpProfileImage) .SetParameter("emailid", gpaccount.EmailId) .SetParameter("fbuserid", gpaccount.GpUserId) .SetParameter("userid", gpaccount.UserId) .ExecuteUpdate(); transaction.Commit(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); // return 0; } }//End Transaction }//End Session }
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { if (Session["AdminProfile"] == null) { Response.Redirect("Default.aspx"); } string id = Request.QueryString["id"].ToString(); string type = Request.QueryString["type"].ToString(); string userid = Request.QueryString["userid"].ToString(); if (type == "twt") { TwtAcc = objTwtRepo.getUserInformation(Guid.Parse(userid), id); Session["updateData"] = TwtAcc; txtName.Text = TwtAcc.TwitterScreenName; //ddltatus.SelectedValue = TwtAcc.IsActive.ToString(); } if (type == "fb") { FBAcc = objFbRepo.getFacebookAccountDetailsById(id, Guid.Parse(userid)); Session["updateData"] = FBAcc; txtName.Text = FBAcc.FbUserName; // ddltatus.SelectedValue = FBAcc.IsActive.ToString(); } if (type == "li") { liAcc = objLiRepo.getLinkedinAccountDetailsById(id); Session["updateData"] = liAcc; txtName.Text = liAcc.LinkedinUserName; // ddltatus.SelectedValue = liAcc.IsActive.ToString(); } if (type == "ins") { InsAcc = objInsRepo.getInstagramAccountDetailsById(id, Guid.Parse(userid)); Session["updateData"] = InsAcc; txtName.Text = InsAcc.InsUserName; // ddltatus.SelectedValue = InsAcc.IsActive.ToString(); } if (type == "gp") { GpAcc = objgpRepo.getGooglePlusAccountDetailsById(id, Guid.Parse(userid)); Session["updateData"] = GpAcc; txtName.Text = GpAcc.GpUserName; //ddltatus.SelectedValue = GpAcc.IsActive.ToString(); } } } catch (Exception Err) { logger.Error(Err.Message); } }
public void addGooglePlusUser(GooglePlusAccount gpaccount) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { session.Save(gpaccount); transaction.Commit(); } } }
/// <addGooglePlusUser> /// Add google account of user /// </summary> /// <param name="gpaccount">Set Values in a GooglePlusAccount Class Property and Pass the same Object of GooglePlusAccount Class.(Domain.GooglePlusAccount)</param> public void addGooglePlusUser(GooglePlusAccount gpaccount) { //Creates a database connection and opens up a session using (NHibernate.ISession session = SessionFactory.GetNewSession()) { //After Session creation, start Transaction. using (NHibernate.ITransaction transaction = session.BeginTransaction()) { //Proceed action to Save new data . session.Save(gpaccount); transaction.Commit(); }//End Transaction }//End Session }
public void GetUerProfile(GooglePlusAccount objgpAcc,string acces_token,string refresh_token,Guid UserId) { PeopleController obj = new PeopleController(); oAuthToken objtoken = new oAuthToken(); GooglePlusAccountRepository objgpRepo = new GooglePlusAccountRepository(); SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository(); SocialProfile socioprofile = new SocialProfile(); socioprofile.Id = Guid.NewGuid(); socioprofile.ProfileDate = DateTime.Now; socioprofile.ProfileId = objgpAcc.GpUserId; socioprofile.ProfileType = "googleplus"; socioprofile.UserId = UserId; JArray objPeopleList = obj.GetPeopleList(objgpAcc.GpUserId, acces_token, "visible"); objgpAcc.PeopleCount = objPeopleList.Count(); if (!objgpRepo.checkGooglePlusUserExists(objgpAcc.GpUserId, UserId)) { objgpRepo.addGooglePlusUser(objgpAcc); if (!socioprofilerepo.checkUserProfileExist(socioprofile)) { socioprofilerepo.addNewProfileForUser(socioprofile); } else { socioprofilerepo.updateSocialProfile(socioprofile); } } else { objgpRepo.updateGooglePlusUser(objgpAcc); if (!socioprofilerepo.checkUserProfileExist(socioprofile)) { socioprofilerepo.addNewProfileForUser(socioprofile); } else { socioprofilerepo.updateSocialProfile(socioprofile); } } GetUserActivities(objgpAcc.GpUserId, acces_token, UserId); }
protected void Page_Load(object sender, EventArgs e) { oAuthToken objToken = new oAuthToken(); GplusHelper objGpHelper = new GplusHelper(); UserRepository objUserRepo = new UserRepository(); PeopleController obj = new PeopleController(); GooglePlusAccount objgpAcc = new GooglePlusAccount(); User user = new User(); try { string objRefresh = objToken.GetRefreshToken(Request.QueryString["code"]); if (!objRefresh.StartsWith("[")) objRefresh = "[" + objRefresh + "]"; JArray objArray = JArray.Parse(objRefresh); if (Session["login"] != null) { if (Session["login"].ToString() == "googleplus") { user = new User(); user.CreateDate = DateTime.Now; user.ExpiryDate = DateTime.Now.AddMonths(1); user.Id = Guid.NewGuid(); user.PaymentStatus = "unpaid"; } } else { /*User class in SocioBoard.Domain to check authenticated user*/ user = (User)Session["LoggedUser"]; } foreach (var item in objArray) { try { JArray objEmail = objToken.GetUserInfo("me", item["access_token"].ToString()); JArray objProfile = obj.GetPeopleProfile("me", item["access_token"].ToString()); // user = (User)HttpContext.Current.Session["LoggedUser"]; foreach (var itemEmail in objEmail) { objgpAcc.EmailId = itemEmail["email"].ToString(); } foreach (var itemProfile in objProfile) { objgpAcc.GpUserId = itemProfile["id"].ToString(); objgpAcc.AccessToken = item["access_token"].ToString(); objgpAcc.EntryDate = DateTime.Now; objgpAcc.GpProfileImage = itemProfile["image"]["url"].ToString(); objgpAcc.GpUserName = itemProfile["displayName"].ToString(); objgpAcc.Id =Guid.NewGuid(); objgpAcc.IsActive = 1; objgpAcc.RefreshToken = item["refresh_token"].ToString(); objgpAcc.UserId = user.Id; } if (Session["login"] != null) { if (string.IsNullOrEmpty(user.Password)) { if (Session["login"].ToString() == "googleplus") { if (objUserRepo.IsUserExist(user.EmailId)) { // user = null; user = objUserRepo.getUserInfoByEmail(user.EmailId); } else { user.EmailId = objgpAcc.EmailId; user.UserName = objgpAcc.GpUserName; user.ProfileUrl = objgpAcc.GpProfileImage; UserRepository.Add(user); } Session["LoggedUser"] = user; objgpAcc.UserId = user.Id; } } } objGpHelper.GetUerProfile(objgpAcc, item["access_token"].ToString(), item["refresh_token"].ToString(), user.Id); if (Session["login"] != null) { if (string.IsNullOrEmpty(user.Password)) { if (Session["login"].ToString() == "googleplus") { Response.Redirect("Plans.aspx"); } } else { Response.Redirect("Home.aspx"); } } else { Response.Redirect("Home.aspx"); } } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); Response.Redirect("Home.aspx"); } } } catch (Exception Err) { Console.Write(Err.Message.ToString()); logger.Error(Err.StackTrace); Response.Redirect("Home.aspx"); } }
public void updateGooglePlusUser(GooglePlusAccount gpaccount) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { session.CreateQuery("Update GooglePlusAccount set GpUserName =:gpusername,AccessToken =:access,RefreshToken=:refreshtoken,GpProfileImage =:gpprofileimage,RefreshToken=:refreshtoken,EmailId=:emailid where GpUserId = :gpuserid and UserId = :userid") .SetParameter("gpusername", gpaccount.GpUserName) .SetParameter("access", gpaccount.AccessToken) .SetParameter("refreshtoken",gpaccount.RefreshToken) .SetParameter("gpprofileimage", gpaccount.GpProfileImage) .SetParameter("emailid", gpaccount.EmailId) .SetParameter("fbuserid", gpaccount.GpUserId) .SetParameter("userid", gpaccount.UserId) .ExecuteUpdate(); transaction.Commit(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); // return 0; } } } }