コード例 #1
0
        protected void lnkMyAccount_Click(object sender, EventArgs e)
        {
            View("Profile");
            btnUpdateInfo.Visible = true;
            HttpCookie myCookie = Request.Cookies["LoginCookie"];

            if (myCookie == null)
            {
                return;
            }
            String token   = myCookie.Values["Password"];
            String myEmail = myCookie.Values["Email"];
            String url     = "http://cis-iis2.temple.edu/Fall2018/CIS3342_tuf97565/TermProjectWS/api/SocialNetworkService/GetProfile?requestingEmail=" + myEmail + "&requestedEmail=" + myEmail + "&token=" + token;
            //String url = "http://localhost:4004/api/SocialNetworkService/GetProfile?requestingEmail=" + myEmail + "&requestedEmail=" + myEmail + "&token=" + token;


            //GetFriends/{RequestingUsername}/{RequestedUsername}/{VerificationToken}
            WebRequest findPeoplebyName = WebRequest.Create(url);

            WebResponse responseUsers = findPeoplebyName.GetResponse();

            Stream       theDataStream1 = responseUsers.GetResponseStream();
            StreamReader reader1        = new StreamReader(theDataStream1);
            String       found          = reader1.ReadToEnd();

            reader1.Close();
            responseUsers.Close();

            // Deserialize a JSON string into a Team object.
            UserOBJ user = js.Deserialize <UserOBJ>(found);

            lblShowName.Text         = user.First + " " + user.Last;
            lblShowEmail.Text        = user.Email;
            lblShowOrganization.Text = user.Organization;
            lblShowCity.Text         = user.City;
            lblShowPhone.Text        = user.Phone;
            lblShowState.Text        = user.State;

            String url2 = "http://cis-iis2.temple.edu/Fall2018/CIS3342_tuf97565/TermProjectWS/api/SocialNetworkService/GetWall?requestingEmail=" + myEmail + "&requestedEmail=" + myEmail + "&token=" + token;
            //String url2 = "http://localhost:4004/api/SocialNetworkService/GetWall?requestingEmail=" + myEmail + "&requestedEmail=" + myEmail + "&token=" + token;

            //GetFriends/{RequestingUsername}/{RequestedUsername}/{VerificationToken}
            WebRequest getWall = WebRequest.Create(url2);

            WebResponse responseWall = getWall.GetResponse();

            Stream       theDataStream2 = responseWall.GetResponseStream();
            StreamReader reader2        = new StreamReader(theDataStream2);
            String       found2         = reader2.ReadToEnd();

            reader2.Close();
            responseWall.Close();

            // Deserialize a JSON string into a Team object.
            List <PostOBJ> myWall = js.Deserialize <List <PostOBJ> >(found2);

            gvWall.DataSource = myWall;
            gvWall.DataBind();
        }
コード例 #2
0
        protected void gvFriends_RowCommand(Object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
        {
            HttpCookie myCookie = Request.Cookies["LoginCookie"];

            if (myCookie == null)
            {
                return;
            }
            String token    = myCookie.Values["Password"];
            int    rowIndex = int.Parse(e.CommandArgument.ToString());

            if (e.CommandName == "ViewProfile")
            {
                View("Profile");
                String url = "http://cis-iis2.temple.edu/Fall2018/CIS3342_tuf97565/TermProjectWS/api/SocialNetworkService/GetProfile?requestingEmail=" + Email + "&requestedEmail=" + gvFriends.Rows[rowIndex].Cells[0].Text + "&token=" + token;

                //String url = "http://*****:*****@Email1", Email);
                GetMessages.Parameters.AddWithValue("@Email2", gvFriends.Rows[rowIndex].Cells[0].Text);
                gvMessages.DataSource = objDB.GetDataSetUsingCmdObj(GetMessages);
                gvMessages.DataBind();
            }
            if (e.CommandName == "Subscribe")
            {
                Subscribe.CommandText = "TP_Subscribe";
                Subscribe.CommandType = CommandType.StoredProcedure;
                Subscribe.Parameters.AddWithValue("@Email1", Email);
                Subscribe.Parameters.AddWithValue("@Email2", gvFriends.Rows[rowIndex].Cells[0].Text);

                objDB.DoUpdateUsingCmdObj(Subscribe);
            }
            if (e.CommandName == "UnSubscribe")
            {
                UnSubscribe.CommandText = "TP_UnSubscribe";
                UnSubscribe.CommandType = CommandType.StoredProcedure;
                UnSubscribe.Parameters.AddWithValue("@Email1", Email);
                UnSubscribe.Parameters.AddWithValue("@Email2", gvFriends.Rows[rowIndex].Cells[0].Text);

                objDB.DoUpdateUsingCmdObj(UnSubscribe);
            }
        }