protected void submit_Click(object sender, EventArgs e)
 {
     String user;
     WebServeur.ImageTransfertClient client = new WebServeur.ImageTransfertClient();
     if(client.checkLogin((user=userName.Text),password.Text))
     {
         resultat.Text = String.Format("Welcome,{0}!You have these albums.You can choose the album to show it.", user);
         Label2.Visible = false;
         userName.Visible = false;
         Label3.Visible = false;
         password.Visible = false;
         submit.Visible = false;
         String[] albums = client.getUserAlbum(user);
         for (int i = 0; i < albums.Length; i++)
         {
             System.Web.UI.WebControls.ListItem item = new System.Web.UI.WebControls.ListItem();
             albumList.Items.Add(item);
             item.Text = albums[i];
         }
     }
     else
     {
         resultat.Text = String.Format("user doesn't exist or password isn't correct.");
     }
 }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String id = Request.QueryString["ImageID"];
            // Si ce paramètre n'est pas nul
            if (id != null)
            {
                var client = new WebServeur.ImageTransfertClient();

                // on récupére notre image là où il faut
                WebServeur.ImageInfo imageInfo = new WebServeur.ImageInfo();
                imageInfo.imageID = id;
                Stream stream = client.DownloadImage(imageInfo);
                MemoryStream imageStreamEnMemoire = new MemoryStream();
                stream.CopyTo(imageStreamEnMemoire);
                Byte[] bytes = imageStreamEnMemoire.ToArray();

                // et on crée le contenu de notre réponse à la requête HTTP
                // (ici un contenu de type image)
                Response.Buffer = true;
                Response.Charset = "";
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.ContentType = "image/jpeg";
                Response.BinaryWrite(bytes);
                Response.Flush();
                Response.End();
            }
        }
Example #3
0
 private static void makeChoice()
 {
     // Instanciation de la référence de service
     WebServeur.ImageTransfertClient client = new WebServeur.ImageTransfertClient();
     String choice;
     while ((choice = welcome()) != "5")
     {
         switch (choice)
         {
             case "1":
                 Console.WriteLine("*******Please enter the userName.******");
                 String userName = Console.ReadLine();
                 Console.WriteLine("*******Please enter the password.******");
                 String password = Console.ReadLine();
                 client.addUser(userName, password);
                 Console.WriteLine("******Add sucessfully the user {0} in the BD.*******", userName);
                 break;
             case "2":
                 String[] users = client.showUsers();
                 Console.WriteLine("******Now we have these users in our BD: ******");
                 for (int i = 0; i < users.Length; i++)
                 {
                     Console.WriteLine(users[i]);
                 }
                 Console.WriteLine("******Please enter the userName which you want to delete.******");
                 client.deleteUser(Console.ReadLine());
                 Console.WriteLine("******Delete sucessfully.*******");
                 break;
             case "3":
                 String[] albums = client.showAlbums();
                 Console.WriteLine("******Now we have these albums in our BD: ******");
                 for (int i = 0; i < albums.Length; i++)
                 {
                     Console.WriteLine(albums[i]);
                 }
                 Console.WriteLine("******Please enter the albumID which you want to delete.******");
                 client.DelectAlbum(Console.ReadLine());
                 Console.WriteLine("******Delete sucessfully.*******");
                 break;
             case "4":
                 Console.WriteLine("******Please enter the imageID which you want to delete.******");
                 client.DelectImage(Console.ReadLine());
                 Console.WriteLine("******Delete sucessfully.*******");
                 break;
             default:
                 Console.WriteLine("******We dont have this choice.Sorry!******");
                 break;
         }
     }
     Console.WriteLine("******Thank you for using.Bye bye!******");
     Console.ReadLine();
 }
 protected void valid_Click(object sender, EventArgs e)
 {
     WebServeur.ImageTransfertClient client = new WebServeur.ImageTransfertClient();
     String[] photos = client.getAlbumPhotos(albumList.SelectedValue);
     for (int i = 0; i < photos.Length; i++)
     {
         System.Web.UI.WebControls.ImageButton img = new System.Web.UI.WebControls.ImageButton();
         Panel1.Controls.Add(img);
         img.ImageUrl = "Image.aspx?ImageID=" + photos[i];
         img.Width = 200;
         img.Height = 150;
         img.ID = photos[i];
     }
 }