Exemplo n.º 1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            int length = FileUpload1.PostedFile.ContentLength;
            string fileName = FileUpload1.FileName.ToString();
            string id = "";
            id = (string)(Session["ID"]);
            int userID = Int32.Parse(id);
            imgservice.ImgWebService imgSvc = new imgservice.ImgWebService();
            blobservice.BlobManager blobSvc = new blobservice.BlobManager();

            byte[] Image = null;


                if (FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "")
                {
                    Image = new byte[FileUpload1.PostedFile.ContentLength];
                    HttpPostedFile UploadedImage = FileUpload1.PostedFile;
                    UploadedImage.InputStream.Read(Image, 0, (int)FileUpload1.PostedFile.ContentLength);

                    string uri = blobSvc.UploadFile(Image, length, fileName); 

                    imgSvc.addImage(userID, Image, uri);

                    //add this line
                    msg.InnerHtml += "<br/> Successfully Added";
                }
                  
            
            else
            {
                msg.InnerHtml = "<br/> Invalid Admin Number";
            }
        }
Exemplo n.º 2
0
        protected void imgData_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string Id = "";
            Id = (string)(Session["ID"]);
            int userID = Int32.Parse(Id);
            imgservice.ImgWebService svc = new imgservice.ImgWebService();
            string rowIndex = e.CommandArgument.ToString();
            int id = Int32.Parse(imgData.DataKeys[Int32.Parse(rowIndex)].Value.ToString());
            if (e.CommandName == "deleteCommand")
            {
                svc.deleteOneImageRecord(id);
                
               DataSet workDS = new DataSet();
               workDS = svc.getRecordsByUser(userID);


               imgData.DataSource = svc.getRecordsByUser(userID);
               imgData.DataBind();
            }
            {
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack == false)
            {
                string id = "";
                id = (string)(Session["ID"]);
                int userID = Int32.Parse(id);
                //userID = Int32.Parse(Request.QueryString["userid"]);
                imgservice.ImgWebService svc = new imgservice.ImgWebService();
                DataSet workDS = new DataSet();
                workDS = svc.getRecordsByUser(userID);

                imgData.DataSource = svc.getRecordsByUser(userID);
                imgData.DataBind();
            }
            bool val1 = (System.Web.HttpContext.Current.User != null) && System.Web.HttpContext.Current.User.Identity.IsAuthenticated;
            if (val1 == true)
            {
                lblUser.Visible = true;
                lblUser.Text = Context.User.Identity.Name;
                lblLogin.Visible = false;
                lblGallery.Visible = true;
                lblLogout.Visible = true;
                lblChangePassword.Visible = true;
                lblProfile.Visible = true;

            }
            else
            {
                lblUser.Text = "";
                lblUser.Visible = false;
                lblLogin.Visible = true;
                lblLogout.Visible = false;
                lblGallery.Visible = false;
                lblChangePassword.Visible = false;
                lblProfile.Visible = false;
            }
        }
Exemplo n.º 4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.Clear();
            context.Response.ContentType = "image/jpeg";
            imgservice.ImgWebService svc = new imgservice.ImgWebService();


            //try catch to be removed after testing


            if (context.Request.QueryString["imageID"] != null)
            {
                string a = context.Request.QueryString["imageID"].ToString();
                int ID = 0 ;
                ID =  Convert.ToInt32(a);
               // ID = Convert.ToInt32(a);


                MemoryStream memoryStream = new MemoryStream(svc.getImagesByID(ID), false);
                System.Drawing.Image imgFromDataBase = System.Drawing.Image.FromStream(memoryStream);
                imgFromDataBase.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
            }
        }