コード例 #1
0
        void LoadFeed(String email)
        {
            DBConnect  objDB      = new DBConnect();
            SqlCommand objCommand = new SqlCommand();

            objCommand.CommandType = CommandType.StoredProcedure;
            objCommand.CommandText = "TP_LoadProfileFeed";
            objCommand.Parameters.AddWithValue("@Email", email);
            DataSet FeedDS = objDB.GetDataSetUsingCmdObj(objCommand);

            if (FeedDS.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < FeedDS.Tables[0].Rows.Count; i++)
                {
                    ProfileFeed feed       = (ProfileFeed)LoadControl("ProfileFeed.ascx");
                    Posts       postObject = new Posts();
                    postObject.PostID     = FeedDS.Tables[0].Rows[i][0].ToString();
                    postObject.UserEmail  = FeedDS.Tables[0].Rows[i][1].ToString();
                    postObject.PostBody   = FeedDS.Tables[0].Rows[i][2].ToString();
                    postObject.DatePosted = DateTime.Parse(FeedDS.Tables[0].Rows[i][4].ToString());
                    postObject.ImageURL   = FeedDS.Tables[0].Rows[i][3].ToString();
                    feed.DataBind(postObject);
                    form1.Controls.Add(feed);
                }
            }
        }
コード例 #2
0
        void LoadFeed(String userEmail)
        {
            FindFriendsClass ffObject = new FindFriendsClass();

            ffObject.userEmail = userEmail;
            JavaScriptSerializer js = new JavaScriptSerializer();  //Coverts Object into JSON String
            String jsonffObject     = js.Serialize(ffObject);

            try
            {
                // Setup an HTTP POST Web Request and get the HTTP Web Response from the server.
                WebRequest request = WebRequest.Create("http://cis-iis2.temple.edu/Fall2018/CIS3342_tug49083/TermProjectWS/api/FindFriends/FindFriendsDS/");
                request.Method        = "POST";
                request.ContentLength = jsonffObject.Length;
                request.ContentType   = "application/json";

                // Write the JSON data to the Web Request
                StreamWriter writer = new StreamWriter(request.GetRequestStream());
                writer.Write(jsonffObject);
                writer.Flush();
                writer.Close();

                // Read the data from the Web Response, which requires working with streams.

                WebResponse  response      = request.GetResponse();
                Stream       theDataStream = response.GetResponseStream();
                StreamReader reader        = new StreamReader(theDataStream);
                String       data          = reader.ReadToEnd();

                reader.Close();
                response.Close();

                FindFriendsClass[] FriensdListArray = js.Deserialize <FindFriendsClass[]>(data);

                //Retrieve Own Feed



                if (FriensdListArray.Length == 0)
                {
                    //No Friends Found
                }
                if (FriensdListArray.Length > 0)
                {
                    for (int i = 0; i < FriensdListArray.Length; i++)
                    {
                        DBConnect  objDB      = new DBConnect();
                        SqlCommand objCommand = new SqlCommand();
                        objCommand.CommandType = CommandType.StoredProcedure;
                        objCommand.CommandText = "TP_LoadRegularFeed";
                        objCommand.Parameters.AddWithValue("@Email", FriensdListArray[i].userEmail);
                        DataSet FeedDS = objDB.GetDataSetUsingCmdObj(objCommand);
                        if (FeedDS.Tables[0].Rows.Count > 0)
                        {
                            for (int n = 0; n < FeedDS.Tables[0].Rows.Count; n++)
                            {
                                ProfileFeed feed       = (ProfileFeed)LoadControl("ProfileFeed.ascx");
                                Posts       postObject = new Posts();
                                postObject.PostID     = FeedDS.Tables[0].Rows[n][0].ToString();
                                postObject.UserEmail  = FeedDS.Tables[0].Rows[n][1].ToString();
                                postObject.PostBody   = FeedDS.Tables[0].Rows[n][2].ToString();
                                postObject.DatePosted = DateTime.Parse(FeedDS.Tables[0].Rows[n][4].ToString());
                                postObject.ImageURL   = FeedDS.Tables[0].Rows[n][3].ToString();
                                feed.DataBind(postObject);
                                form1.Controls.Add(feed);
                            }
                        }
                    }
                }

                //Retrieve Users Own Feed

                DBConnect  dbConnection = new DBConnect();
                SqlCommand objCommand1  = new SqlCommand();
                objCommand1.CommandType = CommandType.StoredProcedure;
                objCommand1.CommandText = "TP_LoadProfileFeed";
                objCommand1.Parameters.AddWithValue("@Email", userEmail);
                DataSet UserFeedDS = dbConnection.GetDataSetUsingCmdObj(objCommand1);

                if (UserFeedDS.Tables[0].Rows.Count == 0)
                {
                    //No Feed Available
                }
                if (UserFeedDS.Tables[0].Rows.Count > 0)
                {
                    for (int n = 0; n < UserFeedDS.Tables[0].Rows.Count; n++)
                    {
                        ProfileFeed feed1      = (ProfileFeed)LoadControl("ProfileFeed.ascx");
                        Posts       postObject = new Posts();
                        postObject.PostID     = UserFeedDS.Tables[0].Rows[n][0].ToString();
                        postObject.UserEmail  = UserFeedDS.Tables[0].Rows[n][1].ToString();
                        postObject.PostBody   = UserFeedDS.Tables[0].Rows[n][2].ToString();
                        postObject.DatePosted = DateTime.Parse(UserFeedDS.Tables[0].Rows[n][4].ToString());
                        postObject.ImageURL   = UserFeedDS.Tables[0].Rows[n][3].ToString();
                        feed1.DataBind(postObject);
                        form1.Controls.Add(feed1);
                    }
                }
            }
            catch (Exception errorEx)
            {
                Response.Write(errorEx.Message);
            }
        }
コード例 #3
0
        void LoadFeed()
        {
            //End of decoder
            var            RequestedUserEmail = Request.Cookies["ViewProfile"]["Email"].ToString();
            ProfileRequest ProfileObject      = new ProfileRequest();

            ProfileObject.Token           = "1234";
            ProfileObject.RequestedEmail  = RequestedUserEmail;
            ProfileObject.RequestingEmail = Session["userEmail"].ToString();

            JavaScriptSerializer js = new JavaScriptSerializer();  //Coverts Object into JSON String
            String jsonffObject     = js.Serialize(ProfileObject);

            try
            {
                // Setup an HTTP POST Web Request and get the HTTP Web Response from the server.
                WebRequest request = WebRequest.Create("http://cis-iis2.temple.edu/Fall2018/CIS3342_tug49083/TermProjectWS/api/LoadFeed/GetProfileFeed/");
                request.Method        = "POST";
                request.ContentLength = jsonffObject.Length;
                request.ContentType   = "application/json";

                // Write the JSON data to the Web Request
                StreamWriter writer = new StreamWriter(request.GetRequestStream());
                writer.Write(jsonffObject);
                writer.Flush();
                writer.Close();

                // Read the data from the Web Response, which requires working with streams.

                WebResponse  response      = request.GetResponse();
                Stream       theDataStream = response.GetResponseStream();
                StreamReader reader        = new StreamReader(theDataStream);
                String       data          = reader.ReadToEnd();

                reader.Close();
                response.Close();

                Utilities.ProfileFeedClass[] ProfileFeed = js.Deserialize <Utilities.ProfileFeedClass[]>(data);

                if (ProfileFeed.Length == 0)
                {
                    //Profile Info Not Available
                    NoFeedLabel.Visible = true;
                }
                else
                {
                    if (ProfileFeed.Length > 0)
                    {
                        for (int i = 0; i < ProfileFeed.Length; i++)
                        {
                            ProfileFeed feed       = (ProfileFeed)LoadControl("ProfileFeed.ascx");
                            Posts       postObject = new Posts();
                            postObject.PostID     = ProfileFeed[i].postID.ToString();
                            postObject.UserEmail  = ProfileFeed[i].userEmail.ToString();
                            postObject.PostBody   = ProfileFeed[i].postBody.ToString();
                            postObject.DatePosted = DateTime.Parse(ProfileFeed[i].datePosted.ToString());
                            postObject.ImageURL   = ProfileFeed[i].imageURL.ToString();
                            feed.DataBind(postObject);
                            form1.Controls.Add(feed);
                        }
                    }
                }
            }
            catch (Exception errorEx)
            {
                Response.Write(errorEx.Message);
            }
        }