Ignore:
Timestamp:
Aug 2, 2011, 4:50:49 PM (13 years ago)
Author:
bayral
Message:

First draw of pwg.image.add and pwg.imae.addtrunck.
addtrunck seem to be ok, but image.add return server error 500.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/PiwigoLib/TestPiwigoLib/Form1.cs

    r11872 r11890  
    4646                //List<PwgTag> lstTag = PwgServiceProvider.Instance.PwgTagsService.GetAdminListOfTag();
    4747
    48                 //Int32 Page = 0;
    49                 //Int32 PerPage = 0;
    50                 //Int32 Count = 0;
     48                Int32 Page = 0;
     49                Int32 PerPage = 0;
     50                Int32 Count = 0;
    5151
    52                 //List<PwgImage> lstImgTag = PwgServiceProvider.Instance.PwgTagsService.GetListOfImagesFormTags(new List<Int32>() { 1, 7 },
    53                 //    null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
    54                 //    ref Page, ref PerPage, ref Count);
     52                List<PwgImage> lstImgTag = PwgServiceProvider.Instance.PwgTagsService.GetListOfImagesFormTags(new List<Int32>() { 1, 7 },
     53                    null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
     54                    ref Page, ref PerPage, ref Count);
    5555
    56                 //List<PwgImage> lstImgCat = PwgServiceProvider.Instance.PwgCategoriesService.GetListOfImagesFormCategory(1,
    57                 //    null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
    58                 //    ref Page, ref PerPage, ref Count);
     56                List<PwgImage> lstImgCat = PwgServiceProvider.Instance.PwgCategoriesService.GetListOfImagesFormCategory(1,
     57                    null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
     58                    ref Page, ref PerPage, ref Count);
    5959
    6060                //Console.WriteLine("lstImg : Page " + Page.ToString() + " PerPage " + PerPage);
     
    7474                //lstCat = PwgServiceProvider.Instance.PwgCategoriesService.GetAdminListOfCategory();
    7575
    76                 //FileInfo fi = new FileInfo("C:\\Users\\bayral\\Downloads\\49133_1636405570_2648232_n.jpg");
    77                 //PwgImageAdded imgAdd = PwgServiceProvider.Instance.PwgImagesService.addImageByMultiPartForm(fi, null, 1, "benoit", "byarl", "test upload", 0, new List<PwgTag>() { new PwgTag() { Name = "Benoit" }, new PwgTag() { Name = "Noé" } });
     76                FileInfo fiBig = new FileInfo("C:\\Users\\bayral\\Downloads\\49133_1636405570_2648232_n.jpg");
     77                FileInfo fiThumb = new FileInfo(MakeThumb(fiBig,"C:\\Users\\bayral\\Downloads\\49133_1636405570_2648232_n_thum.jpg",64));
     78                FileInfo fiLow = new FileInfo(MakeThumb(fiBig,"C:\\Users\\bayral\\Downloads\\49133_1636405570_2648232_n_low.jpg",256));
    7879
    79                 rc = PwgServiceProvider.Instance.PwgImagesService.DeleteImage(319, sess.SecurityToken);
     80                //PwgImageAdded imgAdd = PwgServiceProvider.Instance.PwgImagesService.addImageByMultiPartForm(fiBig, null, 1, "benoit", "byarl", "test upload", 0, new List<PwgTag>() { new PwgTag() { Name = "Benoit" }, new PwgTag() { Name = "Noé" } });
     81                rc = PwgServiceProvider.Instance.PwgImagesService.addImage(fiBig, fiLow, fiThumb, "Benoit", "bayral", DateTime.Now, "demo", null, null, PwgConfidentLevelEnum.All);
     82                //rc = PwgServiceProvider.Instance.PwgImagesService.DeleteImage(319, sess.SecurityToken);
    8083
    81                 PwgImageInfo info = PwgServiceProvider.Instance.PwgImagesService.getImageInfo(319, null, null);
    82 
     84                //PwgImageInfo info = PwgServiceProvider.Instance.PwgImagesService.getImageInfo(imgAdd.Id, null, null);
     85               
    8386                //PwgImageRate imgRate = PwgServiceProvider.Instance.PwgImagesService.RateImage(1, 5);
    8487
     
    9396        }
    9497
     98        private string MakeThumb(FileInfo fi, String ext, int size)       
     99        {
     100        // create an image object, using the filename we just retrieved
     101        System.Drawing.Image image = System.Drawing.Image.FromFile(fi.FullName);
     102
     103        // create the actual thumbnail image
     104        System.Drawing.Image thumbnailImage = image.GetThumbnailImage(size, size, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
     105
     106        // make a memory stream to work with the image bytes
     107        FileStream imageStream = new FileStream(ext, FileMode.OpenOrCreate);
     108
     109        // put the image into the memory stream
     110        thumbnailImage.Save(imageStream, System.Drawing.Imaging.ImageFormat.Jpeg);
     111
     112        imageStream.Close();
     113        return ext;
     114        }
     115
     116        /// <summary>
     117        /// Required, but not used
     118        /// </summary>
     119        /// <returns>true</returns>
     120        public bool ThumbnailCallback()
     121        {
     122            return true;
     123        }
     124
     125
    95126        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    96127        {
Note: See TracChangeset for help on using the changeset viewer.