コード例 #1
0
        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");
            }
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        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;
                    }

                }
            }
        }