Exemplo n.º 1
0
    public static FBLoginDetails ActivateFBUser(FBLoginDetails _FBLoginDetails)
    {
        if ((SessionState._SignInUser != null))
        {
            ConnectionClass conn = new ConnectionClass();
            SqlCommand cmd = new SqlCommand("sp1_brandyy_select_SelectBySmUID");
            cmd.Parameters.AddWithValue("@sm_uid", _FBLoginDetails.ID);
            cmd.Parameters.AddWithValue("@sm_id", 1);
            conn.GetDataSet(cmd);

            if (conn.IsSuccess && conn.DataSet.Tables[0].Rows.Count > 0  )
            {
                // check if the logged in user is same as the fb user registered in our database
                if (Convert.ToString(conn.DataSet.Tables[0].Rows[0]["email"]) == Convert.ToString(_FBLoginDetails.Email))
                {
                    // get user long lived access token and other profile details
                    importfbuserdetails t = new importfbuserdetails();
                    string longlivedtoken = t.getUserLongLivedAccessToken(_FBLoginDetails.AccessToken, SessionState._SignInUser.reg_uid);
                    InsertIntoRegistrationTbl_Fb(_FBLoginDetails, longlivedtoken);
                    t.getUserFriends(_FBLoginDetails.AccessToken, SessionState._SignInUser.reg_uid);
                    _FBLoginDetails.Message = "SUCCESS";
                    _FBLoginDetails.LoginSuccessRedirectHomePage = "myprofile.aspx";
                }
                else
                {
                    _FBLoginDetails.Message = "There is another user registered with the same account.<br>Please contact admin if there is a genuine breach.";
                }
            }
            else
            {

                // get user long lived access token and other profile details
                importfbuserdetails t = new importfbuserdetails();
                string longlivedtoken = t.getUserLongLivedAccessToken(_FBLoginDetails.AccessToken, SessionState._SignInUser.reg_uid);
                InsertIntoRegistrationTbl_Fb(_FBLoginDetails, longlivedtoken);
                t.getUserFriends(_FBLoginDetails.AccessToken, SessionState._SignInUser.reg_uid);
                _FBLoginDetails.Message = "SUCCESS";
                _FBLoginDetails.LoginSuccessRedirectHomePage = "myprofile.aspx";
            }
        }
        else
        {
            _FBLoginDetails.Message = "Your Login session has expired";
            _FBLoginDetails.LoginSuccessRedirectHomePage = "login.aspx";
        }

        return _FBLoginDetails; ;
    }
 private void getFacebookAccessToken()
 {
     string reg_uid = "4";
     string sm_id = "1";
     string token="";
     string sm_uid = "";
     {
         // get user access token
         SqlCommand cmd = new SqlCommand("sp_user_get_Token");
         cmd.Parameters.AddWithValue("@reg_uid", reg_uid);
         cmd.Parameters.AddWithValue("@sm_id", sm_id);
         ConnObj.GetDataSet(cmd);
         if (ConnObj.IsSuccess && ConnObj.DataSet.Tables.Count > 0 && ConnObj.DataSet.Tables[0].Rows.Count > 0)
         {
             token = Convert.ToString(ConnObj.DataSet.Tables[0].Rows[0]["token"]);
             sm_uid = Convert.ToString(ConnObj.DataSet.Tables[0].Rows[0]["sm_uid"]);
             importfbuserdetails obj = new importfbuserdetails();
             obj.getAllProfileDetails(reg_uid, token, sm_uid);
         }
     }
 }