protected void Page_PreRender(Object o, EventArgs e) { using (Database db = new MySqlDatabase()) { ClientInfo ci = db.GetClientInfo(Util.UserId); bool isNotExpired = true; Facebook.AuthenticationService authService = new Facebook.AuthenticationService(); Facebook.Me me; string accessToken = string.Empty; if (authService.TryAuthenticate(out me, out accessToken)) { isNotExpired = true; } else { db.RemoveSocialCredential(ci.ClientId, SocialConnector.Facebook); db.UpdateFacebookID(ci.ClientId); isNotExpired = false; } if (!string.IsNullOrEmpty(ci.SoundCloudId)) SoundcloudItag.Attributes.Add("class", "soundcloud"); else SoundcloudItag.Attributes.Add("class", "soundcloud disabled"); if (isNotExpired) FacebookHeading.Attributes.Add("class", "social facebook"); else FacebookHeading.Attributes.Add("class", "social facebook disabled"); if (!string.IsNullOrEmpty(ci.TwitterId)) TwitterHeading.Attributes.Add("class", "social twitter"); else TwitterHeading.Attributes.Add("class", "social twitter disabled"); } }
protected void RemoveFacebook_Submit(object sender, EventArgs e) { using (Database db = new MySqlDatabase()) { ClientInfo ci = db.GetClientInfo(Util.UserId); db.RemoveSocialCredential(ci.ClientId, SocialConnector.Facebook); db.UpdateFacebookID(ci.ClientId); } UserInformation(); FillAccountInformation(); Session["RemoveBtnIsFired"] = true; }
private bool FillFacebookInfo(ClientInfo ManagedUserInfo) { if (ManagedUserInfo != null) if (!string.IsNullOrEmpty(ManagedUserInfo.FacebookId)) { using (Database db = new MySqlDatabase()) { ClientInfo ci = db.GetClientInfo(Convert.ToInt64(Session["managed.userid"])); Session["FBACC"] = db.GetSocialCredential(ci.ClientId, SocialConnector.Facebook, "accesstoken"); string expiresRaw = db.GetSocialCredential(ci.ClientId, SocialConnector.Facebook, "accesstokenexpires"); Facebook.AuthenticationService authServices = new Facebook.AuthenticationService(); if (authServices.TryAuthenticateAdminFBCred(expiresRaw, Convert.ToString(Session["FBACC"]))) { Me me = authServices.GetMe(Convert.ToString(Session["FBACC"])); try { Session["FBID"] = me.Id; } catch { } FillFBFriendList(Convert.ToString(Session["FBACC"])); FillFBPageList(Convert.ToString(Session["FBACC"])); cbxShareToUserWall.Enabled = true; cbxShareToUserWall.Visible = true; divShareToUserWall.Visible = true; return true; } else { Session["FBACC"] = Session["FBID"] = null; db.RemoveSocialCredential(ci.ClientId, SocialConnector.Facebook); db.UpdateFacebookID(ci.ClientId); FillFBFriendList(null); FillFBPageList(null); cbxShareToUserWall.Enabled = false; cbxShareToUserWall.Visible = false; divShareToUserWall.Visible = false; return false; } } } Session["FBACC"] = Session["FBID"] = null; FillFBFriendList(null); FillFBPageList(null); cbxShareToUserWall.Enabled = false; cbxShareToUserWall.Visible = false; divShareToUserWall.Visible = false; return false; }
private bool FillOwnFacebookInfo() { if (!string.IsNullOrEmpty(_ManAccClientInfo.FacebookId)) { using (Database db = new MySqlDatabase()) { ClientInfo ci = db.GetClientInfo(Util.UserId); AuthenticationService authServices = new AuthenticationService(); Me me; string accessToken = string.Empty; if (authServices.TryAuthenticate(out me, out accessToken)) { Session["FBOwnACC"] = accessToken; try { Session["FBOwnID"] = me.Id; } catch { } FillOwnFBFriendList(Convert.ToString(Session["FBOwnACC"])); FillOwnFBPageList(Convert.ToString(Session["FBOwnACC"])); cbxShareToMyWall.Enabled = true; cbxShareToMyWall.Visible = true; divShareToMyWall.Visible = true; return true; } else { Session["FBOwnACC"] = Session["FBOwnID"] = null; db.RemoveSocialCredential(ci.ClientId, SocialConnector.Facebook); db.UpdateFacebookID(ci.ClientId); FillOwnFBFriendList(null); FillOwnFBPageList(null); cbxShareToMyWall.Enabled = false; cbxShareToMyWall.Visible = false; divShareToMyWall.Visible = false; return false; } } } Session["FBOwnACC"] = Session["FBOwnID"] = null; FillOwnFBFriendList(null); FillOwnFBPageList(null); cbxShareToMyWall.Enabled = false; cbxShareToMyWall.Visible = false; divShareToMyWall.Visible = false; return false; }
private void FillManagedArtistDropDown() { ddlManagedArtist.Items.Clear(); ddlManagedArtist.Items.Add(new ListItem("---", "0")); using (Database db = new MySqlDatabase()) { UserInfo[] uis = db.GetManagedUsers(Util.UserId, 1); foreach (UserInfo ui in uis) { ClientInfo ci = db.GetClientInfo(ui.UserId); ddlManagedArtist.Items.Add(new ListItem(ci.GetFullName(), ui.UserId.ToString())); } if (!string.IsNullOrEmpty(Request["id"])) { Session["managed.userid"] = Convert.ToInt64(Request["id"]); IsrcHandle.Text = GetIsrcCode(Convert.ToInt64(Session["managed.userid"])); ddlManagedArtist.SelectedValue = Request.QueryString["id"].ToString(); ClientInfo _ManagedUserInfo = db.GetClientInfo(Convert.ToInt64(Request.QueryString["id"])); string accessToken = db.GetSocialCredential(_ManagedUserInfo.ClientId, SocialConnector.Facebook, "accesstoken"); string expiresRaw = db.GetSocialCredential(_ManagedUserInfo.ClientId, SocialConnector.Facebook, "accesstokenexpires"); bool isNotExpired = true; Facebook.AuthenticationService authService = new Facebook.AuthenticationService(); if (authService.TryAuthenticateAdminFBCred(expiresRaw, accessToken)) { isNotExpired = true; } else { db.RemoveSocialCredential(_ManagedUserInfo.ClientId, SocialConnector.Facebook); db.UpdateFacebookID(_ManagedUserInfo.ClientId); isNotExpired = false; } } } }
private bool FillFacebookInfo() { if (!string.IsNullOrEmpty(_clientInfo.FacebookId)) { using (Database db = new MySqlDatabase()) { ClientInfo ci = db.GetClientInfo(Util.UserId); AuthenticationService authServices = new AuthenticationService(); Me me; string accessToken = string.Empty; if (authServices.TryAuthenticate(out me, out accessToken)) { Session["FBACC"] = accessToken; try { Session["FBID"] = me.Id; } catch { } Session["AppId"] = db.GetSetting("facebook.app_id"); Session["AppSecret"] = db.GetSetting("facebook.app_secret"); cbxSendToFacebook.Enabled = true; FacebookMsg.Enabled = true; cbxSendToFacebook.Visible = true; return true; } else { Session["FBACC"] = Session["FBID"] = Session["AppId"] = Session["AppSecret"] = null; db.RemoveSocialCredential(ci.ClientId, SocialConnector.Facebook); db.UpdateFacebookID(ci.ClientId); cbxSendToFacebook.Enabled = false; FacebookMsg.Enabled = false; cbxSendToFacebook.Visible = false; return false; } } } Session["FBACC"] = Session["FBID"] = Session["AppId"] = Session["AppSecret"] = null; cbxSendToFacebook.Enabled = false; FacebookMsg.Enabled = false; cbxSendToFacebook.Visible = false; return false; }