- Timestamp:
- Aug 1, 2011, 5:47:03 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/PiwigoLib/PiwigoLib/Service/PwgImagesService.cs
r11850 r11872 49 49 } 50 50 51 public Boolean addImageByMultiPartForm(FileInfo fileImage, Int32? imageId, Int32? categoryId, String imageName, String imageAuthor, String imageComment, Int32? imageLevel, StringimageTags)52 { 53 Boolean returnValue = false;54 55 try 56 { 57 Pwg BaseProxyReponse response = PwgImagesProxy.pwg_images_addSimple(fileImage,imageId, categoryId, imageName, imageAuthor, imageComment, imageLevel, imageTags);51 public PwgImageAdded addImageByMultiPartForm(FileInfo fileImage, Int32? imageId, Int32? categoryId, String imageName, String imageAuthor, String imageComment, Int32? imageLevel, List<PwgTag> imageTags) 52 { 53 PwgImageAdded returnValue = new PwgImageAdded(); 54 55 try 56 { 57 PwgAddSimpleImageProxyResponse response = PwgImagesProxy.pwg_images_addSimple(fileImage, imageId, categoryId, imageName, imageAuthor, imageComment, imageLevel, imageTags); 58 58 59 59 if (response.Retour != PwgBaseProxyReponseRetourEnum.Ok) … … 72 72 else 73 73 { 74 returnValue = ConvertProxyResponseToDTO(response); 75 } 76 } 77 catch (PwgProxyException ex) 78 { 79 throw new PwgServiceException("addImageByMultiPartForm : a error is raised by proxy.", ex); 80 } 81 return returnValue; 82 } 83 84 public Boolean DeleteImage(Int32 imageId, String SecurityToken) 85 { 86 Boolean returnValue = false; 87 88 try 89 { 90 91 PwgBaseProxyReponse response = PwgImagesProxy.pwg_images_delete(imageId, SecurityToken); 92 93 if (response.Retour != PwgBaseProxyReponseRetourEnum.Ok) 94 { 95 if (response.Erreur != null) 96 { 97 throw new PwgServiceException("DeleteImage, the server has return the error.", 98 response.Erreur.Code, 99 response.Erreur.Message); 100 } 101 else 102 { 103 throw new PwgServiceException("DeleteImage : a error occurs during server process."); 104 } 105 } 106 else 107 { 74 108 returnValue = true; 75 109 } … … 77 111 catch (PwgProxyException ex) 78 112 { 79 throw new PwgServiceException("addImageByMultiPartForm : a error is raised by proxy.", ex); 80 } 81 return returnValue; 82 } 113 throw new PwgServiceException("DeleteImage : a error is raised by proxy.", ex); 114 } 115 return returnValue; 116 } 117 118 public PwgImageInfo getImageInfo(Int32 imageId, Int32? commentPage, Int32? commentsPerPage) 119 { 120 PwgImageInfo returnValue = new PwgImageInfo(); 121 122 try 123 { 124 PwgImageInfoProxyResponse response = PwgImagesProxy.pwg_images_getInfos(imageId, commentPage, commentsPerPage); 125 126 if (response.Retour != PwgBaseProxyReponseRetourEnum.Ok) 127 { 128 if (response.Erreur != null) 129 { 130 throw new PwgServiceException("RateImage, the server has return the error.", 131 response.Erreur.Code, 132 response.Erreur.Message); 133 } 134 else 135 { 136 throw new PwgServiceException("RateImage : a error occurs during server process."); 137 } 138 } 139 else 140 { 141 //returnValue = ConvertProxyResponseToDTO(response); 142 } 143 } 144 catch (PwgProxyException ex) 145 { 146 throw new PwgServiceException("RateImage : a error is raised by proxy.", ex); 147 } 148 return returnValue; 149 } 150 /// <summary> 151 /// private: convert response to dto object 152 /// </summary> 153 /// <param name="response"></param> 154 /// <param name="session"></param> 155 internal static PwgImageAdded ConvertProxyResponseToDTO(PwgAddSimpleImageProxyResponse response) 156 { 157 PwgImageAdded returnValue = new PwgImageAdded(); 158 159 returnValue.Id = response.Id; 160 161 if (String.IsNullOrEmpty(response.UrlImage)) 162 { 163 returnValue.UrlElement = null; 164 } 165 else 166 { 167 returnValue.UrlElement = (new UriBuilder(response.UrlImage)).Uri; 168 } 169 170 return returnValue; 171 } 172 83 173 84 174 /// <summary> … … 163 253 returnValue.Width = response.Width; 164 254 255 if (response.AvailableDate != null) 256 { 257 DateTime tryDate; 258 if (DateTime.TryParse(response.AvailableDate, out tryDate)) 259 { 260 returnValue.AvailableDate = tryDate; 261 } 262 } 263 264 if (response.CreatingDate != null) 265 { 266 DateTime tryDate; 267 if (DateTime.TryParse(response.CreatingDate, out tryDate)) 268 { 269 returnValue.CreatingDate = tryDate; 270 } 271 } 272 165 273 if (String.IsNullOrEmpty(response.UrlElement)) 166 274 {
Note: See TracChangeset
for help on using the changeset viewer.