Ignore:
Timestamp:
Aug 1, 2011, 5:47:03 PM (13 years ago)
Author:
bayral
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/PiwigoLib/PiwigoLib/Proxy/PwgImagesProxy.cs

    r11850 r11872  
    1818         * pwg.images.addChunk
    1919         * pwg.images.addComment
    20          * pwg.images.addFile
    21          * pwg.images.addSimple
     20         * pwg.images.addFile               
     21         * pwg.images.addSimple            pwg_images_addSimple
    2222         * pwg.images.checkFiles
    2323         * pwg.images.checkUpload
    24          * pwg.images.delete
     24         * pwg.images.delete               pwg_images_delete
    2525         * pwg.images.exist
    2626         * pwg.images.getInfo
     
    6161        }
    6262
    63         static internal PwgBaseProxyReponse pwg_images_addSimple(FileInfo fileImage, Int32? imageId, Int32? categoryId, String imageName, String imageAuthor, String imageComment, Int32? imageLevel, String imageTags)
     63        /// <summary>
     64        /// pwg.images.addSimple
     65        /// </summary>
     66        /// <param name="fileImage"></param>
     67        /// <param name="imageId"></param>
     68        /// <param name="categoryId"></param>
     69        /// <param name="imageName"></param>
     70        /// <param name="imageAuthor"></param>
     71        /// <param name="imageComment"></param>
     72        /// <param name="imageLevel"></param>
     73        /// <param name="imageTags"></param>
     74        /// <returns></returns>
     75        static internal PwgAddSimpleImageProxyResponse pwg_images_addSimple(FileInfo fileImage, Int32? imageId, Int32? categoryId, String imageName, String imageAuthor, String imageComment, Int32? imageLevel, List<PwgTag> imageTags)
    6476        {
    65             PwgBaseProxyReponse response = null;
     77            PwgAddSimpleImageProxyResponse response = null;
    6678
    6779            Dictionary<String, String> dcFiles  = new Dictionary<string,string>();
    6880            Dictionary<String, String> dcFields = new Dictionary<string,string>();
    69            
     81            String stringData = String.Empty;
     82
    7083            try
    7184            {
    7285                dcFields.Add("method", "pwg.images.addSimple");
    73                 if (imageId.HasValue) { dcFields.Add("image_id", imageId.Value.ToString()); }
    74                 if (categoryId.HasValue) { dcFields.Add("category", categoryId.Value.ToString()); }
    75                 if (imageLevel.HasValue) { dcFields.Add("level", imageLevel.Value.ToString()); }
    76                 if (!String.IsNullOrEmpty(imageName)) { dcFields.Add("name", imageName); }
    77                 if (!String.IsNullOrEmpty(imageAuthor)) { dcFields.Add("author", imageAuthor); }
    78                 if (!String.IsNullOrEmpty(imageComment)) { dcFields.Add("comment", imageComment); }
    79                 if (!String.IsNullOrEmpty(imageTags)) { dcFields.Add("tags", imageTags); }
     86                PwgProxyReponseHelper.buildDicFieldFromValue<Int32>(imageId, "image_id", ref dcFields);
     87                PwgProxyReponseHelper.buildDicFieldFromValue<Int32>(categoryId, "category", ref dcFields);
     88                PwgProxyReponseHelper.buildDicFieldFromValue<Int32>(imageLevel, "level", ref dcFields);
     89                PwgProxyReponseHelper.buildDicFieldFromValue<String>(imageName, "name", ref dcFields);
     90                PwgProxyReponseHelper.buildDicFieldFromValue<String>(imageAuthor, "author", ref dcFields);
     91                PwgProxyReponseHelper.buildDicFieldFromValue<String>(imageComment,"comment",  ref dcFields);
     92                PwgProxyReponseHelper.buildDicFieldFromArray<PwgTag>(imageTags, "tags", ref dcFields);
    8093
    8194                if ((fileImage != null) && (fileImage.Exists))
     
    88101                }
    89102
    90                 response = PwgGenericProxy<PwgBaseProxyReponse>.PostAsMultiPartForm(PwgConfigProxy.PwgServeurUri, dcFiles, dcFields);           
     103                response = PwgGenericProxy<PwgAddSimpleImageProxyResponse>.PostAsMultiPartForm(PwgConfigProxy.PwgServeurUri, dcFiles, dcFields);           
    91104            }
    92105            catch (Exception ex)
     
    97110            return response;
    98111        }
     112
     113        /// <summary>
     114        /// pwg.images.delete
     115        /// </summary>
     116        /// <param name="imageId"></param>
     117        /// <param name="SecurityToken"></param>
     118        /// <returns></returns>
     119        static internal PwgBaseProxyReponse pwg_images_delete(Int32 imageId,
     120                                                              String SecurityToken)
     121        {
     122            PwgBaseProxyReponse response = null;
     123            try
     124            {
     125                StringBuilder data = new StringBuilder();
     126                Boolean firstOcc = true;
     127                data.Append("method=pwg.images.delete");
     128                firstOcc = false;
     129                PwgProxyReponseHelper.buildQueryFromValue<Int32>(imageId, "image_id", ref firstOcc, data);
     130                PwgProxyReponseHelper.buildQueryFromValue<String>(SecurityToken, "pwg_token", ref firstOcc, data);
     131
     132                response = PwgGenericProxy<PwgBaseProxyReponse>.Post(
     133                                PwgConfigProxy.PwgServeurUri,
     134                                data.ToString());
     135            }
     136            catch (Exception ex)
     137            {
     138                throw new PwgProxyException("pwg_images_delete", ex);
     139            }
     140
     141            return response;
     142        }
     143
     144        static internal PwgImageInfoProxyResponse pwg_images_getInfos(Int32 imageId, Int32? commentPage, Int32? commentsPerPage)
     145        {
     146            PwgImageInfoProxyResponse response = null;
     147            try
     148            {
     149                StringBuilder data = new StringBuilder();
     150                Boolean firstOcc = true;
     151                data.Append("method=pwg.images.getInfo");
     152                firstOcc = false;
     153                PwgProxyReponseHelper.buildQueryFromValue<Int32>(imageId, "image_id", ref firstOcc, data);
     154                PwgProxyReponseHelper.buildQueryFromValue<Int32>(commentPage, "comments_page", ref firstOcc, data);
     155                PwgProxyReponseHelper.buildQueryFromValue<Int32>(commentsPerPage, "comments_per_page", ref firstOcc, data);
     156
     157                response = PwgGenericProxy<PwgImageInfoProxyResponse>.Post(
     158                                PwgConfigProxy.PwgServeurUri,
     159                                data.ToString());
     160            }
     161            catch (Exception ex)
     162            {
     163                throw new PwgProxyException("pwg_images_getInfos", ex);
     164            }
     165
     166            return response;
     167        }
     168
    99169    }
    100170
Note: See TracChangeset for help on using the changeset viewer.