public PwgImageAdded addImageByMultiPartForm(FileInfo fileImage, Int32? imageId, Int32? AlbumId, String imageName, String imageAuthor, String imageComment, PwgConfidentLevelEnum? imageLevel, List<PwgTag> imageTags) { PwgImageAdded returnValue = new PwgImageAdded(); try { PwgAddSimpleImageProxyResponse response = PwgImagesProxy.pwg_images_addSimple(fileImage, imageId, AlbumId, imageName, imageAuthor, imageComment, (int) imageLevel, imageTags); if (response.Retour != PwgBaseProxyReponseRetourEnum.Ok) { if (response.Erreur != null) { throw new PwgServiceException("addImageByMultiPartForm, the server has return the error.", response.Erreur.Code, response.Erreur.Message); } else { throw new PwgServiceException("addImageByMultiPartForm : a error occurs during server process."); } } else { returnValue = ConvertProxyResponseToDTO(response); } } catch (PwgProxyException ex) { throw new PwgServiceException("addImageByMultiPartForm : a error is raised by proxy.", ex); } return returnValue; }
/* * pwg.images.add pwg_images_add * pwg.images.addChunk pwg_images_addChunk * pwg.images.addComment * pwg.images.addFile * pwg.images.addSimple pwg_images_addSimple * pwg.images.checkFiles * pwg.images.checkUpload * pwg.images.delete pwg_images_delete * pwg.images.exist * pwg.images.getInfo pwg_images_getInfos * pwg.images.rate pwg_images_rate * pwg.images.regenerateThumbnail * pwg.images.search * pwg.images.setInfo * pwg.images.setPrivacyLevel * */ internal static PwgBaseProxyReponse pwg_images_add(String fileMd5sum, String thunbMd5sum, String HighresMd5sum, String imageMd5sum, String imageFilename, String imageName, String imageAuthor, DateTime creationDate, String authorComment,List<String> lstAlbums, List<String> lstTags, PwgConfidentLevelEnum? confidentLevel) { PwgBaseProxyReponse response = null; try { StringBuilder data = new StringBuilder(); data.Append("method=pwg.images.add"); Boolean firstOcc = false; PwgProxyReponseHelper.buildQueryFromValue<String>(fileMd5sum, "file_sum", ref firstOcc, data); PwgProxyReponseHelper.buildQueryFromValue<String>(thunbMd5sum, "thumbnail_sum", ref firstOcc, data); PwgProxyReponseHelper.buildQueryFromValue<String>(HighresMd5sum, "high_sum", ref firstOcc, data); PwgProxyReponseHelper.buildQueryFromValue<String>(imageMd5sum, "original_sum", ref firstOcc, data); PwgProxyReponseHelper.buildQueryFromValue<String>(imageFilename, "original_filename", ref firstOcc, data); PwgProxyReponseHelper.buildQueryFromValue<String>(imageName, "name", ref firstOcc, data); PwgProxyReponseHelper.buildQueryFromValue<String>(imageAuthor, "author", ref firstOcc, data); PwgProxyReponseHelper.buildQueryFromValue<String>(authorComment, "comment", ref firstOcc, data); PwgProxyReponseHelper.buildQueryFromArray<String>(lstAlbums, "categories", ref firstOcc, data); PwgProxyReponseHelper.buildQueryFromArray<String>(lstTags, "tag_ids", ref firstOcc, data); PwgProxyReponseHelper.buildQueryFromValue<Int32>((int?)confidentLevel, "level", ref firstOcc, data); PwgProxyReponseHelper.buildQueryFromValue<DateTime>(creationDate, "date_creation", ref firstOcc, data); response = PwgGenericProxy<PwgBaseProxyReponse>.Post( PwgConfigProxy.PwgServeurUri, data.ToString()); } catch (Exception ex) { throw new PwgProxyException("pwg_images_rate", ex); } return response; }
public Boolean addImage(FileInfo highResFile, FileInfo lowResFile, FileInfo thumbFile, String imageName, String imageAuthor, DateTime creationDate, String authorComment, List<String> lstAlbums, List<String> lstTags, PwgConfidentLevelEnum? confidentLevel) { Boolean returnValue = false; try { String fileMd5sum = uploadImageByChunk(lowResFile, PwgFileTypeEnum.LowRes, null); String thunbMd5sum = uploadImageByChunk(thumbFile, PwgFileTypeEnum.Thumb, fileMd5sum); String HighresMd5sum = uploadImageByChunk(highResFile, PwgFileTypeEnum.HighDef, fileMd5sum); String imageMd5sum = fileMd5sum; //(highResFile != null ? HighresMd5sum : fileMd5sum); //Md5sum.NewMd5sum().ToString(); String imageFilename = (highResFile != null ? highResFile.Name : lowResFile.Name); PwgBaseProxyReponse response = PwgImagesProxy.pwg_images_add( fileMd5sum, thunbMd5sum, HighresMd5sum, imageMd5sum, imageFilename, imageName, imageAuthor, creationDate, authorComment, lstAlbums, lstTags, confidentLevel); if (response.Retour != PwgBaseProxyReponseRetourEnum.Ok) { if (response.Erreur != null) { throw new PwgServiceException("addImage, the server has return the error.", response.Erreur.Code, response.Erreur.Message); } else { throw new PwgServiceException("addImage : a error occurs during server process."); } } else { returnValue = true; } } catch (PwgProxyException ex) { throw new PwgServiceException("addImage : a error is raised by proxy.", ex); } return returnValue; }