void SetImageGallery(String email)
        {
            DBConnect  objDB      = new DBConnect();
            SqlCommand objCommand = new SqlCommand();

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

            ImageGalleryGV.DataSource = ImageGDS;
            ImageGalleryGV.DataBind();


            if (ImageGalleryGV.Rows.Count == 0)
            {
                NoImagesLabel.Visible = true;
            }
            else
            {
                for (var i = 0; i < ImageGalleryGV.Rows.Count; i++)
                {
                    Image PhotoCollectionImage = (Image)ImageGalleryGV.Rows[i].FindControl("GalleryCollectionImages");
                    //Label ImageIDLabel = (Label)ImageGalleryGV.Rows[i].FindControl("GalleryImageID");
                    //var tempPhotoID = objDB.GetField("ImageID", i).ToString();
                    var tempURL = "Storage\\" + objDB.GetField("ImageURL", i).ToString();
                    PhotoCollectionImage.ImageUrl = tempURL;
                    //ImageIDLabel.Text = tempPhotoID;
                }
            }
        }
Exemple #2
0
        void SetImageGallery(String RequestingUserEmail)
        {
            //End of decoder
            var            RequestedUserEmail = Request.Cookies["ViewProfile"]["Email"].ToString();
            ProfileRequest ProfileObject      = new ProfileRequest();

            ProfileObject.Token           = "1234";
            ProfileObject.RequestedEmail  = RequestedUserEmail;
            ProfileObject.RequestingEmail = RequestingUserEmail;

            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/ImageGallery/GetImages/");
                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.GalleryImagesClass[] ImagesInfo = js.Deserialize <Utilities.GalleryImagesClass[]>(data);

                if (ImagesInfo.Length == 0)
                {
                    //Profile Info Not Available
                    NoImagesLabel.Visible = true;
                }
                else
                {
                    ImageGalleryGV.DataSource = ImagesInfo;
                    ImageGalleryGV.DataBind();
                    for (int i = 0; i < ImageGalleryGV.Rows.Count; i++)
                    {
                        Image PhotoCollectionImage = (Image)ImageGalleryGV.Rows[i].FindControl("GalleryCollectionImages");
                        var   tempURL = "Storage\\" + (ImageGalleryGV.Rows[i].FindControl("GalleryImageURL") as Label).Text;
                        PhotoCollectionImage.ImageUrl = tempURL;
                    }
                }
            }
            catch (Exception errorEx)
            {
                Response.Write(errorEx.Message);
            }
        }