Esempio n. 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Session["Email"] == null)
         {
             Server.Transfer("Default.aspx", false);
         }
         else
         {
             // Create an HTTP Web Request and get the HTTP Web Response from the server.
             string     email             = Session["Email"].ToString();
             string     requestingEmail   = Session["TargetEmail"].ToString();
             int        verificationToken = Convert.ToInt32(Session["VerificationToken"].ToString());
             WebRequest request           = WebRequest.Create("http://localhost:35664/api/SocialNetworkService/GetProfile/" + email + "/" + requestingEmail + "/" + verificationToken);
             //WebRequest request = WebRequest.Create("http://cis-iis2.temple.edu/fall2018/cis3342_tug26951/TermProjectWS/api/SocialNetworkService/GetProfile/" + email + "/" + requestingEmail + "/" + verificationToken);
             WebResponse response = request.GetResponse();
             // Read the data from the Web Response, which requires working with streams.
             Stream       theDataStream = response.GetResponseStream();
             StreamReader reader        = new StreamReader(theDataStream);
             String       data          = reader.ReadToEnd();
             reader.Close();
             response.Close();
             // Deserialize a JSON string into a Team object.
             JavaScriptSerializer js = new JavaScriptSerializer();
             SocialNetworkingClassLibrary.Profile profile = js.Deserialize <SocialNetworkingClassLibrary.Profile>(data);
             profileImageDiv.InnerHtml =
                 "<br /><img src= \"" + profile.User.ProfilePhotoUrl + "\" style=\"width:200px; height:200px;\"></img>";
             profileInformationDiv.InnerHtml = "<br /><br /><br /><br /><h2>" + profile.User.FirstName + " " + profile.User.LastName + "</h2>";
             if (profile.Friends != null)
             {
                 PrivacyColumn.Visible = false;
                 gvFriends.DataSource  = profile.Friends;
                 gvFriends.DataBind();
                 btnSubmitPost.Click += btnSubmitPost_Click;
                 gvPhotos.DataSource  = profile.Photos;
                 gvPhotos.DataBind();
                 DataSet ds = new DataSet();
                 ds = procedures.GetProfilePosts(Session["TargetEmail"].ToString());
                 int         rows = ds.Tables[0].Rows.Count;
                 PostControl ctrl;
                 for (int i = 0; i < rows; i++)
                 {
                     ctrl = (PostControl)LoadControl("PostControl.ascx");
                     String name = ds.Tables[0].Rows[i]["FirstName"].ToString() + " " + ds.Tables[0].Rows[i]["LastName"].ToString();
                     ctrl.ImageURL   = ds.Tables[0].Rows[i]["ProfilePhotoUrl"].ToString();
                     ctrl.PosterName = ds.Tables[0].Rows[i]["Email"].ToString();
                     ctrl.Time       = ds.Tables[0].Rows[i]["Date"].ToString();
                     ctrl.Post       = ds.Tables[0].Rows[i]["Message"].ToString();
                     previousPostColumn.Controls.Add(ctrl);
                 }
             }
             else
             {
                 friends.Visible    = false;
                 postColumn.Visible = false;
             }
         }
     }
 }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["Email"] == null)
                {
                    Server.Transfer("Default.aspx", false);
                }
                else
                {
                    // Create an HTTP Web Request and get the HTTP Web Response from the server.
                    string     email    = Session["Email"].ToString();
                    string     password = Session["Password"].ToString();
                    WebRequest request  = WebRequest.Create("http://localhost:35664/api/SocialNetworkService/GetMyProfile/" + email + "/" + password);
                    //WebRequest request = WebRequest.Create("http://cis-iis2.temple.edu/fall2018/cis3342_tug26951/TermProjectWS/api/SocialNetworkService/GetMyProfile/" + email + "/" + password);
                    WebResponse response = request.GetResponse();
                    // Read the data from the Web Response, which requires working with streams.
                    Stream       theDataStream = response.GetResponseStream();
                    StreamReader reader        = new StreamReader(theDataStream);
                    String       data          = reader.ReadToEnd();
                    reader.Close();
                    response.Close();
                    // Deserialize a JSON string into a Team object.
                    JavaScriptSerializer js = new JavaScriptSerializer();
                    SocialNetworkingClassLibrary.Profile myProfile = js.Deserialize <SocialNetworkingClassLibrary.Profile>(data);
                    profileImageDiv.InnerHtml       = "<br /><img src= \"" + myProfile.User.ProfilePhotoUrl + "\" style=\"width:100%; height:200px;\"></img>";
                    profileInformationDiv.InnerHtml = "<br /><br /><br /><br /><h2>" + myProfile.User.FirstName + " " + myProfile.User.LastName + "</h2>";

                    profileContactInformationDiv.InnerHtml  = "<h2>Contact Information</h2>";
                    profileContactInformationDiv.InnerHtml += "<p>Organization: " + myProfile.User.Organization + "</p>";
                    profileContactInformationDiv.InnerHtml += "<p>Address: " + myProfile.User.Address + " " + myProfile.User.City + ", " + myProfile.User.State + " " + myProfile.User.Zip + "</p>";
                    profileContactInformationDiv.InnerHtml += "<p>Phone Number: " + myProfile.User.PhoneNumber;
                    gvFriends.DataSource = myProfile.Friends;
                    gvFriends.DataBind();
                    gvPhotos.DataSource = myProfile.Photos;
                    gvPhotos.DataBind();
                    //imgPosterIcon.ImageUrl = ImageURL;
                    //lblPosterName.Text = posterName;
                    //lblTime.Text = Time;
                    //lblPost.Text = Post;

                    DataSet ds = new DataSet();
                    ds = procedures.GetProfilePosts(Session["Email"].ToString());
                    int         rows = ds.Tables[0].Rows.Count;
                    PostControl ctrl;
                    for (int i = 0; i < rows; i++)
                    {
                        ctrl = (PostControl)LoadControl("PostControl.ascx");
                        String name = ds.Tables[0].Rows[i]["FirstName"].ToString() + " " + ds.Tables[0].Rows[i]["LastName"].ToString();
                        ctrl.ImageURL   = ds.Tables[0].Rows[i]["ProfilePhotoUrl"].ToString();
                        ctrl.PosterName = ds.Tables[0].Rows[i]["Email"].ToString();
                        ctrl.Time       = ds.Tables[0].Rows[i]["Date"].ToString();
                        ctrl.Post       = ds.Tables[0].Rows[i]["Message"].ToString();
                        previousPostColumn.Controls.Add(ctrl);
                    }
                }
            }
        }